diff --git a/ccm-cms-types-externallink/src/com/arsdigita/cms/contenttypes/ExternalLinkUnloader.java b/ccm-cms-types-externallink/src/com/arsdigita/cms/contenttypes/ExternalLinkUnloader.java index d04f1003d..c86b6bd9b 100644 --- a/ccm-cms-types-externallink/src/com/arsdigita/cms/contenttypes/ExternalLinkUnloader.java +++ b/ccm-cms-types-externallink/src/com/arsdigita/cms/contenttypes/ExternalLinkUnloader.java @@ -50,14 +50,4 @@ public class ExternalLinkUnloader extends AbstractContentTypeUnloader { public String[] getTypes() { return TYPES; } - - /** - * ?????????? - * - * @return - */ - public List getAllInstances() { - return new ArrayList(); - } - -} +} \ No newline at end of file diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/AbstractContentTypeUnloader.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/AbstractContentTypeUnloader.java index 3a36b6d73..ee0e9928c 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/AbstractContentTypeUnloader.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/AbstractContentTypeUnloader.java @@ -18,6 +18,7 @@ */ package com.arsdigita.cms.contenttypes; +import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.ContentType; import com.arsdigita.domain.DomainObjectFactory; @@ -90,9 +91,37 @@ public abstract class AbstractContentTypeUnloader extends PackageLoader { List types = handler.getContentTypes(); Session ssn = ctx.getSession(); + + // Auf contenttype und das base.data.object.type retrieven -> + // datacollection von den instanzen (dataObject) + // domainobjectfactory.newInst... contentItem aus den datacollections + // contentitem method is live. publiziert? + // unpublish ccm-ldn-util und dann alle deleten + DataCollection contentItems = ssn.retrieve( + ContentItem.BASE_DATA_OBJECT_TYPE); + while (contentItems.next()) { + ContentItem contentItem; + try { + contentItem = (ContentItem) + DomainObjectFactory.newInstance(contentItems.getDataObject()); + } catch (Exception ex) { + continue; + } + if (contentItem == null || !contentItem.isPublished()) { + continue; + } + for (Iterator it = types.iterator(); it.hasNext(); ) { + final ContentType type = (ContentType) it.next(); + if (contentItem.getContentType().equals(type)) { + contentItem.unpublish(); + contentItem.delete(); + } + } + } + + // Removes the types from the sections. DataCollection sections = ssn.retrieve( ContentSection.BASE_DATA_OBJECT_TYPE); - while (sections.next()) { ContentSection section = (ContentSection) DomainObjectFactory.newInstance(sections.getDataObject()); @@ -102,12 +131,12 @@ public abstract class AbstractContentTypeUnloader extends PackageLoader { for (Iterator it = types.iterator(); it.hasNext();) { final ContentType type = (ContentType) it.next(); - - //Is the order important?? (here: same as in load step) section.removeContentType(type); + // necessary?? + //type.getAuthoringKit().delete(); + //type.delete(); } } - //TODO: still to be implemented } /** diff --git a/ccm-core/src/com/arsdigita/packaging/Load.java b/ccm-core/src/com/arsdigita/packaging/Load.java index 6f7e3807e..e75cc86a5 100755 --- a/ccm-core/src/com/arsdigita/packaging/Load.java +++ b/ccm-core/src/com/arsdigita/packaging/Load.java @@ -325,6 +325,10 @@ class Load extends Command implements LoadCenter { } //Checks and loads the data. + if (ssn == null) { + new Runtime().startup(); + ssn = SessionManager.getSession(); + } if (!checkAndLoadData(line, loaders, ssn, all, cpr)) { rollbackConfig(config,packages); return false; @@ -333,6 +337,10 @@ class Load extends Command implements LoadCenter { //All --init specific tasks. if (all || line.hasOption("init")) { + if (ssn == null) { + new Runtime().startup(); + ssn = SessionManager.getSession(); + } loadInits(loaders, ssn); } } catch (Throwable t) { @@ -725,11 +733,6 @@ class Load extends Command implements LoadCenter { ssn, boolean all, CompoundParameterReader cpr) { boolean passed = true; if (all || line.hasOption("data")) { - //Starts new session for the db-connection - if (ssn == null) { - new Runtime().startup(); - ssn = SessionManager.getSession(); - } for (Loader loader : loaders) { passed &= loader.checkData(ssn); } @@ -750,11 +753,6 @@ class Load extends Command implements LoadCenter { * @param ssn The session for the database-connection */ private void loadInits(Loader[] loaders, Session ssn) { - //Starts new session for the db-connection - if (ssn == null) { - new Runtime().startup(); - ssn = SessionManager.getSession(); - } for (Loader loader : loaders) { loader.loadInits(ssn); } diff --git a/ccm-core/src/com/arsdigita/packaging/Unload.java b/ccm-core/src/com/arsdigita/packaging/Unload.java index 3dfc080cc..c19b43a6d 100755 --- a/ccm-core/src/com/arsdigita/packaging/Unload.java +++ b/ccm-core/src/com/arsdigita/packaging/Unload.java @@ -202,7 +202,8 @@ class Unload extends Command implements LoadCenter { Connection conn = Connections.acquire( RuntimeConfig.getConfig().getJDBCURL()); - Session ssn = null; + new Runtime().startup(); + Session ssn = SessionManager.getSession(); //Unload boolean result = true; @@ -320,10 +321,6 @@ class Unload extends Command implements LoadCenter { * @return true on success, otherwise false */ private boolean unloadInits(Connection conn, Session ssn, Loader[] unloaders) { - if (ssn == null) { - new Runtime().startup(); - ssn = SessionManager.getSession(); - } boolean passed = true; if (PackageLoader.exists(conn, "inits")) { passed &= checkInitializerDependencies(unloaders, "unloader"); @@ -345,10 +342,6 @@ class Unload extends Command implements LoadCenter { * @return true on success, otherwise false */ private boolean unloadData(Session ssn, Loader[] unloaders) { - if (ssn == null) { - new Runtime().startup(); - ssn = SessionManager.getSession(); - } boolean passed = true; for (Loader unloader : unloaders) { passed &= unloader.checkData(ssn);