Author: xlawrence
Date: Mon Sep 17 16:47:27 2007
New Revision: 18518
URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D18518&repname=
=3Djahia
Log:
Resolve issue http://www.jahia.net/jira/browse/JAHIA-2255: Another containe=
r can be added in a SINGLE_TYPE containers.
Added a check in order to test the list type and the list size. If the list=
type is not standard and the list size is greater than 0, then I no longer=
render the possibility to render the AddContainer launcher.
Modified:
branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/data/beans/Contain=
erListBean.java
branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/taglibs/url/AddCon=
tainerURLTag.java
Modified: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/data/beans/C=
ontainerListBean.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/data/beans/ContainerListBean.java&rev=3D185=
18&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/data/beans/Contain=
erListBean.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/data/beans/Contain=
erListBean.java Mon Sep 17 16:47:27 2007
@@ -14,7 +14,8 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied=
. =
* See the License for the specific language governing permissions and =
* limitations under the License.
- */package org.jahia.data.beans;
+ */
+package org.jahia.data.beans;
=
import org.jahia.content.ContentObject;
import org.jahia.content.ContentObjectKey;
@@ -406,34 +407,50 @@
try {
/** todo FIXME we must still add lock check for all the action=
s */
final ContentContainerList theList =3D jahiaContainerList.getC=
ontentContainerList();
- String curURL =3D guiBean.drawAddContainerUrl(jahiaContainerLi=
st);
- String curLauncherURI =3D htmlToolBox.drawAddContainerLauncher=
(jahiaContainerList);
- ActionURIBean curActionURIBean =3D new ActionURIBean("add", cu=
rURL, curLauncherURI);
- LockKey lockKey =3D LockKey.composeLockKey(LockKey.ADD_CONTAIN=
ER_TYPE, jahiaContainerList.getID());
- // fake container list -> use the page id or parent container =
id
- if (jahiaContainerList.getID() =3D=3D 0 && jahiaContainerList.=
getParentEntryID() !=3D 0) {
- lockKey =3D LockKey.composeLockKey(LockKey.UPDATE_CONTAINE=
R_TYPE, jahiaContainerList.getParentEntryID());
- } else if (jahiaContainerList.getID() =3D=3D 0) {
- lockKey =3D LockKey.composeLockKey(LockKey.UPDATE_PAGE_TYP=
E, jahiaContainerList.getPageID());
- }
final JahiaUser user =3D processingContext.getUser();
- if (!lockRegistry.isAcquireable(lockKey, user, user.getUserKey=
())) {
- curActionURIBean.setLocked(true);
+ LockKey lockKey;
+ ActionURIBean curActionURIBean;
+ String curLauncherURI;
+ String curURL;
+ final Properties listProperties =3D theList.getJahiaContainerL=
ist(processingContext,
+ processingContext.getEntryLoadRequest()).getDefinition=
().getProperties();
+ final int containerListTypePropValue =3D Integer.parseInt(list=
Properties.getProperty(
+ JahiaContainerDefinition.CONTAINER_LIST_TYPE_PROPERTY)=
);
+ final boolean canAddContainer;
+ final int listSize =3D theList.getJahiaContainerList(processin=
gContext, processingContext.getEntryLoadRequest()).getFullSize();
+ if (containerListTypePropValue !=3D JahiaContainerDefinition.S=
TANDARD_TYPE) {
+ canAddContainer =3D (listSize =3D=3D 0);
} else {
- completelyLocked =3D false;
+ canAddContainer =3D true;
}
- if (!lockRegistry.canRelease(lockKey, user, user.getUserKey())=
) {
- curActionURIBean.setReleaseable(true);
- }
- if ((curActionURIBean.getUri() !=3D null) && (!"".equals(curAc=
tionURIBean.getUri()))) {
- actionURIs.put(curActionURIBean.getName(), curActionURIBea=
n);
+ if (canAddContainer) {
+ curURL =3D guiBean.drawAddContainerUrl(jahiaContainerList);
+ curLauncherURI =3D htmlToolBox.drawAddContainerLauncher(ja=
hiaContainerList);
+ curActionURIBean =3D new ActionURIBean("add", curURL, curL=
auncherURI);
+ lockKey =3D LockKey.composeLockKey(LockKey.ADD_CONTAINER_T=
YPE, jahiaContainerList.getID());
+ // fake container list -> use the page id or parent contai=
ner id
+ if (jahiaContainerList.getID() =3D=3D 0 && jahiaContainerL=
ist.getParentEntryID() !=3D 0) {
+ lockKey =3D LockKey.composeLockKey(LockKey.UPDATE_CONT=
AINER_TYPE, jahiaContainerList.getParentEntryID());
+ } else if (jahiaContainerList.getID() =3D=3D 0) {
+ lockKey =3D LockKey.composeLockKey(LockKey.UPDATE_PAGE=
_TYPE, jahiaContainerList.getPageID());
+ }
+
+ if (!lockRegistry.isAcquireable(lockKey, user, user.getUse=
rKey())) {
+ curActionURIBean.setLocked(true);
+ } else {
+ completelyLocked =3D false;
+ }
+ if (!lockRegistry.canRelease(lockKey, user, user.getUserKe=
y())) {
+ curActionURIBean.setReleaseable(true);
+ }
+ if ((curActionURIBean.getUri() !=3D null) && (!"".equals(c=
urActionURIBean.getUri()))) {
+ actionURIs.put(curActionURIBean.getName(), curActionUR=
IBean);
+ }
}
if (jahiaContainerList.getID() !=3D 0) {
curURL =3D guiBean.drawContainerListPropertiesUrl(theList);
- curLauncherURI =3D htmlToolBox.
- drawContainerListPropertiesLauncher(theList);
- curActionURIBean =3D new ActionURIBean("update", curURL,
- curLauncherURI);
+ curLauncherURI =3D htmlToolBox.drawContainerListProperties=
Launcher(theList);
+ curActionURIBean =3D new ActionURIBean("update", curURL, c=
urLauncherURI);
lockKey =3D LockKey.composeLockKey(LockKey.UPDATE_CONTAINE=
RLIST_TYPE, jahiaContainerList.getID());
if (!lockRegistry.isAcquireable(lockKey, user,
processingContext.getSessionID())) {
@@ -458,7 +475,8 @@
}
=
final ContentObject clipSource =3D ContentObject.getCo=
ntentObjectInstance(ContentObjectKey.getInstance(skey));
- if (clipSource !=3D null && ((ContentContainer) clipSo=
urce).getJahiaContainer(processingContext, processingContext.getEntryLoadRe=
quest()) !=3D null) {
+ if (clipSource !=3D null && ((ContentContainer) clipSo=
urce).getJahiaContainer(processingContext, processingContext.getEntryLoadRe=
quest()) !=3D null)
+ {
final JahiaContainerDefinition sDef =3D ((ContentC=
ontainer) clipSource).getJahiaContainer(processingContext, processingContex=
t.getEntryLoadRequest()).getDefinition();
final JahiaContainerDefinition dDef =3D jahiaConta=
inerList.getDefinition();
if (importExportService.isCompatible(dDef, sDef)) {
Modified: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/taglibs/url/=
AddContainerURLTag.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/taglibs/url/AddContainerURLTag.java&rev=3D1=
8518&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/taglibs/url/AddCon=
tainerURLTag.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/taglibs/url/AddCon=
tainerURLTag.java Mon Sep 17 16:47:27 2007
@@ -14,37 +14,41 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied=
. =
* See the License for the specific language governing permissions and =
* limitations under the License.
- */package org.jahia.taglibs.url;
+ */
+package org.jahia.taglibs.url;
=
import javax.servlet.jsp.JspException;
=
import org.jahia.data.beans.ContainerListBean;
import org.jahia.data.containers.JahiaContainerList;
+import org.jahia.data.containers.JahiaContainerDefinition;
import org.jahia.exceptions.JahiaException;
import org.jahia.taglibs.container.ContainerListTag;
=
+import java.util.Properties;
+
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2002</p>
* <p>Company: Jahia Ltd</p>
+ *
* @author Serge Huber
* @version 1.0
- *
* @jsp:tag name=3D"addContainerURL" body-content=3D"empty"
* description=3D"Displays the URL that allows to add a container in a con=
tainer list.
- *
+ * <p/>
* <p><attriInfo>
- *
+ * <p/>
* <p><b>Example 1 :</b>
- * <p>
- * <content:addContainerURL id=3D\"addContainerURL\" display=3D\"false=
\"/>
- *
+ * <p/>
+ * <content:addContainerURL id=3D\"addContainerURL\" display=3D\"false\=
"/>
+ * <p/>
* <p><b>Example 2 :</b>
- * <p>
- * <content:addContainerURL id=3D\"addContainerURL\" display=3D\"false=
\" withJSPopup=3D\"false\" />
- *
- *
+ * <p/>
+ * <content:addContainerURL id=3D\"addContainerURL\" display=3D\"false\=
" withJSPopup=3D\"false\" />
+ * <p/>
+ * <p/>
* <p><TABLE BORDER=3D'1' CELLPADDING=3D'3' CELLSPACING=3D'0' WIDTH=3D'100=
%'>
* <TR BGCOLOR=3D'#EEEEFF' CLASS=3D'TableSubHeadingColor'>
* <TD><B>Attributes inherited from tag <a href=3D'abstractURL.html' targe=
t=3D'tagFrame'>content:abstractURL</a> (i.e. from class org.jahia.taglibs.f=
ield.AbstractURLTag) </B></TD>
@@ -54,51 +58,68 @@
* id, name, display, withJSPopup</CODE></TD>
* </TR>
* </TABLE>
- *
+ * <p/>
* </attriInfo>"
*/
public class AddContainerURLTag extends AbstractURLTag {
=
private static org.apache.log4j.Logger logger =3D
- org.apache.log4j.Logger.getLogger(AddContainerURLTag.class);
+ org.apache.log4j.Logger.getLogger(AddContainerURLTag.class);
=
private JahiaContainerList containerList =3D null;
=
- protected void init () {
+ protected void init() {
=
if (getName() =3D=3D null) {
ContainerListTag parent =3D (ContainerListTag) findAncestorWit=
hClass(this,
- ContainerListTag.class);
+ ContainerListTag.class);
if (parent !=3D null) {
containerList =3D parent.getContainerList();
}
} else {
ContainerListBean containerListBean =3D (ContainerListBean)
- pageContext.findAttribut=
e(
- getName());
+ pageContext.findAttribute(
+ getName());
if (containerListBean !=3D null) {
containerList =3D containerListBean.getJahiaContainerList(=
);
}
}
}
=
- protected Object getIdObject () {
- String resultURL =3D null;
+ protected Object getIdObject() {
+ final String resultURL;
if (isWithJSPopup()) {
resultURL =3D getJSPopupURL();
} else {
resultURL =3D getURL();
}
- if ( (resultURL !=3D null) &&
- (resultURL.length() > 0)) {
+ if ((resultURL !=3D null) &&
+ (resultURL.length() > 0)) {
return resultURL;
}
return null;
}
=
- protected String getURL () {
+ protected String getURL() {
if (containerList !=3D null) {
try {
+ final Properties listProperties =3D containerList.getDefin=
ition().getProperties();
+ final int containerListTypePropValue =3D Integer.parseInt(=
listProperties.getProperty(
+ JahiaContainerDefinition.CONTAINER_LIST_TYPE_PROPE=
RTY));
+ final boolean canAddContainer;
+ final int listSize =3D containerList.getFullSize();
+ if (containerListTypePropValue !=3D JahiaContainerDefiniti=
on.STANDARD_TYPE) {
+ canAddContainer =3D (listSize =3D=3D 0);
+ } else {
+ canAddContainer =3D true;
+ }
+
+ if (! canAddContainer) {
+ logger.warn("Template warning: You are trying to gener=
ate a URL to add a second container to a single typed list");
+ logger.warn("Template warning: The URL will thus not b=
e generated");
+ return null;
+ }
+
return getJahiaData().gui().drawAddContainerUrl(containerL=
ist);
} catch (JahiaException je) {
logger.error("Error during URL generation:", je);
@@ -107,21 +128,41 @@
return null;
}
=
- protected String getJSPopupURL () {
+ protected String getJSPopupURL() {
if (containerList !=3D null) {
- String popupURL =3D getJahiaData().gui().html().
- drawAddContainerLauncher(containerList);
- if ( (popupURL !=3D null) && (!"".equals(popupURL))) {
- return "javascript:" + popupURL;
- } else {
- return null;
+ try {
+ final Properties listProperties =3D containerList.getDefin=
ition().getProperties();
+ final int containerListTypePropValue =3D Integer.parseInt(=
listProperties.getProperty(
+ JahiaContainerDefinition.CONTAINER_LIST_TYPE_PROPE=
RTY));
+ final boolean canAddContainer;
+ final int listSize =3D containerList.getFullSize();
+ if (containerListTypePropValue !=3D JahiaContainerDefiniti=
on.STANDARD_TYPE) {
+ canAddContainer =3D (listSize =3D=3D 0);
+ } else {
+ canAddContainer =3D true;
+ }
+
+ if (! canAddContainer) {
+ logger.warn("Template warning: You are trying to gener=
ate a URL to add a second container to a single typed list");
+ logger.warn("Template warning: The URL will thus not b=
e generated");
+ return null;
+ }
+
+ final String popupURL =3D getJahiaData().gui().html().draw=
AddContainerLauncher(containerList);
+ if ((popupURL !=3D null) && (!"".equals(popupURL))) {
+ return "javascript:" + popupURL;
+ } else {
+ return null;
+ }
+ } catch (JahiaException je) {
+ logger.error("Error getting addContainer URL", je);
}
}
return null;
}
=
- public int doEndTag ()
- throws JspException {
+ public int doEndTag()
+ throws JspException {
super.doEndTag();
containerList =3D null;
return EVAL_PAGE;
_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list