URL changes on an item are now propagated to the bundle and all instances (Issue #2042)
git-svn-id: https://svn.libreccm.org/ccm/trunk@2623 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
12391d31f1
commit
76b9482c9b
|
|
@ -159,6 +159,30 @@ public class ContentBundle extends ContentItem {
|
||||||
super(type);
|
super(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overwritten version of {@code setName(String)} to ensure that all instances have the same
|
||||||
|
* name (URL). Different URLs for instances may cause problems with the URL resolution,
|
||||||
|
* resulting in an 404 or even worse an Unexpected error.
|
||||||
|
*
|
||||||
|
* @param name The new name
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setName(final String name) {
|
||||||
|
super.setName(name);
|
||||||
|
|
||||||
|
final ItemCollection instances = getInstances();
|
||||||
|
ContentItem instance;
|
||||||
|
while(instances.next()) {
|
||||||
|
instance = instances.getContentItem();
|
||||||
|
if (!name.equals(instance.getName())) {
|
||||||
|
//Don't use the setter to avoid an infinite loop
|
||||||
|
//({@link ContentPage#setName(String)} calls this method)
|
||||||
|
instance.set(ContentItem.NAME, name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ContentItem makeCopy() {
|
protected ContentItem makeCopy() {
|
||||||
final ContentBundle newItem = (ContentBundle) super.makeCopy();
|
final ContentBundle newItem = (ContentBundle) super.makeCopy();
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.cms;
|
package com.arsdigita.cms;
|
||||||
|
|
||||||
|
|
||||||
import com.arsdigita.categorization.Category;
|
import com.arsdigita.categorization.Category;
|
||||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||||
import com.arsdigita.kernel.ACSObject;
|
import com.arsdigita.kernel.ACSObject;
|
||||||
|
|
@ -36,8 +35,8 @@ import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class extends {@link com.arsdigita.cms.ContentItem content
|
* This class extends {@link com.arsdigita.cms.ContentItem content
|
||||||
* item} with the additional attributes name, title and description. The name
|
* item} with the additional attributes name, title and description. The name attribute is used in
|
||||||
* attribute is used in generating the URL for this content page.
|
* generating the URL for this content page.
|
||||||
*
|
*
|
||||||
* @author Uday Mathur
|
* @author Uday Mathur
|
||||||
* @author Jack Chung
|
* @author Jack Chung
|
||||||
|
|
@ -48,19 +47,15 @@ public class ContentPage extends ContentItem {
|
||||||
|
|
||||||
private static final Logger s_log = Logger.getLogger(ContentPage.class);
|
private static final Logger s_log = Logger.getLogger(ContentPage.class);
|
||||||
|
|
||||||
public static final String BASE_DATA_OBJECT_TYPE =
|
public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.ContentPage";
|
||||||
"com.arsdigita.cms.ContentPage";
|
|
||||||
|
|
||||||
public static final String TITLE = "title";
|
public static final String TITLE = "title";
|
||||||
public static final String SUMMARY = "summary";
|
public static final String SUMMARY = "summary";
|
||||||
public static final String LAUNCH_DATE = "launchDate";
|
public static final String LAUNCH_DATE = "launchDate";
|
||||||
public static final String DESCRIPTION = "pageDescription";
|
public static final String DESCRIPTION = "pageDescription";
|
||||||
|
|
||||||
|
protected static final String PAGES_IN_FOLDER = "com.arsdigita.cms.pagesInFolder";
|
||||||
protected static final String PAGES_IN_FOLDER =
|
protected static final String PAGES_IN_CATEGORY = "com.arsdigita.cms.pagesInFolderByCategory";
|
||||||
"com.arsdigita.cms.pagesInFolder";
|
|
||||||
protected static final String PAGES_IN_CATEGORY =
|
|
||||||
"com.arsdigita.cms.pagesInFolderByCategory";
|
|
||||||
public static final String QUERY_PAGE = "page";
|
public static final String QUERY_PAGE = "page";
|
||||||
public static final String QUERY_TYPE = "type";
|
public static final String QUERY_TYPE = "type";
|
||||||
public static final String QUERY_ROOT_ID = "rootFolderID";
|
public static final String QUERY_ROOT_ID = "rootFolderID";
|
||||||
|
|
@ -70,32 +65,31 @@ public class ContentPage extends ContentItem {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor. This creates a new content page.
|
* Default constructor. This creates a new content page.
|
||||||
**/
|
*
|
||||||
|
*/
|
||||||
public ContentPage() {
|
public ContentPage() {
|
||||||
super(BASE_DATA_OBJECT_TYPE);
|
super(BASE_DATA_OBJECT_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor. The contained <code>DataObject</code> is retrieved
|
* Constructor. The contained <code>DataObject</code> is retrieved from the persistent storage
|
||||||
* from the persistent storage mechanism with an <code>OID</code>
|
* mechanism with an <code>OID</code> specified by <i>oid</i>.
|
||||||
* specified by <i>oid</i>.
|
|
||||||
*
|
*
|
||||||
* @param oid The <code>OID</code> for the retrieved
|
* @param oid The <code>OID</code> for the retrieved <code>DataObject</code>.
|
||||||
* <code>DataObject</code>.
|
*
|
||||||
**/
|
*/
|
||||||
public ContentPage(OID oid) throws DataObjectNotFoundException {
|
public ContentPage(OID oid) throws DataObjectNotFoundException {
|
||||||
super(oid);
|
super(oid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor. The contained <code>DataObject</code> is retrieved
|
* Constructor. The contained <code>DataObject</code> is retrieved from the persistent storage
|
||||||
* from the persistent storage mechanism with an <code>OID</code>
|
* mechanism with an <code>OID</code> specified by <i>id</i> and
|
||||||
* specified by <i>id</i> and
|
|
||||||
* <code>ContentPage.BASE_DATA_OBJECT_TYPE</code>.
|
* <code>ContentPage.BASE_DATA_OBJECT_TYPE</code>.
|
||||||
*
|
*
|
||||||
* @param id The <code>id</code> for the retrieved
|
* @param id The <code>id</code> for the retrieved <code>DataObject</code>.
|
||||||
* <code>DataObject</code>.
|
*
|
||||||
**/
|
*/
|
||||||
public ContentPage(BigDecimal id) throws DataObjectNotFoundException {
|
public ContentPage(BigDecimal id) throws DataObjectNotFoundException {
|
||||||
this(new OID(BASE_DATA_OBJECT_TYPE, id));
|
this(new OID(BASE_DATA_OBJECT_TYPE, id));
|
||||||
}
|
}
|
||||||
|
|
@ -109,8 +103,8 @@ public class ContentPage extends ContentItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the base PDL object type for this item. Child classes
|
* @return the base PDL object type for this item. Child classes should override this method to
|
||||||
* should override this method to return the correct value.
|
* return the correct value.
|
||||||
*/
|
*/
|
||||||
public String getBaseDataObjectType() {
|
public String getBaseDataObjectType() {
|
||||||
return BASE_DATA_OBJECT_TYPE;
|
return BASE_DATA_OBJECT_TYPE;
|
||||||
|
|
@ -127,10 +121,12 @@ public class ContentPage extends ContentItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the name of the content page. If the parent of the page
|
* Sets the name of the content page. If the parent of the page is a <code>ContentBundle</code>
|
||||||
* is a <code>ContentBundle</code> this method sets the bundle's
|
* this method sets the bundle's name as well.
|
||||||
* name as well.
|
*
|
||||||
|
* @param name The new name of the item
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setName(final String name) {
|
public void setName(final String name) {
|
||||||
super.setName(name);
|
super.setName(name);
|
||||||
|
|
||||||
|
|
@ -138,8 +134,8 @@ public class ContentPage extends ContentItem {
|
||||||
|
|
||||||
if (bundle != null) {
|
if (bundle != null) {
|
||||||
if (s_log.isDebugEnabled()) {
|
if (s_log.isDebugEnabled()) {
|
||||||
s_log.debug(this + " is inside a bundle; setting the " +
|
s_log.debug(this + " is inside a bundle; setting the " + "bundle's name to " + name
|
||||||
"bundle's name to " + name + " as well");
|
+ " as well");
|
||||||
}
|
}
|
||||||
|
|
||||||
bundle.setName(name);
|
bundle.setName(name);
|
||||||
|
|
@ -148,30 +144,27 @@ public class ContentPage extends ContentItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decides whether plugged in assets should be indexed with the
|
* Decides whether plugged in assets should be indexed with the page or separately. Default is
|
||||||
* page or separately. Default is false (assets are ONLY indexed
|
* false (assets are ONLY indexed as separate items) Subtypes may override this method to
|
||||||
* as separate items) Subtypes may override this method to
|
* provide the logic that decides whether or not assets should be indexed separately. If true,
|
||||||
* provide the logic that decides whether or not assets should
|
* content of assets is ONLY included in the page, not as a separate item. This method only
|
||||||
* be indexed separately. If true, content of assets is ONLY
|
* provides guidance to assets. Writers of plug in assets should refer to this method in
|
||||||
* included in the page, not as a separate item. This method only provides
|
* relation to the object that owns the asset and make a decision based on the answer.
|
||||||
* guidance to assets. Writers of plug in assets should
|
|
||||||
* refer to this method in relation to the object that
|
|
||||||
* owns the asset and make a decision based on the answer.
|
|
||||||
*
|
*
|
||||||
* Best course of action is for assets to provide their
|
* Best course of action is for assets to provide their own MetadataProvider which refers to
|
||||||
* own MetadataProvider which refers to this method in the
|
* this method in the indexObject method eg.
|
||||||
* indexObject method eg.
|
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
<pre>
|
* <pre>
|
||||||
public boolean indexObject (DomainObject dobj) {
|
* public boolean indexObject (DomainObject dobj) {
|
||||||
FileAttachment file = (FileAttachment) dobj;
|
* FileAttachment file = (FileAttachment) dobj;
|
||||||
ContentPage owner = (ContentPage) file.getFileOwner();
|
* ContentPage owner = (ContentPage) file.getFileOwner();
|
||||||
s_log.debug("index this file attachment? " + !owner.indexAssetsWithPage());
|
* s_log.debug("index this file attachment? " + !owner.indexAssetsWithPage());
|
||||||
return !owner.indexAssetsWithPage();
|
* return !owner.indexAssetsWithPage();
|
||||||
}
|
* }
|
||||||
</pre>
|
* </pre>
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean indexAssetsWithPage() {
|
public boolean indexAssetsWithPage() {
|
||||||
|
|
@ -197,7 +190,7 @@ public class ContentPage extends ContentItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getLaunchDate() {
|
public Date getLaunchDate() {
|
||||||
return (Date)get(LAUNCH_DATE);
|
return (Date) get(LAUNCH_DATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLaunchDate(Date ldate) {
|
public void setLaunchDate(Date ldate) {
|
||||||
|
|
@ -207,14 +200,15 @@ public class ContentPage extends ContentItem {
|
||||||
public void setDescription(String description) {
|
public void setDescription(String description) {
|
||||||
set(DESCRIPTION, description);
|
set(DESCRIPTION, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return (String)get(DESCRIPTION);
|
return (String) get(DESCRIPTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set parameters on the pagesInFolder data query
|
// Set parameters on the pagesInFolder data query
|
||||||
/**
|
/**
|
||||||
* @deprecated This doesn't filter its results based on the permissions of
|
* @deprecated This doesn't filter its results based on the permissions of the current user. Use
|
||||||
* the current user. Use <code>setPagesQueryParameters( String name, ContentSection s, String context, OID userOID )</code>
|
* <code>setPagesQueryParameters( String name, ContentSection s, String context, OID userOID )</code>
|
||||||
* instead.
|
* instead.
|
||||||
*/
|
*/
|
||||||
protected static DataQuery setPagesQueryParameters(String name,
|
protected static DataQuery setPagesQueryParameters(String name,
|
||||||
|
|
@ -223,9 +217,9 @@ public class ContentPage extends ContentItem {
|
||||||
DataQuery q = SessionManager.getSession().retrieveQuery(name);
|
DataQuery q = SessionManager.getSession().retrieveQuery(name);
|
||||||
Folder root;
|
Folder root;
|
||||||
Folder f = s.getRootFolder();
|
Folder f = s.getRootFolder();
|
||||||
if(ContentItem.LIVE.equals(context)) {
|
if (ContentItem.LIVE.equals(context)) {
|
||||||
root = (Folder)f.getLiveVersion();
|
root = (Folder) f.getLiveVersion();
|
||||||
if(root == null) {
|
if (root == null) {
|
||||||
// A hack to make sure we still return a valid DataQuery; the query
|
// A hack to make sure we still return a valid DataQuery; the query
|
||||||
// will have no rows
|
// will have no rows
|
||||||
root = f;
|
root = f;
|
||||||
|
|
@ -245,8 +239,7 @@ public class ContentPage extends ContentItem {
|
||||||
DataQuery q = setPagesQueryParameters(name, s, context);
|
DataQuery q = setPagesQueryParameters(name, s, context);
|
||||||
|
|
||||||
FilterFactory ff = q.getFilterFactory();
|
FilterFactory ff = q.getFilterFactory();
|
||||||
PrivilegeDescriptor pd =
|
PrivilegeDescriptor pd = PrivilegeDescriptor.get(SecurityManager.CMS_READ_ITEM);
|
||||||
PrivilegeDescriptor.get(SecurityManager.CMS_READ_ITEM);
|
|
||||||
|
|
||||||
Filter f = PermissionService.getFilterQuery(ff, "page.id", pd,
|
Filter f = PermissionService.getFilterQuery(ff, "page.id", pd,
|
||||||
userOID);
|
userOID);
|
||||||
|
|
@ -256,17 +249,17 @@ public class ContentPage extends ContentItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve all pages within the given content section that belong to
|
* Retrieve all pages within the given content section that belong to the given category
|
||||||
* the given category
|
|
||||||
*
|
*
|
||||||
* @param s the section
|
* @param s the section
|
||||||
* @param context if {@link ContentItem#LIVE}, retrieve only live items.
|
* @param context if {@link ContentItem#LIVE}, retrieve only live items. If
|
||||||
* If {@link ContentItem#DRAFT}, return only draft items
|
* {@link ContentItem#DRAFT}, return only draft items
|
||||||
* @param cat the category
|
* @param cat the category
|
||||||
* @return a DataQuery of all then pages within a section that belong to
|
*
|
||||||
* the given category
|
* @return a DataQuery of all then pages within a section that belong to the given category
|
||||||
* @deprecated This doesn't filter its results based on the permissions of
|
*
|
||||||
* the current user. Use <code>getPagesInSectionQuery( ContentSection s, String context, Category cat, OID userOID )</code>
|
* @deprecated This doesn't filter its results based on the permissions of the current user. Use
|
||||||
|
* <code>getPagesInSectionQuery( ContentSection s, String context, Category cat, OID userOID )</code>
|
||||||
* instead.
|
* instead.
|
||||||
*/
|
*/
|
||||||
public static DataQuery getPagesInSectionQuery(ContentSection s,
|
public static DataQuery getPagesInSectionQuery(ContentSection s,
|
||||||
|
|
@ -278,16 +271,16 @@ public class ContentPage extends ContentItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve all pages within the given content section that belong to
|
* Retrieve all pages within the given content section that belong to the given category
|
||||||
* the given category
|
|
||||||
*
|
*
|
||||||
* @param s the section
|
* @param s the section
|
||||||
* @param context if {@link ContentItem#LIVE}, retrieve only live items.
|
* @param context if {@link ContentItem#LIVE}, retrieve only live items. If
|
||||||
* If {@link ContentItem#DRAFT}, return only draft items
|
* {@link ContentItem#DRAFT}, return only draft items
|
||||||
* @param cat the category
|
* @param cat the category
|
||||||
* @param userOID the OID of the current user
|
* @param userOID the OID of the current user
|
||||||
* @return a DataQuery of all then pages within a section that belong to
|
*
|
||||||
* the given category which the current user has permission to view
|
* @return a DataQuery of all then pages within a section that belong to the given category
|
||||||
|
* which the current user has permission to view
|
||||||
*/
|
*/
|
||||||
public static DataQuery getPagesInSectionQuery(ContentSection s,
|
public static DataQuery getPagesInSectionQuery(ContentSection s,
|
||||||
String context,
|
String context,
|
||||||
|
|
@ -303,12 +296,12 @@ public class ContentPage extends ContentItem {
|
||||||
* Retrieve all pages within the given content section.
|
* Retrieve all pages within the given content section.
|
||||||
*
|
*
|
||||||
* @param s the section
|
* @param s the section
|
||||||
* @param context if {@link ContentItem#LIVE}, retrieve only live items.
|
* @param context if {@link ContentItem#LIVE}, retrieve only live items. If
|
||||||
* If {@link ContentItem#DRAFT}, return only draft items
|
* {@link ContentItem#DRAFT}, return only draft items
|
||||||
|
*
|
||||||
* @return a DataQuery of all the pages within the section.
|
* @return a DataQuery of all the pages within the section.
|
||||||
* @deprecated This doesn't filter its results based on the
|
*
|
||||||
* permissions of the current user. Use
|
* @deprecated This doesn't filter its results based on the permissions of the current user. Use <code>getPagesInSectionQuery( ContentSection s, String context,
|
||||||
* <code>getPagesInSectionQuery( ContentSection s, String context,
|
|
||||||
* OID userOID )</code> instead.
|
* OID userOID )</code> instead.
|
||||||
*/
|
*/
|
||||||
public static DataQuery getPagesInSectionQuery(ContentSection s,
|
public static DataQuery getPagesInSectionQuery(ContentSection s,
|
||||||
|
|
@ -320,11 +313,12 @@ public class ContentPage extends ContentItem {
|
||||||
* Retrieve all pages within the given content section.
|
* Retrieve all pages within the given content section.
|
||||||
*
|
*
|
||||||
* @param s the section
|
* @param s the section
|
||||||
* @param context if {@link ContentItem#LIVE}, retrieve only live items.
|
* @param context if {@link ContentItem#LIVE}, retrieve only live items. If
|
||||||
* If {@link ContentItem#DRAFT}, return only draft items
|
* {@link ContentItem#DRAFT}, return only draft items
|
||||||
* @param userOID the OID of the current user
|
* @param userOID the OID of the current user
|
||||||
* @return a DataQuery of all the pages within the section which
|
*
|
||||||
* the current user has permission to view
|
* @return a DataQuery of all the pages within the section which the current user has permission
|
||||||
|
* to view
|
||||||
*/
|
*/
|
||||||
public static DataQuery getPagesInSectionQuery(ContentSection s,
|
public static DataQuery getPagesInSectionQuery(ContentSection s,
|
||||||
String context,
|
String context,
|
||||||
|
|
@ -335,8 +329,8 @@ public class ContentPage extends ContentItem {
|
||||||
// These could be protected, but public may make it easier to
|
// These could be protected, but public may make it easier to
|
||||||
// debug
|
// debug
|
||||||
/**
|
/**
|
||||||
* default behaviour is to return the description. Subtypes should
|
* default behaviour is to return the description. Subtypes should override to change use some
|
||||||
* override to change use some other attribute
|
* other attribute
|
||||||
*/
|
*/
|
||||||
public String getSearchSummary() {
|
public String getSearchSummary() {
|
||||||
return getDescription();
|
return getDescription();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue