java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml | 6 +
java/code/src/com/redhat/rhn/frontend/xmlrpc/InvalidChannelLabelException.java | 21
+++++-
java/code/src/com/redhat/rhn/frontend/xmlrpc/InvalidChannelNameException.java | 19
+++++
java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java | 34
+++++++---
4 files changed, 69 insertions(+), 11 deletions(-)
New commits:
commit 02dd7b9921975b03cab43aa14feb36ecb3cb5abb
Author: Brad Buckingham <bbuckingham(a)redhat.com>
Date: Thu May 28 14:05:05 2009 -0400
remove todo indicator from code
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
b/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
index aebe65c..4f6af70 100644
--- a/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
@@ -8106,7 +8106,6 @@ Follow this url to see the full list of inactive systems:
<context
context-type="sourcefile">/channels/manage/Edit</context>
</context-group>
</trans-unit>
- BRAD
<trans-unit id="edit.channel.invalidchannelname.supportedregex">
<source>Channel name must begin with a letter and may contain only
lowercase letters, hyphens ('-'), periods ('.'), underscores
('_'), numerals, spaces and forward slashes ('/').</source>
</trans-unit>
commit bf2cfbe641761e7f184c36c7814c3e3c4a922658
Author: Brad Buckingham <bbuckingham(a)redhat.com>
Date: Thu May 28 14:03:27 2009 -0400
501358 - api - channel.software.create - update to provide more detail on label/name
errors
Currently, when executing the API, if an error exists with either channel label
or name, the exception message is similar to:
Invalid channel label
Invalid channel name
Recently, modifications were made to the UI to provide more descriptive
information for these name/label errors. As a result, updating the API to
use the same/similar messages.
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
b/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
index 23b593d..aebe65c 100644
--- a/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
@@ -8106,6 +8106,10 @@ Follow this url to see the full list of inactive systems:
<context
context-type="sourcefile">/channels/manage/Edit</context>
</context-group>
</trans-unit>
+ BRAD
+ <trans-unit id="edit.channel.invalidchannelname.supportedregex">
+ <source>Channel name must begin with a letter and may contain only
lowercase letters, hyphens ('-'), periods ('.'), underscores
('_'), numerals, spaces and forward slashes ('/').</source>
+ </trans-unit>
<trans-unit id="edit.channel.invalidchannelname.redhat">
<source>Red Hat channels require admin privileges</source>
<context-group name="ctx">
@@ -8143,6 +8147,9 @@ Follow this url to see the full list of inactive systems:
<context
context-type="sourcefile">/channels/manage/Edit</context>
</context-group>
</trans-unit>
+ <trans-unit id="edit.channel.invalidchannellabel.supportedregex">
+ <source>Channel label must begin with a letter and may contain only
lowercase letters, hyphens ('-'), periods ('.'), underscores
('_'), and numerals.</source>
+ </trans-unit>
<trans-unit id="edit.channel.invalidchannellabel.redhat">
<source>Red Hat channels require admin privileges</source>
<context-group name="ctx">
diff --git
a/java/code/src/com/redhat/rhn/frontend/xmlrpc/InvalidChannelLabelException.java
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/InvalidChannelLabelException.java
index 21f4df6..763b69e 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/InvalidChannelLabelException.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/InvalidChannelLabelException.java
@@ -49,7 +49,7 @@ public class InvalidChannelLabelException extends FaultException {
}
/**
- * Creates a new indication that a given channel name is invalid and
+ * Creates a new indication that a given channel label is invalid
*
* @param labelIn label the user attempted to give the channel
* @param reasonIn flag indicating why the channel name is invalid; cannot be
@@ -63,6 +63,25 @@ public class InvalidChannelLabelException extends FaultException {
}
/**
+ * Creates a new indication that a given channel label is invalid
+ *
+ * @param labelIn label the user attempted to give the channel
+ * @param reasonIn flag indicating why the channel name is invalid; cannot be
+ * <code>null</code>
+ * @param messageIdIn the string resource message ID
+ * @param argIn an optional argument that is associated with messageId. If there
+ * is no argument, pass in an empty string.
+ */
+ public InvalidChannelLabelException(String labelIn, Reason reasonIn,
+ String messageIdIn, String argIn) {
+
+ super(1201, "invalidChannelLabel", messageIdIn, new Object[] {argIn});
+
+ this.label = labelIn;
+ this.reason = reasonIn;
+ }
+
+ /**
* @return invalid label that caused this exception; may be
<code>null</code>
*/
public String getLabel() {
diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/InvalidChannelNameException.java
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/InvalidChannelNameException.java
index 8702d68..a1d1b07 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/InvalidChannelNameException.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/InvalidChannelNameException.java
@@ -63,6 +63,25 @@ public class InvalidChannelNameException extends FaultException {
}
/**
+ * Creates a new indication that a given channel name is invalid.
+ *
+ * @param nameIn name the user attempted to give the channel
+ * @param reasonIn flag indicating why the channel name is invalid; cannot be
+ * <code>null</code>
+ * @param messageIdIn the string resource message ID
+ * @param argIn an optional argument that is associated with messageId. If there
+ * is no argument, pass in an empty string.
+ */
+ public InvalidChannelNameException(String nameIn, Reason reasonIn,
+ String messageIdIn, String argIn) {
+
+ super(1200, "invalidChannelName", messageIdIn, new Object[] {argIn});
+
+ this.name = nameIn;
+ this.reason = reasonIn;
+ }
+
+ /**
* @return invalid name that caused this exception; may be
<code>null</code>
*/
public String getName() {
diff --git a/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java
b/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java
index c3ff972..8ee65e9 100644
--- a/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java
+++ b/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java
@@ -223,12 +223,14 @@ public class CreateChannelCommand {
if (ChannelFactory.doesChannelNameExist(name)) {
throw new InvalidChannelNameException(name,
- InvalidChannelNameException.Reason.NAME_IN_USE);
+ InvalidChannelNameException.Reason.NAME_IN_USE,
+ "edit.channel.invalidchannelname.nameinuse", name);
}
if (ChannelFactory.doesChannelLabelExist(label)) {
throw new InvalidChannelLabelException(label,
- InvalidChannelLabelException.Reason.LABEL_IN_USE);
+ InvalidChannelLabelException.Reason.LABEL_IN_USE,
+ "edit.channel.invalidchannellabel.labelinuse", label);
}
ChannelArch ca = ChannelFactory.findArchByLabel(archLabel);
@@ -326,17 +328,22 @@ public class CreateChannelCommand {
if (cname == null || cname.trim().length() == 0) {
throw new InvalidChannelNameException(cname,
- InvalidChannelNameException.Reason.IS_MISSING);
+ InvalidChannelNameException.Reason.IS_MISSING,
+ "edit.channel.invalidchannelname.missing", "");
}
if (!Pattern.compile(CHANNEL_NAME_REGEX).matcher(cname).find()) {
throw new InvalidChannelNameException(cname,
- InvalidChannelNameException.Reason.REGEX_FAILS);
+ InvalidChannelNameException.Reason.REGEX_FAILS,
+ "edit.channel.invalidchannelname.supportedregex",
"");
}
if (cname.length() < CHANNEL_NAME_MIN_LENGTH) {
+ Integer minLength = new
Integer(CreateChannelCommand.CHANNEL_NAME_MIN_LENGTH);
throw new InvalidChannelNameException(cname,
- InvalidChannelNameException.Reason.TOO_SHORT);
+ InvalidChannelNameException.Reason.TOO_SHORT,
+ "edit.channel.invalidchannelname.minlength",
+ minLength.toString());
}
// the perl code used to ignore case with a /i at the end of
@@ -345,7 +352,8 @@ public class CreateChannelCommand {
if (!user.hasRole(RoleFactory.RHN_SUPERUSER) &&
Pattern.compile(REDHAT_REGEX).matcher(cname.toLowerCase()).find()) {
throw new InvalidChannelNameException(cname,
- InvalidChannelNameException.Reason.RHN_CHANNEL_BAD_PERMISSIONS);
+ InvalidChannelNameException.Reason.RHN_CHANNEL_BAD_PERMISSIONS,
+ "edit.channel.invalidchannelname.redhat", "");
}
}
@@ -358,17 +366,22 @@ public class CreateChannelCommand {
if (clabel == null || clabel.trim().length() == 0) {
throw new InvalidChannelLabelException(clabel,
- InvalidChannelLabelException.Reason.IS_MISSING);
+ InvalidChannelLabelException.Reason.IS_MISSING,
+ "edit.channel.invalidchannellabel.missing", "");
}
if (!Pattern.compile(CHANNEL_LABEL_REGEX).matcher(clabel).find()) {
throw new InvalidChannelLabelException(clabel,
- InvalidChannelLabelException.Reason.REGEX_FAILS);
+ InvalidChannelLabelException.Reason.REGEX_FAILS,
+ "edit.channel.invalidchannellabel.supportedregex",
"");
}
if (clabel.length() < CHANNEL_LABEL_MIN_LENGTH) {
+ Integer minLength = new
Integer(CreateChannelCommand.CHANNEL_LABEL_MIN_LENGTH);
throw new InvalidChannelLabelException(clabel,
- InvalidChannelLabelException.Reason.TOO_SHORT);
+ InvalidChannelLabelException.Reason.TOO_SHORT,
+ "edit.channel.invalidchannellabel.minlength",
+ minLength.toString());
}
// the perl code used to ignore case with a /i at the end of
@@ -377,7 +390,8 @@ public class CreateChannelCommand {
if (!user.hasRole(RoleFactory.RHN_SUPERUSER) &&
Pattern.compile(REDHAT_REGEX).matcher(clabel.toLowerCase()).find()) {
throw new InvalidChannelLabelException(clabel,
- InvalidChannelLabelException.Reason.RHN_CHANNEL_BAD_PERMISSIONS);
+ InvalidChannelLabelException.Reason.RHN_CHANNEL_BAD_PERMISSIONS,
+ "edit.channel.invalidchannellabel.redhat", "");
}
}