diff options
author | Endi S. Dewata <edewata@redhat.com> | 2013-12-14 19:44:47 -0500 |
---|---|---|
committer | Endi S. Dewata <edewata@redhat.com> | 2013-12-16 19:15:48 -0500 |
commit | cbfe95ec0b320713a3375e77975779d8acfaf5aa (patch) | |
tree | e47c24e0ccd67b9dbad98e3e62d23697fab85680 /base | |
parent | c6dc612b3696cdd10f7676bf4cedde83242b22e8 (diff) | |
download | pki-cbfe95ec0b320713a3375e77975779d8acfaf5aa.tar.gz pki-cbfe95ec0b320713a3375e77975779d8acfaf5aa.tar.xz pki-cbfe95ec0b320713a3375e77975779d8acfaf5aa.zip |
Added dialog for adding TPS groups.
A new dialog box has been added for adding TPS groups. A separate
group ID attribute has been added to the REST service as required
by Backbone.
Ticket #654
Diffstat (limited to 'base')
5 files changed, 55 insertions, 11 deletions
diff --git a/base/common/src/com/netscape/certsrv/group/GroupData.java b/base/common/src/com/netscape/certsrv/group/GroupData.java index a21ad7f01..33f66a4e3 100644 --- a/base/common/src/com/netscape/certsrv/group/GroupData.java +++ b/base/common/src/com/netscape/certsrv/group/GroupData.java @@ -34,6 +34,8 @@ import com.netscape.certsrv.common.Constants; public class GroupData { String id; + String groupID; + String description; Link link; @@ -47,6 +49,15 @@ public class GroupData { this.id = id; } + @XmlElement(name="GroupID") + public String getGroupID() { + return groupID; + } + + public void setGroupID(String groupID) { + this.groupID = groupID; + } + @FormParam(Constants.PR_GROUP_DESC) @XmlElement(name="Description") public String getDescription() { @@ -71,7 +82,9 @@ public class GroupData { final int prime = 31; int result = 1; result = prime * result + ((description == null) ? 0 : description.hashCode()); + result = prime * result + ((groupID == null) ? 0 : groupID.hashCode()); result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((link == null) ? 0 : link.hashCode()); return result; } @@ -89,11 +102,21 @@ public class GroupData { return false; } else if (!description.equals(other.description)) return false; + if (groupID == null) { + if (other.groupID != null) + return false; + } else if (!groupID.equals(other.groupID)) + return false; if (id == null) { if (other.id != null) return false; } else if (!id.equals(other.id)) return false; + if (link == null) { + if (other.link != null) + return false; + } else if (!link.equals(other.link)) + return false; return true; } } diff --git a/base/java-tools/src/com/netscape/cmstools/group/GroupAddCLI.java b/base/java-tools/src/com/netscape/cmstools/group/GroupAddCLI.java index a29ce62ef..47153cd3f 100644 --- a/base/java-tools/src/com/netscape/cmstools/group/GroupAddCLI.java +++ b/base/java-tools/src/com/netscape/cmstools/group/GroupAddCLI.java @@ -69,7 +69,7 @@ public class GroupAddCLI extends CLI { String groupID = cmdArgs[0]; GroupData groupData = new GroupData(); - groupData.setID(groupID); + groupData.setGroupID(groupID); groupData.setDescription(cmd.getOptionValue("description")); groupData = groupCLI.groupClient.addGroup(groupData); diff --git a/base/server/cms/src/com/netscape/cms/servlet/admin/GroupService.java b/base/server/cms/src/com/netscape/cms/servlet/admin/GroupService.java index a20b548ad..722979d79 100644 --- a/base/server/cms/src/com/netscape/cms/servlet/admin/GroupService.java +++ b/base/server/cms/src/com/netscape/cms/servlet/admin/GroupService.java @@ -79,14 +79,17 @@ public class GroupService extends PKIService implements GroupResource { GroupData groupData = new GroupData(); - String id = group.getGroupID(); - if (!StringUtils.isEmpty(id)) groupData.setID(id); + String groupID = group.getGroupID(); + if (!StringUtils.isEmpty(groupID)) { + groupData.setID(groupID); + groupData.setGroupID(groupID); + } String description = group.getDescription(); if (!StringUtils.isEmpty(description)) groupData.setDescription(description); - String groupID = URLEncoder.encode(groupData.getID(), "UTF-8"); - URI uri = uriInfo.getBaseUriBuilder().path(GroupResource.class).path("{groupID}").build(groupID); + String encodedGroupID = URLEncoder.encode(groupData.getID(), "UTF-8"); + URI uri = uriInfo.getBaseUriBuilder().path(GroupResource.class).path("{groupID}").build(encodedGroupID); groupData.setLink(new Link("self", uri)); return groupData; @@ -190,7 +193,7 @@ public class GroupService extends PKIService implements GroupResource { if (groupData == null) throw new BadRequestException("Group data is null."); - String groupID = groupData.getID(); + String groupID = groupData.getGroupID(); // ensure that any low-level exceptions are reported // to the signed audit log and stored as failures diff --git a/base/tps-tomcat/shared/webapps/tps/groups.html b/base/tps-tomcat/shared/webapps/tps/groups.html index ade0b7745..5487e1c0d 100644 --- a/base/tps-tomcat/shared/webapps/tps/groups.html +++ b/base/tps-tomcat/shared/webapps/tps/groups.html @@ -25,15 +25,23 @@ <script src="/tps/js/group.js"></script> <script> $(function() { + var addDialog = new Dialog({ + el: $("#group-dialog"), + title: "Add Group", + actions: ["cancel", "add"] + }); + var editDialog = new Dialog({ el: $("#group-dialog"), title: "Edit Group", - readonly: ["id"] + readonly: ["groupID"], + actions: ["cancel", "save"] }); new TableView({ el: $("table[name='groups']"), collection: new GroupCollection({ size: 3 }), + addDialog: addDialog, editDialog: editDialog }); }); @@ -48,7 +56,10 @@ $(function() { <tr> <th class="rcue-table-actions" colspan="2"> <span><input type="text" placeholder="Search..."></span> - <span><button>Add</button><button>Remove</button></span> + <span> + <button name="add">Add</button> + <button name="remove">Remove</button> + </span> </th> </tr> <tr> @@ -58,7 +69,7 @@ $(function() { </thead> <tbody> <tr> - <td name="id"> </td> + <td name="groupID"> </td> <td name="description"> </td> </tr> </tbody> @@ -81,11 +92,13 @@ $(function() { <a class="rcue-button-close" href="#"></a> </header> <fieldset> - <label>Group ID</label><input name="id" type="text"><br> + <label>Group ID</label><input name="groupID" type="text"><br> <label>Description</label><input name="description" type="text"><br> </fieldset> <footer> + <button name="add" class="primary">Add</button> <button name="save" class="primary">Save</button> + <button name="remove" class="primary">Remove</button> <button name="cancel">Cancel</button> </footer> </div> diff --git a/base/tps-tomcat/shared/webapps/tps/js/group.js b/base/tps-tomcat/shared/webapps/tps/js/group.js index 4030712b0..0396bf354 100644 --- a/base/tps-tomcat/shared/webapps/tps/js/group.js +++ b/base/tps-tomcat/shared/webapps/tps/js/group.js @@ -22,15 +22,18 @@ var GroupModel = Model.extend({ urlRoot: "/tps/rest/admin/groups", parseResponse: function(response) { + if (!response || !response.Group) return {}; return { id: response.Group["@id"], + groupID: response.Group.GroupID, description: response.Group.Description }; }, createRequest: function(attributes) { return { Group: { - "@id": attributes.id, + "@id": this.id, + GroupID: attributes.groupID, Description: attributes.description } }; @@ -38,6 +41,7 @@ var GroupModel = Model.extend({ }); var GroupCollection = Collection.extend({ + model: GroupModel, urlRoot: "/tps/rest/admin/groups", getEntries: function(response) { return response.Groups.Group; @@ -48,6 +52,7 @@ var GroupCollection = Collection.extend({ parseEntry: function(entry) { return new GroupModel({ id: entry["@id"], + groupID: entry.GroupID, description: entry.Description }); } |