From 17c35737f97511044bb3b96c7f9f6fd80f690181 Mon Sep 17 00:00:00 2001 From: jensp Date: Fri, 29 Oct 2010 16:42:14 +0000 Subject: [PATCH] - Problem bei Publizieren bei Contact behoben - Verschiedene Formatierungen git-svn-id: https://svn.libreccm.org/ccm/trunk@593 8810af33-2d31-482b-a856-94f89814c4df --- .../content-types/GenericContact.pdl | 2 +- .../GenericOrganizationalUnit.pdl | 21 +- .../cms/contenttypes/GenericContact.java | 82 ++++-- .../GenericOrganizationalUnit.java | 28 +- ...ricOrganizationalUnitPersonCollection.java | 4 +- .../cms/contenttypes/GenericPerson.java | 1 + .../GenericContactPersonPropertiesStep.java | 15 +- ...enericOrganizationalUnitPersonAddForm.java | 8 +- ...GenericOrganizationalUnitPersonsTable.java | 72 +++-- .../domain/DomainObjectTraversal.java | 239 ++++++++-------- .../domain/DomainObjectXMLRenderer.java | 1 + .../arsdigita/persistence/DataObjectImpl.java | 4 + .../src/com/redhat/persistence/Expander.java | 28 +- .../com/redhat/persistence/PropertyData.java | 7 + .../WEB-INF/resources/exporter-adapters.xml | 2 +- .../navigation/DataCollectionRenderer.java | 3 +- .../cms/CMSDataCollectionRenderer.java | 15 +- .../cms/contenttypes/SciOrganization.xml | 16 +- .../arsdigita/cms/contenttypes/SciProject.xml | 1 - .../contenttypes/SciOrganizationLoader.java | 12 +- .../src/com/arsdigita/aplaws/Loader.java | 268 +++++++++--------- 21 files changed, 466 insertions(+), 363 deletions(-) diff --git a/ccm-cms/pdl/com/arsdigita/content-types/GenericContact.pdl b/ccm-cms/pdl/com/arsdigita/content-types/GenericContact.pdl index 705bd3211..c5e92696e 100644 --- a/ccm-cms/pdl/com/arsdigita/content-types/GenericContact.pdl +++ b/ccm-cms/pdl/com/arsdigita/content-types/GenericContact.pdl @@ -46,7 +46,7 @@ object type GenericContactEntry extends ContentItem { association { - GenericPerson[0..1] person = join cms_contacts.contact_id + GenericPerson[0..n] person = join cms_contacts.contact_id to cms_person_contact_map.contact_id, join cms_person_contact_map.person_id to cms_persons.person_id; diff --git a/ccm-cms/pdl/com/arsdigita/content-types/GenericOrganizationalUnit.pdl b/ccm-cms/pdl/com/arsdigita/content-types/GenericOrganizationalUnit.pdl index a8132c0c7..aa2cef8d9 100644 --- a/ccm-cms/pdl/com/arsdigita/content-types/GenericOrganizationalUnit.pdl +++ b/ccm-cms/pdl/com/arsdigita/content-types/GenericOrganizationalUnit.pdl @@ -20,12 +20,12 @@ model com.arsdigita.cms.contenttypes; -import com.arsdigita.cms.ContentPage; +import com.arsdigita.cms.*; +import com.arsdigita.domain.*; +import com.arsdigita.kernel.ACSObject; // PDL definition for a commons base type for organizations, departments, projects etc. object type GenericOrganizationalUnit extends ContentPage { - //String[0..1] orgaunit_name = cms_organizationalunits.name VARCHAR(256); - String[0..1] addendum = cms_organizationalunits.addendum VARCHAR(512); reference key (cms_organizationalunits.organizationalunit_id); @@ -34,7 +34,7 @@ object type GenericOrganizationalUnit extends ContentPage { // Link for contact points. association { - GenericOrganizationalUnit[0..1] organizationalunit = join cms_contacts.contact_id + GenericOrganizationalUnit[0..n] organizationalunit = join cms_contacts.contact_id to cms_organizationalunits_contact_map.contact_id, join cms_organizationalunits_contact_map.organizationalunit_id to cms_organizationalunits.organizationalunit_id; @@ -55,7 +55,7 @@ association { GenericOrganizationalUnit[0..n] organizationalunit = join cms_persons.person_id to cms_organizationalunits_person_map.person_id, - join cms_organizationalunits_person_map.organizationalunit_id + join cms_organizationalunits_person_map.organizationalunit_id to cms_organizationalunits.organizationalunit_id; GenericPerson[0..n] persons = join cms_organizationalunits.organizationalunit_id @@ -64,6 +64,15 @@ association { to cms_persons.person_id; // Additional attributes for the association - String role_name = cms_organizationalunits_person_map.role_name VARCHAR(100); + String[0..1] role_name = cms_organizationalunits_person_map.role_name VARCHAR(100); } + +//object type GenericOrganizationalUnitPersonAssociation extends ACSObject { +// +// GenericPerson[0..1] person = join cms_organizationalunit_person_assoc.person_id +// to cms_persons.person_id; +// String[0..1] roleName = cms_organizationalunit_person_assoc.role_name VARCHAR(100); +// +// reference key (cms_organizationalunit_person_assoc.assoc_id); +//} diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericContact.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericContact.java index d4179d021..298192bfb 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericContact.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericContact.java @@ -30,30 +30,30 @@ import com.arsdigita.util.Assert; import java.math.BigDecimal; import java.util.StringTokenizer; - /** * This content type represents an basic contact * */ -public class GenericContact extends ContentPage implements RelationAttributeInterface { +public class GenericContact extends ContentPage implements + RelationAttributeInterface { /** PDL property names */ public static final String PERSON = "person"; // public static final String CONTACT_TYPE = ""; public static final String ADDRESS = "address"; public static final String CONTACT_ENTRIES = "contactentries"; - - private static final String RELATION_ATTRIBUTES = "GenericContactType;GenericContactEntryType"; - + private static final String RELATION_ATTRIBUTES = + "GenericContactType;GenericContactEntryType"; // Config - private static final GenericContactConfig s_config = new GenericContactConfig(); + private static final GenericContactConfig s_config = + new GenericContactConfig(); + static { - s_config.load(); + s_config.load(); } - /** Data object type for tihs domain object */ - public static final String BASE_DATA_OBJECT_TYPE - = "com.arsdigita.cms.contenttypes.GenericContact"; + public static final String BASE_DATA_OBJECT_TYPE = + "com.arsdigita.cms.contenttypes.GenericContact"; public GenericContact() { super(BASE_DATA_OBJECT_TYPE); @@ -75,12 +75,13 @@ public class GenericContact extends ContentPage implements RelationAttributeInte public GenericContact(String type) { super(type); + //unsetPerson(); } @Override public void beforeSave() { super.beforeSave(); - + Assert.exists(getContentType(), ContentType.class); } @@ -90,19 +91,42 @@ public class GenericContact extends ContentPage implements RelationAttributeInte public static final GenericContactConfig getConfig() { return s_config; } - /////////////////////////////////////////////////////////////// // accessors - // Get the person for this contact public GenericPerson getPerson() { - return (GenericPerson) DomainObjectFactory.newInstance((DataObject)get(PERSON)); + DataCollection collection; + + collection = (DataCollection) get(PERSON); + + if (collection.size() == 0) { + return null; + } else { + DataObject dobj; + + collection.next(); + dobj = collection.getDataObject(); + + return (GenericPerson) DomainObjectFactory.newInstance(dobj); + } + //return (GenericPerson) DomainObjectFactory.newInstance((DataObject)get(PERSON)); } // Set the person for this contact public void setPerson(GenericPerson person) { - set(PERSON, person); + //set(PERSON, person); + if (getPerson() != null) { + unsetPerson(); + } + + if (person != null) { + Assert.exists(person, GenericPerson.class); + DataObject link = add(PERSON, person); + link.set(GenericPerson.CONTACTS_ORDER, + new BigDecimal(person.getContacts().size())); + link.save(); + } } // // Get the type for this contact @@ -114,44 +138,50 @@ public class GenericContact extends ContentPage implements RelationAttributeInte // public void setContactType(String type) { // set(CONTACT_TYPE, type); // } - // Unset the address for this contact public void unsetPerson() { - set(PERSON, null); + //set(PERSON, null); + GenericPerson oldPerson; + oldPerson = getPerson(); + if (oldPerson != null) { + remove(PERSON, oldPerson); + } } - + // Get the address for this contact public GenericAddress getAddress() { - return (GenericAddress)DomainObjectFactory.newInstance((DataObject)get(ADDRESS)); + return (GenericAddress) DomainObjectFactory.newInstance((DataObject) get( + ADDRESS)); } - + // Set the address for this contact public void setAddress(GenericAddress address) { set(ADDRESS, address); } - + // Unset the address for this contact public void unsetAddress() { set(ADDRESS, null); } - + // Get all contact entries for this contact, p. ex. phone number, type of contact etc. public GenericContactEntryCollection getContactEntries() { - return new GenericContactEntryCollection ((DataCollection) get(CONTACT_ENTRIES)); + return new GenericContactEntryCollection((DataCollection) get( + CONTACT_ENTRIES)); } - + // Add a contact entry for this contact public void addContactEntry(GenericContactEntry contactEntry) { Assert.exists(contactEntry, GenericContactEntry.class); add(CONTACT_ENTRIES, contactEntry); } - + // Remove a contect entry for this contact public void removeContactEntry(GenericContactEntry contactEntry) { Assert.exists(contactEntry, GenericContactEntry.class); remove(CONTACT_ENTRIES, contactEntry); } - + public boolean hasPerson() { return !(this.getPerson() == null); } diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericOrganizationalUnit.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericOrganizationalUnit.java index b959d8663..193d2b71a 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericOrganizationalUnit.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericOrganizationalUnit.java @@ -41,14 +41,15 @@ import org.apache.log4j.Logger; */ public class GenericOrganizationalUnit extends ContentPage { - private static final Logger logger = Logger.getLogger(GenericOrganizationalUnit.class); + private static final Logger logger = Logger.getLogger( + GenericOrganizationalUnit.class); //public final static String ORGAUNIT_NAME = "ORGAUNIT_NAME"; public final static String ADDENDUM = "addendum"; public final static String CONTACTS = "contacts"; public final static String CONTACT_TYPE = "contact_type"; public final static String CONTACT_ORDER = "contact_order"; public final static String PERSONS = "persons"; - public final static String ROLE = "role_name"; + public final static String ROLE = "role_name"; public final static String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.GenericOrganizationalUnit"; @@ -56,8 +57,8 @@ public class GenericOrganizationalUnit extends ContentPage { this(BASE_DATA_OBJECT_TYPE); } - public GenericOrganizationalUnit(BigDecimal id) - throws DataObjectNotFoundException { + public GenericOrganizationalUnit(BigDecimal id) + throws DataObjectNotFoundException { this(new OID(BASE_DATA_OBJECT_TYPE, id)); } @@ -90,11 +91,12 @@ public class GenericOrganizationalUnit extends ContentPage { public void addContact(GenericContact contact, String contactType) { Assert.exists(contact, GenericContact.class); - logger.debug(String.format("Adding contact of type \"%s\"...", contactType)); + logger.debug(String.format("Adding contact of type \"%s\"...", + contactType)); DataObject link = add(CONTACTS, contact); link.set(CONTACT_TYPE, contactType); - link.set(CONTACT_ORDER, Integer.valueOf((int)getContacts().size())); + link.set(CONTACT_ORDER, Integer.valueOf((int) getContacts().size())); link.save(); } @@ -108,8 +110,9 @@ public class GenericOrganizationalUnit extends ContentPage { } public GenericOrganizationalUnitPersonCollection getPersons() { - return new GenericOrganizationalUnitPersonCollection((DataCollection) get( - PERSONS)); + DataCollection dataColl = (DataCollection) get(PERSONS); + logger.debug(String.format("GenericOrganizationalUnitPersonCollection size = %d", dataColl.size())); + return new GenericOrganizationalUnitPersonCollection(dataColl); } public void addPerson(GenericPerson person, String role) { @@ -118,12 +121,13 @@ public class GenericOrganizationalUnit extends ContentPage { DataObject link = add(PERSONS, person); link.set(ROLE, role); - link.save(); + link.save(); } - public void removePerson(GenericPerson person) { - Assert.exists(person, GenericPerson.class); - remove(PERSONS, person); + public void removePerson(GenericPerson person) { + logger.debug("Removing person association..."); + Assert.exists(person, GenericPerson.class); + remove(PERSONS, person); } public boolean hasPersons() { diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericOrganizationalUnitPersonCollection.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericOrganizationalUnitPersonCollection.java index 3713116c2..8fc395a95 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericOrganizationalUnitPersonCollection.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericOrganizationalUnitPersonCollection.java @@ -20,7 +20,6 @@ package com.arsdigita.cms.contenttypes; import com.arsdigita.domain.DomainCollection; import com.arsdigita.persistence.DataCollection; -import java.math.BigDecimal; /** * Collection class for the GenericOrganizationalUnit -> Person relation. @@ -29,13 +28,14 @@ import java.math.BigDecimal; */ public class GenericOrganizationalUnitPersonCollection extends DomainCollection { - public static final String PERSON_ROLE = "link.role_name"; + public static final String PERSON_ROLE = "link.role_name"; public GenericOrganizationalUnitPersonCollection( DataCollection dataCollection) { super(dataCollection); } + /** * Gets the name of the role of this orgaunit-person link */ diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericPerson.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericPerson.java index 2a1cf3c5a..29bfdcfe8 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericPerson.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericPerson.java @@ -74,6 +74,7 @@ public class GenericPerson extends ContentPage implements RelationAttributeInter public GenericPerson(String type) { super(type); + //set(CONTACTS, null); } @Override diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericContactPersonPropertiesStep.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericContactPersonPropertiesStep.java index ded792a52..b0cb5aeaa 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericContactPersonPropertiesStep.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericContactPersonPropertiesStep.java @@ -13,12 +13,10 @@ import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; import com.arsdigita.cms.ui.authoring.BasicPageForm; import com.arsdigita.cms.ui.authoring.SimpleEditStep; import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; -import com.arsdigita.toolbox.ui.DomainObjectPropertySheet; import com.arsdigita.bebop.Component; import com.arsdigita.bebop.Label; import com.arsdigita.bebop.PageState; import com.arsdigita.cms.contenttypes.GenericContact; -import com.arsdigita.cms.contenttypes.GenericPerson; import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil; /** @@ -63,12 +61,15 @@ public class GenericContactPersonPropertiesStep extends SimpleEditStep { } public static Component getPersonPropertySheet(ItemSelectionModel itemModel) { - DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel); + /*DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel); - sheet.add((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.surname").localize(), "person." + GenericPerson.SURNAME); - sheet.add((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.givenname").localize(), "person." + GenericPerson.GIVENNAME); - sheet.add((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.titlepre").localize(), "person." + GenericPerson.TITLEPRE); - sheet.add((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.titlepost").localize(), "person." + GenericPerson.TITLEPOST); + sheet.add(ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.surname"), "person." + GenericPerson.SURNAME); + sheet.add(ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.givenname"), "person." + GenericPerson.GIVENNAME); + sheet.add(ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.titlepre"), "person." + GenericPerson.TITLEPRE); + sheet.add(ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.titlepost"), "person." + GenericPerson.TITLEPOST);*/ + + GenericContactPersonSheet sheet = new GenericContactPersonSheet( + itemModel); return sheet; } diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonAddForm.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonAddForm.java index f0bb929f1..f57b2e216 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonAddForm.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonAddForm.java @@ -72,8 +72,8 @@ public class GenericOrganizationalUnitPersonAddForm extends BasicItemForm { add(new Label(ContenttypesGlobalizationUtil.globalize( "cms.contenttypes.ui.genericorgaunit.person.role"))); ParameterModel roleParam = - new StringParameter( - GenericOrganizationalUnitPersonCollection.PERSON_ROLE); + new StringParameter( + GenericOrganizationalUnitPersonCollection.PERSON_ROLE); SingleSelect roleSelect = new SingleSelect(roleParam); roleSelect.addValidationListener(new NotNullValidationListener()); roleSelect.addOption( @@ -120,8 +120,8 @@ public class GenericOrganizationalUnitPersonAddForm extends BasicItemForm { getFullName())); } orga.addPerson((GenericPerson) data.get(ITEM_SEARCH), - (String) data.get( - GenericOrganizationalUnitPersonCollection.PERSON_ROLE)); + (String) data.get( + GenericOrganizationalUnitPersonCollection.PERSON_ROLE)); } init(fse); diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonsTable.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonsTable.java index 47eaac45b..cf11ad5ed 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonsTable.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonsTable.java @@ -22,6 +22,7 @@ package com.arsdigita.cms.contenttypes.ui; import com.arsdigita.bebop.Component; import com.arsdigita.bebop.ControlLink; import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.Link; import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.Table; import com.arsdigita.bebop.event.TableActionEvent; @@ -31,14 +32,18 @@ import com.arsdigita.bebop.table.TableColumn; import com.arsdigita.bebop.table.TableColumnModel; import com.arsdigita.bebop.table.TableModel; import com.arsdigita.bebop.table.TableModelBuilder; -import com.arsdigita.bebop.util.GlobalizationUtil; +import com.arsdigita.cms.CMS; +import com.arsdigita.cms.ContentItem; +import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.RelationAttributeCollection; import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit; import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitPersonCollection; import com.arsdigita.cms.contenttypes.GenericPerson; import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil; +import com.arsdigita.cms.dispatcher.ItemResolver; import com.arsdigita.cms.dispatcher.Utilities; +import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.util.LockableImpl; import java.math.BigDecimal; import org.apache.log4j.Logger; @@ -78,24 +83,27 @@ public class GenericOrganizationalUnitPersonsTable extends Table implements new TableColumn( 2, ContenttypesGlobalizationUtil.globalize( - "cms.contenttypes.ui.genericorgaunit.persons.delete").localize())); + "cms.contenttypes.ui.genericorgaunit.persons.delete").localize(), + TABLE_COL_DEL)); setModelBuilder( new GenericOrganizationalUnitTableModelBuilder(itemModel)); tabModel.get(0).setCellRenderer(new EditCellRenderer()); tabModel.get(2).setCellRenderer(new DeleteCellRenderer()); + + addTableActionListener(this); } private class GenericOrganizationalUnitTableModelBuilder extends LockableImpl implements TableModelBuilder { - private ItemSelectionModel m_itemModel; + private ItemSelectionModel m_itemModel; public GenericOrganizationalUnitTableModelBuilder( ItemSelectionModel itemModel) { - m_itemModel = itemModel; + m_itemModel = itemModel; } public TableModel makeModel(Table table, PageState state) { @@ -113,14 +121,16 @@ public class GenericOrganizationalUnitPersonsTable extends Table implements private Table m_table; private GenericOrganizationalUnitPersonCollection m_personsCollection; - private GenericPerson m_person; + private GenericPerson m_person; private GenericOrganizationalUnitTableModel( Table table, PageState state, GenericOrganizationalUnit orgaunit) { m_table = table; - m_personsCollection = orgaunit.getPersons(); + m_personsCollection = orgaunit.getPersons(); + s_log.debug(String.format("m_personsCollection.size() = %d", m_personsCollection. + size())); } public int getColumnCount() { @@ -145,17 +155,19 @@ public class GenericOrganizationalUnitPersonsTable extends Table implements switch (columnIndex) { case 0: return m_person.getFullName(); - case 1: + case 1: RelationAttributeCollection role = new RelationAttributeCollection( getRoleAttributeName(), - m_personsCollection.getRoleName()); + m_personsCollection.getRoleName()); if (role.next()) { return role.getName(); } else { - return ContenttypesGlobalizationUtil.globalize("cms.ui.unknownRole"); + return ContenttypesGlobalizationUtil.globalize( + "cms.ui.unknownRole"); } case 2: - return ContenttypesGlobalizationUtil.globalize("cms.ui.delete").localize(); + return ContenttypesGlobalizationUtil.globalize( + "cms.ui.delete").localize(); default: return null; } @@ -177,7 +189,7 @@ public class GenericOrganizationalUnitPersonsTable extends Table implements Object key, int row, int col) { - /*com.arsdigita.cms.SecurityManager securityManager = Utilities. + com.arsdigita.cms.SecurityManager securityManager = Utilities. getSecurityManager(state); GenericOrganizationalUnit orgaunit = (GenericOrganizationalUnit) m_itemModel. getSelectedObject( @@ -187,11 +199,27 @@ public class GenericOrganizationalUnitPersonsTable extends Table implements com.arsdigita.cms.SecurityManager.EDIT_ITEM, orgaunit); if (canEdit) { - ControlLink link = new ControlLink(value.toString()); + GenericPerson person; + try { + person = new GenericPerson((BigDecimal) key); + } catch (DataObjectNotFoundException ex) { + s_log.warn(String.format("No object with key '%s' found.", + key), + ex); + return new Label(value.toString()); + } + ContentSection section = CMS.getContext().getContentSection(); + ItemResolver resolver = section.getItemResolver(); + Link link = new Link(value.toString(), + resolver.generateItemURL(state, + person, + section, + person.getVersion())); + return link; - } else {*/ + } else { return new Label(value.toString()); - // } + } } } @@ -230,7 +258,11 @@ public class GenericOrganizationalUnitPersonsTable extends Table implements @Override public void cellSelected(TableActionEvent event) { + s_log.debug("Cell selected."); PageState state = event.getPageState(); + s_log.debug(String.format("RowKey = %s", event.getRowKey().toString())); + s_log.debug(String.format("Selected column: %d", event.getColumn(). + intValue())); GenericPerson person = new GenericPerson(new BigDecimal(event.getRowKey(). toString())); @@ -240,20 +272,26 @@ public class GenericOrganizationalUnitPersonsTable extends Table implements TableColumn col = getColumnModel().get(event.getColumn().intValue()); - if (col.getHeaderKey().toString().equals(TABLE_COL_EDIT)) { - } - if (col.getHeaderKey().toString().equals(TABLE_COL_DEL)) { + + if (col.getHeaderKey().toString().equals(TABLE_COL_EDIT)) { + } else if (col.getHeaderKey().toString().equals(TABLE_COL_DEL)) { + s_log.debug("Removing person assoc..."); orga.removePerson(person); + + } } @Override public void headSelected(TableActionEvent event) { throw new UnsupportedOperationException("Not supported yet."); + + } protected String getRoleAttributeName() { return "GenericOrganizationalUnitRole"; + } } diff --git a/ccm-core/src/com/arsdigita/domain/DomainObjectTraversal.java b/ccm-core/src/com/arsdigita/domain/DomainObjectTraversal.java index d6bee578d..2dbe63494 100755 --- a/ccm-core/src/com/arsdigita/domain/DomainObjectTraversal.java +++ b/ccm-core/src/com/arsdigita/domain/DomainObjectTraversal.java @@ -72,8 +72,8 @@ public abstract class DomainObjectTraversal { private Set m_visited = new HashSet(); private static Map s_adapters = new HashMap(); - private static final Logger s_log = Logger.getLogger(DomainObjectTraversal.class); - + private static final Logger s_log = Logger.getLogger( + DomainObjectTraversal.class); public final static String LINK_NAME = "link"; /** @@ -89,17 +89,14 @@ public abstract class DomainObjectTraversal { final String context) { Assert.exists(adapter, "The DomainObjectTraversalAdapter is null for context '" - + context + "' and object type '" + type); - Assert.exists(type, "The ObjectType for context '" + context + - "' and adapter '" + adapter + "' is null"); + + context + "' and object type '" + type); + Assert.exists(type, "The ObjectType for context '" + context + + "' 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); + s_log.debug("Registering adapter " + adapter.getClass() + + " for object type " + type.getQualifiedName() + + " in context " + context); } s_adapters.put(new AdapterKey(type, context), adapter); } @@ -117,11 +114,8 @@ public abstract class DomainObjectTraversal { 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)); @@ -137,7 +131,7 @@ public abstract class DomainObjectTraversal { */ public static void registerAdapter(final String type, final DomainObjectTraversalAdapter adapter, - final String context) { + final String context) { registerAdapter(SessionManager.getMetadataRoot().getObjectType(type), adapter, context); @@ -163,20 +157,19 @@ public abstract class DomainObjectTraversal { * @param type the object type to lookup * @param context the adapter context */ - public static DomainObjectTraversalAdapter lookupAdapter(final ObjectType type, + public static DomainObjectTraversalAdapter lookupAdapter( + final ObjectType type, final String context) { Assert.exists(type, ObjectType.class); Assert.exists(context, String.class); if (s_log.isDebugEnabled()) { - s_log.debug("lookupAdapter for type " + - type.getQualifiedName() + - " in context " + - context); + s_log.debug("lookupAdapter for type " + type.getQualifiedName() + + " in context " + context); } - return (DomainObjectTraversalAdapter)s_adapters - .get(new AdapterKey(type, context)); + return (DomainObjectTraversalAdapter) s_adapters.get( + new AdapterKey(type, context)); } /** @@ -193,21 +186,19 @@ public abstract class DomainObjectTraversal { 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); + s_log.debug("findAdapter for type " + type.getQualifiedName() + + " in context " + context); StringBuffer buf = new StringBuffer(); - buf.append( "Adapters contain:\n" ); + buf.append("Adapters contain:\n"); Iterator keys = s_adapters.keySet().iterator(); - while( keys.hasNext() ) { + while (keys.hasNext()) { Object key = keys.next(); - buf.append( key.toString() ).append( ": " ); - buf.append( s_adapters.get( key ).toString() ).append( '\n' ); + buf.append(key.toString()).append(": "); + buf.append(s_adapters.get(key).toString()).append('\n'); } - s_log.debug( buf.toString() ); + s_log.debug(buf.toString()); } DomainObjectTraversalAdapter adapter = null; ObjectType tmpType = type; @@ -216,10 +207,8 @@ 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; } @@ -233,13 +222,12 @@ public abstract class DomainObjectTraversal { */ public void walk(final DomainObject obj, final String context) { - final DomainObjectTraversalAdapter adapter = findAdapter(obj.getObjectType(), - context); + final DomainObjectTraversalAdapter adapter = findAdapter(obj. + getObjectType(), + context); if (adapter == null) { - final String errorMsg = "No adapter for object " + - obj.getOID() + - " in context " + - context; + final String errorMsg = "No adapter for object " + obj.getOID() + + " in context " + context; s_log.error(errorMsg); throw new IllegalArgumentException(errorMsg); } @@ -259,16 +247,16 @@ public abstract class DomainObjectTraversal { // ContentBundle instead of the content item. To get the corresponding // 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)); OID oid = obj.getOID(); OID linkOid = null; if (linkObject != null) { - linkOid = linkObject.getOID(); + linkOid = linkObject.getOID(); } OID[] visitedKey = {oid, linkOid}; // Prevent infinite recursion @@ -284,7 +272,7 @@ public abstract class DomainObjectTraversal { if (linkObject != null) { beginLink(linkObject, path); - walk(adapter, + walk(adapter, linkObject, appendToPath(path, LINK_NAME), context, @@ -295,7 +283,7 @@ public abstract class DomainObjectTraversal { ObjectType type = obj.getObjectType(); // Test all properties against the traversal xml - for (Iterator i = type.getProperties(); i.hasNext(); ) { + for (Iterator i = type.getProperties(); i.hasNext();) { Property prop = (Property) i.next(); String propName = prop.getName(); @@ -303,20 +291,19 @@ public abstract class DomainObjectTraversal { 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().getName() ); + if (s_log.isDebugEnabled()) { + s_log.debug("Not processing " + appendToPath(path, prop. + getName()) + " in object " + oid + " and context " + + context + " with adapter " + adapter.getClass(). + getName()); } continue; } Object propValue = obj.get(propName); if (propValue == null) { - if( s_log.isDebugEnabled() ) { - s_log.debug( "Object " + oid.toString() + " doesn't " + - "contain property " + propName ); + if (s_log.isDebugEnabled()) { + s_log.debug("Object " + oid.toString() + " doesn't " + + "contain property " + propName); } continue; } @@ -324,75 +311,76 @@ public abstract class DomainObjectTraversal { if (prop.isAttribute()) { handleAttribute(obj, path, prop); - // Property is a DataObject, so start recursion + // Property is a DataObject, so start recursion } else if (propValue instanceof DataObject) { - if( s_log.isDebugEnabled() ) { - s_log.debug( prop.getName() + " is a DataObject" ); + if (s_log.isDebugEnabled()) { + s_log.debug(prop.getName() + " is a DataObject"); } beginRole(obj, path, prop); - walk(adapter, - DomainObjectFactory.newInstance((DataObject)propValue), + walk(adapter, + DomainObjectFactory.newInstance((DataObject) propValue), appendToPath(path, propName), context, null); endRole(obj, path, prop); } else if (propValue instanceof DataAssociation) { - - - // 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()) { + + + // 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()) { // make true a config - DataQuery fileAttachmentsQuery = - SessionManager.getSession().retrieveQuery( - "com.arsdigita.cms.contentassets.fileAttachmentsQuery"); - - fileAttachmentsQuery.setParameter("item_id", + DataQuery fileAttachmentsQuery = + SessionManager.getSession().retrieveQuery( + "com.arsdigita.cms.contentassets.fileAttachmentsQuery"); + + fileAttachmentsQuery.setParameter("item_id", obj.getOID().get("id")); - - DataCollection files = new DataQueryDataCollectionAdapter( - fileAttachmentsQuery, "file"); - - while(files.next()) { - DataObject file = files.getDataObject(); - walk(adapter, - DomainObjectFactory.newInstance - (file), - appendToPath(path, propName), - context, - null); - } - - } else { - - if( s_log.isDebugEnabled() ) { - s_log.debug( prop.getName() + " is a DataAssociation" ); - } - beginAssociation(obj, path, prop); - - DataAssociationCursor daCursor = - ((DataAssociation)propValue).getDataAssociationCursor(); - - while (daCursor.next()) { - DataObject link = daCursor.getLink(); - DomainObject linkObj = null; - if (link != null) { - linkObj = new LinkDomainObject(link); + + DataCollection files = new DataQueryDataCollectionAdapter( + fileAttachmentsQuery, "file"); + + while (files.next()) { + DataObject file = files.getDataObject(); + walk(adapter, + DomainObjectFactory.newInstance(file), + appendToPath(path, propName), + context, + null); } - walk(adapter, - DomainObjectFactory.newInstance - (daCursor.getDataObject()), - appendToPath(path, propName), - context, - linkObj); + + } else { + + if (s_log.isDebugEnabled()) { + s_log.debug(prop.getName() + " is a DataAssociation"); + } + beginAssociation(obj, path, prop); + + DataAssociationCursor daCursor = + ((DataAssociation) propValue). + getDataAssociationCursor(); + + while (daCursor.next()) { + s_log.debug("Processing data assoication cursor..."); + 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); + } + endAssociation(obj, path, prop); } - endAssociation(obj, path, prop); - } } else { // Unknown property value type - do nothing } @@ -402,13 +390,13 @@ public abstract class DomainObjectTraversal { endObject(obj, path); } - /** * Method called when the processing of an object * starts */ protected abstract void beginObject(DomainObject obj, String path); + /** * Method called when the procesing of an object * completes @@ -420,12 +408,17 @@ public abstract class DomainObjectTraversal { * Method called when the processing of a Link Object * starts */ - protected void beginLink(DomainObject obj, String path) {} + protected void beginLink(DomainObject obj, String path) { + s_log.debug(String.format("Starting link with path = %s", path)); + } + /** * Method called when the procesing of a Link Object * completes */ - protected void endLink(DomainObject obj, String path) {} + protected void endLink(DomainObject obj, String path) { + s_log.debug(String.format("Finished link with path = %s", path)); + } /** * Method called when a previously visited object @@ -473,7 +466,6 @@ public abstract class DomainObjectTraversal { String path, Property property); - protected String appendToPath(String path, String name) { if (path.endsWith("/" + name)) { @@ -481,7 +473,7 @@ public abstract class DomainObjectTraversal { } else if (!path.endsWith("/" + name + "+")) { path = path + "/" + name; } - + return path; } @@ -507,8 +499,8 @@ public abstract class DomainObjectTraversal { } } - protected static class AdapterKey { + private final ObjectType m_type; private final String m_context; @@ -522,9 +514,8 @@ public abstract class DomainObjectTraversal { public boolean equals(Object o) { if (o instanceof AdapterKey) { - AdapterKey k = (AdapterKey)o; - return k.m_type.equals(m_type) && - k.m_context.equals(m_context); + AdapterKey k = (AdapterKey) o; + return k.m_type.equals(m_type) && k.m_context.equals(m_context); } else { return false; } @@ -544,9 +535,9 @@ public abstract class DomainObjectTraversal { * but we don't have any other domain object to use. */ private class LinkDomainObject extends DomainObject { + LinkDomainObject(DataObject object) { super(object); } } - } diff --git a/ccm-core/src/com/arsdigita/domain/DomainObjectXMLRenderer.java b/ccm-core/src/com/arsdigita/domain/DomainObjectXMLRenderer.java index b7d22675f..7ddaef97a 100755 --- a/ccm-core/src/com/arsdigita/domain/DomainObjectXMLRenderer.java +++ b/ccm-core/src/com/arsdigita/domain/DomainObjectXMLRenderer.java @@ -218,6 +218,7 @@ public class DomainObjectXMLRenderer extends DomainObjectTraversal { return XML.format(value); } + @Override protected void walk(DomainObject obj, String context, DomainObjectTraversalAdapter adapter) { diff --git a/ccm-core/src/com/arsdigita/persistence/DataObjectImpl.java b/ccm-core/src/com/arsdigita/persistence/DataObjectImpl.java index 398852049..b8cbd964b 100755 --- a/ccm-core/src/com/arsdigita/persistence/DataObjectImpl.java +++ b/ccm-core/src/com/arsdigita/persistence/DataObjectImpl.java @@ -425,10 +425,13 @@ class DataObjectImpl implements DataObject { getSession().m_beforeFP.fireNow(new BeforeSaveEvent(this)); if (!getSsn().isFlushed(this)) { + s_log.debug("Flushing..."); getSsn().flush(); + s_log.debug("Checking flushing..."); assertFlushed(); } else { // with no changes on the object fire after save directly + s_log.debug("Direct save..."); getSession().m_afterFP.fireNow(new AfterSaveEvent(this)); } } catch (ProtoException pe) { @@ -441,6 +444,7 @@ class DataObjectImpl implements DataObject { for (Iterator it = getObjectType().getProperties(); it.hasNext(); ) { Property p = (Property) it.next(); + s_log.debug(String.format("Asserting that property '%s' is flushed...", p.getName())); if (!getSsn().isFlushed(this, C.prop(m_ssn.getRoot(), p))) { // use m_ssn to generate the exception getSsn().assertFlushed(this); diff --git a/ccm-core/src/com/redhat/persistence/Expander.java b/ccm-core/src/com/redhat/persistence/Expander.java index e9e07ea25..c546176ce 100755 --- a/ccm-core/src/com/redhat/persistence/Expander.java +++ b/ccm-core/src/com/redhat/persistence/Expander.java @@ -8,7 +8,7 @@ * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * MERCHANTABILITY or FITNESS FOR sA PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public @@ -18,6 +18,7 @@ */ package com.redhat.persistence; +import com.arsdigita.persistence.DataObject; import com.arsdigita.util.UncheckedWrapperException; import com.redhat.persistence.metadata.Adapter; import com.redhat.persistence.metadata.ObjectType; @@ -77,12 +78,8 @@ class Expander extends Event.Switch { final void expand(Event ev) { try { Session.trace(ev.getName(), new Object[]{ev}); - try { - ev.dispatch(this); - } catch (DuplicateObjectException ex) { - s_log.warn("Duplicate object exception: ", ex); - s_log.warn("This is maybe an error, but not in all cases."); - } + ev.dispatch(this); + } catch (RuntimeException re) { if (re instanceof ProtoException) { ProtoException pe = (ProtoException) re; @@ -114,17 +111,20 @@ class Expander extends Event.Switch { public void onCreate(CreateEvent e) { final Object obj = e.getObject(); - + ObjectData od = m_ssn.getObjectData(obj); if (od == null) { - od = new ObjectData(m_ssn, obj, od.INFANTILE); + od = new ObjectData(m_ssn, obj, ObjectData.INFANTILE); } else if (!od.isDeleted()) { - od.dump(); - ProtoException pe = new DuplicateObjectException(obj); - pe.setInternal(false); - throw pe; + //od.dump(); + //ProtoException pe = new DuplicateObjectException(obj); + //pe.setInternal(false); + //throw pe; + s_log.warn("Duplicate object: " + ((DataObject) od.getObject()). + getOID()); + return; } else { - od.setState(od.INFANTILE); + od.setState(ObjectData.INFANTILE); } Adapter a = m_ssn.getAdapter(obj); diff --git a/ccm-core/src/com/redhat/persistence/PropertyData.java b/ccm-core/src/com/redhat/persistence/PropertyData.java index 2b3e842cb..c06d81c40 100755 --- a/ccm-core/src/com/redhat/persistence/PropertyData.java +++ b/ccm-core/src/com/redhat/persistence/PropertyData.java @@ -24,6 +24,7 @@ import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import org.apache.log4j.Logger; /** * PropertyData @@ -34,6 +35,8 @@ import java.util.List; class PropertyData { + private final static Logger s_log = Logger.getLogger(PropertyData.class); + final private ObjectData m_odata; final private Property m_prop; private Object m_value; @@ -92,6 +95,10 @@ class PropertyData { (getObject(), getProperty()); return evs.size() == 0; } else { + if (getSession().getEventStream().getLastEvent(getObject(), getProperty()) != null) { + //s_log.error(String.format("Last event is not null, property '%s' is not flushed. Last event is: '%s'", + // getProperty().getName(), getSession().getEventStream().getLastEvent(getObject(), getProperty()).getName())); + } return getSession().getEventStream().getLastEvent (getObject(), getProperty()) == null; } diff --git a/ccm-ldn-exporter/src/WEB-INF/resources/exporter-adapters.xml b/ccm-ldn-exporter/src/WEB-INF/resources/exporter-adapters.xml index 608fc9992..82ed769c2 100755 --- a/ccm-ldn-exporter/src/WEB-INF/resources/exporter-adapters.xml +++ b/ccm-ldn-exporter/src/WEB-INF/resources/exporter-adapters.xml @@ -202,7 +202,7 @@ - + diff --git a/ccm-ldn-navigation/src/com/arsdigita/london/navigation/DataCollectionRenderer.java b/ccm-ldn-navigation/src/com/arsdigita/london/navigation/DataCollectionRenderer.java index 58510c7a6..3368c57b7 100755 --- a/ccm-ldn-navigation/src/com/arsdigita/london/navigation/DataCollectionRenderer.java +++ b/ccm-ldn-navigation/src/com/arsdigita/london/navigation/DataCollectionRenderer.java @@ -221,7 +221,7 @@ public class DataCollectionRenderer extends LockableImpl { private void outputValue(final Element item, final Object value, final String name, - final String[] paths, final int depth) { + final String[] paths, final int depth) { if (null == value) { return; } @@ -298,5 +298,6 @@ public class DataCollectionRenderer extends LockableImpl { DataObject dobj, ACSObject obj, int index) { + } } diff --git a/ccm-ldn-navigation/src/com/arsdigita/london/navigation/cms/CMSDataCollectionRenderer.java b/ccm-ldn-navigation/src/com/arsdigita/london/navigation/cms/CMSDataCollectionRenderer.java index b33c7defa..308107788 100755 --- a/ccm-ldn-navigation/src/com/arsdigita/london/navigation/cms/CMSDataCollectionRenderer.java +++ b/ccm-ldn-navigation/src/com/arsdigita/london/navigation/cms/CMSDataCollectionRenderer.java @@ -15,10 +15,11 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - package com.arsdigita.london.navigation.cms; import com.arsdigita.cms.ContentItem; +import com.arsdigita.cms.ContentItemXMLRenderer; +import com.arsdigita.cms.dispatcher.SimpleXMLGenerator; import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.kernel.ACSObject; import com.arsdigita.london.navigation.DataCollectionRenderer; @@ -39,16 +40,24 @@ public class CMSDataCollectionRenderer extends DataCollectionRenderer { obj = (ACSObject) DomainObjectFactory.newInstance(dobj); } if (obj instanceof ContentItem) { - OID oid = ( (ContentItem) obj).getDraftVersion().getOID(); + OID oid = ((ContentItem) obj).getDraftVersion().getOID(); return Navigation.redirectURL(oid); } return super.getStableURL(dobj, obj); } - + @Override protected void generateItemXML(Element item, DataObject dobj, ACSObject obj, int index) { + if (obj != null) { + ContentItemXMLRenderer renderer = new ContentItemXMLRenderer(item); + renderer.setRevisitFullObject(false); + renderer.setWrapAttributes(true); + renderer.setWrapRoot(false); + renderer.setWrapObjects(false); + renderer.walk(obj, SimpleXMLGenerator.ADAPTER_CONTEXT); + } } } diff --git a/ccm-sci-types-organization/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/SciOrganization.xml b/ccm-sci-types-organization/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/SciOrganization.xml index 5590f9868..7d5af7f9d 100644 --- a/ccm-sci-types-organization/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/SciOrganization.xml +++ b/ccm-sci-types-organization/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/SciOrganization.xml @@ -8,13 +8,21 @@ The default properties for BaseContact are left as is and are inherited from ContentPage --> - + - - - + + + + + + + + + + \ No newline at end of file diff --git a/ccm-sci-types-organization/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/SciProject.xml b/ccm-sci-types-organization/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/SciProject.xml index ddd394bca..2d2d337a5 100644 --- a/ccm-sci-types-organization/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/SciProject.xml +++ b/ccm-sci-types-organization/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/SciProject.xml @@ -12,7 +12,6 @@ - diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/SciOrganizationLoader.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/SciOrganizationLoader.java index cdacf6bc6..31504ab77 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/SciOrganizationLoader.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/SciOrganizationLoader.java @@ -26,8 +26,18 @@ package com.arsdigita.cms.contenttypes; */ public class SciOrganizationLoader extends AbstractContentTypeLoader { + public SciOrganizationLoader() { + super(); + + /* Template.create("SciOrganization Description Only", + "Display only the description of a SciOrganization", + "/WEB-INF/content-types/com/arsdigita/cms/contenttypes/" + + "SciOrganizationDescription.jsp");*/ + + } private static final String[] TYPES = { - "/WEB-INF/content-types/com/arsdigita/cms/contenttypes/SciOrganization.xml" + "/WEB-INF/content-types/com/arsdigita/cms/contenttypes/" + + "SciOrganization.xml" }; @Override diff --git a/ccm-zes-aplaws/src/com/arsdigita/aplaws/Loader.java b/ccm-zes-aplaws/src/com/arsdigita/aplaws/Loader.java index 3b13d0756..145582c37 100644 --- a/ccm-zes-aplaws/src/com/arsdigita/aplaws/Loader.java +++ b/ccm-zes-aplaws/src/com/arsdigita/aplaws/Loader.java @@ -15,7 +15,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - package com.arsdigita.aplaws; import com.arsdigita.london.navigation.Navigation; @@ -66,12 +65,10 @@ import java.util.Set; public class Loader extends PackageLoader { private static final Logger s_log = Logger.getLogger(Loader.class); - - private static final String[] categoryFiles = new String[] { - "WEB-INF/aplaws/zes-nav-domain-1.00.xml" - , "WEB-INF/aplaws/zes-nav-hierarchy-1.00.xml" + private static final String[] categoryFiles = new String[]{ + "WEB-INF/aplaws/zes-nav-domain-1.00.xml", + "WEB-INF/aplaws/zes-nav-hierarchy-1.00.xml" }; - private StringParameter m_navigationDomain; // private StringParameter m_servicesDomain; // private StringParameter m_interactionDomain; @@ -79,7 +76,7 @@ public class Loader extends PackageLoader { // private StringParameter m_rssDomain; public Loader() { - + // Es werden stumpf mehrere Kategorisierungsdomains fuer TERMS // definiert und dann über xml Dateien gefüllt: // navigationDomain f. Navigation @@ -88,60 +85,58 @@ public class Loader extends PackageLoader { // rssDomain fuer vermutlich RSS Feed // m_navigationDomain = new StringParameter( - "com.arsdigita.aplaws.navigation_domain", - Parameter.REQUIRED, - "ZES-NAV"); + "com.arsdigita.aplaws.navigation_domain", + Parameter.REQUIRED, + "ZES-NAV"); register(m_navigationDomain); /* * You may add more catagory domains by adding resources * according the followin schema */ - + /* currently not used m_subjectDomain = new StringParameter( - "com.arsdigita.aplaws.subject_domain", - Parameter.REQUIRED, - "LGCL"); + "com.arsdigita.aplaws.subject_domain", + Parameter.REQUIRED, + "LGCL"); register(m_subjectDomain); */ - + /* currently not used m_interactionDomain = new StringParameter( - "com.arsdigita.aplaws.subject_domain", - Parameter.REQUIRED, - "LGIL"); + "com.arsdigita.aplaws.subject_domain", + Parameter.REQUIRED, + "LGIL"); register(m_interactionDomain); */ - + /* currently not used m_rssDomain = new StringParameter( - "com.arsdigita.aplaws.rss_domain", - Parameter.REQUIRED, - "APLAWS-RSS"); + "com.arsdigita.aplaws.rss_domain", + Parameter.REQUIRED, + "APLAWS-RSS"); register(m_rssDomain); */ - + } - public void run(final ScriptContext ctx) { - + String[] files = categoryFiles; final Parser parser = new Parser(); - for (int i = 0 ; i < files.length ; i++) { + for (int i = 0; i < files.length; i++) { final String file = files[i]; if (s_log.isInfoEnabled()) { s_log.info("Process " + file); } - parser.parse(Thread.currentThread().getContextClassLoader - ().getResourceAsStream - (file)); + parser.parse(Thread.currentThread().getContextClassLoader(). + getResourceAsStream(file)); } - String navigationKey = (String)get(m_navigationDomain); + String navigationKey = (String) get(m_navigationDomain); registerDomain(navigationKey, "/navigation/", null); registerDomain(navigationKey, "/content/", null); registerDomain(navigationKey, "/portal/", null); @@ -169,16 +164,16 @@ public class Loader extends PackageLoader { // registerDomain(interactionKey, "/content/", "interaction"); - + // register new / addidional JSP templates (index pages) in Navigation // registerServicesTemplate("/services/"); wird nicht gebraucht registerNavigationTemplates(); // Switch /portal/ to use 1 column layout for funky aplaws stuff. - Workspace portal = (Workspace)Application - .retrieveApplicationForPath("/portal/"); - portal.setDefaultLayout(PageLayout - .findLayoutByFormat(PageLayout.FORMAT_ONE_COLUMN)); + Workspace portal = (Workspace) Application.retrieveApplicationForPath( + "/portal/"); + portal.setDefaultLayout(PageLayout.findLayoutByFormat( + PageLayout.FORMAT_ONE_COLUMN)); } // public void registerServicesTemplate(String appURL) { @@ -197,7 +192,6 @@ public class Loader extends PackageLoader { // Template.DEFAULT_DISPATCHER_CONTEXT, // Template.DEFAULT_USE_CONTEXT ); // } - /** * Use Package com.arsdigita.london.navigation to add additional * templates (JSP page - index page) for use in navigation. @@ -208,35 +202,46 @@ public class Loader extends PackageLoader { */ public void registerNavigationTemplates() { - Template template ; + Template template; - /* In navigation werden bereits Grund-Templates erstellt. - */ + /* In navigation werden bereits Grund-Templates erstellt. + */ template = Template.create( - "ZeS AtoZ paginator", - "ZeS AtoZ paginator index page", - "/packages/navigation/templates/zes-atoz.jsp"); + "ZeS AtoZ paginator", + "ZeS AtoZ paginator index page", + "/packages/navigation/templates/zes-atoz.jsp"); template = Template.create( - "ZeS Default", - "ZeS default index page", - "/packages/navigation/templates/zes-default.jsp"); + "ZeS Default", + "ZeS default index page", + "/packages/navigation/templates/zes-default.jsp"); template = Template.create( - "ZeS Portalseite", - "ZeS Portal Page", - "/packages/navigation/templates/zes-portal.jsp"); + "ZeS Portalseite", + "ZeS Portal Page", + "/packages/navigation/templates/zes-portal.jsp"); template = Template.create( - "ZeS Recent", - "ZeS reverse order page", - "/packages/navigation/templates/zes-recent.jsp"); + "ZeS Recent", + "ZeS reverse order page", + "/packages/navigation/templates/zes-recent.jsp"); template = Template.create( - "ZeS Welcome Page", - "ZeS Welcome Page for navigation", - "/packages/navigation/templates/zes-welcome.jsp"); - + "ZeS Welcome Page", + "ZeS Welcome Page for navigation", + "/packages/navigation/templates/zes-welcome.jsp"); + + template = Template.create( + "ZeS Project List", + "List of SciProjects", + "/packages/navigation/templates/zes-project-list.jsp"); + + template = Template.create( + "SciOrganization Description Only", + "Display only the description of a SciOrganization", + "/packages/navigation/templates/" + + "SciOrganizationDescription.jsp"); + } /** @@ -247,85 +252,66 @@ public class Loader extends PackageLoader { * delivered. */ // -- public void registerDefaultNavigationDomain() { - - // -- private StringParameter m_customNavKey; + // -- private StringParameter m_customNavKey; // -- private URLParameter m_customNavDomainURL; // -- private StringParameter m_customNavPath; // -- private StringParameter m_customNavUseContext; // -- private StringParameter m_customNavTitle; // -- private StringParameter m_customNavDesc; - - // -- m_customNavKey = new StringParameter( - // -- "com.arsdigita.aplaws.custom_nav_key", - // -- Parameter.REQUIRED, - // -- "APLAWS-NAVIGATION"); - -/* Zugriff auf Website wird nicht benötigt, aber der Parameter bei Einrichtung - * der Kategorien. Funktion URL prüft auf korrekte Syntax, nicht auf Existenz - */ - // -- try { - // -- m_customNavDomainURL = new URLParameter( - // -- "com.arsdigita.aplaws.custom_nav_domain_url", - // -- Parameter.REQUIRED, - // -- new URL("http://www.aplaws.org.uk/" + - // -- "standards/custom/1.00/termslist.xml")); - // -- } catch (MalformedURLException ex) { - // -- throw new UncheckedWrapperException("Cannot parse url", ex); - // -- } - - - // -- m_customNavPath = new StringParameter( - // -- "com.arsdigita.aplaws.custom_nav_path", - // -- Parameter.REQUIRED, - // -- "local"); - - // -- m_customNavUseContext = new StringParameter( - // -- "com.arsdigita.aplaws.custom_nav_use_context", - // -- Parameter.REQUIRED, - // -- "local"); - - // -- m_customNavTitle = new StringParameter( - // -- "com.arsdigita.aplaws.custom_nav_title", - // -- Parameter.REQUIRED, - // -- "APLAWS Custom Navigation"); - - // -- m_customNavDesc = new StringParameter( - // -- "com.arsdigita.aplaws.custom_nav_desc", - // -- Parameter.REQUIRED, - // -- "Installation specific navigation tree"); - - - // -- register(m_customNavDesc); - // -- register(m_customNavDomainURL); - // -- register(m_customNavKey); - // -- register(m_customNavPath); - // -- register(m_customNavTitle); - // -- register(m_customNavUseContext); - - // -- String customNavPath = (String)get(m_customNavPath); - // -- String customNavTitle = (String)get(m_customNavTitle); - - // Package com.arsdigita.web - // Application.createApplication(Navigation.BASE_DATA_OBJECT_TYPE, - // customNavPath, - // customNavTitle, - // null); - - - - // -- String customNavDesc = (String)get(m_customNavDesc); - // -- String customNavKey = (String)get(m_customNavKey); - // -- String customNavUseContext = (String)get(m_customNavUseContext); - // -- URL customNavDomainURL = (URL)get(m_customNavDomainURL); - - // -- Domain.create(customNavKey, customNavDomainURL, - // -- customNavTitle, customNavDesc, "1.0.0", new Date()); - - // registerDomain(customNavKey, '/'+customNavPath+'/', null); - // -- registerDomain(customNavKey, "/content/", customNavUseContext); - + // -- m_customNavKey = new StringParameter( + // -- "com.arsdigita.aplaws.custom_nav_key", + // -- Parameter.REQUIRED, + // -- "APLAWS-NAVIGATION"); + /* Zugriff auf Website wird nicht benötigt, aber der Parameter bei Einrichtung + * der Kategorien. Funktion URL prüft auf korrekte Syntax, nicht auf Existenz + */ + // -- try { + // -- m_customNavDomainURL = new URLParameter( + // -- "com.arsdigita.aplaws.custom_nav_domain_url", + // -- Parameter.REQUIRED, + // -- new URL("http://www.aplaws.org.uk/" + + // -- "standards/custom/1.00/termslist.xml")); + // -- } catch (MalformedURLException ex) { + // -- throw new UncheckedWrapperException("Cannot parse url", ex); + // -- } + // -- m_customNavPath = new StringParameter( + // -- "com.arsdigita.aplaws.custom_nav_path", + // -- Parameter.REQUIRED, + // -- "local"); + // -- m_customNavUseContext = new StringParameter( + // -- "com.arsdigita.aplaws.custom_nav_use_context", + // -- Parameter.REQUIRED, + // -- "local"); + // -- m_customNavTitle = new StringParameter( + // -- "com.arsdigita.aplaws.custom_nav_title", + // -- Parameter.REQUIRED, + // -- "APLAWS Custom Navigation"); + // -- m_customNavDesc = new StringParameter( + // -- "com.arsdigita.aplaws.custom_nav_desc", + // -- Parameter.REQUIRED, + // -- "Installation specific navigation tree"); + // -- register(m_customNavDesc); + // -- register(m_customNavDomainURL); + // -- register(m_customNavKey); + // -- register(m_customNavPath); + // -- register(m_customNavTitle); + // -- register(m_customNavUseContext); + // -- String customNavPath = (String)get(m_customNavPath); + // -- String customNavTitle = (String)get(m_customNavTitle); + // Package com.arsdigita.web + // Application.createApplication(Navigation.BASE_DATA_OBJECT_TYPE, + // customNavPath, + // customNavTitle, + // null); + // -- String customNavDesc = (String)get(m_customNavDesc); + // -- String customNavKey = (String)get(m_customNavKey); + // -- String customNavUseContext = (String)get(m_customNavUseContext); + // -- URL customNavDomainURL = (URL)get(m_customNavDomainURL); + // -- Domain.create(customNavKey, customNavDomainURL, + // -- customNavTitle, customNavDesc, "1.0.0", new Date()); + // registerDomain(customNavKey, '/'+customNavPath+'/', null); + // -- registerDomain(customNavKey, "/content/", customNavUseContext); // -- } - /** * Use Package com.arsdigita.london.terms to register a Domain for * Categorisation @@ -334,42 +320,46 @@ public class Loader extends PackageLoader { String appURL, String context) { if (s_log.isDebugEnabled()) { - s_log.debug("Mapping domain " + domainKey + - " to app " + appURL + - " in context " + context); + s_log.debug("Mapping domain " + domainKey + " to app " + appURL + + " in context " + context); } Domain domain = Domain.retrieve(domainKey); // package com.arsdigita.london.terms Application app = Application.retrieveApplicationForPath(appURL); domain.setAsRootForObject(app, context); if (app instanceof ContentSection) { - RoleCollection coll = ((ContentSection) app).getStaffGroup().getOrderedRoles(); + RoleCollection coll = ((ContentSection) app).getStaffGroup(). + getOrderedRoles(); Set adminRoles = new HashSet(); Set categorizeRoles = new HashSet(); while (coll.next()) { Role role = coll.getRole(); - final DataQuery privs = RoleFactory.getRolePrivileges - (app.getID(), role.getGroup().getID()); + final DataQuery privs = RoleFactory.getRolePrivileges( + app.getID(), role.getGroup().getID()); while (privs.next()) { String priv = (String) privs.get(RoleFactory.PRIVILEGE); if (priv.equals(SecurityManager.CMS_CATEGORY_ADMIN)) { adminRoles.add(role); - } else if (priv.equals(SecurityManager.CMS_CATEGORIZE_ITEMS)) { + } else if (priv.equals( + SecurityManager.CMS_CATEGORIZE_ITEMS)) { categorizeRoles.add(role); } } - + } - RootCategoryCollection catCollection = Category.getRootCategories(((ContentSection) app)); + RootCategoryCollection catCollection = Category.getRootCategories( + ((ContentSection) app)); while (catCollection.next()) { Iterator adminIter = adminRoles.iterator(); while (adminIter.hasNext()) { - ((Role) adminIter.next()).grantPermission(catCollection.getCategory(), + ((Role) adminIter.next()).grantPermission(catCollection. + getCategory(), PrivilegeDescriptor.ADMIN); } Iterator categorizeIter = categorizeRoles.iterator(); while (categorizeIter.hasNext()) { - ((Role) categorizeIter.next()).grantPermission(catCollection.getCategory(), + ((Role) categorizeIter.next()).grantPermission(catCollection. + getCategory(), Category.MAP_DESCRIPTOR); } }