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

View File

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

View File

@ -85,18 +85,18 @@ public abstract class DomainObjectTraversal {
* @param context the context in which the adapter should be used
*/
public static void registerAdapter(final ObjectType type,
final DomainObjectTraversalAdapter adapter,
final String context) {
final DomainObjectTraversalAdapter adapter,
final String context) {
Assert.exists(adapter,
"The DomainObjectTraversalAdapter is null for context '"
+ context + "' and object type '" + type);
"The DomainObjectTraversalAdapter is null for context '"
+ context + "' and object type '" + type);
Assert.exists(type, "The ObjectType for context '" + context
+ "' and adapter '" + adapter + "' is null");
+ "' and adapter '" + adapter + "' is null");
Assert.exists(context, String.class);
if (s_log.isDebugEnabled()) {
s_log.debug("Registering adapter " + adapter.getClass()
+ " for object type " + type.getQualifiedName()
+ " in context " + context);
+ " for object type " + type.getQualifiedName()
+ " in context " + context);
}
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
*/
public static void unregisterAdapter(final ObjectType type,
final String context) {
final String context) {
Assert.exists(type, ObjectType.class);
Assert.exists(context, String.class);
if (s_log.isDebugEnabled()) {
s_log.debug("Removing adapter " + " for object type " + type.
getQualifiedName() + " in context " + context);
s_log.debug("Removing adapter " + " for object type " + type.getQualifiedName() + " in context " + 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
*/
public static void registerAdapter(final String type,
final DomainObjectTraversalAdapter adapter,
final String context) {
final DomainObjectTraversalAdapter adapter,
final String context) {
registerAdapter(SessionManager.getMetadataRoot().getObjectType(type),
adapter,
context);
adapter,
context);
}
/**
@ -145,9 +144,9 @@ public abstract class DomainObjectTraversal {
* @param context the context in which the adapter should be used
*/
public static void unregisterAdapter(final String type,
final String context) {
final String context) {
unregisterAdapter(SessionManager.getMetadataRoot().getObjectType(type),
context);
context);
}
/**
@ -164,7 +163,7 @@ public abstract class DomainObjectTraversal {
Assert.exists(context, String.class);
if (s_log.isDebugEnabled()) {
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
*/
public static DomainObjectTraversalAdapter findAdapter(ObjectType type,
final String context) {
final String context) {
Assert.exists(type, ObjectType.class);
Assert.exists(context, String.class);
if (s_log.isDebugEnabled()) {
s_log.debug("findAdapter for type " + type.getQualifiedName()
+ " in context " + context);
+ " in context " + context);
StringBuilder buf = new StringBuilder();
buf.append("Adapters contain:\n");
@ -207,8 +206,7 @@ public abstract class DomainObjectTraversal {
tmpType = tmpType.getSupertype();
}
if (adapter == null) {
s_log.warn("Could not find adapter for object type " + type.
getQualifiedName() + " in context " + context);
s_log.warn("Could not find adapter for object type " + type.getQualifiedName() + " in context " + context);
}
return adapter;
}
@ -221,13 +219,12 @@ public abstract class DomainObjectTraversal {
* @param context the context for the traversal adapter
*/
public void walk(final DomainObject obj,
final String context) {
final DomainObjectTraversalAdapter adapter = findAdapter(obj.
getObjectType(),
context);
final String context) {
final DomainObjectTraversalAdapter adapter = findAdapter(obj.getObjectType(),
context);
if (adapter == null) {
final String errorMsg = "No adapter for object " + obj.getOID()
+ " in context " + context;
+ " in context " + context;
s_log.error(errorMsg);
throw new IllegalArgumentException(errorMsg);
}
@ -235,8 +232,8 @@ public abstract class DomainObjectTraversal {
}
protected void walk(final DomainObject obj,
final String context,
final DomainObjectTraversalAdapter adapter) {
final String context,
final DomainObjectTraversalAdapter adapter) {
Assert.exists(adapter, DomainObjectTraversalAdapter.class);
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
// negotiate the language version. This is not possible in com.arsdigita.ccm.
protected void walk(final DomainObjectTraversalAdapter adapter,
final DomainObject obj,
final String path,
final String context,
final DomainObject linkObject) {
final DomainObject obj,
final String path,
final String context,
final DomainObject linkObject) {
s_log.debug(String.format("Walking with path %s and context %s...", path,
context));
context));
OID oid = obj.getOID();
OID linkOid = null;
if (linkObject != null) {
@ -274,10 +271,10 @@ public abstract class DomainObjectTraversal {
if (linkObject != null) {
beginLink(linkObject, path);
walk(adapter,
linkObject,
appendToPath(path, LINK_NAME),
context,
null);
linkObject,
appendToPath(path, LINK_NAME),
context,
null);
endLink(linkObject, path);
}
@ -289,13 +286,12 @@ public abstract class DomainObjectTraversal {
String propName = prop.getName();
if (!adapter.processProperty(obj,
appendToPath(path, prop.getName()),
prop,
context)) {
appendToPath(path, prop.getName()),
prop,
context)) {
if (s_log.isDebugEnabled()) {
s_log.debug("Not processing " + appendToPath(path, prop.
getName()) + " in object " + oid + " and context "
+ context + " with adapter " + adapter.getClass().
s_log.debug("Not processing " + appendToPath(path, prop.getName()) + " in object " + oid + " and context "
+ context + " with adapter " + adapter.getClass().
getName());
}
continue;
@ -304,7 +300,7 @@ public abstract class DomainObjectTraversal {
if (propValue == null) {
if (s_log.isDebugEnabled()) {
s_log.debug("Object " + oid.toString() + " doesn't "
+ "contain property " + propName);
+ "contain property " + propName);
}
continue;
}
@ -321,10 +317,10 @@ public abstract class DomainObjectTraversal {
beginRole(obj, path, prop);
walk(adapter,
DomainObjectFactory.newInstance((DataObject) propValue),
appendToPath(path, propName),
context,
null);
DomainObjectFactory.newInstance((DataObject) propValue),
appendToPath(path, propName),
context,
null);
endRole(obj, path, prop);
} else if (propValue instanceof DataAssociation) {
@ -333,15 +329,14 @@ public abstract class DomainObjectTraversal {
// see #25808 - this hack prevents the content field of cms_files
// (which is a blob) from being queried when all we need is a
// list of the files on an item..
if (prop.getName().equals("fileAttachments") && !Domain.
getConfig().queryBlobContentForFileAttachments()) {
if (prop.getName().equals("fileAttachments") && !Domain.getConfig().queryBlobContentForFileAttachments()) {
// make true a config
DataQuery fileAttachmentsQuery =
SessionManager.getSession().retrieveQuery(
SessionManager.getSession().retrieveQuery(
"com.arsdigita.cms.contentassets.fileAttachmentsQuery");
fileAttachmentsQuery.setParameter("item_id",
obj.getOID().get("id"));
obj.getOID().get("id"));
DataCollection files = new DataQueryDataCollectionAdapter(
fileAttachmentsQuery, "file");
@ -349,10 +344,10 @@ public abstract class DomainObjectTraversal {
while (files.next()) {
DataObject file = files.getDataObject();
walk(adapter,
DomainObjectFactory.newInstance(file),
appendToPath(path, propName),
context,
null);
DomainObjectFactory.newInstance(file),
appendToPath(path, propName),
context,
null);
}
} else {
@ -384,12 +379,12 @@ public abstract class DomainObjectTraversal {
endAssociation(obj, path, prop);*/
walkDataAssociations(adapter,
obj,
path,
context,
prop,
propName,
propValue);
obj,
path,
context,
prop,
propName,
propValue);
}
} else {
// Unknown property value type - do nothing
@ -401,49 +396,49 @@ public abstract class DomainObjectTraversal {
}
protected void walkDataAssociations(DomainObjectTraversalAdapter adapter,
DomainObject obj,
String path,
String context,
Property prop,
String propName,
Object propValue) {
DomainObject obj,
String path,
String context,
Property prop,
String propName,
Object propValue) {
s_log.debug(String.format("%s is a DataAssociation", prop.getName()));
beginAssociation(obj, path, prop);
DataAssociationCursor daCursor =
((DataAssociation) propValue).
getDataAssociationCursor();
((DataAssociation) propValue).getDataAssociationCursor();
while (daCursor.next()) {
walkDataAssociation(adapter,
obj,
path,
context,
propName,
daCursor);
obj,
path,
context,
propName,
daCursor);
}
endAssociation(obj, path, prop);
}
protected void walkDataAssociation(DomainObjectTraversalAdapter adapter,
DomainObject obj,
String path,
String context,
String propName,
DataAssociationCursor daCursor) {
s_log.debug("Processing data assoication cursor...");
DomainObject obj,
String path,
String context,
String propName,
DataAssociationCursor daCursor) {
s_log.debug(String.format("Processing data assoication cursor for object '%s'...",
obj.getOID().toString()));
DataObject link = daCursor.getLink();
DomainObject linkObj = null;
if (link != null) {
linkObj = new LinkDomainObject(link);
}
walk(adapter,
DomainObjectFactory.newInstance(daCursor.getDataObject()),
appendToPath(path, propName),
context,
linkObj);
DomainObjectFactory.newInstance(daCursor.getDataObject()),
appendToPath(path, propName),
context,
linkObj);
}
/**
@ -451,14 +446,14 @@ public abstract class DomainObjectTraversal {
* starts
*/
protected abstract void beginObject(DomainObject obj,
String path);
String path);
/**
* Method called when the procesing of an object
* completes
*/
protected abstract void endObject(DomainObject obj,
String path);
String path);
/**
* Method called when the processing of a Link Object
@ -481,49 +476,49 @@ public abstract class DomainObjectTraversal {
* is encountered for a second time.
*/
protected abstract void revisitObject(DomainObject obj,
String path);
String path);
/**
* Method called when an attribute is encountered
*/
protected abstract void handleAttribute(DomainObject obj,
String path,
Property property);
String path,
Property property);
/**
* Method called when the processing of a role
* starts
*/
protected abstract void beginRole(DomainObject obj,
String path,
Property property);
String path,
Property property);
/**
* Method called when the procesing of a role
* completes
*/
protected abstract void endRole(DomainObject obj,
String path,
Property property);
String path,
Property property);
/**
* Method called when the processing of an association
* starts
*/
protected abstract void beginAssociation(DomainObject obj,
String path,
Property property);
String path,
Property property);
/**
* Method called when the procesing of an association
* completes
*/
protected abstract void endAssociation(DomainObject obj,
String path,
Property property);
String path,
Property property);
protected String appendToPath(String path,
String name) {
String name) {
if (path.endsWith("/" + name)) {
path = path + "+";
} else if (!path.endsWith("/" + name + "+")) {
@ -561,7 +556,7 @@ public abstract class DomainObjectTraversal {
private final String m_context;
public AdapterKey(ObjectType type,
String context) {
String context) {
Assert.exists(type, ObjectType.class);
Assert.exists(context, String.class);
m_type = type;
@ -601,7 +596,7 @@ public abstract class DomainObjectTraversal {
@Override
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 {
private static final Logger s_log =
Logger.getLogger(DataCollectionRenderer.class);
Logger.getLogger(DataCollectionRenderer.class);
private ArrayList m_attributes = new ArrayList();
private ArrayList m_properties = new ArrayList();
private int m_pageSize = 20;
@ -61,7 +61,7 @@ public class DataCollectionRenderer extends LockableImpl {
* {@link SimpleXMLGenerator.ADAPTER_CONTEXT}.
*/
private String m_specializeObjectsContext =
SimpleXMLGenerator.ADAPTER_CONTEXT;
SimpleXMLGenerator.ADAPTER_CONTEXT;
private boolean m_wrapAttributes = false;
private boolean m_navItems = true;
@ -128,7 +128,7 @@ public class DataCollectionRenderer extends LockableImpl {
* @return
*/
public Element generateXML(DataCollection objects,
int pageNumber) {
int pageNumber) {
Assert.isLocked(this);
// Quasimodo: Begin
@ -151,7 +151,7 @@ public class DataCollectionRenderer extends LockableImpl {
long objectCount = objects.size();
int pageCount = (int) Math.ceil((double) objectCount
/ (double) m_pageSize);
/ (double) m_pageSize);
if (pageNumber < 1) {
pageNumber = 1;
@ -167,7 +167,7 @@ public class DataCollectionRenderer extends LockableImpl {
if (count != 0) {
objects.setRange(new Integer((int) begin + 1),
new Integer((int) end + 1));
new Integer((int) end + 1));
}
Element paginator = Navigation.newElement("paginator");
@ -210,6 +210,12 @@ public class DataCollectionRenderer extends LockableImpl {
ACSObject object = null;
if (m_specializeObjects) {
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");
@ -223,8 +229,7 @@ public class DataCollectionRenderer extends LockableImpl {
Iterator properties = m_properties.iterator();
while (properties.hasNext()) {
DataCollectionPropertyRenderer property = (DataCollectionPropertyRenderer) properties.
next();
DataCollectionPropertyRenderer property = (DataCollectionPropertyRenderer) properties.next();
property.render(objects, item);
}
@ -243,13 +248,13 @@ public class DataCollectionRenderer extends LockableImpl {
protected String getStableURL(DataObject dobj, ACSObject obj) {
OID oid = new OID((String) dobj.get(ACSObject.OBJECT_TYPE),
dobj.get(ACSObject.ID));
dobj.get(ACSObject.ID));
return Navigation.redirectURL(oid);
}
private void outputValue(final Element item, final Object value,
final String name,
final String[] paths, final int depth) {
final String name,
final String[] paths, final int depth) {
if (null == value) {
return;
}
@ -295,8 +300,7 @@ public class DataCollectionRenderer extends LockableImpl {
// Quasimodo: BEGIN
// Add attributes for date and time
Locale negLocale = com.arsdigita.globalization.GlobalizationHelper.
getNegotiatedLocale();
Locale negLocale = com.arsdigita.globalization.GlobalizationHelper.getNegotiatedLocale();
DateFormat dateFormatter = DateFormat.getDateInstance(
DateFormat.MEDIUM, negLocale);
DateFormat timeFormatter = DateFormat.getTimeInstance(
@ -313,7 +317,7 @@ public class DataCollectionRenderer extends LockableImpl {
}
private void valuePersistenceError(PersistenceException ex,
String[] paths, int depth) {
String[] paths, int depth) {
StringBuffer msg = new StringBuffer();
msg.append("Attribute ");
for (int i = 0; i <= depth; i++) {
@ -332,8 +336,8 @@ public class DataCollectionRenderer extends LockableImpl {
}
protected void generateItemXML(Element item,
DataObject dobj,
ACSObject obj,
int index) {
DataObject dobj,
ACSObject obj,
int index) {
}
}