Überprüfung von allen Aufrufen von getPrimaryInstance() außer in Navigation abgeschlossen. Sollte jetzt, soweit ich das erkennen konnte, korrekt sein.

git-svn-id: https://svn.libreccm.org/ccm/trunk@269 8810af33-2d31-482b-a856-94f89814c4df
master
quasi 2009-09-29 07:00:18 +00:00
parent c559db1ad7
commit 36e5dd7b66
6 changed files with 1009 additions and 1005 deletions

View File

@ -57,29 +57,29 @@ import org.apache.log4j.Logger;
*/
public class ContentBundle extends ContentItem {
public static final String versionId =
"$Id: ContentBundle.java 967 2005-10-28 18:08:42Z sskracic $" +
"$Author: sskracic $" +
"$DateTime: $";
"$Id: ContentBundle.java 967 2005-10-28 18:08:42Z sskracic $" +
"$Author: sskracic $" +
"$DateTime: $";
private static final Logger s_log = Logger.getLogger(ContentBundle.class);
private static DomainObjectObserver s_instancesObserver =
new AbstractDomainObjectObserver() {
public void add(DomainObject dom, String name,
DataObject dobj) {
if (INSTANCES.equals(name)) {
if (dobj != null) {
PermissionService.setContext(dobj.getOID(), dom.getOID());
}
new AbstractDomainObjectObserver() {
public void add(DomainObject dom, String name,
DataObject dobj) {
if (INSTANCES.equals(name)) {
if (dobj != null) {
PermissionService.setContext(dobj.getOID(), dom.getOID());
}
}
};
}
};
/**
* The base data object type of a bundle
*/
public static final String BASE_DATA_OBJECT_TYPE =
"com.arsdigita.cms.ContentBundle";
"com.arsdigita.cms.ContentBundle";
/**
* The primary instances association
@ -138,7 +138,7 @@ public class ContentBundle extends ContentItem {
* retrieve
*/
public ContentBundle(final BigDecimal id)
throws DataObjectNotFoundException {
throws DataObjectNotFoundException {
this(new OID(BASE_DATA_OBJECT_TYPE, id));
}
@ -168,7 +168,7 @@ public class ContentBundle extends ContentItem {
final ContentBundle newItem = (ContentBundle) super.makeCopy();
final WorkflowTemplate template =
ContentTypeWorkflowTemplate.getWorkflowTemplate
ContentTypeWorkflowTemplate.getWorkflowTemplate
(newItem.getContentSection(), newItem.getContentType());
if (template != null) {
@ -202,7 +202,7 @@ public class ContentBundle extends ContentItem {
if (Assert.isEnabled()) {
Assert.exists(language, String.class);
Assert.truth(language.length() == 2,
language + " is not an ISO639 language code");
language + " is not an ISO639 language code");
}
set(DEFAULT_LANGUAGE, language);
@ -229,8 +229,8 @@ public class ContentBundle extends ContentItem {
if (Assert.isEnabled()) {
Assert.exists(instance, ContentItem.class);
Assert.falsity(hasInstance(instance.getLanguage()),
"The bundle already contains an instance " +
"for the language " + instance.getLanguage());
"The bundle already contains an instance " +
"for the language " + instance.getLanguage());
}
instance.setParent(this);
@ -306,8 +306,8 @@ public class ContentBundle extends ContentItem {
if (Assert.isEnabled()) {
Assert.exists(language, String.class);
Assert.truth(language.length() == 2,
language + " does not look like a valid language " +
"code");
language + " does not look like a valid language " +
"code");
}
final DataAssociationCursor instances = instances();
@ -362,7 +362,7 @@ public class ContentBundle extends ContentItem {
if (Assert.isEnabled()) {
Assert.exists(language, String.class);
Assert.truth(language.length() == 2,
language + " is not an ISO639 language code");
language + " is not an ISO639 language code");
}
final DataAssociationCursor instances = instances();
@ -433,8 +433,8 @@ public class ContentBundle extends ContentItem {
matchingInstance = dataObject;
if (s_log.isDebugEnabled()) {
s_log.debug("negotiate: "
+ "bestMatch= " + i
+ ", language= " + language);
+ "bestMatch= " + i
+ ", language= " + language);
}
} // else other match with less preferred language found
}
@ -448,7 +448,7 @@ public class ContentBundle extends ContentItem {
instancesCursor.close();
if (matchingInstance != null) {
return (ContentItem) DomainObjectFactory.newInstance
(matchingInstance);
(matchingInstance);
} else {
s_log.info("negotiate: no match found!");
return null;
@ -503,8 +503,8 @@ public class ContentBundle extends ContentItem {
match = dataObject;
if (s_log.isDebugEnabled()) {
s_log.debug("negotiate: "
+ "bestMatch= " + i
+ ", language= " + language);
+ "bestMatch= " + i
+ ", language= " + language);
}
} // else other match with less preferred language found
}
@ -545,7 +545,7 @@ public class ContentBundle extends ContentItem {
}
public ContentItem publish(final LifecycleDefinition definition,
final Date start) {
final Date start) {
throw new UnsupportedOperationException();
}
@ -575,14 +575,14 @@ public class ContentBundle extends ContentItem {
* to copy the property.
*/
public boolean copyProperty(final CustomCopy source,
final Property property,
final ItemCopier copier) {
final Property property,
final ItemCopier copier) {
if (copier.getCopyType() == ItemCopier.VERSION_COPY) {
if (INSTANCES.equals(property.getName())) {
return true;
} else if (ATOZ_ALIASING_PROVIDERS.equals(property.getName())) {
return true;
}
if (INSTANCES.equals(property.getName())) {
return true;
} else if (ATOZ_ALIASING_PROVIDERS.equals(property.getName())) {
return true;
}
}
return super.copyProperty(source, property, copier);
@ -591,7 +591,7 @@ public class ContentBundle extends ContentItem {
public boolean copyServices(final ContentItem source) {
if (s_log.isDebugEnabled()) {
s_log.debug("Copying services on bundle " + getName() + " " +
getID() + " using source " + source.getID());
getID() + " using source " + source.getID());
}
// Copy categories
@ -625,7 +625,7 @@ public class ContentBundle extends ContentItem {
private DataAssociationCursor instances() {
final DataAssociationCursor cursor =
((DataAssociation) super.get(INSTANCES)).cursor();
((DataAssociation) super.get(INSTANCES)).cursor();
return cursor;
}

View File

@ -52,12 +52,12 @@ import java.util.StringTokenizer;
*/
public class MultilingualItemResolver extends AbstractItemResolver implements ItemResolver {
public static final String versionId =
"$Id: MultilingualItemResolver.java 1795 2009-02-07 10:47:32Z pboy $" +
"$Author: pboy $" +
"$DateTime: 2004/08/17 23:15:09 $";
"$Id: MultilingualItemResolver.java 1795 2009-02-07 10:47:32Z pboy $" +
"$Author: pboy $" +
"$DateTime: 2004/08/17 23:15:09 $";
private static final Logger s_log = Logger.getLogger
(MultilingualItemResolver.class);
(MultilingualItemResolver.class);
private static MasterPage s_masterP = null;
private static final String ADMIN_PREFIX = "admin";
@ -74,7 +74,7 @@ public class MultilingualItemResolver extends AbstractItemResolver implements It
*/
protected static final String SEPARATOR = "&";
public MultilingualItemResolver () {
public MultilingualItemResolver() {
s_log.debug("Undergoing creation");
}
@ -90,124 +90,124 @@ public class MultilingualItemResolver extends AbstractItemResolver implements It
* #getCurrentContext}.
* @return The content item, or null if no such item exists
*/
public ContentItem getItem(final ContentSection section,
String url,
final String context) {
if (s_log.isDebugEnabled()) {
s_log.debug("Resolving the item in content section " + section +
" at URL '" + url + "' for context " + context);
}
public ContentItem getItem(final ContentSection section,
String url,
final String context) {
if (s_log.isDebugEnabled()) {
s_log.debug("Resolving the item in content section " + section +
" at URL '" + url + "' for context " + context);
}
Assert.exists(section, "ContentSection section");
Assert.exists(url, "String url");
Assert.exists(context, "String context");
Assert.exists(section, "ContentSection section");
Assert.exists(url, "String url");
Assert.exists(context, "String context");
Folder rootFolder = section.getRootFolder();
url = stripTemplateFromURL(url);
Folder rootFolder = section.getRootFolder();
url = stripTemplateFromURL(url);
// nothing to do, if root folder is null
if (rootFolder == null) {
s_log.debug("The root folder is null; returning no item");
} else {
if (s_log.isDebugEnabled()) {
s_log.debug("Using root folder " + rootFolder);
}
// nothing to do, if root folder is null
if (rootFolder == null) {
s_log.debug("The root folder is null; returning no item");
} else {
if (s_log.isDebugEnabled()) {
s_log.debug("Using root folder " + rootFolder);
}
if (ContentItem.LIVE.equals(context)) {
s_log.debug("The use context is 'live'");
if (ContentItem.LIVE.equals(context)) {
s_log.debug("The use context is 'live'");
// We allow for returning null, so the root folder may
// not be live.
//Assert.assertTrue(rootFolder.isLive(),
// "live context - root folder of secion must be live");
// We allow for returning null, so the root folder may
// not be live.
//Assert.assertTrue(rootFolder.isLive(),
// "live context - root folder of secion must be live");
// If the context is 'live', we need the live item.
// If the context is 'live', we need the live item.
rootFolder = (Folder) rootFolder.getLiveVersion();
rootFolder = (Folder) rootFolder.getLiveVersion();
if (rootFolder == null) {
s_log.debug("The live version of the root folder is " +
"null; returning no item");
} else {
s_log.debug("The root folder has a live version; " +
"recursing");
if (rootFolder == null) {
s_log.debug("The live version of the root folder is " +
"null; returning no item");
} else {
s_log.debug("The root folder has a live version; " +
"recursing");
final String prefix =
section.getURL() + rootFolder.getPath();
final String prefix =
section.getURL() + rootFolder.getPath();
if (url.startsWith(prefix)) {
if (s_log.isDebugEnabled()) {
s_log.debug("The URL starts with prefix '" +
prefix + "'; removing it");
}
if (url.startsWith(prefix)) {
if (s_log.isDebugEnabled()) {
s_log.debug("The URL starts with prefix '" +
prefix + "'; removing it");
}
url = url.substring(prefix.length());
}
url = url.substring(prefix.length());
}
final ContentItem item = getItemFromLiveURL(url, rootFolder);
final ContentItem item = getItemFromLiveURL(url, rootFolder);
if (s_log.isDebugEnabled()) {
s_log.debug("Resolved URL '" + url + "' to item " +
item);
}
if (s_log.isDebugEnabled()) {
s_log.debug("Resolved URL '" + url + "' to item " +
item);
}
return item;
}
} else if (ContentItem.DRAFT.equals(context)) {
s_log.debug("The use context is 'draft'");
return item;
}
} else if (ContentItem.DRAFT.equals(context)) {
s_log.debug("The use context is 'draft'");
// For 'draft' items, 'generateUrl()' method returns
// URL like this
// '/acs/wcms/admin/item.jsp?item_id=10201&set_tab=1'
// Check if URL contains any match of string
// 'item_id', then try to instanciate item_id value
// and return FIXME: Please hack this if there is
// more graceful solution. [aavetyan]
// For 'draft' items, 'generateUrl()' method returns
// URL like this
// '/acs/wcms/admin/item.jsp?item_id=10201&set_tab=1'
// Check if URL contains any match of string
// 'item_id', then try to instanciate item_id value
// and return FIXME: Please hack this if there is
// more graceful solution. [aavetyan]
if (Assert.isEnabled()) {
Assert.isTrue
(url.indexOf(ITEM_ID) >= 0,
"url must contain parameter " + ITEM_ID);
}
if (Assert.isEnabled()) {
Assert.isTrue
(url.indexOf(ITEM_ID) >= 0,
"url must contain parameter " + ITEM_ID);
}
final ContentItem item = getItemFromDraftURL(url);
final ContentItem item = getItemFromDraftURL(url);
if (s_log.isDebugEnabled()) {
s_log.debug("Resolved URL '" + url + "' to item " + item);
}
if (s_log.isDebugEnabled()) {
s_log.debug("Resolved URL '" + url + "' to item " + item);
}
return item;
} else if (CMSDispatcher.PREVIEW.equals(context)) {
s_log.debug("The use context is 'preview'");
return item;
} else if (CMSDispatcher.PREVIEW.equals(context)) {
s_log.debug("The use context is 'preview'");
final String prefix = CMSDispatcher.PREVIEW + "/";
final String prefix = CMSDispatcher.PREVIEW + "/";
if (url.startsWith(prefix)) {
if (s_log.isDebugEnabled()) {
s_log.debug("The URL starts with prefix '" +
prefix + "'; removing it");
}
if (url.startsWith(prefix)) {
if (s_log.isDebugEnabled()) {
s_log.debug("The URL starts with prefix '" +
prefix + "'; removing it");
}
url = url.substring(prefix.length());
}
url = url.substring(prefix.length());
}
final ContentItem item = getItemFromLiveURL(url, rootFolder);
final ContentItem item = getItemFromLiveURL(url, rootFolder);
if (s_log.isDebugEnabled()) {
s_log.debug("Resolved URL '" + url + "' to item " + item);
}
if (s_log.isDebugEnabled()) {
s_log.debug("Resolved URL '" + url + "' to item " + item);
}
return item;
} else {
throw new IllegalArgumentException
("Invalid item resolver context " + context);
}
}
return item;
} else {
throw new IllegalArgumentException
("Invalid item resolver context " + context);
}
}
s_log.debug("No item resolved; returning null");
s_log.debug("No item resolved; returning null");
return null;
}
return null;
}
/**
* Fetches the current context based on the page state.
@ -225,7 +225,7 @@ public class MultilingualItemResolver extends AbstractItemResolver implements It
String url = state.getRequest().getRequestURI();
final ContentSection section =
CMS.getContext().getContentSection();
CMS.getContext().getContentSection();
// If this page is associated with a content section,
// transform the URL so that it is relative to the content
@ -267,10 +267,10 @@ public class MultilingualItemResolver extends AbstractItemResolver implements It
* @see #getCurrentContext
*/
public String generateItemURL(final PageState state,
final BigDecimal itemId,
final String name,
final ContentSection section,
final String context) {
final BigDecimal itemId,
final String name,
final ContentSection section,
final String context) {
return generateItemURL(state, itemId, name, section, context, null);
}
@ -289,15 +289,15 @@ public class MultilingualItemResolver extends AbstractItemResolver implements It
* @see #getCurrentContext
*/
public String generateItemURL(final PageState state,
final BigDecimal itemId,
final String name,
final ContentSection section,
final String context,
final String templateContext) {
final BigDecimal itemId,
final String name,
final ContentSection section,
final String context,
final String templateContext) {
if (s_log.isDebugEnabled()) {
s_log.debug("Generating an item URL for item id " + itemId +
", section " + section + ", and context '" +
context + "' with name '" + name + "'");
", section " + section + ", and context '" +
context + "' with name '" + name + "'");
}
Assert.exists(itemId, "BigDecimal itemId");
@ -317,14 +317,14 @@ public class MultilingualItemResolver extends AbstractItemResolver implements It
if (Assert.isEnabled()) {
Assert.exists(item, "item");
Assert.isTrue(ContentItem.LIVE.equals(item.getVersion()),
"Generating " + ContentItem.LIVE + " " +
"URL; this item must be the live version");
"Generating " + ContentItem.LIVE + " " +
"URL; this item must be the live version");
}
return generateLiveURL(section, item, templateContext);
} else {
throw new IllegalArgumentException
("Unknown context '" + context + "'");
("Unknown context '" + context + "'");
}
}
@ -340,9 +340,9 @@ public class MultilingualItemResolver extends AbstractItemResolver implements It
* @see #getCurrentContext
*/
public String generateItemURL(final PageState state,
final ContentItem item,
final ContentSection section,
final String context) {
final ContentItem item,
final ContentSection section,
final String context) {
return generateItemURL(state, item, section, context, null);
}
@ -360,14 +360,14 @@ public class MultilingualItemResolver extends AbstractItemResolver implements It
* @see #getCurrentContext
*/
public String generateItemURL(final PageState state,
final ContentItem item,
ContentSection section,
final String context,
final String templateContext) {
final ContentItem item,
ContentSection section,
final String context,
final String templateContext) {
if (s_log.isDebugEnabled()) {
s_log.debug("Generating an item URL for item " + item +
", section " + section + ", and context " +
context);
", section " + section + ", and context " +
context);
}
Assert.exists(item, "ContentItem item");
@ -380,8 +380,8 @@ public class MultilingualItemResolver extends AbstractItemResolver implements It
if (ContentItem.DRAFT.equals(context)) {
if (Assert.isEnabled()) {
Assert.isTrue(ContentItem.DRAFT.equals(item.getVersion()),
"Generating " + ContentItem.DRAFT +
" url: item must be draft version");
"Generating " + ContentItem.DRAFT +
" url: item must be draft version");
}
return generateDraftURL(section, item.getID());
@ -390,8 +390,8 @@ public class MultilingualItemResolver extends AbstractItemResolver implements It
} else if (ContentItem.LIVE.equals(context)) {
if (Assert.isEnabled()) {
Assert.isTrue(ContentItem.LIVE.equals(item.getVersion()),
"Generating " + ContentItem.LIVE +
" url: item must be live version");
"Generating " + ContentItem.LIVE +
" url: item must be live version");
}
return generateLiveURL(section, item, templateContext);
@ -408,25 +408,25 @@ public class MultilingualItemResolver extends AbstractItemResolver implements It
* @param request The HTTP request
* @return The master page
*/
public CMSPage getMasterPage(final ContentItem item,
final HttpServletRequest request)
throws ServletException {
if (s_log.isDebugEnabled()) {
s_log.debug("Getting the master page for item " + item);
}
public CMSPage getMasterPage(final ContentItem item,
final HttpServletRequest request)
throws ServletException {
if (s_log.isDebugEnabled()) {
s_log.debug("Getting the master page for item " + item);
}
// taken from SimpleItemResolver
if (s_masterP == null) {
s_masterP = new MasterPage();
s_masterP.init();
}
// taken from SimpleItemResolver
if (s_masterP == null) {
s_masterP = new MasterPage();
s_masterP.init();
}
if (s_log.isDebugEnabled()) {
s_log.debug("Returning master page " + s_masterP);
}
if (s_log.isDebugEnabled()) {
s_log.debug("Returning master page " + s_masterP);
}
return s_masterP;
}
return s_masterP;
}
/**
* Returns content item's draft version URL
@ -436,20 +436,20 @@ public class MultilingualItemResolver extends AbstractItemResolver implements It
* @return generated URL string
*/
protected String generateDraftURL(final ContentSection section,
final BigDecimal itemId) {
final BigDecimal itemId) {
if (s_log.isDebugEnabled()) {
s_log.debug("Generating draft URL for item ID " + itemId +
" and section " + section);
" and section " + section);
}
if (Assert.isEnabled()) {
Assert.isTrue(section != null && itemId != null,
"get draft url: neither secion nor item " +
"can be null");
"get draft url: neither secion nor item " +
"can be null");
}
final String url = ContentItemPage.getItemURL
(section.getPath() + "/", itemId, ContentItemPage.AUTHORING_TAB);
(section.getPath() + "/", itemId, ContentItemPage.AUTHORING_TAB);
if (s_log.isDebugEnabled()) {
s_log.debug("Generated draft URL " + url);
@ -476,11 +476,11 @@ public class MultilingualItemResolver extends AbstractItemResolver implements It
* be presented within the given <code>templateContext</code>
*/
protected String generateLiveURL(final ContentSection section,
final ContentItem item,
final String templateContext) {
final ContentItem item,
final String templateContext) {
if (s_log.isDebugEnabled()) {
s_log.debug("Generating live URL for item " + item + " in " +
"section " + section);
"section " + section);
}
/*
@ -495,7 +495,7 @@ public class MultilingualItemResolver extends AbstractItemResolver implements It
* add template context, if one is given
*/
// This is breaking URL's...not sure why it's here. XXX
// this should work with the appropriate logic. trying again.
// this should work with the appropriate logic. trying again.
if (!(templateContext == null || templateContext.length() == 0)) {
url.append(TEMPLATE_CONTEXT_PREFIX + templateContext + "/");
}
@ -518,7 +518,7 @@ public class MultilingualItemResolver extends AbstractItemResolver implements It
if (s_log.isDebugEnabled()) {
s_log.debug("Appending the bundle's file name '" +
fname + "'");
fname + "'");
}
url.append(fname);
@ -533,10 +533,10 @@ public class MultilingualItemResolver extends AbstractItemResolver implements It
if (language == null) {
s_log.debug("The item has no language; omitting the " +
"language encoding");
"language encoding");
} else {
s_log.debug("Encoding the language of the item passed in, '" +
language + "'");
language + "'");
url.append("." + language);
}
@ -567,8 +567,8 @@ public class MultilingualItemResolver extends AbstractItemResolver implements It
* <code>item</code>
*/
protected String generatePreviewURL(ContentSection section,
ContentItem item,
String templateContext) {
ContentItem item,
String templateContext) {
Assert.exists(section, "ContentSection section");
Assert.exists(item, "ContentItem item");
@ -581,7 +581,7 @@ public class MultilingualItemResolver extends AbstractItemResolver implements It
* add template context, if one is given
*/
// This is breaking URL's...not sure why it's here. XXX
// this should work with the appropriate logic. trying again.
// this should work with the appropriate logic. trying again.
if (!(templateContext == null || templateContext.length() == 0)) {
url.append(TEMPLATE_CONTEXT_PREFIX + templateContext + "/");
}
@ -610,10 +610,10 @@ public class MultilingualItemResolver extends AbstractItemResolver implements It
if (language == null) {
s_log.debug("The item has no language; omitting the " +
"language encoding");
"language encoding");
} else {
s_log.debug("Encoding the language of the item passed in, '" +
language + "'");
language + "'");
url.append("." + language);
}
@ -646,7 +646,7 @@ public class MultilingualItemResolver extends AbstractItemResolver implements It
// parameter; below we return null.
if (Assert.isEnabled()) {
Assert.isTrue(pos >= 0,
"Draft URL must contain parameter " + ITEM_ID);
"Draft URL must contain parameter " + ITEM_ID);
}
String item_id = url.substring(pos); // item_id == ITEM_ID=.... ?
@ -673,7 +673,7 @@ public class MultilingualItemResolver extends AbstractItemResolver implements It
OID oid = new OID(ContentItem.BASE_DATA_OBJECT_TYPE, new BigDecimal(item_id));
final ContentItem item = (ContentItem) DomainObjectFactory.newInstance
(oid);
(oid);
if (s_log.isDebugEnabled()) {
s_log.debug("Returning item " + item);
@ -692,17 +692,17 @@ public class MultilingualItemResolver extends AbstractItemResolver implements It
* or Folder objects, depending on URL and file language extension
*/
protected ContentItem getItemFromLiveURL(String url,
Folder parentFolder) {
Folder parentFolder) {
if (s_log.isDebugEnabled()) {
s_log.debug("Resolving the item for live URL " + url +
" and parent folder " + parentFolder);
" and parent folder " + parentFolder);
}
if (parentFolder == null || url == null || url.equals("")) {
if (s_log.isDebugEnabled()) {
s_log.debug("The url is null or parent folder was null " +
"or something else is wrong, so just return " +
"the parent folder");
"or something else is wrong, so just return " +
"the parent folder");
}
return parentFolder;
@ -713,7 +713,7 @@ public class MultilingualItemResolver extends AbstractItemResolver implements It
if (index >= 0) {
s_log.debug("The URL starts with a slash; paring off the first " +
"URL element and recursing");
"URL element and recursing");
// If we got first slash (index == 0), ignore it and go
// on, sample '/foo/bar/item.html.en', in next recursion
@ -721,23 +721,23 @@ public class MultilingualItemResolver extends AbstractItemResolver implements It
String name = index > 0 ? url.substring(0, index) : "";
parentFolder =
// really object identity? Don't think so
// name != "" ? (Folder) parentFolder.getItem(URLEncoder.encode(name), true)
// : parentFolder;
name.isEmpty() ? parentFolder
: (Folder) parentFolder.getItem(URLEncoder.encode(name), true);
// really object identity? Don't think so
// name != "" ? (Folder) parentFolder.getItem(URLEncoder.encode(name), true)
// : parentFolder;
name.isEmpty() ? parentFolder
: (Folder) parentFolder.getItem(URLEncoder.encode(name), true);
url = index + 1 < len ? url.substring(index + 1) : "";
return getItemFromLiveURL(url, parentFolder);
} else {
s_log.debug("Found a file element in the URL");
String[] nameAndLang = getNameAndLangFromURLFrag(url);
String[] nameAndLang = getNameAndLangFromURLFrag(url);
String name = nameAndLang[0];
String lang = nameAndLang[1];
ContentItem item = parentFolder.getItem(URLEncoder.encode(name), false);
return getItemFromLangAndBundle(lang, item);
return getItemFromLangAndBundle(lang, item);
}
}
@ -750,107 +750,107 @@ public class MultilingualItemResolver extends AbstractItemResolver implements It
* the lang string
*/
protected String[] getNameAndLangFromURLFrag(String url) {
String name = null;
String lang = null;
String name = null;
String lang = null;
/*
* Try to find out if there's an extension with the language code
* 1 Get a list of all "extensions", i.e. parts of the url
* which are separated by colons
* 2 If one or more extensions have been found, compare them against
* the list of known language codes
* 2a if a match is found, this language is used to retrieve an instance
* from a bundle
* 2b if no match is found
*/
/*
* Try to find out if there's an extension with the language code
* 1 Get a list of all "extensions", i.e. parts of the url
* which are separated by colons
* 2 If one or more extensions have been found, compare them against
* the list of known language codes
* 2a if a match is found, this language is used to retrieve an instance
* from a bundle
* 2b if no match is found
*/
final ArrayList exts = new ArrayList(5);
final StringTokenizer tok = new StringTokenizer(url, ".");
final ArrayList exts = new ArrayList(5);
final StringTokenizer tok = new StringTokenizer(url, ".");
while (tok.hasMoreTokens()) {
exts.add(tok.nextToken());
}
while (tok.hasMoreTokens()) {
exts.add(tok.nextToken());
}
if (exts.size() > 0) {
if (s_log.isDebugEnabled()) {
s_log.debug("Found some file extensions to look at; they " +
"are " + exts);
}
if (exts.size() > 0) {
if (s_log.isDebugEnabled()) {
s_log.debug("Found some file extensions to look at; they " +
"are " + exts);
}
/*
* We have found at least one extension, so we can
* proceed. Now try to find out if one of the
* extensions looks like a language code (we only
* support 2-letter language codes!).
* If so, use this as the language to look for.
*/
/*
* We have found at least one extension, so we can
* proceed. Now try to find out if one of the
* extensions looks like a language code (we only
* support 2-letter language codes!).
* If so, use this as the language to look for.
*/
/*
* First element is the NAME of the item, not an extension!
*/
name = (String) exts.get(0);
String ext = null;
Collection supportedLangs =
LanguageUtil.getSupportedLanguages2LA();
Iterator supportedLangIt = null;
/*
* First element is the NAME of the item, not an extension!
*/
name = (String) exts.get(0);
String ext = null;
Collection supportedLangs =
LanguageUtil.getSupportedLanguages2LA();
Iterator supportedLangIt = null;
for (int i = 1; i < exts.size(); i++) {
ext = (String) exts.get(i);
for (int i = 1; i < exts.size(); i++) {
ext = (String) exts.get(i);
if (s_log.isDebugEnabled()) {
s_log.debug("Examining extension " + ext);
}
if (s_log.isDebugEnabled()) {
s_log.debug("Examining extension " + ext);
}
/*
* Loop through all extensions, but discard the
* first one, which is the name of the item.
*/
if (ext != null && ext.length() == 2) {
/* Only check extensions consisting of 2
* characters.
*
* Compare current extension with known
* languages; if it matches, we've found the
* language we should use!
*/
supportedLangIt = supportedLangs.iterator();
while (supportedLangIt.hasNext()) {
if (ext.equals(supportedLangIt.next())) {
lang = ext;
if (s_log.isDebugEnabled()) {
s_log.debug("Found a match; using " +
"language " + lang);
}
break;
}
}
} else {
if (s_log.isDebugEnabled()) {
s_log.debug("Discarding extension " + ext + "; " +
"it is too short");
}
}
}
} else {
s_log.debug("The file has no extensions; no language was " +
"encoded");
name = url; // no extension, so we just have a name here
lang = null; // no extension, so we cannot guess the language
}
/*
* Loop through all extensions, but discard the
* first one, which is the name of the item.
*/
if (ext != null && ext.length() == 2) {
/* Only check extensions consisting of 2
* characters.
*
* Compare current extension with known
* languages; if it matches, we've found the
* language we should use!
*/
supportedLangIt = supportedLangs.iterator();
while (supportedLangIt.hasNext()) {
if (ext.equals(supportedLangIt.next())) {
lang = ext;
if (s_log.isDebugEnabled()) {
s_log.debug("Found a match; using " +
"language " + lang);
}
break;
}
}
} else {
if (s_log.isDebugEnabled()) {
s_log.debug("Discarding extension " + ext + "; " +
"it is too short");
}
}
}
} else {
s_log.debug("The file has no extensions; no language was " +
"encoded");
name = url; // no extension, so we just have a name here
lang = null; // no extension, so we cannot guess the language
}
if (Assert.isEnabled()) {
Assert.exists(name, "String name");
Assert.exists(lang == null || lang.length() == 2);
}
if (Assert.isEnabled()) {
Assert.exists(name, "String name");
Assert.exists(lang == null || lang.length() == 2);
}
if (s_log.isDebugEnabled()) {
s_log.debug("File name resolved to " + name);
s_log.debug("File language resolved to " + lang);
}
String[] returnArray = new String[2];
returnArray[0] = name;
returnArray[1] = lang;
return returnArray;
if (s_log.isDebugEnabled()) {
s_log.debug("File name resolved to " + name);
s_log.debug("File language resolved to " + lang);
}
String[] returnArray = new String[2];
returnArray[0] = name;
returnArray[1] = lang;
return returnArray;
}
@ -864,74 +864,73 @@ public class MultilingualItemResolver extends AbstractItemResolver implements It
* @return The negotiated lang instance for the current request.
*/
protected ContentItem getItemFromLangAndBundle(String lang, ContentItem item) {
if (item != null && item instanceof ContentBundle) {
if (s_log.isDebugEnabled()) {
s_log.debug("Found content bundle " + item);
}
if (lang == null) {
s_log.debug("The URL has no language encoded in it; " +
"negotiating the language");
/*
* Either there were no extensions at all, or
* neither one of them matched one of the
* supported languages. So the ContentBundle has
* to decide which language it will show; this
* decision is based on the preferred languages as
* defined in the client's request.
*/
// TODO: do something about this UCI (Unknown Content Item)...
if (item != null && item instanceof ContentBundle) {
if (s_log.isDebugEnabled()) {
s_log.debug("Found content bundle " + item);
}
if (lang == null) {
s_log.debug("The URL has no language encoded in it; " +
"negotiating the language");
/*
* Either there were no extensions at all, or
* neither one of them matched one of the
* supported languages. So the ContentBundle has
* to decide which language it will show; this
* decision is based on the preferred languages as
* defined in the client's request.
*/
// TODO: do something about this UCI (Unknown Content Item)...
// XXX sketchy getRequest
HttpServletRequest req = Web.getRequest();
final ContentItem resolved;
if (req != null) {
resolved = ((ContentBundle) item)
.negotiate(req.getLocales());
// XXX sketchy getRequest
HttpServletRequest req = Web.getRequest();
final ContentItem resolved;
if (req != null) {
resolved = ((ContentBundle) item).negotiate(req.getLocales());
} else {
// fallback to the primary instance when request is not available
resolved = ((ContentBundle) item).getPrimaryInstance();
}
if (s_log.isDebugEnabled()) {
s_log.debug("Resolved URL to item " + resolved);
}
return resolved;
} else {
s_log.debug("The URL is encoded with a langauge; " +
"fetching the appropriate item from " +
"the bundle");
/*
* So the request contains a language code as an
* extension of the "name" ==>go ahead and try to
* find the item from its ContentBundle. Fail if
* the bundle does not contain an instance for the
* given language.
*/
final ContentItem resolved =
((ContentBundle) item).getInstance(lang);
if (s_log.isDebugEnabled()) {
s_log.debug("Resolved URL to item " + resolved);
}
return resolved;
}
} else {
// fallback to the primary instance when request is not available
resolved = ((ContentBundle) item).getPrimaryInstance();
if (s_log.isDebugEnabled()) {
s_log.debug("I expected to get a content bundle; I got " +
item);
}
/*
* We expected something like a Bundle, but it seems
* like we got something completely different... just
* return this crap and let other people's code deal
* with it ;-).
*
* NOTE: This should never happen :-)
*/
return item; // might be null
}
if (s_log.isDebugEnabled()) {
s_log.debug("Resolved URL to item " + resolved);
}
return resolved;
} else {
s_log.debug("The URL is encoded with a langauge; " +
"fetching the appropriate item from " +
"the bundle");
/*
* So the request contains a language code as an
* extension of the "name" ==>go ahead and try to
* find the item from its ContentBundle. Fail if
* the bundle does not contain an instance for the
* given language.
*/
final ContentItem resolved =
((ContentBundle) item).getInstance(lang);
if (s_log.isDebugEnabled()) {
s_log.debug("Resolved URL to item " + resolved);
}
return resolved;
}
} else {
if (s_log.isDebugEnabled()) {
s_log.debug("I expected to get a content bundle; I got " +
item);
}
/*
* We expected something like a Bundle, but it seems
* like we got something completely different... just
* return this crap and let other people's code deal
* with it ;-).
*
* NOTE: This should never happen :-)
*/
return item; // might be null
}
}
}

View File

@ -80,22 +80,22 @@ import javax.servlet.ServletException;
*/
public class FolderBrowser extends Table {
public static final String versionId =
"$Id: FolderBrowser.java 1540 2007-03-26 20:44:49Z apevec $" +
"$Author: apevec $" +
"$DateTime: 2004/08/17 23:15:09 $";
"$Id: FolderBrowser.java 1540 2007-03-26 20:44:49Z apevec $" +
"$Author: apevec $" +
"$DateTime: 2004/08/17 23:15:09 $";
private static final Logger s_log = Logger.getLogger(FolderBrowser.class);
private static GlobalizedMessage[] s_headers = {
globalize("cms.ui.folder.name"), globalize("cms.ui.folder.title"),
globalize("cms.ui.folder.type"), globalize("cms.ui.folder.creation_date"),
globalize("cms.ui.folder.last_modified"), globalize("cms.ui.folder.action"),
globalize("cms.ui.folder.last_modified"), globalize("cms.ui.folder.action"),
globalize("cms.ui.folder.index") };
private static GlobalizedMessage[] s_noIndexHeaders = {
globalize("cms.ui.folder.name"), globalize("cms.ui.folder.title"),
globalize("cms.ui.folder.type"), globalize("cms.ui.folder.creation_date"),
globalize("cms.ui.folder.last_modified"), globalize("cms.ui.folder.action") };
globalize("cms.ui.folder.last_modified"), globalize("cms.ui.folder.action") };
private static final String SORT_ACTION_UP = "sortActionUp";
private static final String SORT_ACTION_DOWN = "sortActionDown";
@ -123,12 +123,12 @@ public class FolderBrowser extends Table {
public FolderBrowser(FolderSelectionModel currentFolder) {
//super(new FolderTableModelBuilder(), s_headers);
super();
m_sortType.setDefaultValue(SORT_KEY_NAME);
m_sortDirection.setDefaultValue(SORT_ACTION_UP);
m_sortType.setDefaultValue(SORT_KEY_NAME);
m_sortDirection.setDefaultValue(SORT_ACTION_UP);
setModelBuilder(new FolderTableModelBuilder(currentFolder));
setColumnModel(new DefaultTableColumnModel(hideIndexColumn() ? s_noIndexHeaders : s_headers));
setHeader(new TableHeader(getColumnModel()));
setModelBuilder(new FolderTableModelBuilder(currentFolder));
setColumnModel(new DefaultTableColumnModel(hideIndexColumn() ? s_noIndexHeaders : s_headers));
setHeader(new TableHeader(getColumnModel()));
// DEE 1/18/02: the folder table model builder needs to know about
// 'this' in order to set visibility, but 'this' isn't available
// until after the super class' constructor has run, so we can't
@ -153,13 +153,13 @@ public class FolderBrowser extends Table {
m_currentFolder.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
PageState state = e.getPageState();
state.setValue(m_sortType, m_sortType.getDefaultValue());
state.setValue(m_sortDirection, m_sortDirection.getDefaultValue());
public void stateChanged(ChangeEvent e) {
PageState state = e.getPageState();
state.setValue(m_sortType, m_sortType.getDefaultValue());
state.setValue(m_sortDirection, m_sortDirection.getDefaultValue());
}});
*/
}});
*/
setClassAttr("dataTable");
getHeader().setDefaultRenderer(new com.arsdigita.cms.ui.util.DefaultTableCellRenderer());
@ -200,14 +200,14 @@ public class FolderBrowser extends Table {
p.addComponentStateParam(this, m_sortType);
p.addComponentStateParam(this, m_sortDirection);
p.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
final PageState state = e.getPageState();
public void actionPerformed(ActionEvent e) {
final PageState state = e.getPageState();
if (state.isVisibleOnPage(FolderBrowser.this)) {
showHideFolderActions(state);
}
if (state.isVisibleOnPage(FolderBrowser.this)) {
showHideFolderActions(state);
}
});
}
});
}
private void showHideFolderActions(PageState state) {
@ -216,7 +216,7 @@ public class FolderBrowser extends Table {
Assert.assertNotNull(folder);
boolean canDelete =
sm.canAccess(state.getRequest(), SecurityManager.DELETE_ITEM, folder);
sm.canAccess(state.getRequest(), SecurityManager.DELETE_ITEM, folder);
m_deleteColumn.setVisible(state, canDelete);
}
@ -228,7 +228,7 @@ public class FolderBrowser extends Table {
state.setValue(m_sortType, value);
state.setValue(m_sortDirection, SORT_ACTION_UP);
} else if ( SORT_ACTION_DOWN.equals(key) ) {
state.setValue(m_sortType, value);
state.setValue(m_sortType, value);
state.setValue(m_sortDirection, SORT_ACTION_DOWN);
} else {
super.respond(state);
@ -241,7 +241,7 @@ public class FolderBrowser extends Table {
}
private class FolderTableModelBuilder
extends AbstractTableModelBuilder implements PaginationModelBuilder {
extends AbstractTableModelBuilder implements PaginationModelBuilder {
private FolderSelectionModel m_folder;
private RequestLocal m_size;
@ -268,7 +268,7 @@ public class FolderBrowser extends Table {
} else {
t.getRowSelectionModel().clearSelection(s);
return new FolderTableModel
((FolderBrowser) t, s, (Folder.ItemCollection) m_itemColl.get(s));
((FolderBrowser) t, s, (Folder.ItemCollection) m_itemColl.get(s));
}
}
@ -287,16 +287,16 @@ public class FolderBrowser extends Table {
}
PermissionService.filterQuery(
itemColl,
"id",
PrivilegeDescriptor.READ,
Kernel.getContext().getParty().getOID()
);
itemColl,
"id",
PrivilegeDescriptor.READ,
Kernel.getContext().getParty().getOID()
);
size = new Integer( (int) f.getPrimaryInstances().size());
itemColl.setRange(new Integer(paginator.getFirst(state)),
new Integer(paginator.getLast(state) + 1));
new Integer(paginator.getLast(state) + 1));
String sortKey = (String)state.getValue(m_sortType);
String direction = "asc";
@ -306,17 +306,17 @@ public class FolderBrowser extends Table {
if ( sortKey.equals(SORT_KEY_TITLE) ) {
itemColl.setOrder("lower(item." +
ContentItem.DISPLAY_NAME + ") " +
direction);
ContentItem.DISPLAY_NAME + ") " +
direction);
} else if ( sortKey.equals(SORT_KEY_NAME) ) {
itemColl.setOrder("lower(item." +
ContentItem.NAME + ") " + direction);
ContentItem.NAME + ") " + direction);
} else if ( sortKey.equals(SORT_KEY_LAST_MODIFIED_DATE)) {
itemColl.setOrder("item.auditing.lastModifiedDate " +
direction);
direction);
} else if ( sortKey.equals(SORT_KEY_CREATION_DATE)) {
itemColl.setOrder("item.auditing.creationDate " +
direction);
direction);
}
m_size.set(state, size);
@ -344,7 +344,7 @@ public class FolderBrowser extends Table {
private class HeaderCellRenderer
extends com.arsdigita.cms.ui.util.DefaultTableCellRenderer {
extends com.arsdigita.cms.ui.util.DefaultTableCellRenderer {
private String m_key;
@ -354,9 +354,9 @@ public class FolderBrowser extends Table {
}
public Component getComponent(final Table table, final PageState state,
Object value,
boolean isSelected, Object key,
int row, int column) {
Object value,
boolean isSelected, Object key,
int row, int column) {
String headerName = (String)((GlobalizedMessage)value).localize();
String sortKey = (String)state.getValue(m_sortType);
final boolean isCurrentKey = sortKey.equals(m_key);
@ -370,21 +370,21 @@ public class FolderBrowser extends Table {
}
ControlLink cl = new ControlLink(headerName) {
public void setControlEvent(PageState ps) {
String sortDirectionAction = null;
// by default, everything sorts "up" unless it
// is the current key and it is already pointing up
if (SORT_ACTION_UP.equals(currentSortDirection) &&
public void setControlEvent(PageState ps) {
String sortDirectionAction = null;
// by default, everything sorts "up" unless it
// is the current key and it is already pointing up
if (SORT_ACTION_UP.equals(currentSortDirection) &&
isCurrentKey) {
sortDirectionAction = SORT_ACTION_DOWN;
} else {
sortDirectionAction = SORT_ACTION_UP;
}
ps.setControlEvent(table,
sortDirectionAction,
m_key);
sortDirectionAction = SORT_ACTION_DOWN;
} else {
sortDirectionAction = SORT_ACTION_UP;
}
};
ps.setControlEvent(table,
sortDirectionAction,
m_key);
}
};
Label l = new Label();
l.setLabel("<font color=\"blue\">" + headerName + "</font>");
l.setOutputEscaping(false);
@ -412,14 +412,14 @@ public class FolderBrowser extends Table {
}
public Component getComponent(Table table, PageState state, Object value,
boolean isSelected, Object key,
int row, int column) {
boolean isSelected, Object key,
int row, int column) {
Folder.ItemCollection coll = (Folder.ItemCollection) value;
String name = coll.getName();
if ( coll.isFolder() ) {
return super.getComponent(table, state, name,
isSelected, key, row, column);
isSelected, key, row, column);
} else {
ContentSection section = CMS.getContext().getContentSection();
BigDecimal id = coll.getID();
@ -429,7 +429,7 @@ public class FolderBrowser extends Table {
} else {
ItemResolver resolver = section.getItemResolver();
return new Link(name, resolver.generateItemURL
(state, id, name, section, coll.getVersion()));
(state, id, name, section, coll.getVersion()));
}
}
}
@ -451,8 +451,8 @@ public class FolderBrowser extends Table {
}
public Component getComponent(Table table, PageState state, Object value,
boolean isSelected, Object key,
int row, int column) {
boolean isSelected, Object key,
int row, int column) {
if ( ((Boolean) value).booleanValue() ) {
return s_link;
} else {
@ -535,7 +535,7 @@ public class FolderBrowser extends Table {
//}
public FolderTableModel
(FolderBrowser table, PageState state, Folder.ItemCollection itemColl) {
(FolderBrowser table, PageState state, Folder.ItemCollection itemColl) {
m_state = state;
m_table = table;
m_itemColl = itemColl;
@ -561,45 +561,45 @@ public class FolderBrowser extends Table {
public Object getElementAt(int columnIndex) {
switch (columnIndex) {
case NAME:
return m_itemColl;
case TITLE:
return m_itemColl.getDisplayName();
case TYPE:
return m_itemColl.getTypeLabel();
case CREATION_DATE: {
java.util.Date creationDate = m_itemColl.getCreationDate();
if ( creationDate == null ) {
return "--";
case NAME:
return m_itemColl;
case TITLE:
return m_itemColl.getDisplayName();
case TYPE:
return m_itemColl.getTypeLabel();
case CREATION_DATE: {
java.util.Date creationDate = m_itemColl.getCreationDate();
if ( creationDate == null ) {
return "--";
}
return FormatStandards.formatDate(creationDate);
}
return FormatStandards.formatDate(creationDate);
}
case LAST_MODIFIED: {
java.util.Date lastModified = m_itemColl.getLastModifiedDate();
if ( lastModified == null ) {
return "--";
case LAST_MODIFIED: {
java.util.Date lastModified = m_itemColl.getLastModifiedDate();
if ( lastModified == null ) {
return "--";
}
return FormatStandards.formatDate(lastModified);
}
return FormatStandards.formatDate(lastModified);
}
case DELETABLE:
return new Boolean(isDeletable());
case IS_INDEX: {
if (hideIndexColumn()) {
case DELETABLE:
return new Boolean(isDeletable());
case IS_INDEX: {
if (hideIndexColumn()) {
throw new IndexOutOfBoundsException("Column index " + columnIndex +
" not in table model.");
}
if ( m_itemColl.isFolder() ) {
return null;
}
if ( m_folIndexID == null ) {
return new Boolean(false);
}
return new Boolean(m_folIndexID
.compareTo(m_itemColl.getBundleID()) == 0);
}
default:
throw new IndexOutOfBoundsException("Column index " + columnIndex +
" not in table model.");
}
if ( m_itemColl.isFolder() ) {
return null;
}
if ( m_folIndexID == null ) {
return new Boolean(false);
}
return new Boolean(m_folIndexID
.compareTo(m_itemColl.getBundleID()) == 0);
}
default:
throw new IndexOutOfBoundsException("Column index " + columnIndex +
" not in table model.");
" not in table model.");
}
}
@ -620,13 +620,13 @@ public class FolderBrowser extends Table {
if (!m_itemColl.hasChildren()) {
if (s_log.isDebugEnabled()) {
s_log.debug("The item is an empty folder; it may be " +
"deleted");
"deleted");
}
return true;
} else {
if (s_log.isDebugEnabled()) {
s_log.debug("The folder is not empty; it cannot be " +
"deleted");
"deleted");
}
return false;
}
@ -642,7 +642,7 @@ public class FolderBrowser extends Table {
public Object getKeyAt(int columnIndex) {
// Mark folders by using their negative ID (dirty, dirty)
return ( m_itemColl.isFolder() ) ? m_itemColl.getID().negate()
: m_itemColl.getBundleID();
: m_itemColl.getBundleID();
}
}

View File

@ -67,7 +67,7 @@ public class DocLink extends ContentPage implements Resource, Searchable {
/** Data object type for this domain object */
public static final String BASE_DATA_OBJECT_TYPE =
"com.arsdigita.cms.docmgr.DocLink";
"com.arsdigita.cms.docmgr.DocLink";
/** Data object type for this domain object (for CMS compatibility) */
public static final String TYPE = BASE_DATA_OBJECT_TYPE;
@ -80,14 +80,14 @@ public class DocLink extends ContentPage implements Resource, Searchable {
public DocLink() {
this(BASE_DATA_OBJECT_TYPE);
try {
setContentType(
ContentType.findByAssociatedObjectType(BASE_DATA_OBJECT_TYPE));
setContentType(
ContentType.findByAssociatedObjectType(BASE_DATA_OBJECT_TYPE));
} catch (DataObjectNotFoundException e) {
throw new UncheckedWrapperException(
(String) GlobalizationUtil
.globalize("cms.contenttypes.event_type_not_registered")
.localize(),
e);
(String) GlobalizationUtil
.globalize("cms.contenttypes.event_type_not_registered")
.localize(),
e);
}
}
@ -200,7 +200,7 @@ public class DocLink extends ContentPage implements Resource, Searchable {
*/
public Resource getParentResource() {
DocFolder parent =
(DocFolder) ((ContentBundle) getParent()).getParent();
(DocFolder) ((ContentBundle) getParent()).getParent();
return parent;
}
@ -241,13 +241,13 @@ public class DocLink extends ContentPage implements Resource, Searchable {
*/
public Resource copyTo(String name, final Resource parent) throws ResourceExistsException {
Folder.ItemCollection ic =
((Folder) parent).getItems();
((Folder) parent).getItems();
ic.addEqualsFilter("name",URLEncoder.encode(name));
boolean resourceExists = ic.next();
ic.close();
if(resourceExists) {
throw new ResourceExistsException
("Copying document would result in duplicate: "+name);
("Copying document would result in duplicate: "+name);
}
ContentItem item = this;
@ -271,7 +271,7 @@ public class DocLink extends ContentPage implements Resource, Searchable {
PermissionService.setContext(newItem,(ACSObject) parent);
}}.run();
return (Resource) ((ContentBundle) newItem).getPrimaryInstance();
return (Resource) ((ContentBundle) newItem).getPrimaryInstance();
}
/**
@ -308,7 +308,7 @@ public class DocLink extends ContentPage implements Resource, Searchable {
PermissionService.setContext(cb, (ACSObject) parent);
}
}
.run();
.run();
}
/**
@ -352,11 +352,11 @@ public class DocLink extends ContentPage implements Resource, Searchable {
}
}
CategoryCollection cats = getCategoryCollection();
Category cat;
if (cats.next()) {
cat = cats.getCategory();
String catID = cat.getID().toString();
CategoryCollection cats = getCategoryCollection();
Category cat;
if (cats.next()) {
cat = cats.getCategory();
String catID = cat.getID().toString();
if (newCategories.contains(catID)) {
newCategories.remove(catID);
} else {
@ -366,13 +366,13 @@ public class DocLink extends ContentPage implements Resource, Searchable {
Iterator additions = newCategories.iterator();
while (additions.hasNext()) {
addCategory(new Category(new BigDecimal
((String) additions.next())));
((String) additions.next())));
}
}
protected void beforeSave() {
super.beforeSave();
setLastModifiedLocal(new Date());
super.beforeSave();
setLastModifiedLocal(new Date());
}
public String getSearchLanguage() {
@ -386,7 +386,7 @@ public class DocLink extends ContentPage implements Resource, Searchable {
}
public String getSearchUrlStub() {
return "";
return "";
}
}

View File

@ -21,6 +21,7 @@ package com.arsdigita.london.atoz;
import com.arsdigita.cms.ContentBundle;
import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.ContentPage;
import com.arsdigita.dispatcher.DispatcherHelper;
import com.arsdigita.persistence.DataQuery;
import com.arsdigita.persistence.Filter;
import com.arsdigita.persistence.OID;
@ -58,7 +59,11 @@ public class AtoZItemGenerator extends AbstractAtoZGenerator {
bundle = new ContentBundle(new BigDecimal(entries.get("id")
.toString()));
if (bundle != null) {
item = bundle.getPrimaryInstance();
/* Fix by Quasimodo*/
/* getPrimaryInstance doesn't negotiate the language of the content item */
/* item = bundle.getPrimaryInstance(); */
item = bundle.negotiate(DispatcherHelper.getRequest().getLocales());
if (item != null) {
// this is necessary because aliases refer to the non-live
// version,

View File

@ -64,7 +64,7 @@ import com.arsdigita.kernel.User;
*/
public class RSSService {
private static org.apache.log4j.Logger s_log =
org.apache.log4j.Logger.getLogger(RSSService.class);
org.apache.log4j.Logger.getLogger(RSSService.class);
private static final RSSConfig s_config = new RSSConfig();
@ -80,10 +80,10 @@ public class RSSService {
* Generates an RSS channel for a specified category and and all of its Articles.
*/
public static void generateChannel(
BigDecimal categoryId,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
BigDecimal categoryId,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
Category cat = new Category(categoryId);
boolean useLAWs = "laws-1.0".equals(request.getParameter("extension"));
@ -95,7 +95,7 @@ public class RSSService {
// The two namespaces used for basic rdf. rssNS is the default namespace
// for all elements.
Namespace rdfNS =
Namespace.getNamespace(
Namespace.getNamespace(
"rdf",
"http://www.w3.org/1999/02/22-rdf-syntax-ns#");
Namespace rssNS = Namespace.getNamespace("http://purl.org/rss/1.0/");
@ -103,21 +103,21 @@ public class RSSService {
// The following namespaces are declared for the possible
// use of the LAWS extension
Namespace dcNS =
Namespace.getNamespace("dc", "http://purl.org/dc/elements/1.1/");
Namespace.getNamespace("dc", "http://purl.org/dc/elements/1.1/");
Namespace egmsNS = null;
if (useESD) {
egmsNS =
Namespace.getNamespace(
Namespace.getNamespace(
"esd",
"http://www.esd.org.uk/standards/esd/3.0/esd.rdfs");
} else {
egmsNS =
Namespace.getNamespace(
Namespace.getNamespace(
"egms",
"http://www.esd.org.uk/standards/egms/3.0/egms.rdfs");
}
Namespace lgclNS =
Namespace.getNamespace(
Namespace.getNamespace(
"lgcl",
"http://www.esd.org.uk/standards/lgcl/1.03/lgcl.rdfs");
@ -133,9 +133,9 @@ public class RSSService {
// Channel info
Element channel = new Element("channel", rssNS);
channel.setAttribute(
"about",
URL.here(request, "/rss/").getURL(),
rdfNS);
"about",
URL.here(request, "/rss/").getURL(),
rdfNS);
rdf.addContent(channel);
Element channelTitle = new Element("title", rssNS);
@ -167,7 +167,7 @@ public class RSSService {
// (below rdf)
SortedSet items = new TreeSet();
CategorizedCollection objects =
cat.getObjects(ContentItem.BASE_DATA_OBJECT_TYPE);
cat.getObjects(ContentItem.BASE_DATA_OBJECT_TYPE);
while (objects.next()) {
ContentItem item = (ContentItem) objects.getACSObject();
@ -229,11 +229,11 @@ public class RSSService {
if (description != null) {
Element descEl = new Element("description", rssNS);
descEl.setText(
com.arsdigita.util.StringUtils.truncateString(
com.arsdigita.util.StringUtils.truncateString(
description,
100,
true)
+ "...");
+ "...");
itemEl.addContent(descEl);
}
@ -264,7 +264,7 @@ public class RSSService {
itemEl.addContent(dcDateEl);
Element subjectCategoryEl =
new Element("subjectCategory", egmsNS);
new Element("subjectCategory", egmsNS);
itemEl.addContent(subjectCategoryEl);
Element subjectBagEl = new Element("Bag", rdfNS);
@ -284,7 +284,7 @@ public class RSSService {
if (terms != null) {
DomainCollectionIterator it =
new DomainCollectionIterator(terms);
new DomainCollectionIterator(terms);
while (it.hasNext()) {
@ -344,7 +344,7 @@ public class RSSService {
public int compareTo(Object o) {
if ((o instanceof NewestFirstItem)) {
return
- 1 * (m_liveID.compareTo(((NewestFirstItem) o).getLiveID()));
- 1 * (m_liveID.compareTo(((NewestFirstItem) o).getLiveID()));
} else {
throw new ClassCastException("Must compare to NewestFirstItem");
}
@ -363,15 +363,15 @@ public class RSSService {
* Generates an RSS channel for a specified category purpose
*/
public static void generateChannelList(
Category root,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
Category root,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
// The two namespaces used for basic rdf. rssNS is the default namespace
// for all elements.
Namespace rdfNS =
Namespace.getNamespace(
Namespace.getNamespace(
"rdf",
"http://www.w3.org/1999/02/22-rdf-syntax-ns#");
Namespace rssNS = Namespace.getNamespace("http://purl.org/rss/1.0/");
@ -383,9 +383,9 @@ public class RSSService {
// Channel info
Element channel = new Element("channel", rssNS);
channel.setAttribute(
"about",
URL.here(request, "/rss/").getURL(),
rdfNS);
"about",
URL.here(request, "/rss/").getURL(),
rdfNS);
rdf.addContent(channel);
Element channelTitle = new Element("title", rssNS);
@ -464,14 +464,14 @@ public class RSSService {
* Generates an RSS channel for a specified category and and all of its Articles.
*/
public static void generateFeedList(
boolean acsj,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
boolean acsj,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
// The two namespaces used for basic rdf. rssNS is the default namespace
// for all elements.
Namespace rdfNS =
Namespace.getNamespace(
Namespace.getNamespace(
"rdf",
"http://www.w3.org/1999/02/22-rdf-syntax-ns#");
Namespace rssNS = Namespace.getNamespace("http://purl.org/rss/1.0/");
@ -483,9 +483,9 @@ public class RSSService {
// Channel info
Element channel = new Element("channel", rssNS);
channel.setAttribute(
"about",
URL.here(request, "/rss/").getURL(),
rdfNS);
"about",
URL.here(request, "/rss/").getURL(),
rdfNS);
rdf.addContent(channel);
Element channelTitle = new Element("title", rssNS);
@ -564,7 +564,7 @@ public class RSSService {
upperCamel += word.toUpperCase();
} else {
upperCamel += word.substring(0, 1).toUpperCase()
+ word.substring(1, word.length());
+ word.substring(1, word.length());
}
}