Das Entfernen von Instanzen (ContentItems) derjenigen ContentTypes aus den Tabellen der Datenbank, die deinstalliert werden sollen über "ccm unload". Funktionalität ccm unload kann jetzt verwendet werden.


git-svn-id: https://svn.libreccm.org/ccm/trunk@3448 8810af33-2d31-482b-a856-94f89814c4df
master
tosmers 2015-06-01 18:13:50 +00:00
parent 9ed9fe3b21
commit 2ac2d9a7ff
4 changed files with 44 additions and 34 deletions

View File

@ -50,14 +50,4 @@ public class ExternalLinkUnloader extends AbstractContentTypeUnloader {
public String[] getTypes() {
return TYPES;
}
/**
* ??????????
*
* @return
*/
public List getAllInstances() {
return new ArrayList();
}
}
}

View File

@ -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
}
/**

View File

@ -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);
}

View File

@ -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);