[UPDATE]
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-94f89814c4dfmaster
parent
9ed9fe3b21
commit
2ac2d9a7ff
|
|
@ -50,14 +50,4 @@ public class ExternalLinkUnloader extends AbstractContentTypeUnloader {
|
||||||
public String[] getTypes() {
|
public String[] getTypes() {
|
||||||
return TYPES;
|
return TYPES;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* ??????????
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public List getAllInstances() {
|
|
||||||
return new ArrayList();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.cms.contenttypes;
|
package com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.ContentItem;
|
||||||
import com.arsdigita.cms.ContentSection;
|
import com.arsdigita.cms.ContentSection;
|
||||||
import com.arsdigita.cms.ContentType;
|
import com.arsdigita.cms.ContentType;
|
||||||
import com.arsdigita.domain.DomainObjectFactory;
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
|
|
@ -90,9 +91,37 @@ public abstract class AbstractContentTypeUnloader extends PackageLoader {
|
||||||
|
|
||||||
List types = handler.getContentTypes();
|
List types = handler.getContentTypes();
|
||||||
Session ssn = ctx.getSession();
|
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(
|
DataCollection sections = ssn.retrieve(
|
||||||
ContentSection.BASE_DATA_OBJECT_TYPE);
|
ContentSection.BASE_DATA_OBJECT_TYPE);
|
||||||
|
|
||||||
while (sections.next()) {
|
while (sections.next()) {
|
||||||
ContentSection section = (ContentSection)
|
ContentSection section = (ContentSection)
|
||||||
DomainObjectFactory.newInstance(sections.getDataObject());
|
DomainObjectFactory.newInstance(sections.getDataObject());
|
||||||
|
|
@ -102,12 +131,12 @@ public abstract class AbstractContentTypeUnloader extends PackageLoader {
|
||||||
|
|
||||||
for (Iterator it = types.iterator(); it.hasNext();) {
|
for (Iterator it = types.iterator(); it.hasNext();) {
|
||||||
final ContentType type = (ContentType) it.next();
|
final ContentType type = (ContentType) it.next();
|
||||||
|
|
||||||
//Is the order important?? (here: same as in load step)
|
|
||||||
section.removeContentType(type);
|
section.removeContentType(type);
|
||||||
|
// necessary??
|
||||||
|
//type.getAuthoringKit().delete();
|
||||||
|
//type.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//TODO: still to be implemented
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -325,6 +325,10 @@ class Load extends Command implements LoadCenter {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Checks and loads the data.
|
//Checks and loads the data.
|
||||||
|
if (ssn == null) {
|
||||||
|
new Runtime().startup();
|
||||||
|
ssn = SessionManager.getSession();
|
||||||
|
}
|
||||||
if (!checkAndLoadData(line, loaders, ssn, all, cpr)) {
|
if (!checkAndLoadData(line, loaders, ssn, all, cpr)) {
|
||||||
rollbackConfig(config,packages);
|
rollbackConfig(config,packages);
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -333,6 +337,10 @@ class Load extends Command implements LoadCenter {
|
||||||
|
|
||||||
//All --init specific tasks.
|
//All --init specific tasks.
|
||||||
if (all || line.hasOption("init")) {
|
if (all || line.hasOption("init")) {
|
||||||
|
if (ssn == null) {
|
||||||
|
new Runtime().startup();
|
||||||
|
ssn = SessionManager.getSession();
|
||||||
|
}
|
||||||
loadInits(loaders, ssn);
|
loadInits(loaders, ssn);
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
|
@ -725,11 +733,6 @@ class Load extends Command implements LoadCenter {
|
||||||
ssn, boolean all, CompoundParameterReader cpr) {
|
ssn, boolean all, CompoundParameterReader cpr) {
|
||||||
boolean passed = true;
|
boolean passed = true;
|
||||||
if (all || line.hasOption("data")) {
|
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) {
|
for (Loader loader : loaders) {
|
||||||
passed &= loader.checkData(ssn);
|
passed &= loader.checkData(ssn);
|
||||||
}
|
}
|
||||||
|
|
@ -750,11 +753,6 @@ class Load extends Command implements LoadCenter {
|
||||||
* @param ssn The session for the database-connection
|
* @param ssn The session for the database-connection
|
||||||
*/
|
*/
|
||||||
private void loadInits(Loader[] loaders, Session ssn) {
|
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) {
|
for (Loader loader : loaders) {
|
||||||
loader.loadInits(ssn);
|
loader.loadInits(ssn);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -202,7 +202,8 @@ class Unload extends Command implements LoadCenter {
|
||||||
|
|
||||||
Connection conn = Connections.acquire(
|
Connection conn = Connections.acquire(
|
||||||
RuntimeConfig.getConfig().getJDBCURL());
|
RuntimeConfig.getConfig().getJDBCURL());
|
||||||
Session ssn = null;
|
new Runtime().startup();
|
||||||
|
Session ssn = SessionManager.getSession();
|
||||||
|
|
||||||
//Unload
|
//Unload
|
||||||
boolean result = true;
|
boolean result = true;
|
||||||
|
|
@ -320,10 +321,6 @@ class Unload extends Command implements LoadCenter {
|
||||||
* @return true on success, otherwise false
|
* @return true on success, otherwise false
|
||||||
*/
|
*/
|
||||||
private boolean unloadInits(Connection conn, Session ssn, Loader[] unloaders) {
|
private boolean unloadInits(Connection conn, Session ssn, Loader[] unloaders) {
|
||||||
if (ssn == null) {
|
|
||||||
new Runtime().startup();
|
|
||||||
ssn = SessionManager.getSession();
|
|
||||||
}
|
|
||||||
boolean passed = true;
|
boolean passed = true;
|
||||||
if (PackageLoader.exists(conn, "inits")) {
|
if (PackageLoader.exists(conn, "inits")) {
|
||||||
passed &= checkInitializerDependencies(unloaders, "unloader");
|
passed &= checkInitializerDependencies(unloaders, "unloader");
|
||||||
|
|
@ -345,10 +342,6 @@ class Unload extends Command implements LoadCenter {
|
||||||
* @return true on success, otherwise false
|
* @return true on success, otherwise false
|
||||||
*/
|
*/
|
||||||
private boolean unloadData(Session ssn, Loader[] unloaders) {
|
private boolean unloadData(Session ssn, Loader[] unloaders) {
|
||||||
if (ssn == null) {
|
|
||||||
new Runtime().startup();
|
|
||||||
ssn = SessionManager.getSession();
|
|
||||||
}
|
|
||||||
boolean passed = true;
|
boolean passed = true;
|
||||||
for (Loader unloader : unloaders) {
|
for (Loader unloader : unloaders) {
|
||||||
passed &= unloader.checkData(ssn);
|
passed &= unloader.checkData(ssn);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue