Sprachinvariate ContentItems

LangUtil:
 - supportedLanguage wird immer um "--" für die invarianten CIs erweitert, d.h. Invariante CIs werden immer unterstützt
 - trim() für alle LanguageStrings eingeführt, da sonst ein versehentliches Leerzeichen in der Config für die supportedLanguages das System in einen Fehler laufen läßt.

iso639full.properties:
 - Eigentlich ist diese Datei überflüssig, aber in diesem Fall noch hilfreich, da ich den String für sprachinvariante CIs ("--") einfach eintragen konnte

ContentBundle:
 - getInstance(String language), negotiate(...) und hasInstance(String language) so angepaßt, daß sie mit sprachunabhängigen CIs umgehen können

AbstrctObjectList:
 - Filter in generateObjectListXML() geändert, so daß er auch auf sprachinvariante CI matched

git-svn-id: https://svn.libreccm.org/ccm/trunk@1161 8810af33-2d31-482b-a856-94f89814c4df
master
quasi 2011-10-12 08:30:30 +00:00
parent 66a189a304
commit ad84f95434
5 changed files with 175 additions and 143 deletions

View File

@ -32,6 +32,8 @@ import com.arsdigita.kernel.permissions.PermissionService;
import com.arsdigita.persistence.DataAssociation; import com.arsdigita.persistence.DataAssociation;
import com.arsdigita.persistence.DataAssociationCursor; import com.arsdigita.persistence.DataAssociationCursor;
import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.Filter;
import com.arsdigita.persistence.FilterFactory;
import com.arsdigita.persistence.OID; import com.arsdigita.persistence.OID;
import com.arsdigita.persistence.metadata.Property; import com.arsdigita.persistence.metadata.Property;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
@ -57,42 +59,37 @@ import org.apache.log4j.Logger;
* @version $Id: ContentBundle.java 2140 2011-01-16 12:04:20Z pboy $ * @version $Id: ContentBundle.java 2140 2011-01-16 12:04:20Z pboy $
*/ */
public class ContentBundle extends ContentItem { public class ContentBundle extends ContentItem {
private static final Logger s_log = Logger.getLogger(ContentBundle.class);
private static final Logger s_log = Logger.getLogger(ContentBundle.class);
private static DomainObjectObserver s_instancesObserver = private static DomainObjectObserver s_instancesObserver =
new AbstractDomainObjectObserver() { new AbstractDomainObjectObserver() {
public void add(DomainObject dom, String name,
DataObject dobj) { public void add(DomainObject dom, String name,
if (INSTANCES.equals(name)) { DataObject dobj) {
if (dobj != null) { if (INSTANCES.equals(name)) {
PermissionService.setContext(dobj.getOID(), dom.getOID()); if (dobj != null) {
PermissionService.setContext(dobj.getOID(), dom.getOID());
}
} }
} }
} };
};
/** /**
* The base data object type of a bundle * The base data object type of a bundle
*/ */
public static final String BASE_DATA_OBJECT_TYPE = public static final String BASE_DATA_OBJECT_TYPE =
"com.arsdigita.cms.ContentBundle"; "com.arsdigita.cms.ContentBundle";
/** /**
* The primary instances association * The primary instances association
*/ */
public static final String INSTANCES = "instances"; public static final String INSTANCES = "instances";
/** /**
* The association to AtoZ aliases * The association to AtoZ aliases
*/ */
public static final String ATOZ_ALIASING_PROVIDERS = "atozAliasingProviders"; public static final String ATOZ_ALIASING_PROVIDERS = "atozAliasingProviders";
/** /**
* The default language property * The default language property
*/ */
public static final String DEFAULT_LANGUAGE = "defaultLanguage"; public static final String DEFAULT_LANGUAGE = "defaultLanguage";
private boolean m_wasNew = false; private boolean m_wasNew = false;
/** /**
@ -101,7 +98,7 @@ public class ContentBundle extends ContentItem {
public String getBaseDataObjectType() { public String getBaseDataObjectType() {
return BASE_DATA_OBJECT_TYPE; return BASE_DATA_OBJECT_TYPE;
} }
/** /**
* Creates a new bundle. * Creates a new bundle.
* *
@ -109,16 +106,16 @@ public class ContentBundle extends ContentItem {
*/ */
public ContentBundle(final ContentItem primary) { public ContentBundle(final ContentItem primary) {
super(BASE_DATA_OBJECT_TYPE); super(BASE_DATA_OBJECT_TYPE);
Assert.exists(primary, ContentItem.class); Assert.exists(primary, ContentItem.class);
setDefaultLanguage(primary.getLanguage()); setDefaultLanguage(primary.getLanguage());
setContentType(primary.getContentType()); setContentType(primary.getContentType());
addInstance(primary); addInstance(primary);
super.setName(primary.getName()); super.setName(primary.getName());
} }
/** /**
* Retrieves a bundle. * Retrieves a bundle.
* *
@ -127,7 +124,7 @@ public class ContentBundle extends ContentItem {
public ContentBundle(final OID oid) throws DataObjectNotFoundException { public ContentBundle(final OID oid) throws DataObjectNotFoundException {
super(oid); super(oid);
} }
/** /**
* Retrieves a bundle. * Retrieves a bundle.
* *
@ -135,10 +132,10 @@ public class ContentBundle extends ContentItem {
* retrieve * retrieve
*/ */
public ContentBundle(final BigDecimal id) public ContentBundle(final BigDecimal id)
throws DataObjectNotFoundException { throws DataObjectNotFoundException {
this(new OID(BASE_DATA_OBJECT_TYPE, id)); this(new OID(BASE_DATA_OBJECT_TYPE, id));
} }
/** /**
* Retrieves or creates a bundle using the <code>DataObject</code> * Retrieves or creates a bundle using the <code>DataObject</code>
* argument. * argument.
@ -149,7 +146,7 @@ public class ContentBundle extends ContentItem {
public ContentBundle(final DataObject object) { public ContentBundle(final DataObject object) {
super(object); super(object);
} }
/** /**
* Creates a bundle. * Creates a bundle.
* *
@ -159,15 +156,13 @@ public class ContentBundle extends ContentItem {
public ContentBundle(final String type) { public ContentBundle(final String type) {
super(type); super(type);
} }
protected ContentItem makeCopy() { protected ContentItem makeCopy() {
final ContentBundle newItem = (ContentBundle) super.makeCopy(); final ContentBundle newItem = (ContentBundle) super.makeCopy();
final WorkflowTemplate template = final WorkflowTemplate template =
ContentTypeWorkflowTemplate.getWorkflowTemplate ContentTypeWorkflowTemplate.getWorkflowTemplate(newItem.getContentSection(), newItem.getContentType());
(newItem.getContentSection(), newItem.getContentType());
if (template != null) { if (template != null) {
s_log.debug("Setting up new workflow template"); s_log.debug("Setting up new workflow template");
ItemCollection instances = getInstances(); ItemCollection instances = getInstances();
@ -178,20 +173,20 @@ public class ContentBundle extends ContentItem {
workflow.setObjectID(instance.getID()); workflow.setObjectID(instance.getID());
workflow.start(Web.getContext().getUser()); workflow.start(Web.getContext().getUser());
workflow.save(); workflow.save();
} }
} }
return newItem; return newItem;
} }
/** /**
* Gets the default language of the bundle. * Gets the default language of the bundle.
*/ */
public final String getDefaultLanguage() { public final String getDefaultLanguage() {
return (String) get(DEFAULT_LANGUAGE); return (String) get(DEFAULT_LANGUAGE);
} }
/** /**
* Sets the default language of the bundle. * Sets the default language of the bundle.
*/ */
@ -201,10 +196,10 @@ public class ContentBundle extends ContentItem {
Assert.isTrue(language.length() == 2, Assert.isTrue(language.length() == 2,
language + " is not an ISO639 language code"); language + " is not an ISO639 language code");
} }
set(DEFAULT_LANGUAGE, language); set(DEFAULT_LANGUAGE, language);
} }
/** /**
* Adds a language instance to this bundle. This method will fail * Adds a language instance to this bundle. This method will fail
* if the bundle already contains a different instance for the * if the bundle already contains a different instance for the
@ -222,22 +217,22 @@ public class ContentBundle extends ContentItem {
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("Adding " + instance + " to bundle " + this); s_log.debug("Adding " + instance + " to bundle " + this);
} }
if (Assert.isEnabled()) { if (Assert.isEnabled()) {
Assert.exists(instance, ContentItem.class); Assert.exists(instance, ContentItem.class);
Assert.isFalse(hasInstance(instance.getLanguage()), Assert.isFalse(hasInstance(instance.getLanguage()),
"The bundle already contains an instance " + "The bundle already contains an instance "
"for the language " + instance.getLanguage()); + "for the language " + instance.getLanguage());
} }
instance.setParent(this); instance.setParent(this);
instance.setContentSection(getContentSection()); instance.setContentSection(getContentSection());
if (Assert.isEnabled()) { if (Assert.isEnabled()) {
Assert.isEqual(this, instance.getParent()); Assert.isEqual(this, instance.getParent());
} }
} }
/** /**
* Removes a language instance from the bundle. This method will * Removes a language instance from the bundle. This method will
* fail if <code>instance</code> is the primary instance. * fail if <code>instance</code> is the primary instance.
@ -256,14 +251,14 @@ public class ContentBundle extends ContentItem {
Assert.isEqual(this, instance.getParent()); Assert.isEqual(this, instance.getParent());
Assert.isNotEqual(instance, getPrimaryInstance()); Assert.isNotEqual(instance, getPrimaryInstance());
} }
instance.setParent(null); instance.setParent(null);
if (Assert.isEnabled()) { if (Assert.isEnabled()) {
Assert.isTrue(instance.getParent() == null); Assert.isTrue(instance.getParent() == null);
} }
} }
/** /**
* Gets the primary instance of this bundle. * Gets the primary instance of this bundle.
* *
@ -271,10 +266,10 @@ public class ContentBundle extends ContentItem {
* the primary instance * the primary instance
* @see #addInstance(ContentItem) * @see #addInstance(ContentItem)
*/ */
public final ContentItem getPrimaryInstance() { public final ContentItem getPrimaryInstance() {
return getInstance(getDefaultLanguage()); return getInstance(getDefaultLanguage());
} }
/** /**
* Produces a collection containing all language instances in this * Produces a collection containing all language instances in this
* bundle. * bundle.
@ -284,7 +279,7 @@ public class ContentBundle extends ContentItem {
public final ItemCollection getInstances() { public final ItemCollection getInstances() {
return new ItemCollection(instances()); return new ItemCollection(instances());
} }
/** /**
* Returns a language instance for <code>language</code> or * Returns a language instance for <code>language</code> or
* <code>null</code> if no such instance exists. * <code>null</code> if no such instance exists.
@ -303,34 +298,49 @@ public class ContentBundle extends ContentItem {
if (Assert.isEnabled()) { if (Assert.isEnabled()) {
Assert.exists(language, String.class); Assert.exists(language, String.class);
Assert.isTrue(language.length() == 2, Assert.isTrue(language.length() == 2,
language + " does not look like a valid language " + language + " does not look like a valid language "
"code"); + "code");
} }
final DataAssociationCursor instances = instances(); DataAssociationCursor instances = instances();
instances.addEqualsFilter(LANGUAGE, language); instances.addEqualsFilter(LANGUAGE, language);
DataObject dataObject = null; DataObject dataObject = null;
if (instances.next()) { if (instances.next()) {
final DataObject data = instances.getDataObject(); final DataObject data = instances.getDataObject();
if (Assert.isEnabled()) { if (Assert.isEnabled()) {
//Assert.isFalse(instances.next(), //Assert.isFalse(instances.next(),
// "There is more than one instance with the " + // "There is more than one instance with the " +
// "same language"); // "same language");
} }
instances.close(); instances.close();
return (ContentItem) DomainObjectFactory.newInstance(data); return (ContentItem) DomainObjectFactory.newInstance(data);
} else { } else {
instances.close(); instances.close();
// Look for language invariant version
instances = instances();
instances.addEqualsFilter(LANGUAGE, "--");
if (instances.next()) {
final DataObject data = instances.getDataObject();
instances.close();
return (ContentItem) DomainObjectFactory.newInstance(data);
} else {
instances.close();
}
return null; return null;
} }
} }
/** /**
* Tells whether <code>instance</code> is present in the bundle. * Tells whether <code>instance</code> is present in the bundle.
* *
@ -339,13 +349,13 @@ public class ContentBundle extends ContentItem {
*/ */
public final boolean hasInstance(final ContentItem instance) { public final boolean hasInstance(final ContentItem instance) {
Assert.exists(instance, ContentItem.class); Assert.exists(instance, ContentItem.class);
final DataAssociationCursor instances = instances(); final DataAssociationCursor instances = instances();
instances.addEqualsFilter(ID, instance.getID()); instances.addEqualsFilter(ID, instance.getID());
return !instances.isEmpty(); return !instances.isEmpty();
} }
/** /**
* Utility method to check if this bundle already contains an * Utility method to check if this bundle already contains an
* instance for the given <code>language</code>. * instance for the given <code>language</code>.
@ -361,13 +371,17 @@ public class ContentBundle extends ContentItem {
Assert.isTrue(language.length() == 2, Assert.isTrue(language.length() == 2,
language + " is not an ISO639 language code"); language + " is not an ISO639 language code");
} }
final DataAssociationCursor instances = instances(); final DataAssociationCursor instances = instances();
instances.addEqualsFilter(LANGUAGE, language); // instances.addEqualsFilter(LANGUAGE, language);
FilterFactory ff = instances.getFilterFactory();
Filter filter = ff.or().
addFilter(ff.equals("language", language)).
addFilter(ff.equals("language", "--"));
instances.addFilter(filter);
return !instances.isEmpty(); return !instances.isEmpty();
} }
/** /**
* List all languages in which this item is available, i.e. the * List all languages in which this item is available, i.e. the
* language codes of all instances in this bundle. * language codes of all instances in this bundle.
@ -379,24 +393,24 @@ public class ContentBundle extends ContentItem {
// XXX For LIVE bundles, there might be several PENDING // XXX For LIVE bundles, there might be several PENDING
// instances with the same language. Maybe we should filter // instances with the same language. Maybe we should filter
// these out and return only one? // these out and return only one?
final ItemCollection items = getInstances(); final ItemCollection items = getInstances();
final Collection list = new ArrayList(); final Collection list = new ArrayList();
while (items.next()) { while (items.next()) {
list.add(items.getLanguage()); list.add(items.getLanguage());
} }
items.close(); items.close();
if (Assert.isEnabled()) { if (Assert.isEnabled()) {
Assert.isTrue(!list.isEmpty() || getInstances().isEmpty()); Assert.isTrue(!list.isEmpty() || getInstances().isEmpty());
} }
return list; return list;
} }
/** /**
* Negotiate the right language instance for this bundle and return it. * Negotiate the right language instance for this bundle and return it.
* *
@ -407,7 +421,6 @@ public class ContentBundle extends ContentItem {
* <code>locales</code> * <code>locales</code>
* @pre locales != null * @pre locales != null
*/ */
// Quasimodo: // Quasimodo:
// Is this method ever used? Netbeans couldn't find anything. // Is this method ever used? Netbeans couldn't find anything.
public ContentItem negotiate(Locale[] locales) { public ContentItem negotiate(Locale[] locales) {
@ -423,28 +436,36 @@ public class ContentBundle extends ContentItem {
language = (String) dataObject.get(LANGUAGE); language = (String) dataObject.get(LANGUAGE);
// If language is not one of the supported languages, skip this entry // If language is not one of the supported languages, skip this entry
if(!supportedLanguages.contains(language)) { if (!supportedLanguages.contains(language)) {
continue; continue;
} }
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("negotiate: language= " + language); s_log.debug("negotiate: language= " + language);
} }
if (language != null) { if (language != null) {
for (int i=0; i < locales.length; i++) { // If the current object is languange invariant and no better
if (language.equals(locales[i].getLanguage())) { // match is already found, match it with the lowest priority
if (i < bestMatch || matchingInstance == null) { if (language.equals("--") && matchingInstance == null) {
bestMatch = i; bestMatch = locales.length;
matchingInstance = dataObject; matchingInstance = dataObject;
if (s_log.isDebugEnabled()) { } else {
s_log.debug("negotiate: " // In any other case
+ "bestMatch= " + i for (int i = 0; i < locales.length; i++) {
+ ", language= " + language); if (language.equals(locales[i].getLanguage())) {
} if (i < bestMatch || matchingInstance == null) {
} // else other match with less preferred language found bestMatch = i;
} matchingInstance = dataObject;
} // end for if (s_log.isDebugEnabled()) {
s_log.debug("negotiate: "
+ "bestMatch= " + i
+ ", language= " + language);
}
} // else other match with less preferred language found
}
} // end for
}
} // end if } // end if
if (bestMatch == 0 && matchingInstance != null) { if (bestMatch == 0 && matchingInstance != null) {
s_log.debug("negotiate: best possible match found, exiting"); s_log.debug("negotiate: best possible match found, exiting");
@ -453,14 +474,13 @@ public class ContentBundle extends ContentItem {
} }
instancesCursor.close(); instancesCursor.close();
if (matchingInstance != null) { if (matchingInstance != null) {
return (ContentItem) DomainObjectFactory.newInstance return (ContentItem) DomainObjectFactory.newInstance(matchingInstance);
(matchingInstance);
} else { } else {
s_log.info("negotiate: no match found!"); s_log.info("negotiate: no match found!");
return null; return null;
} }
} }
/** /**
* Negotiate the right language instance for this bundle and return it. * Negotiate the right language instance for this bundle and return it.
* *
@ -481,36 +501,42 @@ public class ContentBundle extends ContentItem {
Locale loc = null; Locale loc = null;
List languageCodes = new ArrayList(); List languageCodes = new ArrayList();
for (int i = 0; locales.hasMoreElements(); i++) { for (int i = 0; locales.hasMoreElements(); i++) {
loc = (Locale)locales.nextElement(); loc = (Locale) locales.nextElement();
// Quasimodo: // Quasimodo:
// Only add languages to the List which are supported by cms // Only add languages to the List which are supported by cms
if(supportedLanguages.contains(loc.getLanguage())) { if (supportedLanguages.contains(loc.getLanguage())) {
languageCodes.add( loc.getLanguage()); languageCodes.add(loc.getLanguage());
} }
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("negotiate: pref " + i + ": "+ loc.getLanguage()); s_log.debug("negotiate: pref " + i + ": " + loc.getLanguage());
} }
} }
// Add unspecified language for language invariant objects
if (supportedLanguages.contains("--")) {
languageCodes.add("--");
}
final DataAssociationCursor instances = instances(); final DataAssociationCursor instances = instances();
DataObject dataObject = null; DataObject dataObject = null;
int bestMatch = 0; int bestMatch = 0;
DataObject match = null; DataObject match = null;
String language = null; String language = null;
while (instances.next()) { while (instances.next()) {
dataObject = instances.getDataObject(); dataObject = instances.getDataObject();
language = (String) dataObject.get(LANGUAGE); language = (String) dataObject.get(LANGUAGE);
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("negotiate: language= " + language); s_log.debug("negotiate: language= " + language);
} }
if (language != null) { if (language != null) {
for (int i=0; i < languageCodes.size(); i++) { for (int i = 0; i < languageCodes.size(); i++) {
if (language.equals( (String)languageCodes.get(i) )) { if (language.equals((String) languageCodes.get(i))) {
if (i < bestMatch || match == null) { if (i < bestMatch || match == null) {
bestMatch = i; bestMatch = i;
match = dataObject; match = dataObject;
@ -523,58 +549,56 @@ public class ContentBundle extends ContentItem {
} }
} // end for } // end for
} // end if } // end if
if (bestMatch == 0 && match != null) { if (bestMatch == 0 && match != null) {
s_log.debug("negotiate: best possible match found, exiting"); s_log.debug("negotiate: best possible match found, exiting");
break; // exit loop when best match is found break; // exit loop when best match is found
} }
} }
instances.close(); instances.close();
return (ContentItem) DomainObjectFactory.newInstance(match); return (ContentItem) DomainObjectFactory.newInstance(match);
} }
// Methods from item that bundle overrides // Methods from item that bundle overrides
protected void beforeSave() { protected void beforeSave() {
super.beforeSave(); super.beforeSave();
final ContentItem primary = getPrimaryInstance(); final ContentItem primary = getPrimaryInstance();
Assert.exists(getContentType(), ContentType.class); Assert.exists(getContentType(), ContentType.class);
if (primary != null) { if (primary != null) {
primary.setContentSection(getContentSection()); primary.setContentSection(getContentSection());
} }
} }
protected boolean canPublishToFS() { protected boolean canPublishToFS() {
return false; return false;
} }
protected void publishToFS() { protected void publishToFS() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public ContentItem publish(final LifecycleDefinition definition, public ContentItem publish(final LifecycleDefinition definition,
final Date start) { final Date start) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public Lifecycle getLifecycle() { public Lifecycle getLifecycle() {
// Bundles do not have lifecycles. // Bundles do not have lifecycles.
return null; return null;
} }
public void setLifecycle(final Lifecycle lifecycle) { public void setLifecycle(final Lifecycle lifecycle) {
// I'd like to do the following, but VersionCopier calls // I'd like to do the following, but VersionCopier calls
// setLifecycle. // setLifecycle.
//throw new UnsupportedOperationException(); //throw new UnsupportedOperationException();
} }
/** /**
* Ignore the <code>INSTANCES</code> property for * Ignore the <code>INSTANCES</code> property for
* <code>ItemCopier.VERSION_COPY</code>. * <code>ItemCopier.VERSION_COPY</code>.
@ -597,57 +621,56 @@ public class ContentBundle extends ContentItem {
return true; return true;
} }
} }
return super.copyProperty(source, property, copier); return super.copyProperty(source, property, copier);
} }
public boolean copyServices(final ContentItem source) { public boolean copyServices(final ContentItem source) {
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("Copying services on bundle " + getName() + " " + s_log.debug("Copying services on bundle " + getName() + " "
getID() + " using source " + source.getID()); + getID() + " using source " + source.getID());
} }
// Copy categories // Copy categories
CategoryCollection categories = source.getCategoryCollection(); CategoryCollection categories = source.getCategoryCollection();
while (categories.next() ) { while (categories.next()) {
final Category category = categories.getCategory(); final Category category = categories.getCategory();
category.addChild(this); category.addChild(this);
category.save(); // XXX remove me category.save(); // XXX remove me
} }
categories.close(); categories.close();
return true; return true;
} }
protected void initialize() { protected void initialize() {
super.initialize(); super.initialize();
addObserver(s_instancesObserver); addObserver(s_instancesObserver);
m_wasNew = isNew(); m_wasNew = isNew();
} }
protected void afterSave() { protected void afterSave() {
if (m_wasNew) { if (m_wasNew) {
getPrimaryInstance().setContentSection(getContentSection()); getPrimaryInstance().setContentSection(getContentSection());
} }
super.afterSave(); super.afterSave();
} }
// Utility methods // Utility methods
private DataAssociationCursor instances() { private DataAssociationCursor instances() {
final DataAssociationCursor cursor = final DataAssociationCursor cursor =
((DataAssociation) super.get(INSTANCES)).cursor(); ((DataAssociation) super.get(INSTANCES)).cursor();
return cursor; return cursor;
} }
private DataAssociationCursor instances(final String version) { private DataAssociationCursor instances(final String version) {
final DataAssociationCursor cursor = instances(); final DataAssociationCursor cursor = instances();
cursor.addEqualsFilter(VERSION, version); cursor.addEqualsFilter(VERSION, version);
return cursor; return cursor;
} }
} }

View File

@ -63,7 +63,7 @@ public class LanguageUtil {
* at the server startup * at the server startup
*/ */
public static void setSupportedLanguages(String languages) { public static void setSupportedLanguages(String languages) {
s_languages = languages; s_languages = languages + ",--";
} }
/** Get the comma separated list of all supported languages */ /** Get the comma separated list of all supported languages */
@ -80,7 +80,7 @@ public class LanguageUtil {
StringTokenizer tokenizer = new StringTokenizer(allLanguages , ","); StringTokenizer tokenizer = new StringTokenizer(allLanguages , ",");
Collection langList = new LinkedList(); Collection langList = new LinkedList();
while (tokenizer.hasMoreElements()) { while (tokenizer.hasMoreElements()) {
String language = tokenizer.nextToken(); String language = tokenizer.nextToken().trim();
langList.add(language); langList.add(language);
} }
return langList; return langList;
@ -95,7 +95,7 @@ public class LanguageUtil {
StringTokenizer tokenizer = new StringTokenizer(allLanguages , ","); StringTokenizer tokenizer = new StringTokenizer(allLanguages , ",");
Collection langList = new LinkedList(); Collection langList = new LinkedList();
while (tokenizer.hasMoreElements()) { while (tokenizer.hasMoreElements()) {
String language = tokenizer.nextToken(); String language = tokenizer.nextToken().trim();
langList.add(new Pair(language , getLang3LA(language))); langList.add(new Pair(language , getLang3LA(language)));
} }
return langList; return langList;
@ -110,7 +110,7 @@ public class LanguageUtil {
StringTokenizer tokenizer = new StringTokenizer(allLanguages , ","); StringTokenizer tokenizer = new StringTokenizer(allLanguages , ",");
Collection langList = new LinkedList(); Collection langList = new LinkedList();
while (tokenizer.hasMoreElements()) { while (tokenizer.hasMoreElements()) {
String language = tokenizer.nextToken(); String language = tokenizer.nextToken().trim();
langList.add(new Pair(language , getLangFull(language))); langList.add(new Pair(language , getLangFull(language)));
} }
return langList; return langList;

View File

@ -138,3 +138,4 @@ yo=Yoruba
za=Zhuang za=Zhuang
zh=Chinese zh=Chinese
zu=Zulu zu=Zulu
--=Undefined

View File

@ -24,6 +24,8 @@ import com.arsdigita.london.navigation.DataCollectionRenderer;
import com.arsdigita.persistence.DataCollection; import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.Filter;
import com.arsdigita.persistence.FilterFactory;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import com.arsdigita.util.UncheckedWrapperException; import com.arsdigita.util.UncheckedWrapperException;
@ -94,9 +96,14 @@ public abstract class AbstractObjectList
DataCollection objects = getObjects(request, response); DataCollection objects = getObjects(request, response);
// Quasimodo: Begin // Quasimodo: Begin
// Limit list to objects in the negotiated language // Limit list to objects in the negotiated language and language invariant items
if (objects != null && objects.size() > 0) { if (objects != null && objects.size() > 0) {
objects.addEqualsFilter("language", com.arsdigita.globalization.GlobalizationHelper.getNegotiatedLocale().getLanguage()); FilterFactory ff = objects.getFilterFactory();
Filter filter = ff.or().
addFilter(ff.equals("language", com.arsdigita.globalization.GlobalizationHelper.getNegotiatedLocale().getLanguage())).
addFilter(ff.equals("language", "--"));
objects.addFilter(filter);
// objects.addEqualsFilter("language", com.arsdigita.globalization.GlobalizationHelper.getNegotiatedLocale().getLanguage());
} }
// Quasimodo: End // Quasimodo: End

View File

@ -94,7 +94,8 @@
<!-- ZeS extension --> <!-- ZeS extension -->
<!-- - - - - - - - --> <!-- - - - - - - - -->
<ccm:application name="ccm-cms-dabinimporter" /> <ccm:application name="ccm-cms-dabinimporter"/>
<!-- <ccm:application name="ccm-cms-publicpersonalprofile"/> -->
<ccm:application name="ccm-sci-types-organization"/> <ccm:application name="ccm-sci-types-organization"/>
<ccm:application name="ccm-sci-publications"/> <ccm:application name="ccm-sci-publications"/>
<ccm:application name="ccm-zes-aplaws"/> <ccm:application name="ccm-zes-aplaws"/>