Fix für Bug beim Publizieren von Bundle-Instanzen. Achtung: Nicht abschließend getestet.
git-svn-id: https://svn.libreccm.org/ccm/trunk@1544 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
451b67580d
commit
c757188e00
|
|
@ -617,8 +617,7 @@ public class ContentItem extends VersionedACSObject implements CustomCopy {
|
||||||
*
|
*
|
||||||
* The item's root is the ancestor reachable through repeated
|
* The item's root is the ancestor reachable through repeated
|
||||||
* <code>getParent()</code> calls whose parent is
|
* <code>getParent()</code> calls whose parent is
|
||||||
* <code>null</code>. This is usually a folder, but may be any
|
* <code>null</code>. This is usually a folder, but may be any {
|
||||||
* {
|
|
||||||
*
|
*
|
||||||
* @see com.arsdigita.kernel.ACSObject}.
|
* @see com.arsdigita.kernel.ACSObject}.
|
||||||
*
|
*
|
||||||
|
|
@ -1173,7 +1172,7 @@ public class ContentItem extends VersionedACSObject implements CustomCopy {
|
||||||
save();
|
save();
|
||||||
|
|
||||||
PublishedLink.updateLiveLinks(version);
|
PublishedLink.updateLiveLinks(version);
|
||||||
PublishedAssociation.updateLiveAssoications(version);
|
PublishedAssociation.updateLiveAssociations(version);
|
||||||
save();
|
save();
|
||||||
|
|
||||||
// publish item (as template or html pages) to the file
|
// publish item (as template or html pages) to the file
|
||||||
|
|
@ -1884,50 +1883,52 @@ public class ContentItem extends VersionedACSObject implements CustomCopy {
|
||||||
== ItemCopier.VERSION_COPY) {
|
== ItemCopier.VERSION_COPY) {
|
||||||
if (parent instanceof ContentBundle) {
|
if (parent instanceof ContentBundle) {
|
||||||
|
|
||||||
ContentBundle bundle = (ContentBundle) parent;
|
final ContentBundle bundle = (ContentBundle) parent;
|
||||||
ContentBundle liveBundle = (ContentBundle) bundle.
|
final ContentBundle oldLiveBundle = (ContentBundle) bundle.
|
||||||
getPublicVersion();
|
getPublicVersion();
|
||||||
//jensp 2012-03-07 Changes to the ContentBundle were not
|
//jensp 2012-03-07 Changes to the ContentBundle were not
|
||||||
//published because the ContentBundle was not republished.
|
//published because the ContentBundle was not republished.
|
||||||
//Moved the next lines out of the if below to enable
|
//Moved the next lines out of the if below to enable
|
||||||
//republishing of the ContentBundle
|
//republishing of the ContentBundle
|
||||||
liveBundle =
|
final ContentBundle liveBundle =
|
||||||
(ContentBundle) bundle.createPendingVersion(null);
|
(ContentBundle) bundle.
|
||||||
if (liveBundle == null) {
|
createPendingVersion(null);
|
||||||
} else {
|
/*
|
||||||
Set liveCatSet = new HashSet();
|
* if (liveBundle == null) { } else { Set liveCatSet = new
|
||||||
Set draftCatSet = new HashSet();
|
* HashSet(); Set draftCatSet = new HashSet();
|
||||||
|
*
|
||||||
CategoryCollection liveCategories =
|
* CategoryCollection liveCategories =
|
||||||
liveBundle.getCategoryCollection();
|
* liveBundle.getCategoryCollection(); while
|
||||||
while (liveCategories.next()) {
|
* (liveCategories.next()) {
|
||||||
liveCatSet.add(liveCategories.getCategory());
|
* liveCatSet.add(liveCategories.getCategory()); }
|
||||||
|
* liveCategories.close();
|
||||||
|
*
|
||||||
|
* CategoryCollection draftCategories =
|
||||||
|
* bundle.getCategoryCollection(); while
|
||||||
|
* (draftCategories.next()) {
|
||||||
|
* draftCatSet.add(draftCategories.getCategory()); }
|
||||||
|
* draftCategories.close();
|
||||||
|
*
|
||||||
|
* Set catsToRemove = new HashSet(liveCatSet);
|
||||||
|
* catsToRemove.removeAll(draftCatSet); Set catsToAdd = new
|
||||||
|
* HashSet(draftCatSet); catsToAdd.removeAll(liveCatSet);
|
||||||
|
*
|
||||||
|
* Iterator removeIter = catsToRemove.iterator(); while
|
||||||
|
* (removeIter.hasNext()) { liveBundle.removeCategory(
|
||||||
|
* (Category) removeIter.next()); } Iterator addIter =
|
||||||
|
* catsToAdd.iterator(); while (addIter.hasNext()) {
|
||||||
|
* liveBundle.addCategory((Category) addIter.next()); }
|
||||||
|
*
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
if (oldLiveBundle != null) {
|
||||||
|
final ItemCollection instances = oldLiveBundle.
|
||||||
|
getInstances();
|
||||||
|
while (instances.next()) {
|
||||||
|
liveBundle.addInstance(instances.getContentItem());
|
||||||
}
|
}
|
||||||
liveCategories.close();
|
|
||||||
|
|
||||||
CategoryCollection draftCategories =
|
|
||||||
bundle.getCategoryCollection();
|
|
||||||
while (draftCategories.next()) {
|
|
||||||
draftCatSet.add(draftCategories.getCategory());
|
|
||||||
}
|
|
||||||
draftCategories.close();
|
|
||||||
|
|
||||||
Set catsToRemove = new HashSet(liveCatSet);
|
|
||||||
catsToRemove.removeAll(draftCatSet);
|
|
||||||
Set catsToAdd = new HashSet(draftCatSet);
|
|
||||||
catsToAdd.removeAll(liveCatSet);
|
|
||||||
|
|
||||||
Iterator removeIter = catsToRemove.iterator();
|
|
||||||
while (removeIter.hasNext()) {
|
|
||||||
liveBundle.removeCategory(
|
|
||||||
(Category) removeIter.next());
|
|
||||||
}
|
|
||||||
Iterator addIter = catsToAdd.iterator();
|
|
||||||
while (addIter.hasNext()) {
|
|
||||||
liveBundle.addCategory((Category) addIter.next());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setBundle(liveBundle);
|
setBundle(liveBundle);
|
||||||
return true;
|
return true;
|
||||||
} else if (parent instanceof Folder) {
|
} else if (parent instanceof Folder) {
|
||||||
|
|
|
||||||
|
|
@ -429,7 +429,8 @@ public class GenericContactPersonAssocUpgrade extends Program {
|
||||||
try {
|
try {
|
||||||
conn.rollback();
|
conn.rollback();
|
||||||
} catch (SQLException ex1) {
|
} catch (SQLException ex1) {
|
||||||
System.out.println("Rollback failed.");
|
System.err.println("Rollback failed.");
|
||||||
|
ex1.printStackTrace(System.err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -437,7 +438,7 @@ public class GenericContactPersonAssocUpgrade extends Program {
|
||||||
try {
|
try {
|
||||||
conn.close();
|
conn.close();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
System.err.println("Failed to close JDBC connectio.");
|
System.err.println("Failed to close JDBC connection.");
|
||||||
printStackTrace(ex);
|
printStackTrace(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,93 +27,96 @@ import com.arsdigita.web.ApplicationType;
|
||||||
/**
|
/**
|
||||||
* @author Peter Kopunec
|
* @author Peter Kopunec
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Initializer extends CompoundInitializer {
|
public class Initializer extends CompoundInitializer {
|
||||||
|
|
||||||
private static final Logger s_log = Logger.getLogger(Initializer.class);
|
private static final Logger s_log = Logger.getLogger(Initializer.class);
|
||||||
|
|
||||||
//ublic Initializer() throws InitializationException {
|
//ublic Initializer() throws InitializationException {
|
||||||
public Initializer() {
|
public Initializer() {
|
||||||
final String url = RuntimeConfig.getConfig().getJDBCURL();
|
final String url = RuntimeConfig.getConfig().getJDBCURL();
|
||||||
final int database = DbHelper.getDatabaseFromURL(url);
|
final int database = DbHelper.getDatabaseFromURL(url);
|
||||||
|
|
||||||
add(new PDLInitializer(new ManifestSource("ccm-weblog.pdl.mf",
|
add(new PDLInitializer(new ManifestSource("ccm-weblog.pdl.mf",
|
||||||
new NameFilter(DbHelper.getDatabaseSuffix(database), "pdl"))));
|
new NameFilter(DbHelper.
|
||||||
}
|
getDatabaseSuffix(database), "pdl"))));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(DomainInitEvent e) {
|
public void init(DomainInitEvent e) {
|
||||||
s_log.info("WebLog Initializer starting.");
|
s_log.info("WebLog Initializer starting.");
|
||||||
|
|
||||||
boolean isMyTransaction = false;
|
boolean isMyTransaction = false;
|
||||||
TransactionContext txn = SessionManager.getSession()
|
TransactionContext txn = SessionManager.getSession().
|
||||||
.getTransactionContext();
|
getTransactionContext();
|
||||||
if (!txn.inTxn()) {
|
if (!txn.inTxn()) {
|
||||||
txn.beginTxn();
|
txn.beginTxn();
|
||||||
isMyTransaction = true;
|
isMyTransaction = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// register application
|
||||||
|
DomainObjectInstantiator instantiator = new ACSObjectInstantiator() {
|
||||||
|
|
||||||
// register application
|
|
||||||
DomainObjectInstantiator instantiator = new ACSObjectInstantiator() {
|
|
||||||
@Override
|
@Override
|
||||||
protected DomainObject doNewInstance(DataObject dataObject) {
|
protected DomainObject doNewInstance(DataObject dataObject) {
|
||||||
return new WebLogApplication(dataObject);
|
return new WebLogApplication(dataObject);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
DomainObjectFactory.registerInstantiator(
|
DomainObjectFactory.registerInstantiator(
|
||||||
WebLogApplication.BASE_DATA_OBJECT_TYPE, instantiator);
|
WebLogApplication.BASE_DATA_OBJECT_TYPE, instantiator);
|
||||||
checkSetup();
|
checkSetup();
|
||||||
|
|
||||||
|
// Register the portlets
|
||||||
|
instantiator = new ACSObjectInstantiator() {
|
||||||
|
|
||||||
// Register the portlets
|
|
||||||
instantiator = new ACSObjectInstantiator() {
|
|
||||||
@Override
|
@Override
|
||||||
protected DomainObject doNewInstance(DataObject dataObject) {
|
protected DomainObject doNewInstance(DataObject dataObject) {
|
||||||
return new WebLogPortlet(dataObject);
|
return new WebLogPortlet(dataObject);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
DomainObjectFactory.registerInstantiator(
|
DomainObjectFactory.registerInstantiator(
|
||||||
WebLogPortlet.BASE_DATA_OBJECT_TYPE, instantiator);
|
WebLogPortlet.BASE_DATA_OBJECT_TYPE, instantiator);
|
||||||
|
|
||||||
if (isMyTransaction) {
|
if (isMyTransaction) {
|
||||||
txn.commitTxn();
|
txn.commitTxn();
|
||||||
}
|
}
|
||||||
|
|
||||||
s_log.debug("WebLog Initializer done.");
|
s_log.debug("WebLog Initializer done.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkSetup() {
|
private void checkSetup() {
|
||||||
try {
|
try {
|
||||||
s_log.debug("WebLog Initializer - verifying setup.");
|
s_log.debug("WebLog Initializer - verifying setup.");
|
||||||
PackageType entityType = PackageType.findByKey("weblog");
|
PackageType entityType = PackageType.findByKey("weblog");
|
||||||
} catch (DataObjectNotFoundException e) {
|
} catch (DataObjectNotFoundException e) {
|
||||||
setup();
|
setup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setup() {
|
private void setup() {
|
||||||
s_log.info("WebLog Initializer - setting up new package");
|
s_log.info("WebLog Initializer - setting up new package");
|
||||||
|
|
||||||
PackageType entityType = PackageType.create("weblog", "WebLog",
|
PackageType entityType = PackageType.create("weblog", "WebLog",
|
||||||
"WebLogs", "http://www.undp.org/weblog");
|
"WebLogs",
|
||||||
s_log.debug("Just added package type WebLog ");
|
"http://www.undp.org/weblog");
|
||||||
|
s_log.debug("Just added package type WebLog ");
|
||||||
|
|
||||||
|
|
||||||
entityType.setDispatcherClass(WebLogDispatcher.class.getName());
|
entityType.setDispatcherClass(WebLogDispatcher.class.getName());
|
||||||
|
|
||||||
entityType.save();
|
entityType.save();
|
||||||
|
|
||||||
final ApplicationType entityAppType = ApplicationType
|
final ApplicationType entityAppType = ApplicationType.
|
||||||
.createApplicationType(entityType, "WebLog Application",
|
createApplicationType(entityType, "WebLog Application",
|
||||||
WebLogApplication.BASE_DATA_OBJECT_TYPE);
|
WebLogApplication.BASE_DATA_OBJECT_TYPE);
|
||||||
entityAppType.save();
|
entityAppType.save();
|
||||||
|
|
||||||
// portlet
|
// portlet
|
||||||
AppPortletType portletType = AppPortletType.createAppPortletType(
|
AppPortletType portletType = AppPortletType.createAppPortletType(
|
||||||
"WebLog Portlet", AppPortletType.WIDE_PROFILE,
|
"WebLog Portlet", AppPortletType.WIDE_PROFILE,
|
||||||
WebLogPortlet.BASE_DATA_OBJECT_TYPE);
|
WebLogPortlet.BASE_DATA_OBJECT_TYPE);
|
||||||
portletType.setProviderApplicationType(entityAppType);
|
portletType.setProviderApplicationType(entityAppType);
|
||||||
portletType.setPortalApplication(true);
|
portletType.setPortalApplication(true);
|
||||||
portletType.save();
|
portletType.save();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue