Patch for JBPORTAL-74 (Delete a group)
--------------------------------------
Key: JBPORTAL-197
URL: http://jira.jboss.com/jira/browse/JBPORTAL-197
Project: JBoss Portal
Type: Patch
Components: Portal Core
Reporter: wdimac
Assigned to: Julien Viet
Priority: Minor
Patch diff below (hope I did this right):
Index: src/main/org/jboss/portal/core/impl/role/RoleModuleImpl.java
===================================================================
RCS file:
/cvsroot/jboss/jboss-portal/core/src/main/org/jboss/portal/core/impl/role/RoleModuleImpl.java,v
retrieving revision 1.1
diff -u -r1.1 RoleModuleImpl.java
--- src/main/org/jboss/portal/core/impl/role/RoleModuleImpl.java 15 Jan
2005 22:11:25 -0000 1.1
+++ src/main/org/jboss/portal/core/impl/role/RoleModuleImpl.java 3 Feb
2005 06:42:41 -0000
@@ -18,6 +18,7 @@
import org.apache.log4j.Logger;
import org.jboss.hibernate.session.HibernateContext;
import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.core.impl.user.UserImpl;
import org.jboss.portal.core.model.Role;
import org.jboss.portal.core.modules.AbstractModule;
import org.jboss.portal.core.modules.RoleModule;
@@ -192,11 +193,16 @@
try
{
Session session = getSession();
- int num = session.delete("from RoleImpl as g where g.ID=" +
id.toString());
- if (num == 0)
+ RoleImpl role = (RoleImpl)session.load(RoleImpl.class, id);
+ // User manages the relation.
+ Iterator users = role.getUsers().iterator();
+ while (users.hasNext())
{
- throw new ModuleException("No such role " + id);
+ UserImpl user = (UserImpl)users.next();
+ user.getRoles().remove(role);
}
+ session.delete(role);
+ session.flush();
}
catch (HibernateException e)
{
Index: src/main/org/jboss/portal/core/portlet/role/RolePortlet.java
===================================================================
RCS file:
/cvsroot/jboss/jboss-portal/core/src/main/org/jboss/portal/core/portlet/role/RolePortlet.java,v
retrieving revision 1.1
diff -u -r1.1 RolePortlet.java
--- src/main/org/jboss/portal/core/portlet/role/RolePortlet.java 15 Jan
2005 22:11:40 -0000 1.1
+++ src/main/org/jboss/portal/core/portlet/role/RolePortlet.java 3 Feb
2005 06:42:42 -0000
@@ -309,6 +309,35 @@
}
/**
+ * Action to delete a role
+ *
+ * @param req
+ * @param resp
+ */
+ public void removeRole(JBossActionRequest req, JBossActionResponse resp)
+ {
+ if (PortletHelper.isAuthorized(req.getAuthorizationRealm(),
req.getUser(), new String[] {},
+ Level.ACCESS_ADMIN))
+ {
+ Integer roleID = req.getParameters().getIntObject("roleid");
+ try
+ {
+ roleModule.removeRole(roleID);
+ resp.setRenderParameter("roledelete_error", "ROLE_DELETED");
+ resp.setRenderParameter(getOperationName(), OP_SHOWEDITROLE);
+ }
+ catch (ModuleException e)
+ {
+ log.error("Cannot remove role, unexpected error");
+ e.printStackTrace();
+ portletHelper.setRenderParameter(resp, "roleid",
roleID.toString());
+ resp.setRenderParameter("roledelete_error",
"ROLE_ERROR_DELETE_FAILED");
+ resp.setRenderParameter(getOperationName(), OP_SHOWEDITROLE);
+ }
+ }
+ }
+
+ /**
* REturns trus if the role with display name in argument is available
*
* @param name
Index: src/resources/portal-core-war/WEB-INF/classes/Resource.properties
===================================================================
RCS file:
/cvsroot/jboss/jboss-portal/core/src/resources/portal-core-war/WEB-INF/classes/Resource.properties,v
retrieving revision 1.2
diff -u -r1.2 Resource.properties
--- src/resources/portal-core-war/WEB-INF/classes/Resource.properties 15 Jan
2005 22:11:26 -0000 1.2
+++ src/resources/portal-core-war/WEB-INF/classes/Resource.properties 3 Feb
2005 06:42:42 -0000
@@ -338,11 +338,14 @@
ROLE_CREATE=Create user role
ROLE_UPDATE=Update user role
ROLE_EDIT=Edit user role
+ROLE_DELETE=Delete selected role
+ROLE_DELETED=The role has been deleted
ROLE_ERROR_DISPLAYNAMEALREADYEXISTS=There is already a role with that display
name
ROLE_ERROR_NAMEALREADYEXISTS=There is already a role with that name
ROLE_ERROR_NAMEEMPTY=The role name cannot be empty
ROLE_ERROR_DISPLAYNAMEEMPTY=The role display name cannot be empty
+ROLE_ERROR_DELETE_FAILED=Could not delete the role
MENU_CREATEROLE=Create new role
MENU_EDITROLE=Edit existing role
Index: src/resources/portal-core-war/WEB-INF/classes/Resource_en.properties
===================================================================
RCS file:
/cvsroot/jboss/jboss-portal/core/src/resources/portal-core-war/WEB-INF/classes/Resource_en.properties,v
retrieving revision 1.2
diff -u -r1.2 Resource_en.properties
--- src/resources/portal-core-war/WEB-INF/classes/Resource_en.properties
15 Jan 2005 22:11:26 -0000 1.2
+++ src/resources/portal-core-war/WEB-INF/classes/Resource_en.properties
3 Feb 2005 06:42:42 -0000
@@ -338,11 +338,14 @@
ROLE_CREATE=Create user role
ROLE_UPDATE=Update user role
ROLE_EDIT=Edit user role
+ROLE_DELETE=Delete selected role
+ROLE_DELETED=The role has been deleted
ROLE_ERROR_DISPLAYNAMEALREADYEXISTS=There is already a role with that display
name
ROLE_ERROR_NAMEALREADYEXISTS=There is already a role with that name
ROLE_ERROR_NAMEEMPTY=The role name cannot be empty
ROLE_ERROR_DISPLAYNAMEEMPTY=The role display name cannot be empty
+ROLE_ERROR_DELETE_FAILED=Could not delete the role
MENU_CREATEROLE=Create new role
MENU_EDITROLE=Edit existing role
Index: src/resources/portal-core-war/WEB-INF/jsp/role/editRole.jsp
===================================================================
RCS file:
/cvsroot/jboss/jboss-portal/core/src/resources/portal-core-war/WEB-INF/jsp/role/editRole.jsp,v
retrieving revision 1.1
diff -u -r1.1 editRole.jsp
--- src/resources/portal-core-war/WEB-INF/jsp/role/editRole.jsp 15 Jan 2005
22:11:36 -0000 1.1
+++ src/resources/portal-core-war/WEB-INF/jsp/role/editRole.jsp 3 Feb 2005
06:42:43 -0000
@@ -3,7 +3,7 @@
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
<%@ page isELIgnored ="false" %>
-<form action="<portlet:actionURL><portlet:param name="op"
value="editGroup"/></portlet:actionURL>" method="post">
+<form action="<portlet:actionURL><portlet:param name="op"
value="editRole"/></portlet:actionURL>" method="post">
<table border="0" class="portlet-font" cellspacing="0" cellpadding="6">
<tr>
<td
class="portlet-form-label">${n:i18n("ROLE_SELECTONETOMODIFY")}:</td>
@@ -25,3 +25,22 @@
</tr>
</table>
</form>
+<form action="<portlet:actionURL><portlet:param name="op"
value="removeRole"/></portlet:actionURL>" method="post">
+ <table border="0" class="portlet-font" cellspacing="0" cellpadding="6">
+ <tr>
+ <td
class="portlet-form-label">${n:i18n("ROLE_SELECTONETOMODIFY")}:</td>
+ <td class="portlet-form-input-field">
+ <select name="roleid" class="pn-normal">
+ <n:iterate ctx="role">
+ <option value="${n:out("role.id")}"
${n:out("role.selected")}>${n:out("role.displayname")}</option>
+ </n:iterate>
+ </select> <n:error key="roledelete_error"/></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td align="center">
+ <input type="submit" value="${n:i18n("ROLE_DELETE")}">
+ </td>
+ </tr>
+ </table>
+</form>
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
JBoss-Development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-development