Author: bpapez
Date: Mon Aug 27 12:23:22 2007
New Revision: 18268

URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D18268&repname=
=3Djahia
Log:
JAHIA-2141: in validation checks consider that in "mixed language" mode it =
could happen that the title is not captured for each language

Modified:
    branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/pages/Con=
tentPage.java

Modified: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/pag=
es/ContentPage.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/services/pages/ContentPage.java&rev=3D18268=
&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
--- branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/pages/Con=
tentPage.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/pages/Con=
tentPage.java Mon Aug 27 12:23:22 2007
@@ -2913,11 +2913,11 @@
             throws JahiaException {
         ActivationTestResults activationTestResults =3D super.isValidForAc=
tivation(languageCodes, jParams, stateModifContext);
         int pageType =3D getPageType(EntryLoadRequest.STAGED);
-
+        JahiaSite theSite =3D jParams.getSite();
+        =

         // first we must test if we have all the mandatory languages in our
         // page only if the page is not marked for deletion.
         if (!isMarkedForDelete()) {
-            JahiaSite theSite =3D jParams.getSite();
             Vector languageSettings =3D theSite.getLanguageSettings();
             Enumeration languageSettingsEnum =3D languageSettings.elements=
();
             while (languageSettingsEnum.hasMoreElements()) {
@@ -2958,102 +2958,36 @@
         // validated.
         Iterator languageCodeIter =3D languageCodes.iterator();
         if (getPageType(jParams.getEntryLoadRequest()) =3D=3D JahiaPage.TY=
PE_DIRECT) {
+            boolean oneLanguageSet =3D false;
+            JahiaPageInfo curPageInfo =3D null;
             while (languageCodeIter.hasNext()) {
                 String curLanguageCode =3D (String) languageCodeIter.next(=
);
-                JahiaPageInfo curPageInfo =3D (JahiaPageInfo) mStagingPage=
Infos.get(curLanguageCode);
+                curPageInfo =3D (JahiaPageInfo) mStagingPageInfos
+                        .get(curLanguageCode);
                 if (curPageInfo =3D=3D null) {
                     // no staging page info found, let's try in active...
-                    curPageInfo =3D (JahiaPageInfo) mActivePageInfos.get(c=
urLanguageCode);
-                    if (curPageInfo =3D=3D null) {
-                        /* Deactivated because pages are created by the pa=
ge field
-                       engine with default type to TYPE_DIRECT so we must =
be
-                       able to validate sub pages that were never initiali=
zed.
-                    if (pageType > -1) {
-                        // no page info for this language in active or sta=
ged modes,
-                        // let's signal error by issuing a warning or error
-                        // depending on the page type.
-                        if (pageType =3D=3D ContentPage.TYPE_DIRECT) {
-                            activationTestResults.setStatus(ActivationTest=
Results.
-                                FAILED_OPERATION_STATUS);
-                            try {
-                                activationTestResults.appendError(
-                                    new IsValidForActivationResults(Conten=
tPageKey.PAGE_TYPE,
-                                    getID(),
-                                    curPageInfo.getLanguageCode(),
-                                    "Cannot validate page since it has no =
title in live or edit mode for this language"));
-                            } catch (ClassNotFoundException cnfe) {
-                                logger.debug("Error while creating activat=
ion test node result", cnfe);
-                            }
-                        } else { */
-                        try {
-                            final EngineMessage msg =3D new EngineMessage(
-                                    "org.jahia.services.pages.ContentPage.=
noTitleError");
-                            activationTestResults
-                                    .appendError(new IsValidForActivationR=
esults(
-                                            ContentPageKey.PAGE_TYPE, getI=
D(),
-                                            curLanguageCode, msg));
-                        } catch (ClassNotFoundException cnfe) {
-                            logger.debug(
-                                    "Error while creating activation test =
node result",
-                                    cnfe);
-                        }
-                    } else {
-                        // we found a page info, let's check if the title =
was set.
-                        // normally this should always be the case if the =
page
-                        // was activated !!! If this is false it means the=
 database
-                        // is corrupted !
-                        if (curPageInfo.getTitle() =3D=3D null) {
-                            // missing title, let's signal it.
-                            activationTestResults.setStatus(ActivationTest=
Results.
-                                    FAILED_OPERATION_STATUS);
-                            try {
-                                final EngineMessage msg =3D new EngineMess=
age(
-                                        "org.jahia.services.pages.ContentP=
age.noTitleError");
-                                activationTestResults
-                                        .appendError(new IsValidForActivat=
ionResults(
-                                                ContentPageKey.PAGE_TYPE, =
getID(),
-                                                curPageInfo.getLanguageCod=
e(), msg));
-                            } catch (ClassNotFoundException cnfe) {
-                                logger.debug("Error while creating activat=
ion test node result",
-                                        cnfe);
-                            }
-                        } else if ("".equals(curPageInfo.getTitle().trim()=
)) {
-                            // empty title, let's signal it
-                            activationTestResults.setStatus(ActivationTest=
Results.
-                                    FAILED_OPERATION_STATUS);
-                            try {
-                                final EngineMessage msg =3D new EngineMess=
age(
-                                        "org.jahia.services.pages.ContentP=
age.emptyTitleError");
-                                activationTestResults
-                                        .appendError(new IsValidForActivat=
ionResults(
-                                                ContentPageKey.PAGE_TYPE, =
getID(),
-                                                curPageInfo.getLanguageCod=
e(), msg));
-                            } catch (ClassNotFoundException cnfe) {
-                                logger.debug("Error while creating activat=
ion test node result",
+                    curPageInfo =3D (JahiaPageInfo) mActivePageInfos
+                            .get(curLanguageCode);
+                }
+                if (curPageInfo =3D=3D null || curPageInfo.getTitle() =3D=
=3D null) {
+                    try {
+                        final EngineMessage msg =3D new EngineMessage(
+                                "org.jahia.services.pages.ContentPage.noTi=
tleError");
+                        activationTestResults
+                                .appendError(new IsValidForActivationResul=
ts(
+                                        ContentPageKey.PAGE_TYPE, getID(),
+                                        curLanguageCode, msg));
+                    } catch (ClassNotFoundException cnfe) {
+                        logger
+                                .debug(
+                                        "Error while creating activation t=
est node result",
                                         cnfe);
-                            }
-                        }
                     }
-                } else {
-                    // let's check if the title was set.
-                    if (curPageInfo.getTitle() =3D=3D null) {
-                        // missing title, let's signal it.
-                        activationTestResults.setStatus(ActivationTestResu=
lts.
-                                FAILED_OPERATION_STATUS);
-                        try {
-                            final EngineMessage msg =3D new EngineMessage(
-                                    "org.jahia.services.pages.ContentPage.=
noTitleError");
-                            activationTestResults
-                                    .appendError(new IsValidForActivationR=
esults(
-                                            ContentPageKey.PAGE_TYPE, getI=
D(),
-                                            curPageInfo.getLanguageCode(),=
 msg));
-                        } catch (ClassNotFoundException cnfe) {
-                            logger.debug("Error while creating activation =
test node result", cnfe);
-                        }
-                    } else if ("".equals(curPageInfo.getTitle().trim())) {
-                        // empty title, let's signal it
-                        activationTestResults.setStatus(ActivationTestResu=
lts.
-                                FAILED_OPERATION_STATUS);
+                } else if ("".equals(curPageInfo.getTitle().trim())) {
+                    // empty title, let's signal it if mixed language mode=
 is not activated
+                    if (!theSite.isMixLanguagesActive()) {
+                        activationTestResults
+                                .setStatus(ActivationTestResults.FAILED_OP=
ERATION_STATUS);
                         try {
                             final EngineMessage msg =3D new EngineMessage(
                                     "org.jahia.services.pages.ContentPage.=
emptyTitleError");
@@ -3062,9 +2996,30 @@
                                             ContentPageKey.PAGE_TYPE, getI=
D(),
                                             curPageInfo.getLanguageCode(),=
 msg));
                         } catch (ClassNotFoundException cnfe) {
-                            logger.debug("Error while creating activation =
test node result", cnfe);
+                            logger
+                                    .debug(
+                                            "Error while creating activati=
on test node result",
+                                            cnfe);
                         }
                     }
+                } else {
+                    oneLanguageSet =3D true;
+                }
+            }
+            if (theSite.isMixLanguagesActive() && !oneLanguageSet) {
+                activationTestResults
+                        .setStatus(ActivationTestResults.FAILED_OPERATION_=
STATUS);
+                try {
+                    final EngineMessage msg =3D new EngineMessage(
+                            "org.jahia.services.pages.ContentPage.emptyTit=
leError");
+                    activationTestResults
+                            .appendError(new IsValidForActivationResults(
+                                    ContentPageKey.PAGE_TYPE, getID(),
+                                    curPageInfo.getLanguageCode(), msg));
+                } catch (ClassNotFoundException cnfe) {
+                    logger.debug(
+                            "Error while creating activation test node res=
ult",
+                            cnfe);
                 }
             }
         }

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

Reply via email to