Verschiedene kleinere Korrekturen, unter anderem versuchte der SiteProxyLoader noch die mehr vorhandene siteproxy-item.jsp zu finden.

git-svn-id: https://svn.libreccm.org/ccm/trunk@1222 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2011-11-03 11:44:48 +00:00
parent e4d037885e
commit 5df0e51cb0
5 changed files with 159 additions and 153 deletions

View File

@ -37,7 +37,9 @@ import com.arsdigita.persistence.SessionManager;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import com.arsdigita.util.UncheckedWrapperException; import com.arsdigita.util.UncheckedWrapperException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.TooManyListenersException; import java.util.TooManyListenersException;
/** /**
@ -53,7 +55,7 @@ public class PublicPersonalProfileCreate extends PageCreate {
getConfig(); getConfig();
public PublicPersonalProfileCreate(final ItemSelectionModel itemModel, public PublicPersonalProfileCreate(final ItemSelectionModel itemModel,
final CreationSelector parent) { final CreationSelector parent) {
super(itemModel, parent); super(itemModel, parent);
} }
@ -73,7 +75,7 @@ public class PublicPersonalProfileCreate extends PageCreate {
add(new Label(PublicPersonalProfileGlobalizationUtil.globalize( add(new Label(PublicPersonalProfileGlobalizationUtil.globalize(
"publicpersonalprofile.ui.create.select_person"))); "publicpersonalprofile.ui.create.select_person")));
ParameterModel ownerModel = ParameterModel ownerModel =
new StringParameter(PublicPersonalProfile.OWNER); new StringParameter(PublicPersonalProfile.OWNER);
SingleSelect ownerSelect = new SingleSelect(ownerModel); SingleSelect ownerSelect = new SingleSelect(ownerModel);
ownerSelect.addValidationListener(new NotNullValidationListener()); ownerSelect.addValidationListener(new NotNullValidationListener());
@ -81,36 +83,48 @@ public class PublicPersonalProfileCreate extends PageCreate {
ownerSelect.addPrintListener(new PrintListener() { ownerSelect.addPrintListener(new PrintListener() {
public void prepare(final PrintEvent event) { public void prepare(final PrintEvent event) {
final SingleSelect ownerSelect = (SingleSelect) event. final SingleSelect ownerSelect = (SingleSelect) event.getTarget();
getTarget();
String personType = config.getPersonType(); String personType = config.getPersonType();
if ((personType == null) || (personType.isEmpty())) { if ((personType == null) || (personType.isEmpty())) {
personType = personType =
"com.arsdigita.cms.contenttypes.GenericPerson"; "com.arsdigita.cms.contenttypes.GenericPerson";
} }
ContentTypeCollection types = ContentTypeCollection types =
ContentType.getAllContentTypes(); ContentType.getAllContentTypes();
types.addFilter( types.addFilter(
String.format("className = '%s'", personType)); String.format("className = '%s'", personType));
if (types.size() == 0) { if (types.size() == 0) {
personType = personType =
"com.arsdigita.cms.contenttypes.GenericPerson"; "com.arsdigita.cms.contenttypes.GenericPerson";
} }
DataCollection persons = SessionManager.getSession(). DataCollection persons = SessionManager.getSession().
retrieve( retrieve(
personType); personType);
persons.addFilter("profile is null"); persons.addFilter("profile is null");
persons.addFilter(String.format("version = '%s'", persons.addFilter(String.format("version = '%s'",
ContentItem.DRAFT)); ContentItem.DRAFT));
persons.addOrder("surname asc");
persons.addOrder("givenname asc");
persons.addOrder("language asc");
ownerSelect.addOption(new Option("", "")); ownerSelect.addOption(new Option("", ""));
//Store the parent ids of processed items to remove double entries.
final List<BigDecimal> processed = new ArrayList<BigDecimal>();
while (persons.next()) { while (persons.next()) {
GenericPerson person = GenericPerson person =
(GenericPerson) DomainObjectFactory. (GenericPerson) DomainObjectFactory.newInstance(persons.getDataObject());
newInstance(persons.getDataObject()); if (processed.contains(person.getParent().getID())) {
ownerSelect.addOption(new Option( continue;
person.getID().toString(), person.getFullName())); } else {
ownerSelect.addOption(new Option(
person.getID().toString(),
String.format("%s (%s)",
person.getFullName(),
person.getLanguage())));
processed.add(person.getParent().getID());
}
} }
} }
}); });
@ -125,7 +139,7 @@ public class PublicPersonalProfileCreate extends PageCreate {
"cms.ui.authoring.page_launch_date"))); "cms.ui.authoring.page_launch_date")));
ParameterModel launchDateParam = new DateParameter(LAUNCH_DATE); ParameterModel launchDateParam = new DateParameter(LAUNCH_DATE);
com.arsdigita.bebop.form.Date launchDate = com.arsdigita.bebop.form.Date launchDate =
new com.arsdigita.bebop.form.Date( new com.arsdigita.bebop.form.Date(
launchDateParam); launchDateParam);
if (ContentSection.getConfig().getRequireLaunchDate()) { if (ContentSection.getConfig().getRequireLaunchDate()) {
launchDate.addValidationListener( launchDate.addValidationListener(
@ -145,17 +159,16 @@ public class PublicPersonalProfileCreate extends PageCreate {
PublicPersonalProfile.OWNER); PublicPersonalProfile.OWNER);
if ((id == null) || id.trim().isEmpty()) { if ((id == null) || id.trim().isEmpty()) {
fse.getFormData().addError(PublicPersonalProfileGlobalizationUtil. fse.getFormData().addError(PublicPersonalProfileGlobalizationUtil.globalize("publicpersonalprofile.ui.person.required"));
globalize("publicpersonalprofile.ui.person.required"));
return; return;
} }
GenericPerson owner = new GenericPerson(new BigDecimal(id)); GenericPerson owner = new GenericPerson(new BigDecimal(id));
validateNameUniqueness(folder, validateNameUniqueness(folder,
fse, fse,
String.format("%s-profile", String.format("%s-profile",
GenericPerson.urlSave( GenericPerson.urlSave(
owner.getFullName()))); owner.getFullName())));
} }
@ -173,7 +186,7 @@ public class PublicPersonalProfileCreate extends PageCreate {
GenericPerson owner = new GenericPerson(new BigDecimal(id)); GenericPerson owner = new GenericPerson(new BigDecimal(id));
String name = String.format("%s-profile", String name = String.format("%s-profile",
GenericPerson.urlSave(owner.getFullName())); GenericPerson.urlSave(owner.getFullName()));
String title = String.format("%s (Profil)", owner.getFullName()); String title = String.format("%s (Profil)", owner.getFullName());
final ContentPage item = createContentPage(state); final ContentPage item = createContentPage(state);
@ -207,18 +220,18 @@ public class PublicPersonalProfileCreate extends PageCreate {
DataCollection profiles = SessionManager.getSession().retrieve( DataCollection profiles = SessionManager.getSession().retrieve(
PublicPersonalProfile.BASE_DATA_OBJECT_TYPE); PublicPersonalProfile.BASE_DATA_OBJECT_TYPE);
profiles.addFilter(String.format("profileUrl = '%s'", profiles.addFilter(String.format("profileUrl = '%s'",
profileUrl)); profileUrl));
profiles.addFilter(String.format("version = '%s'", ContentItem.DRAFT)); profiles.addFilter(String.format("version = '%s'", ContentItem.DRAFT));
while (profiles.size() > 0) { while (profiles.size() > 0) {
i++; i++;
profileUrl = String.format("%s%d", profileUrl = String.format("%s%d",
owner.getSurname().toLowerCase(), owner.getSurname().toLowerCase(),
i); i);
profiles.reset(); profiles.reset();
profiles.addFilter(String.format("profileUrl = '%s'", profiles.addFilter(String.format("profileUrl = '%s'",
profileUrl)); profileUrl));
profiles.addFilter( profiles.addFilter(
String.format("version = '%s'", ContentItem.DRAFT)); String.format("version = '%s'", ContentItem.DRAFT));
} }

View File

@ -19,14 +19,8 @@
package com.arsdigita.cms.contenttypes; package com.arsdigita.cms.contenttypes;
// import com.arsdigita.cms.contenttypes.AbstractContentTypeLoader; // import com.arsdigita.cms.contenttypes.AbstractContentTypeLoader;
import com.arsdigita.cms.ContentType;
import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.lifecycle.LifecycleDefinition;
import com.arsdigita.util.parameter.Parameter;
import com.arsdigita.util.parameter.ResourceParameter; import com.arsdigita.util.parameter.ResourceParameter;
// import com.arsdigita.util.UncheckedWrapperException; // import com.arsdigita.util.UncheckedWrapperException;
import com.arsdigita.workflow.simple.WorkflowTemplate;
import java.io.InputStream;
// import java.net.MalformedURLException; // import java.net.MalformedURLException;
@ -48,7 +42,7 @@ public class SiteProxyLoader extends AbstractContentTypeLoader {
/** /**
* SiteProxyLoader Constructor * SiteProxyLoader Constructor
*/ */
public SiteProxyLoader() { /*public SiteProxyLoader() {
m_template = new ResourceParameter m_template = new ResourceParameter
("com.arsdigita.cms.contenttypes.siteproxy.defaulttemplate", ("com.arsdigita.cms.contenttypes.siteproxy.defaulttemplate",
Parameter.REQUIRED, Parameter.REQUIRED,
@ -56,7 +50,7 @@ public class SiteProxyLoader extends AbstractContentTypeLoader {
"/siteproxy-item.jsp"); "/siteproxy-item.jsp");
register(m_template); register(m_template);
} }*/
public String[] getTypes() { public String[] getTypes() {
return TYPES; return TYPES;

View File

@ -85,18 +85,18 @@ public abstract class DomainObjectTraversal {
* @param context the context in which the adapter should be used * @param context the context in which the adapter should be used
*/ */
public static void registerAdapter(final ObjectType type, public static void registerAdapter(final ObjectType type,
final DomainObjectTraversalAdapter adapter, final DomainObjectTraversalAdapter adapter,
final String context) { final String context) {
Assert.exists(adapter, Assert.exists(adapter,
"The DomainObjectTraversalAdapter is null for context '" "The DomainObjectTraversalAdapter is null for context '"
+ context + "' and object type '" + type); + context + "' and object type '" + type);
Assert.exists(type, "The ObjectType for context '" + context Assert.exists(type, "The ObjectType for context '" + context
+ "' and adapter '" + adapter + "' is null"); + "' and adapter '" + adapter + "' is null");
Assert.exists(context, String.class); Assert.exists(context, String.class);
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("Registering adapter " + adapter.getClass() s_log.debug("Registering adapter " + adapter.getClass()
+ " for object type " + type.getQualifiedName() + " for object type " + type.getQualifiedName()
+ " in context " + context); + " in context " + context);
} }
s_adapters.put(new AdapterKey(type, context), adapter); s_adapters.put(new AdapterKey(type, context), adapter);
} }
@ -109,13 +109,12 @@ public abstract class DomainObjectTraversal {
* @param context the context in which the adapter should be used * @param context the context in which the adapter should be used
*/ */
public static void unregisterAdapter(final ObjectType type, public static void unregisterAdapter(final ObjectType type,
final String context) { final String context) {
Assert.exists(type, ObjectType.class); Assert.exists(type, ObjectType.class);
Assert.exists(context, String.class); Assert.exists(context, String.class);
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("Removing adapter " + " for object type " + type. s_log.debug("Removing adapter " + " for object type " + type.getQualifiedName() + " in context " + context);
getQualifiedName() + " in context " + context);
} }
s_adapters.remove(new AdapterKey(type, context)); s_adapters.remove(new AdapterKey(type, context));
@ -130,11 +129,11 @@ public abstract class DomainObjectTraversal {
* @param context the context in which the adapter should be used * @param context the context in which the adapter should be used
*/ */
public static void registerAdapter(final String type, public static void registerAdapter(final String type,
final DomainObjectTraversalAdapter adapter, final DomainObjectTraversalAdapter adapter,
final String context) { final String context) {
registerAdapter(SessionManager.getMetadataRoot().getObjectType(type), registerAdapter(SessionManager.getMetadataRoot().getObjectType(type),
adapter, adapter,
context); context);
} }
/** /**
@ -145,9 +144,9 @@ public abstract class DomainObjectTraversal {
* @param context the context in which the adapter should be used * @param context the context in which the adapter should be used
*/ */
public static void unregisterAdapter(final String type, public static void unregisterAdapter(final String type,
final String context) { final String context) {
unregisterAdapter(SessionManager.getMetadataRoot().getObjectType(type), unregisterAdapter(SessionManager.getMetadataRoot().getObjectType(type),
context); context);
} }
/** /**
@ -164,7 +163,7 @@ public abstract class DomainObjectTraversal {
Assert.exists(context, String.class); Assert.exists(context, String.class);
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("lookupAdapter for type " + type.getQualifiedName() s_log.debug("lookupAdapter for type " + type.getQualifiedName()
+ " in context " + context); + " in context " + context);
} }
@ -182,12 +181,12 @@ public abstract class DomainObjectTraversal {
* @param context the adapter context * @param context the adapter context
*/ */
public static DomainObjectTraversalAdapter findAdapter(ObjectType type, public static DomainObjectTraversalAdapter findAdapter(ObjectType type,
final String context) { final String context) {
Assert.exists(type, ObjectType.class); Assert.exists(type, ObjectType.class);
Assert.exists(context, String.class); Assert.exists(context, String.class);
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("findAdapter for type " + type.getQualifiedName() s_log.debug("findAdapter for type " + type.getQualifiedName()
+ " in context " + context); + " in context " + context);
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();
buf.append("Adapters contain:\n"); buf.append("Adapters contain:\n");
@ -207,8 +206,7 @@ public abstract class DomainObjectTraversal {
tmpType = tmpType.getSupertype(); tmpType = tmpType.getSupertype();
} }
if (adapter == null) { if (adapter == null) {
s_log.warn("Could not find adapter for object type " + type. s_log.warn("Could not find adapter for object type " + type.getQualifiedName() + " in context " + context);
getQualifiedName() + " in context " + context);
} }
return adapter; return adapter;
} }
@ -221,13 +219,12 @@ public abstract class DomainObjectTraversal {
* @param context the context for the traversal adapter * @param context the context for the traversal adapter
*/ */
public void walk(final DomainObject obj, public void walk(final DomainObject obj,
final String context) { final String context) {
final DomainObjectTraversalAdapter adapter = findAdapter(obj. final DomainObjectTraversalAdapter adapter = findAdapter(obj.getObjectType(),
getObjectType(), context);
context);
if (adapter == null) { if (adapter == null) {
final String errorMsg = "No adapter for object " + obj.getOID() final String errorMsg = "No adapter for object " + obj.getOID()
+ " in context " + context; + " in context " + context;
s_log.error(errorMsg); s_log.error(errorMsg);
throw new IllegalArgumentException(errorMsg); throw new IllegalArgumentException(errorMsg);
} }
@ -235,8 +232,8 @@ public abstract class DomainObjectTraversal {
} }
protected void walk(final DomainObject obj, protected void walk(final DomainObject obj,
final String context, final String context,
final DomainObjectTraversalAdapter adapter) { final DomainObjectTraversalAdapter adapter) {
Assert.exists(adapter, DomainObjectTraversalAdapter.class); Assert.exists(adapter, DomainObjectTraversalAdapter.class);
walk(adapter, obj, "/object", context, null); walk(adapter, obj, "/object", context, null);
} }
@ -248,12 +245,12 @@ public abstract class DomainObjectTraversal {
// content item during XML generation, I have to test for ContentBundle and // content item during XML generation, I have to test for ContentBundle and
// negotiate the language version. This is not possible in com.arsdigita.ccm. // negotiate the language version. This is not possible in com.arsdigita.ccm.
protected void walk(final DomainObjectTraversalAdapter adapter, protected void walk(final DomainObjectTraversalAdapter adapter,
final DomainObject obj, final DomainObject obj,
final String path, final String path,
final String context, final String context,
final DomainObject linkObject) { final DomainObject linkObject) {
s_log.debug(String.format("Walking with path %s and context %s...", path, s_log.debug(String.format("Walking with path %s and context %s...", path,
context)); context));
OID oid = obj.getOID(); OID oid = obj.getOID();
OID linkOid = null; OID linkOid = null;
if (linkObject != null) { if (linkObject != null) {
@ -274,10 +271,10 @@ public abstract class DomainObjectTraversal {
if (linkObject != null) { if (linkObject != null) {
beginLink(linkObject, path); beginLink(linkObject, path);
walk(adapter, walk(adapter,
linkObject, linkObject,
appendToPath(path, LINK_NAME), appendToPath(path, LINK_NAME),
context, context,
null); null);
endLink(linkObject, path); endLink(linkObject, path);
} }
@ -289,13 +286,12 @@ public abstract class DomainObjectTraversal {
String propName = prop.getName(); String propName = prop.getName();
if (!adapter.processProperty(obj, if (!adapter.processProperty(obj,
appendToPath(path, prop.getName()), appendToPath(path, prop.getName()),
prop, prop,
context)) { context)) {
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("Not processing " + appendToPath(path, prop. s_log.debug("Not processing " + appendToPath(path, prop.getName()) + " in object " + oid + " and context "
getName()) + " in object " + oid + " and context " + context + " with adapter " + adapter.getClass().
+ context + " with adapter " + adapter.getClass().
getName()); getName());
} }
continue; continue;
@ -304,7 +300,7 @@ public abstract class DomainObjectTraversal {
if (propValue == null) { if (propValue == null) {
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("Object " + oid.toString() + " doesn't " s_log.debug("Object " + oid.toString() + " doesn't "
+ "contain property " + propName); + "contain property " + propName);
} }
continue; continue;
} }
@ -321,10 +317,10 @@ public abstract class DomainObjectTraversal {
beginRole(obj, path, prop); beginRole(obj, path, prop);
walk(adapter, walk(adapter,
DomainObjectFactory.newInstance((DataObject) propValue), DomainObjectFactory.newInstance((DataObject) propValue),
appendToPath(path, propName), appendToPath(path, propName),
context, context,
null); null);
endRole(obj, path, prop); endRole(obj, path, prop);
} else if (propValue instanceof DataAssociation) { } else if (propValue instanceof DataAssociation) {
@ -333,15 +329,14 @@ public abstract class DomainObjectTraversal {
// see #25808 - this hack prevents the content field of cms_files // see #25808 - this hack prevents the content field of cms_files
// (which is a blob) from being queried when all we need is a // (which is a blob) from being queried when all we need is a
// list of the files on an item.. // list of the files on an item..
if (prop.getName().equals("fileAttachments") && !Domain. if (prop.getName().equals("fileAttachments") && !Domain.getConfig().queryBlobContentForFileAttachments()) {
getConfig().queryBlobContentForFileAttachments()) {
// make true a config // make true a config
DataQuery fileAttachmentsQuery = DataQuery fileAttachmentsQuery =
SessionManager.getSession().retrieveQuery( SessionManager.getSession().retrieveQuery(
"com.arsdigita.cms.contentassets.fileAttachmentsQuery"); "com.arsdigita.cms.contentassets.fileAttachmentsQuery");
fileAttachmentsQuery.setParameter("item_id", fileAttachmentsQuery.setParameter("item_id",
obj.getOID().get("id")); obj.getOID().get("id"));
DataCollection files = new DataQueryDataCollectionAdapter( DataCollection files = new DataQueryDataCollectionAdapter(
fileAttachmentsQuery, "file"); fileAttachmentsQuery, "file");
@ -349,10 +344,10 @@ public abstract class DomainObjectTraversal {
while (files.next()) { while (files.next()) {
DataObject file = files.getDataObject(); DataObject file = files.getDataObject();
walk(adapter, walk(adapter,
DomainObjectFactory.newInstance(file), DomainObjectFactory.newInstance(file),
appendToPath(path, propName), appendToPath(path, propName),
context, context,
null); null);
} }
} else { } else {
@ -384,12 +379,12 @@ public abstract class DomainObjectTraversal {
endAssociation(obj, path, prop);*/ endAssociation(obj, path, prop);*/
walkDataAssociations(adapter, walkDataAssociations(adapter,
obj, obj,
path, path,
context, context,
prop, prop,
propName, propName,
propValue); propValue);
} }
} else { } else {
// Unknown property value type - do nothing // Unknown property value type - do nothing
@ -401,49 +396,49 @@ public abstract class DomainObjectTraversal {
} }
protected void walkDataAssociations(DomainObjectTraversalAdapter adapter, protected void walkDataAssociations(DomainObjectTraversalAdapter adapter,
DomainObject obj, DomainObject obj,
String path, String path,
String context, String context,
Property prop, Property prop,
String propName, String propName,
Object propValue) { Object propValue) {
s_log.debug(String.format("%s is a DataAssociation", prop.getName())); s_log.debug(String.format("%s is a DataAssociation", prop.getName()));
beginAssociation(obj, path, prop); beginAssociation(obj, path, prop);
DataAssociationCursor daCursor = DataAssociationCursor daCursor =
((DataAssociation) propValue). ((DataAssociation) propValue).getDataAssociationCursor();
getDataAssociationCursor();
while (daCursor.next()) { while (daCursor.next()) {
walkDataAssociation(adapter, walkDataAssociation(adapter,
obj, obj,
path, path,
context, context,
propName, propName,
daCursor); daCursor);
} }
endAssociation(obj, path, prop); endAssociation(obj, path, prop);
} }
protected void walkDataAssociation(DomainObjectTraversalAdapter adapter, protected void walkDataAssociation(DomainObjectTraversalAdapter adapter,
DomainObject obj, DomainObject obj,
String path, String path,
String context, String context,
String propName, String propName,
DataAssociationCursor daCursor) { DataAssociationCursor daCursor) {
s_log.debug("Processing data assoication cursor..."); s_log.debug(String.format("Processing data assoication cursor for object '%s'...",
obj.getOID().toString()));
DataObject link = daCursor.getLink(); DataObject link = daCursor.getLink();
DomainObject linkObj = null; DomainObject linkObj = null;
if (link != null) { if (link != null) {
linkObj = new LinkDomainObject(link); linkObj = new LinkDomainObject(link);
} }
walk(adapter, walk(adapter,
DomainObjectFactory.newInstance(daCursor.getDataObject()), DomainObjectFactory.newInstance(daCursor.getDataObject()),
appendToPath(path, propName), appendToPath(path, propName),
context, context,
linkObj); linkObj);
} }
/** /**
@ -451,14 +446,14 @@ public abstract class DomainObjectTraversal {
* starts * starts
*/ */
protected abstract void beginObject(DomainObject obj, protected abstract void beginObject(DomainObject obj,
String path); String path);
/** /**
* Method called when the procesing of an object * Method called when the procesing of an object
* completes * completes
*/ */
protected abstract void endObject(DomainObject obj, protected abstract void endObject(DomainObject obj,
String path); String path);
/** /**
* Method called when the processing of a Link Object * Method called when the processing of a Link Object
@ -481,49 +476,49 @@ public abstract class DomainObjectTraversal {
* is encountered for a second time. * is encountered for a second time.
*/ */
protected abstract void revisitObject(DomainObject obj, protected abstract void revisitObject(DomainObject obj,
String path); String path);
/** /**
* Method called when an attribute is encountered * Method called when an attribute is encountered
*/ */
protected abstract void handleAttribute(DomainObject obj, protected abstract void handleAttribute(DomainObject obj,
String path, String path,
Property property); Property property);
/** /**
* Method called when the processing of a role * Method called when the processing of a role
* starts * starts
*/ */
protected abstract void beginRole(DomainObject obj, protected abstract void beginRole(DomainObject obj,
String path, String path,
Property property); Property property);
/** /**
* Method called when the procesing of a role * Method called when the procesing of a role
* completes * completes
*/ */
protected abstract void endRole(DomainObject obj, protected abstract void endRole(DomainObject obj,
String path, String path,
Property property); Property property);
/** /**
* Method called when the processing of an association * Method called when the processing of an association
* starts * starts
*/ */
protected abstract void beginAssociation(DomainObject obj, protected abstract void beginAssociation(DomainObject obj,
String path, String path,
Property property); Property property);
/** /**
* Method called when the procesing of an association * Method called when the procesing of an association
* completes * completes
*/ */
protected abstract void endAssociation(DomainObject obj, protected abstract void endAssociation(DomainObject obj,
String path, String path,
Property property); Property property);
protected String appendToPath(String path, protected String appendToPath(String path,
String name) { String name) {
if (path.endsWith("/" + name)) { if (path.endsWith("/" + name)) {
path = path + "+"; path = path + "+";
} else if (!path.endsWith("/" + name + "+")) { } else if (!path.endsWith("/" + name + "+")) {
@ -561,7 +556,7 @@ public abstract class DomainObjectTraversal {
private final String m_context; private final String m_context;
public AdapterKey(ObjectType type, public AdapterKey(ObjectType type,
String context) { String context) {
Assert.exists(type, ObjectType.class); Assert.exists(type, ObjectType.class);
Assert.exists(context, String.class); Assert.exists(context, String.class);
m_type = type; m_type = type;
@ -601,7 +596,7 @@ public abstract class DomainObjectTraversal {
@Override @Override
public Object get(String attr) { public Object get(String attr) {
return super.get(attr); return super.get(attr);
} }
} }
} }

View File

@ -50,7 +50,7 @@ import org.apache.log4j.Logger;
public class DataCollectionRenderer extends LockableImpl { public class DataCollectionRenderer extends LockableImpl {
private static final Logger s_log = private static final Logger s_log =
Logger.getLogger(DataCollectionRenderer.class); Logger.getLogger(DataCollectionRenderer.class);
private ArrayList m_attributes = new ArrayList(); private ArrayList m_attributes = new ArrayList();
private ArrayList m_properties = new ArrayList(); private ArrayList m_properties = new ArrayList();
private int m_pageSize = 20; private int m_pageSize = 20;
@ -61,7 +61,7 @@ public class DataCollectionRenderer extends LockableImpl {
* {@link SimpleXMLGenerator.ADAPTER_CONTEXT}. * {@link SimpleXMLGenerator.ADAPTER_CONTEXT}.
*/ */
private String m_specializeObjectsContext = private String m_specializeObjectsContext =
SimpleXMLGenerator.ADAPTER_CONTEXT; SimpleXMLGenerator.ADAPTER_CONTEXT;
private boolean m_wrapAttributes = false; private boolean m_wrapAttributes = false;
private boolean m_navItems = true; private boolean m_navItems = true;
@ -128,7 +128,7 @@ public class DataCollectionRenderer extends LockableImpl {
* @return * @return
*/ */
public Element generateXML(DataCollection objects, public Element generateXML(DataCollection objects,
int pageNumber) { int pageNumber) {
Assert.isLocked(this); Assert.isLocked(this);
// Quasimodo: Begin // Quasimodo: Begin
@ -151,7 +151,7 @@ public class DataCollectionRenderer extends LockableImpl {
long objectCount = objects.size(); long objectCount = objects.size();
int pageCount = (int) Math.ceil((double) objectCount int pageCount = (int) Math.ceil((double) objectCount
/ (double) m_pageSize); / (double) m_pageSize);
if (pageNumber < 1) { if (pageNumber < 1) {
pageNumber = 1; pageNumber = 1;
@ -167,7 +167,7 @@ public class DataCollectionRenderer extends LockableImpl {
if (count != 0) { if (count != 0) {
objects.setRange(new Integer((int) begin + 1), objects.setRange(new Integer((int) begin + 1),
new Integer((int) end + 1)); new Integer((int) end + 1));
} }
Element paginator = Navigation.newElement("paginator"); Element paginator = Navigation.newElement("paginator");
@ -210,6 +210,12 @@ public class DataCollectionRenderer extends LockableImpl {
ACSObject object = null; ACSObject object = null;
if (m_specializeObjects) { if (m_specializeObjects) {
object = (ACSObject) DomainObjectFactory.newInstance(dobj); object = (ACSObject) DomainObjectFactory.newInstance(dobj);
if (object == null) {
s_log.error(String.format("Failed to specialize object with with id %s. Skiping object.", dobj.getOID().toString()));
continue;
} else {
s_log.error("Specializing successful.");
}
} }
Element item = Navigation.newElement("item"); Element item = Navigation.newElement("item");
@ -223,8 +229,7 @@ public class DataCollectionRenderer extends LockableImpl {
Iterator properties = m_properties.iterator(); Iterator properties = m_properties.iterator();
while (properties.hasNext()) { while (properties.hasNext()) {
DataCollectionPropertyRenderer property = (DataCollectionPropertyRenderer) properties. DataCollectionPropertyRenderer property = (DataCollectionPropertyRenderer) properties.next();
next();
property.render(objects, item); property.render(objects, item);
} }
@ -243,13 +248,13 @@ public class DataCollectionRenderer extends LockableImpl {
protected String getStableURL(DataObject dobj, ACSObject obj) { protected String getStableURL(DataObject dobj, ACSObject obj) {
OID oid = new OID((String) dobj.get(ACSObject.OBJECT_TYPE), OID oid = new OID((String) dobj.get(ACSObject.OBJECT_TYPE),
dobj.get(ACSObject.ID)); dobj.get(ACSObject.ID));
return Navigation.redirectURL(oid); return Navigation.redirectURL(oid);
} }
private void outputValue(final Element item, final Object value, private void outputValue(final Element item, final Object value,
final String name, final String name,
final String[] paths, final int depth) { final String[] paths, final int depth) {
if (null == value) { if (null == value) {
return; return;
} }
@ -295,8 +300,7 @@ public class DataCollectionRenderer extends LockableImpl {
// Quasimodo: BEGIN // Quasimodo: BEGIN
// Add attributes for date and time // Add attributes for date and time
Locale negLocale = com.arsdigita.globalization.GlobalizationHelper. Locale negLocale = com.arsdigita.globalization.GlobalizationHelper.getNegotiatedLocale();
getNegotiatedLocale();
DateFormat dateFormatter = DateFormat.getDateInstance( DateFormat dateFormatter = DateFormat.getDateInstance(
DateFormat.MEDIUM, negLocale); DateFormat.MEDIUM, negLocale);
DateFormat timeFormatter = DateFormat.getTimeInstance( DateFormat timeFormatter = DateFormat.getTimeInstance(
@ -313,7 +317,7 @@ public class DataCollectionRenderer extends LockableImpl {
} }
private void valuePersistenceError(PersistenceException ex, private void valuePersistenceError(PersistenceException ex,
String[] paths, int depth) { String[] paths, int depth) {
StringBuffer msg = new StringBuffer(); StringBuffer msg = new StringBuffer();
msg.append("Attribute "); msg.append("Attribute ");
for (int i = 0; i <= depth; i++) { for (int i = 0; i <= depth; i++) {
@ -332,8 +336,8 @@ public class DataCollectionRenderer extends LockableImpl {
} }
protected void generateItemXML(Element item, protected void generateItemXML(Element item,
DataObject dobj, DataObject dobj,
ACSObject obj, ACSObject obj,
int index) { int index) {
} }
} }