Author: xlawrence
Date: Fri Jun 29 11:28:27 2007
New Revision: 17832

URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D17832&repname=
=3Djahia
Log:
Backported modifications on saveACL method

Modified:
    trunk/core/src/java/org/jahia/engines/filemanager/DAVFilemanager_Engine=
.java

Modified: trunk/core/src/java/org/jahia/engines/filemanager/DAVFilemanager_=
Engine.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/java/o=
rg/jahia/engines/filemanager/DAVFilemanager_Engine.java&rev=3D17832&repname=
=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/core/src/java/org/jahia/engines/filemanager/DAVFilemanager_Engine=
.java (original)
+++ trunk/core/src/java/org/jahia/engines/filemanager/DAVFilemanager_Engine=
.java Fri Jun 29 11:28:27 2007
@@ -429,12 +429,13 @@
                 logger.debug("tab value is: " + tab);
                 if (tab.equals("rightsMgmt")) {
                     List futur403 =3D null;
+                    final boolean ignoreWarning =3D jParams.getParameter("=
ignoreAllWarnings") !=3D null;
                     try {
-                        futur403 =3D saveAcl(objectDav, jParams);
+                        futur403 =3D saveAcl(objectDav, jParams, ignoreWar=
ning);
                     } catch (JahiaException je) {
                         logger.error(je, je);
                     }
-                    result =3D (futur403 =3D=3D null || futur403.size() =
=3D=3D 0);
+                    result =3D ignoreWarning || (futur403 =3D=3D null || f=
utur403.size() =3D=3D 0);
                     if (!result) {
                         if (objectDav.isCollection()) {
                             jParams.setAttribute("error", "org.jahia.engin=
es.filemanager.Filemanager_Engine.permissionError.label");
@@ -500,13 +501,12 @@
                 } else {
                     result =3D true;
                 }
-
             } else if (lastScreen.equals("fileRename")) {
                 result =3D renameFile(objectDav, jParams);
 =

             } else if (lastScreen.equals("rightsMgmt")) {
                 try {
-                    final List tmp =3D saveAcl(objectDav, jParams);
+                    final List tmp =3D saveAcl(objectDav, jParams, false);
                     result =3D (tmp =3D=3D null || tmp.size() =3D=3D 0);
                 } catch (JahiaException je) {
                     logger.error(je, je);
@@ -1242,7 +1242,7 @@
                     ) {
                 String initialContentType =3D contentType;
                 contentType =3D jParams.getContext().getMimeType(filename);
-                if ( contentType =3D=3D null || "".equals(contentType) ){
+                if (contentType =3D=3D null || "".equals(contentType)) {
                     contentType =3D initialContentType;
                 }
             }
@@ -1580,7 +1580,7 @@
         return true;
     }
 =

-    private List saveAcl(final DAVFileAccess dav, final ProcessingContext =
jParams) throws JahiaException {
+    private List saveAcl(final DAVFileAccess dav, final ProcessingContext =
jParams, final boolean ignoreWarning) throws JahiaException {
         // Check if the inheritance has to be permanently prevent or not.
         final Integer userNameWidth =3D (Integer) jParams.getSessionState(=
).getAttribute(
                 "userNameWidth");
@@ -1644,22 +1644,25 @@
                     break;
                 default:
                     logger.error("Unknown principal type");
-                    throw new JahiaException("Unknown principal type", "Un=
known principal type",
-                            JahiaException.ACL_ERROR, JahiaException.CRITI=
CAL_SEVERITY);
+                    return null;
             }
             // Decode the select box value parameters
             int vDefInherit =3D mRights.getVDefaultInherit();
-            String permissions =3D aclEntry.substring(ManageRights.V_DEFAU=
LT_PERMISSION, vDefInherit);
+            String permissions =3D aclEntry.substring(ManageRights.V_DEFAU=
LT_PERMISSION,
+                    vDefInherit);
+
             final boolean cannotRead =3D permissions.charAt(JahiaBaseACL.R=
EAD_RIGHTS) =3D=3D '-';
 =

-            if (cannotRead && submitedACLEntries[i].charAt(2) !=3D '1') {
+            if (cannotRead && aclEntry.charAt(2) !=3D '1') {
                 final List usages =3D jahiaWebdavBaseService.findUsages(da=
v.getPath(), jParams, false);
                 if (usages !=3D null && usages.size() > 0) {
                     // Since we are cutting READ rights on the dav file, w=
e need to check its usages and check
                     // the FileFields' rights.
 =

-                    final List futur403 =3D areWeGoingtoGenerateA403(usage=
s, subject, jParams);
-                    if (futur403.size() > 0) return futur403;
+                    if (!ignoreWarning) {
+                        final List futur403 =3D areWeGoingtoGenerateA403(u=
sages, subject, jParams);
+                        if (futur403.size() > 0) return futur403;
+                    }
                 }
             }
 =

@@ -1673,6 +1676,7 @@
                 }
             } else if (aclEntry.charAt(vDefInherit) =3D=3D '%') {
                 logger.debug("Cut inheritance for user : " + subject);
+
                 boolean res =3D dav.changePermissions(subject, permissions=
);
                 if (!res) {
                     final List tmp =3D new ArrayList();
@@ -1689,8 +1693,7 @@
                 }
                 continue;
             } else if (aclEntry.charAt(ManageRights.V_RIGHT_CHANGE) =3D=3D=
 '1') {
-                logger.debug("Permissions have changed to " +
-                        permissions + " for user : " + subject);
+                logger.debug("Permissions have changed to " + permissions =
+ " for user : " + subject);
                 boolean res =3D dav.changePermissions(subject, permissions=
);
                 if (!res) {
                     final List tmp =3D new ArrayList();
@@ -1742,18 +1745,19 @@
             if (theEntry.getWorkflow() =3D=3D EntryLoadRequest.VERSIONED_W=
ORKFLOW_STATE) continue;
             final JahiaField field =3D theEntry.getField();
 =

-            // Get all the groups which can see the field
-            final Vector fieldACLGroups =3D field.getACL().getGroupnameLis=
tNoAdmin(aclEntry);
-            logger.debug("fieldACLGroups with READ: " + fieldACLGroups);
+            if (field !=3D null) {
+                // Get all the groups which can see the field
+                final Vector fieldACLGroups =3D field.getACL().getGroupnam=
eListNoAdmin(aclEntry);
+                logger.debug("fieldACLGroups with READ: " + fieldACLGroups=
);
 =

-            if (fieldACLGroups.contains(entryName)) {
-                result.add(new Object[]{theEntry, entryName});
+                if (fieldACLGroups.contains(entryName)) {
+                    result.add(new Object[]{theEntry, entryName});
+                }
             }
         }
         return result;
     }
 =

-
     private int getPermissionsAsInt(String subject, int c, Map perms) {
         if (perms.containsKey(subject)) {
             c =3D 1 << c;

_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list

Reply via email to