summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSidharth Singh2013-09-11 03:01:56 (EDT)
committerStephan Born2013-09-11 03:01:56 (EDT)
commit7ae41cfdee42075d78441a2343b6cbc5a00ee3e3 (patch)
tree3cf023a7424e693fc0075b5eaa0420f0160e7578
parent65c16c9cd18190d161bcb8eb23c79bd69fdb1829 (diff)
downloadorg.eclipse.stardust.ui.web-7ae41cfdee42075d78441a2343b6cbc5a00ee3e3.zip
org.eclipse.stardust.ui.web-7ae41cfdee42075d78441a2343b6cbc5a00ee3e3.tar.gz
org.eclipse.stardust.ui.web-7ae41cfdee42075d78441a2343b6cbc5a00ee3e3.tar.bz2
Jira-ID: CRNT-30086
Made changes to save the Access control entry removal to jcr. Removed unwanted field from AccessContolBean.java and added saved flag for UI. git-svn-id: https://svn.csa.sungard.com/repos/ipp2/product/trunk/stardust/ui.web@67188 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b Signed-off-by: Sidharth Singh <sidharth.singh@sungard.com>
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/security/AccessControlBean.java17
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/security/SecurityDialog.java116
2 files changed, 88 insertions, 45 deletions
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/security/AccessControlBean.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/security/AccessControlBean.java
index 717d5e2..7f1d5ba 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/security/AccessControlBean.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/security/AccessControlBean.java
@@ -72,7 +72,7 @@ public class AccessControlBean extends DefaultRowModel
public static final String MODIFYACL = "Modify ACL";
- private boolean newOrModified;
+ private boolean saved;
public boolean isEdit()
{
@@ -212,11 +212,6 @@ public class AccessControlBean extends DefaultRowModel
setModifyAcl(ALLOW);
}
- public boolean isNewOrModified()
- {
- return newOrModified;
- }
-
public String getCreatePolicyChangedValue()
{
return createPolicyChangedValue;
@@ -263,6 +258,16 @@ public class AccessControlBean extends DefaultRowModel
return modelLabel;
}
+ public boolean isSaved()
+ {
+ return saved;
+ }
+
+ public void setSaved(boolean saved)
+ {
+ this.saved = saved;
+ }
+
public boolean equals(Object acb)
{
if (!(acb instanceof AccessControlBean))
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/security/SecurityDialog.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/security/SecurityDialog.java
index fb663ab..4213b85 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/security/SecurityDialog.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/security/SecurityDialog.java
@@ -322,6 +322,9 @@ public class SecurityDialog extends PopupUIComponentBean
{
if (updateACBList)
{
+ // While removing ACB entry, if saved flag is false, means new entry
+ // (not saved to JCR)
+ acb.setSaved(true);
acbs.add(acb);
}
}
@@ -389,29 +392,7 @@ public class SecurityDialog extends PopupUIComponentBean
DocumentManagementService dms = ContextPortalServices.getDocumentManagementService();
// TODO Delete the print line after perfecting the functionality
// printDmsSecurity(dms, getResourceId());
- Set<AccessControlPolicy> applicablePolicies = null;
- AccessControlPolicy next = null;
- try
- {
- applicablePolicies = dms.getPolicies(getResourceId());
- next = applicablePolicies.iterator().next();
- }
- catch (java.util.NoSuchElementException nee)
- {
- try
- {
- applicablePolicies = dms.getApplicablePolicies(getResourceId());
- next = applicablePolicies.iterator().next();
- }
- catch (Exception e)
- {
- trace.error(e);
- }
- }
- catch (Exception e)
- {
- trace.error(e);
- }
+ AccessControlPolicy next = getAccessControlPolicy();
next.removeAllAccessControlEntries();
for (AccessControlBean acb : accessControlBean)
@@ -424,44 +405,47 @@ public class SecurityDialog extends PopupUIComponentBean
if (next != null)
{
acb.setEdit(false);
+ // While removing ACB entry, if saved flag is false, means new entry (not
+ // saved to JCR)
+ acb.setSaved(true);
if (!acb.getCreate().equals(AccessControlBean.INHERIT))
{
next.addAccessControlEntry(acb.getParticipant().getPrincipal(),
- Collections.<Privilege> singleton(DmsPrivilege.CREATE_PRIVILEGE),
- acb.getCreate().toUpperCase().equals(EntryType.ALLOW.toString()) ? EntryType.ALLOW : EntryType.DENY);
+ Collections.<Privilege> singleton(DmsPrivilege.CREATE_PRIVILEGE), acb.getCreate().toUpperCase()
+ .equals(EntryType.ALLOW.toString()) ? EntryType.ALLOW : EntryType.DENY);
}
if (!acb.getDelete().equals(AccessControlBean.INHERIT))
{
next.addAccessControlEntry(acb.getParticipant().getPrincipal(),
- Collections.<Privilege> singleton(DmsPrivilege.DELETE_PRIVILEGE),
- acb.getDelete().toUpperCase().equals(EntryType.ALLOW.toString()) ? EntryType.ALLOW : EntryType.DENY);
+ Collections.<Privilege> singleton(DmsPrivilege.DELETE_PRIVILEGE), acb.getDelete().toUpperCase()
+ .equals(EntryType.ALLOW.toString()) ? EntryType.ALLOW : EntryType.DENY);
next.addAccessControlEntry(acb.getParticipant().getPrincipal(),
- Collections.<Privilege> singleton(DmsPrivilege.DELETE_CHILDREN_PRIVILEGE),
- acb.getDelete().toUpperCase().equals(EntryType.ALLOW.toString()) ? EntryType.ALLOW : EntryType.DENY);
+ Collections.<Privilege> singleton(DmsPrivilege.DELETE_CHILDREN_PRIVILEGE), acb.getDelete()
+ .toUpperCase().equals(EntryType.ALLOW.toString()) ? EntryType.ALLOW : EntryType.DENY);
}
if (!acb.getModify().equals(AccessControlBean.INHERIT))
{
next.addAccessControlEntry(acb.getParticipant().getPrincipal(),
- Collections.<Privilege> singleton(DmsPrivilege.MODIFY_PRIVILEGE),
- acb.getModify().toUpperCase().equals(EntryType.ALLOW.toString()) ? EntryType.ALLOW : EntryType.DENY);
+ Collections.<Privilege> singleton(DmsPrivilege.MODIFY_PRIVILEGE), acb.getModify().toUpperCase()
+ .equals(EntryType.ALLOW.toString()) ? EntryType.ALLOW : EntryType.DENY);
}
if (!acb.getRead().equals(AccessControlBean.INHERIT))
{
next.addAccessControlEntry(acb.getParticipant().getPrincipal(),
- Collections.<Privilege> singleton(DmsPrivilege.READ_PRIVILEGE),
- acb.getRead().toUpperCase().equals(EntryType.ALLOW.toString()) ? EntryType.ALLOW : EntryType.DENY);
+ Collections.<Privilege> singleton(DmsPrivilege.READ_PRIVILEGE), acb.getRead().toUpperCase()
+ .equals(EntryType.ALLOW.toString()) ? EntryType.ALLOW : EntryType.DENY);
}
if (!acb.getReadAcl().equals(AccessControlBean.INHERIT))
{
next.addAccessControlEntry(acb.getParticipant().getPrincipal(),
- Collections.<Privilege> singleton(DmsPrivilege.READ_ACL_PRIVILEGE),
- acb.getReadAcl().toUpperCase().equals(EntryType.ALLOW.toString()) ? EntryType.ALLOW : EntryType.DENY);
+ Collections.<Privilege> singleton(DmsPrivilege.READ_ACL_PRIVILEGE), acb.getReadAcl().toUpperCase()
+ .equals(EntryType.ALLOW.toString()) ? EntryType.ALLOW : EntryType.DENY);
}
if (!acb.getModifyAcl().equals(AccessControlBean.INHERIT))
{
next.addAccessControlEntry(acb.getParticipant().getPrincipal(),
- Collections.<Privilege> singleton(DmsPrivilege.MODIFY_ACL_PRIVILEGE),
- acb.getModifyAcl().toUpperCase().equals(EntryType.ALLOW.toString()) ? EntryType.ALLOW : EntryType.DENY);
+ Collections.<Privilege> singleton(DmsPrivilege.MODIFY_ACL_PRIVILEGE), acb.getModifyAcl()
+ .toUpperCase().equals(EntryType.ALLOW.toString()) ? EntryType.ALLOW : EntryType.DENY);
}
}
}
@@ -704,19 +688,73 @@ public class SecurityDialog extends PopupUIComponentBean
securityDialogTable.initialize();
}
+ private AccessControlPolicy getAccessControlPolicy()
+ {
+ DocumentManagementService dms = ContextPortalServices.getDocumentManagementService();
+ Set<AccessControlPolicy> applicablePolicies = null;
+ AccessControlPolicy next = null;
+ try
+ {
+ applicablePolicies = dms.getPolicies(getResourceId());
+ next = applicablePolicies.iterator().next();
+ }
+ catch (java.util.NoSuchElementException nee)
+ {
+ try
+ {
+ applicablePolicies = dms.getApplicablePolicies(getResourceId());
+ next = applicablePolicies.iterator().next();
+ }
+ catch (Exception e)
+ {
+ trace.error(e);
+ }
+ }
+ catch (Exception e)
+ {
+ trace.error(e);
+ }
+ return next;
+ }
+
public void removeRole(ActionEvent event)
{
AccessControlBean acb = (AccessControlBean) event.getComponent().getAttributes().get("acb");
+ AccessControlPolicy next = null;
+ AccessControlBean acbRemoveObj = null;
+ AccessControlEntry aceRemoveObj = null;
for (int i = 0; i < accessControlBean.size(); i++)
{
if (accessControlBean.get(i).equals(acb))
{
- accessControlBean.remove(i);
- policyChanged = true;
+ acbRemoveObj = accessControlBean.get(i);
break;
}
}
+
+ // If current entry is not yet saved to JCR,no need to read from DMS
+ if (acb.isSaved() && acbRemoveObj != null)
+ {
+ next = getAccessControlPolicy();
+ for (AccessControlEntry ace : next.getAccessControlEntries())
+ {
+ if (ace.getPrincipal().getName().equals(acbRemoveObj.getParticipant().getPrincipal().getName()))
+ {
+ aceRemoveObj = ace;
+ break;
+ }
+ }
+ if (null != aceRemoveObj)
+ {
+ next.removeAccessControlEntry(aceRemoveObj);
+ ContextPortalServices.getDocumentManagementService().setPolicy(getResourceId(), next);
+ policyChanged = true;
+ }
+ }
+
+ accessControlBean.remove(acbRemoveObj);
+
// When all roles are removed, do not show Apply btn
if (accessControlBean.size() == 0)
{