[UPDATE]
Angefangen, das Problem mit den Initalizern beim unload zu beseitigen. git-svn-id: https://svn.libreccm.org/ccm/trunk@3484 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
825aa26231
commit
e11267a809
|
|
@ -107,7 +107,6 @@ public abstract class AbstractContentTypeLoader extends PackageLoader {
|
||||||
* @param ctx The context to the unload-script
|
* @param ctx The context to the unload-script
|
||||||
*/
|
*/
|
||||||
private void createTypes(ScriptContext ctx) {
|
private void createTypes(ScriptContext ctx) {
|
||||||
|
|
||||||
XMLContentTypeHandler handler = new XMLContentTypeHandler();
|
XMLContentTypeHandler handler = new XMLContentTypeHandler();
|
||||||
// Retrieve the content type definition file(s)
|
// Retrieve the content type definition file(s)
|
||||||
String[] contentTypes = getTypes();
|
String[] contentTypes = getTypes();
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ public abstract class AbstractContentTypeUnloader extends PackageLoader {
|
||||||
* @param ctx The context to the unload-script
|
* @param ctx The context to the unload-script
|
||||||
*/
|
*/
|
||||||
private void sweepTypes(ScriptContext ctx) {
|
private void sweepTypes(ScriptContext ctx) {
|
||||||
XMLContentTypeHandler handler = new XMLContentTypeHandler();
|
XMLContentTypeHandler handler = new XMLContentTypeHandler(false);
|
||||||
// Retrieve the content type definition file(s)
|
// Retrieve the content type definition file(s)
|
||||||
String[] contentTypes = getTypes();
|
String[] contentTypes = getTypes();
|
||||||
for (String contentType : contentTypes) {
|
for (String contentType : contentTypes) {
|
||||||
|
|
@ -130,10 +130,6 @@ 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();
|
||||||
section.removeContentType(type);
|
section.removeContentType(type);
|
||||||
//section.removeNotAssociatedContentTypes(type);
|
|
||||||
// necessary??
|
|
||||||
//type.getAuthoringKit().delete();
|
|
||||||
//type.delete();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,8 @@ import com.arsdigita.cms.ContentType;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
public interface ContentTypeHelper {
|
public interface ContentTypeHelper {
|
||||||
|
|
||||||
|
|
||||||
public void setName(String name) ;
|
public void setName(String name) ;
|
||||||
/** @deprecated */
|
/** @deprecated */
|
||||||
public void setLabel(String label) ;
|
public void setLabel(String label) ;
|
||||||
|
|
@ -90,5 +92,7 @@ public interface ContentTypeHelper {
|
||||||
String component,
|
String component,
|
||||||
BigDecimal ordering) ;
|
BigDecimal ordering) ;
|
||||||
|
|
||||||
public void saveType();
|
public void saveType();
|
||||||
|
|
||||||
|
public void deleteType();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -329,10 +329,17 @@ public class ContentTypeHelperImpl implements ContentTypeHelper {
|
||||||
m_type.save();
|
m_type.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void saveType() {
|
public void saveType() {
|
||||||
m_kit.save();
|
m_kit.save();
|
||||||
m_type.save();
|
m_type.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteType() {
|
||||||
|
m_kit.delete();
|
||||||
|
m_type.delete();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates the pedigree for this content type
|
* Generates the pedigree for this content type
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ package com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
import com.arsdigita.cms.AuthoringKit;
|
import com.arsdigita.cms.AuthoringKit;
|
||||||
import com.arsdigita.cms.ContentType;
|
import com.arsdigita.cms.ContentType;
|
||||||
import com.arsdigita.cms.contenttypes.ContentTypeInitializer;
|
|
||||||
import com.arsdigita.xml.XML;
|
import com.arsdigita.xml.XML;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
@ -48,7 +47,16 @@ public class XMLContentTypeHandler extends DefaultHandler {
|
||||||
private AuthoringKit m_authoringKit;
|
private AuthoringKit m_authoringKit;
|
||||||
private int m_nextOrder;
|
private int m_nextOrder;
|
||||||
private boolean m_including;
|
private boolean m_including;
|
||||||
|
private boolean create;
|
||||||
|
|
||||||
|
public XMLContentTypeHandler() {
|
||||||
|
this.create = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public XMLContentTypeHandler(boolean create) {
|
||||||
|
this.create = create;
|
||||||
|
}
|
||||||
|
|
||||||
public List getContentTypes() {
|
public List getContentTypes() {
|
||||||
return m_types;
|
return m_types;
|
||||||
}
|
}
|
||||||
|
|
@ -135,9 +143,15 @@ public class XMLContentTypeHandler extends DefaultHandler {
|
||||||
String qName, Attributes atts) {
|
String qName, Attributes atts) {
|
||||||
if (name.equals("content-type")) {
|
if (name.equals("content-type")) {
|
||||||
// reset the helper
|
// reset the helper
|
||||||
m_contentType.save();
|
if (create) {
|
||||||
m_authoringKit.save();
|
m_contentType.save();
|
||||||
m_type.saveType();
|
m_authoringKit.save();
|
||||||
|
m_type.saveType();
|
||||||
|
} else {
|
||||||
|
m_contentType.delete();
|
||||||
|
m_authoringKit.delete();
|
||||||
|
m_type.deleteType();
|
||||||
|
}
|
||||||
m_type = null;
|
m_type = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -657,7 +657,8 @@ class Load extends Command implements LoadCenter {
|
||||||
boolean success = true;
|
boolean success = true;
|
||||||
if (PackageLoader.exists(conn, "inits")
|
if (PackageLoader.exists(conn, "inits")
|
||||||
&& (line.hasOption("init") || all)) {
|
&& (line.hasOption("init") || all)) {
|
||||||
success = checkInitializerDependencies(loaders, "loader");
|
success = checkInitializerDependencies(loaders, "loader",
|
||||||
|
LoadType.LOAD);
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
@ -671,12 +672,13 @@ class Load extends Command implements LoadCenter {
|
||||||
* @param loaders A list of loaders to the corresponding packages
|
* @param loaders A list of loaders to the corresponding packages
|
||||||
* to-be-loaded
|
* to-be-loaded
|
||||||
* @param sessionName Name of the session
|
* @param sessionName Name of the session
|
||||||
|
* @param type The load-type
|
||||||
* @return true on success, otherwise false
|
* @return true on success, otherwise false
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean checkInitializerDependencies(final Loader[] loaders,
|
public boolean checkInitializerDependencies(final Loader[] loaders,
|
||||||
String sessionName) {
|
String sessionName, LoadType type) {
|
||||||
return delegate.checkInitializerDependencies(loaders, sessionName);
|
return delegate.checkInitializerDependencies(loaders, sessionName, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -99,9 +99,10 @@ public interface LoadCenter {
|
||||||
* @param loaders A list of loaders to the corresponding packages
|
* @param loaders A list of loaders to the corresponding packages
|
||||||
* to-be-loaded
|
* to-be-loaded
|
||||||
* @param sessionName Name of the session
|
* @param sessionName Name of the session
|
||||||
|
* @param type The load-type
|
||||||
* @return true on success, otherwise false
|
* @return true on success, otherwise false
|
||||||
*/
|
*/
|
||||||
boolean checkInitializerDependencies(final Loader[] loaders,
|
boolean checkInitializerDependencies(final Loader[] loaders,
|
||||||
String sessionName);
|
String sessionName, LoadType type);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -469,11 +469,12 @@ public class LoadCenterDelegate implements LoadCenter {
|
||||||
* @param loaders A list of loaders to the corresponding packages
|
* @param loaders A list of loaders to the corresponding packages
|
||||||
* to-be-loaded
|
* to-be-loaded
|
||||||
* @param sessionName Name of the session
|
* @param sessionName Name of the session
|
||||||
|
* @param type The load-type
|
||||||
* @return true on success, otherwise false
|
* @return true on success, otherwise false
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean checkInitializerDependencies(final Loader[] loaders,
|
public boolean checkInitializerDependencies(final Loader[] loaders,
|
||||||
String sessionName) {
|
String sessionName, LoadType type) {
|
||||||
final List required = new ArrayList();
|
final List required = new ArrayList();
|
||||||
final List provided = new ArrayList();
|
final List provided = new ArrayList();
|
||||||
addTo(required, InfoGetter.getRequiredInitializers(loaders));
|
addTo(required, InfoGetter.getRequiredInitializers(loaders));
|
||||||
|
|
@ -482,15 +483,26 @@ public class LoadCenterDelegate implements LoadCenter {
|
||||||
|
|
||||||
final Session boot = session(sessionName);
|
final Session boot = session(sessionName);
|
||||||
final List missing = getMissing(boot, required);
|
final List missing = getMissing(boot, required);
|
||||||
final List conflicts = getConflicts(boot, provided);
|
final List existing = getExisting(boot, provided);
|
||||||
|
|
||||||
if (!missing.isEmpty()) {
|
if (!missing.isEmpty()) {
|
||||||
System.err.println("required initializers: " + missing);
|
System.err.println("required initializers: " + missing);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!conflicts.isEmpty()) {
|
|
||||||
System.err.println("conflicting initializers: " + conflicts);
|
if (type==LoadType.LOAD) {
|
||||||
return false;
|
// Beim laden
|
||||||
|
if (!existing.isEmpty()) {
|
||||||
|
System.err.println("already existing initializers, "
|
||||||
|
+ "thus conflicting: " + existing);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (type==LoadType.UNLOAD) {
|
||||||
|
if (existing.isEmpty()) {
|
||||||
|
System.err.println("not existing initializers,"
|
||||||
|
+ "thus not unloadable: " + existing);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -548,24 +560,24 @@ public class LoadCenterDelegate implements LoadCenter {
|
||||||
/**
|
/**
|
||||||
* [SUPPORT]
|
* [SUPPORT]
|
||||||
* Returns all initializers, provided by initializers in the given list,
|
* Returns all initializers, provided by initializers in the given list,
|
||||||
* which have already been initialized, thus all conflicting initializers.
|
* which have already been initialized, thus all existing initializers.
|
||||||
*
|
*
|
||||||
* used in: checkInitializerDependencies
|
* used in: checkInitializerDependencies
|
||||||
*
|
*
|
||||||
* @param ssn The session for the db-connection
|
* @param ssn The session for the db-connection
|
||||||
* @param inits List of initializers
|
* @param inits List of initializers
|
||||||
* @return List of conflicting initializers
|
* @return List of existing initializers
|
||||||
*/
|
*/
|
||||||
private static List getConflicts(Session ssn, List inits) {
|
private static List getExisting(Session ssn, List inits) {
|
||||||
List conflicts = new ArrayList();
|
List existing = new ArrayList();
|
||||||
for (Iterator it = inits.iterator(); it.hasNext(); ) {
|
for (Iterator it = inits.iterator(); it.hasNext(); ) {
|
||||||
String init = (String) it.next();
|
String init = (String) it.next();
|
||||||
OID oid = new OID(ssn.getMetadataRoot().getObjectType(INIT), init);
|
OID oid = new OID(ssn.getMetadataRoot().getObjectType(INIT), init);
|
||||||
if (ssn.retrieve(oid) != null) {
|
if (ssn.retrieve(oid) != null) {
|
||||||
conflicts.add(init);
|
existing.add(init);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return conflicts;
|
return existing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -317,15 +317,18 @@ class Loader {
|
||||||
final List required = m_info.getRequiredInitializers();
|
final List required = m_info.getRequiredInitializers();
|
||||||
for (Iterator it = inits.iterator(); it.hasNext(); ) {
|
for (Iterator it = inits.iterator(); it.hasNext(); ) {
|
||||||
String init = (String) it.next();
|
String init = (String) it.next();
|
||||||
OID oid = new OID(INIT, init);
|
DataObject dataObject = ssn.retrieve(new OID(INIT, init));
|
||||||
DataObject dataObject = ssn.retrieve(oid);
|
|
||||||
DataAssociation da =
|
DataAssociation da1 =
|
||||||
(DataAssociation) dataObject.get("requirements");
|
(DataAssociation) dataObject.get("requirements");
|
||||||
for (Iterator reqIt = required.iterator(); reqIt.hasNext(); ) {
|
for (Iterator reqIt = required.iterator(); reqIt.hasNext(); ) {
|
||||||
String reqInit = (String) reqIt.next();
|
String reqInit = (String) reqIt.next();
|
||||||
da.remove(ssn.retrieve(new OID(INIT, reqInit)));
|
da1.remove(ssn.retrieve(new OID(INIT, reqInit)));
|
||||||
}
|
}
|
||||||
ssn.delete(oid);
|
|
||||||
|
DataAssociation da2 =
|
||||||
|
(DataAssociation) dataObject.get("inits");
|
||||||
|
da2.remove(ssn.retrieve(new OID(INIT, init)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (txn.inTxn()) {
|
if (txn.inTxn()) {
|
||||||
|
|
|
||||||
|
|
@ -305,16 +305,17 @@ class Unload extends Command implements LoadCenter {
|
||||||
* @param loaders A list of loaders to the corresponding packages
|
* @param loaders A list of loaders to the corresponding packages
|
||||||
* to-be-loaded
|
* to-be-loaded
|
||||||
* @param sessionName Name of the session
|
* @param sessionName Name of the session
|
||||||
|
* @param type The load-type
|
||||||
* @return true on success, otherwise false
|
* @return true on success, otherwise false
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean checkInitializerDependencies(final Loader[] loaders,
|
public boolean checkInitializerDependencies(final Loader[] loaders,
|
||||||
String sessionName) {
|
String sessionName, LoadType type) {
|
||||||
return delegate.checkInitializerDependencies(loaders, sessionName);
|
return delegate.checkInitializerDependencies(loaders, sessionName, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unloads the initializers. needed?
|
* Unloads the initializers.
|
||||||
*
|
*
|
||||||
* @param ssn The session for the db-connection
|
* @param ssn The session for the db-connection
|
||||||
* @param unloaders The list of unloaders from the packages to be unloaded
|
* @param unloaders The list of unloaders from the packages to be unloaded
|
||||||
|
|
@ -323,7 +324,8 @@ class Unload extends Command implements LoadCenter {
|
||||||
private boolean unloadInits(Connection conn, Session ssn, Loader[] unloaders) {
|
private boolean unloadInits(Connection conn, Session ssn, Loader[] unloaders) {
|
||||||
boolean passed = true;
|
boolean passed = true;
|
||||||
if (PackageLoader.exists(conn, "inits")) {
|
if (PackageLoader.exists(conn, "inits")) {
|
||||||
passed &= checkInitializerDependencies(unloaders, "unloader");
|
passed &= checkInitializerDependencies(unloaders, "unloader",
|
||||||
|
LoadType.UNLOAD);
|
||||||
if (!passed) {
|
if (!passed) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -197,9 +197,8 @@ class DataObjectImpl implements DataObject {
|
||||||
builder.append(((Property) properties.next()).getName());
|
builder.append(((Property) properties.next()).getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new PersistenceException(String.format(
|
throw new PersistenceException(String.format("no such property: %s for %s. Available properties: %s",
|
||||||
"no such property: %s for %s. Available properties: %s",
|
property,
|
||||||
property.toString(),
|
|
||||||
this.toString(),
|
this.toString(),
|
||||||
builder.toString()));
|
builder.toString()));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue