Author: bpapez
Date: Thu Jan  3 15:55:44 2008
New Revision: 19453

URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D19453&repname=
=3Djahia
Log:
JAHIA-2645: Not possible to remove windowSize from declareContainerList
- it was impossible to remove any property on declaration, now it is

Modified:
    trunk/core/src/java/org/jahia/data/containers/JahiaContainerDefinition.=
java
    trunk/core/src/java/org/jahia/data/containers/JahiaContainerSet.java

Modified: trunk/core/src/java/org/jahia/data/containers/JahiaContainerDefin=
ition.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/java/o=
rg/jahia/data/containers/JahiaContainerDefinition.java&rev=3D19453&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/data/containers/JahiaContainerDefinition.=
java (original)
+++ trunk/core/src/java/org/jahia/data/containers/JahiaContainerDefinition.=
java Thu Jan  3 15:55:44 2008
@@ -413,34 +413,6 @@
         }
     }
 =

-    /**
-     * Merge a set of properties passed in parameters with the internal
-     * properties set. Returns true if the resulting set of internal prope=
rties
-     * must be serialized.
-     * @param newProperties
-     * @return true if the result of the merge is a different set of prope=
rties
-     * that needs to be serialized.
-     */
-    public boolean propertiesChanged(Properties newProperties) {
-        boolean mustSave =3D false;
-        Enumeration newPropKeys =3D newProperties.keys();
-        while (newPropKeys.hasMoreElements()) {
-            String curNewPropName =3D (String) newPropKeys.nextElement();
-            String curNewPropValue =3D newProperties.getProperty(curNewPro=
pName);
-            if (this.ctnDefProperties.containsKey(curNewPropName)) {
-                String internalPropValue =3D this.ctnDefProperties.getProp=
erty(curNewPropName);
-                if (!internalPropValue.equals(curNewPropValue)) {
-                    // properties are not equals, lets set it.
-                    mustSave =3D true;
-                }
-            } else {
-                // this is a new property.
-                mustSave =3D true;
-            }
-        }
-        return mustSave;
-    }
-
     //--------------------------------------------------------------------=
------
     /**
      * Set the Container Edit View

Modified: trunk/core/src/java/org/jahia/data/containers/JahiaContainerSet.j=
ava
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/java/o=
rg/jahia/data/containers/JahiaContainerSet.java&rev=3D19453&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/data/containers/JahiaContainerSet.java (o=
riginal)
+++ trunk/core/src/java/org/jahia/data/containers/JahiaContainerSet.java Th=
u Jan  3 15:55:44 2008
@@ -302,21 +302,21 @@
                 Map props =3D aDef.getProperties();
                 Properties declaredProps =3D (Properties) this.declaredFie=
ldDefProps.get(fieldName);
 =

-                boolean propsHaveChanged =3D ((props =3D=3D null && (decla=
redProps !=3D null && declaredProps.size() > 0)) ||
-                        ((props !=3D null && props.size() > 0) && declared=
Props =3D=3D null)
+                boolean propsHaveChanged =3D ((props =3D=3D null && declar=
edProps !=3D null && !declaredProps.isEmpty()) ||
+                        (props !=3D null && !props.isEmpty() && declaredPr=
ops =3D=3D null)
                         || (props !=3D null && declaredProps !=3D null && =
!props.equals(declaredProps)));
                 boolean titleHasChanged =3D !aDef.getTitle(pageDefID).equa=
ls(fieldTitle);
                 boolean typeHasChanged =3D (aDef.getType(pageDefID) !=3D f=
ieldType);
                 boolean defaultValueHasChanged =3D ((aDef.getDefaultValue(=
pageDefID) !=3D null) &&
                         (aDef.getDefaultValue(pageDefID) =3D=3D null ||
-                                (!aDef.getDefaultValue(pageDefID).equals(d=
efaultValue))));
+                                !aDef.getDefaultValue(pageDefID).equals(de=
faultValue)));
                 if (titleHasChanged || typeHasChanged || defaultValueHasCh=
anged || propsHaveChanged) {
                     // well, data is not the same in the registry and in t=
he declare() method !
                     // this means the user has changed the field declarati=
on in the template...
                     // before doing anything else, we have to be sure that=
 the user didn't change the
                     // field data type, because this could crash the whole=
 application !
-                    if ((aDef.getType(pageDefID) !=3D fieldType) &&
-                            (aDef.getType(pageDefID) !=3D -1)) {
+                    if (aDef.getType(pageDefID) !=3D fieldType &&
+                            aDef.getType(pageDefID) !=3D -1) {
                         // okay, this user think he's smart : he tried to =
change the data type of
                         // fields already existing...
                         // let's send him a Jahia error to learn him a lit=
tle lesson
@@ -643,8 +643,8 @@
                 }
                 if (theName.equals("_self")) {
                                        
containerFields.setElementAt(containerName, i);
-                               } else if ((!isField && !checkDeclared(theName))
-                                               && (!isContainer && 
!checkDeclaredField(theName))) {
+                               } else if (!isField && !checkDeclared(theName)
+                                               && !isContainer && 
!checkDeclaredField(theName)) {
 =

                                        // one of the fields or containers in 
containerFields
                                        // doesn't exist !!
@@ -660,11 +660,11 @@
             // second, let's build the property set of the container
                        // definition
                        Properties ctnDefProperties =3D new Properties();
-                       if ((containerDefProperties !=3D null)
-                                       && (containerDefProperties.size() > 0)) 
{
+                       if (containerDefProperties !=3D null
+                                       && !containerDefProperties.isEmpty()) {
                                ctnDefProperties.putAll(containerDefProperties);
                        }
-                       if ((windowSize >=3D 1)) {
+                       if (windowSize >=3D 1) {
                                if (windowOffset < 0) {
                                        windowOffset =3D 0;
                                }
@@ -710,9 +710,8 @@
                        if (aDef !=3D null) {
                                // okay, it seems the definition already exists.
                                // now has it the same data than in the 
database ?
-                               Properties properties =3D new 
Properties(aDef.getProperties());
-                               boolean propertiesHaveChanged =3D aDef
-                                               
.propertiesChanged(ctnDefProperties);
+                               boolean propertiesHaveChanged =3D 
!aDef.getProperties().equals(ctnDefP=
roperties);
+
                                // checks if title changed
                                boolean titleHasChanged =3D 
!aDef.getTitle(pageDefID).equals(
                                                containerTitle);
@@ -727,7 +726,7 @@
                                                                + " has 
changed");
                                                if (propertiesHaveChanged) {
                                                        logger.warn(" 
Properties have changed : "
-                                                                       + 
properties + " / " + ctnDefProperties);
+                                                                       + 
aDef.getProperties() + " / " + ctnDefProperties);
                                                }
                                                if (titleHasChanged) {
                                                        logger.warn(" Title has 
changed : "
@@ -739,7 +738,7 @@
                                                }
                                        }
                                        synchronized (ctnDefRegistry) {
-                                               
aDef.getProperties().putAll(ctnDefProperties);
+                                               
aDef.setProperties(ctnDefProperties);
                                                // well, data is not the same 
in the registry and in the
                                                // declare() method !
                                                // this means the user has 
changed the container
@@ -934,7 +933,7 @@
         logger.debug("Updating definition for container name=3D" +
                 containerName +
                 " title=3D" + containerTitle +
-                " with " + Integer.toString(containerFields.size()) +
+                " with " + containerFields.size() +
                 " fields");
         // checks if container name and title are not empty
         if ((containerName.length() !=3D 0) && (containerTitle.length() !=
=3D 0) &&
@@ -946,8 +945,8 @@
                 String theName =3D (String) containerFields.elementAt(i);
                 if (theName.equals("_self")) {
                     containerFields.setElementAt(containerName, i);
-                } else if ((!checkDeclared(theName)) &&
-                        (!checkDeclaredField(containerName, theName))) {
+                } else if (!checkDeclared(theName) &&
+                        !checkDeclaredField(containerName, theName)) {
                     // one of the fields or containers in containerFields =
doesn't exist !!
                     String errorMsg =3D "Element not defined in container =
" +
                             containerName + " : " + theName;
@@ -1372,7 +1371,7 @@
              * definitions are not local to a page, but sub container defi=
nitions
              * are...
              */
-            if (parentSubContainerDefinitions.size() !=3D 0) {
+            if (!parentSubContainerDefinitions.isEmpty()) {
                 throw new JahiaException(
                         "Error while loading absolute container list",
                         "Cannot load a sub container list with this method=
 ! " +
@@ -1638,7 +1637,7 @@
 =

                 int containerType =3D def.getContainerListType();
                 if (jahiaContainersService
-                        .getctnidsInList(list.getID()).size() =3D=3D 0
+                        .getctnidsInList(list.getID()).isEmpty()
                         && ((containerType & JahiaContainerDefinition.MAND=
ATORY_TYPE) !=3D 0)) {
 =

                     JahiaContainer container =3D new JahiaContainer(0,

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

Reply via email to