Syncronisieren mit r2079-2082.
git-svn-id: https://svn.libreccm.org/ccm/trunk@368 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
f6b0f9685a
commit
7faab110f4
|
|
@ -28,7 +28,7 @@ import com.arsdigita.web.ApplicationType;
|
||||||
* Loader.
|
* Loader.
|
||||||
*
|
*
|
||||||
* @author Justin Ross <jross@redhat.com>
|
* @author Justin Ross <jross@redhat.com>
|
||||||
* @version $Id: Loader.java 287 2005-02-22 00:29:02Z sskracic $
|
* @version $Id: Loader.java 1878 2009-04-21 13:56:23Z terry $
|
||||||
*/
|
*/
|
||||||
public class Loader extends PackageLoader {
|
public class Loader extends PackageLoader {
|
||||||
public void run(final ScriptContext ctx) {
|
public void run(final ScriptContext ctx) {
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
package com.arsdigita.london.terms;
|
package com.arsdigita.london.terms;
|
||||||
|
|
||||||
import com.arsdigita.persistence.DataQuery;
|
import com.arsdigita.persistence.DataQuery;
|
||||||
|
import com.arsdigita.domain.DomainCollection;
|
||||||
import com.arsdigita.persistence.SessionManager;
|
import com.arsdigita.persistence.SessionManager;
|
||||||
import com.arsdigita.util.UncheckedWrapperException;
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
import com.arsdigita.web.Application;
|
import com.arsdigita.web.Application;
|
||||||
|
|
@ -33,5 +34,24 @@ public class Util {
|
||||||
|
|
||||||
return applicationDomain;
|
return applicationDomain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* retrieve a unique integer to allocate to a new term.
|
||||||
|
* Useful for applications that dynamically generate terms.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static String getNextTermID(Domain domain) {
|
||||||
|
|
||||||
|
DomainCollection terms = domain.getTerms();
|
||||||
|
terms.addOrder(Term.UNIQUE_ID + " desc");
|
||||||
|
int id = 1;
|
||||||
|
if(terms.next()) {
|
||||||
|
Term other = (Term) terms.getDomainObject();
|
||||||
|
id = Integer.parseInt(other.getUniqueID()) + 1;
|
||||||
|
terms.close();
|
||||||
|
}
|
||||||
|
return Integer.toString(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ import com.arsdigita.domain.DataObjectNotFoundException;
|
||||||
import com.arsdigita.london.terms.Domain;
|
import com.arsdigita.london.terms.Domain;
|
||||||
import com.arsdigita.london.terms.Term;
|
import com.arsdigita.london.terms.Term;
|
||||||
import com.arsdigita.london.terms.Terms;
|
import com.arsdigita.london.terms.Terms;
|
||||||
|
import com.arsdigita.london.terms.Util;
|
||||||
import com.arsdigita.london.util.ui.parameters.DomainObjectParameter;
|
import com.arsdigita.london.util.ui.parameters.DomainObjectParameter;
|
||||||
import com.arsdigita.util.UncheckedWrapperException;
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
|
|
||||||
|
|
@ -146,7 +147,7 @@ public class TermForm extends Form {
|
||||||
|
|
||||||
if (term == null) {
|
if (term == null) {
|
||||||
Domain domain = (Domain)state.getValue(m_domain);
|
Domain domain = (Domain)state.getValue(m_domain);
|
||||||
m_uniqueid.setValue(state, null);
|
m_uniqueid.setValue(state, Util.getNextTermID(domain));
|
||||||
m_name.setValue(state, null);
|
m_name.setValue(state, null);
|
||||||
m_desc.setValue(state, null);
|
m_desc.setValue(state, null);
|
||||||
m_shortcut.setValue(state, null);
|
m_shortcut.setValue(state, null);
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ import com.arsdigita.tools.junit.framework.PackageTestSuite;
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @author Joseph A. Bank (jbank@alum.mit.edu)
|
* @author Joseph A. Bank (jbank@alum.mit.edu)
|
||||||
* @version "$Id: TermsSuite.java 287 2005-02-22 00:29:02Z sskracic $
|
* @version "$Id: TermsSuite.java 1963 2009-08-16 19:15:12Z pboy $
|
||||||
**/
|
**/
|
||||||
public class TermsSuite extends PackageTestSuite {
|
public class TermsSuite extends PackageTestSuite {
|
||||||
public TermsSuite() {
|
public TermsSuite() {
|
||||||
|
|
|
||||||
|
|
@ -42,13 +42,9 @@ import java.util.Iterator;
|
||||||
* Recursively copies a domain object.
|
* Recursively copies a domain object.
|
||||||
*
|
*
|
||||||
* @author Justin Ross <jross@redhat.com>
|
* @author Justin Ross <jross@redhat.com>
|
||||||
* @version $Id: DomainObjectCopier.java 755 2005-09-02 13:42:47Z sskracic $
|
* @version $Id: DomainObjectCopier.java 1942 2009-05-29 07:53:23Z terry $
|
||||||
*/
|
*/
|
||||||
public class DomainObjectCopier extends DomainService {
|
public class DomainObjectCopier extends DomainService {
|
||||||
public static final String versionId =
|
|
||||||
"$Id: DomainObjectCopier.java 755 2005-09-02 13:42:47Z sskracic $" +
|
|
||||||
"$Author: sskracic $" +
|
|
||||||
"$DateTime: 2004/03/01 09:31:36 $";
|
|
||||||
|
|
||||||
private static Logger s_log = Logger.getLogger(DomainObjectCopier.class);
|
private static Logger s_log = Logger.getLogger(DomainObjectCopier.class);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,13 +31,9 @@ import org.apache.log4j.Logger;
|
||||||
* The CMS initializer.
|
* The CMS initializer.
|
||||||
*
|
*
|
||||||
* @author Justin Ross <jross@redhat.com>
|
* @author Justin Ross <jross@redhat.com>
|
||||||
* @version $Id: Initializer.java 758 2005-09-02 14:26:56Z sskracic $
|
* @version $Id: Initializer.java 1942 2009-05-29 07:53:23Z terry $
|
||||||
*/
|
*/
|
||||||
public class Initializer extends CompoundInitializer {
|
public class Initializer extends CompoundInitializer {
|
||||||
public final static String versionId =
|
|
||||||
"$Id: Initializer.java 758 2005-09-02 14:26:56Z sskracic $" +
|
|
||||||
"$Author: sskracic $" +
|
|
||||||
"$DateTime: 2004/01/31 11:58:22 $";
|
|
||||||
|
|
||||||
private static final Logger s_log = Logger.getLogger
|
private static final Logger s_log = Logger.getLogger
|
||||||
(Initializer.class);
|
(Initializer.class);
|
||||||
|
|
|
||||||
|
|
@ -27,13 +27,9 @@ import org.apache.log4j.Logger;
|
||||||
* Loader.
|
* Loader.
|
||||||
*
|
*
|
||||||
* @author Justin Ross <jross@redhat.com>
|
* @author Justin Ross <jross@redhat.com>
|
||||||
* @version $Id: Loader.java 287 2005-02-22 00:29:02Z sskracic $
|
* @version $Id: Loader.java 1942 2009-05-29 07:53:23Z terry $
|
||||||
*/
|
*/
|
||||||
public class Loader extends PackageLoader {
|
public class Loader extends PackageLoader {
|
||||||
public final static String versionId =
|
|
||||||
"$Id: Loader.java 287 2005-02-22 00:29:02Z sskracic $" +
|
|
||||||
"$Author: sskracic $" +
|
|
||||||
"$DateTime: 2003/10/28 14:26:55 $";
|
|
||||||
|
|
||||||
private static final Logger s_log = Logger.getLogger(Loader.class);
|
private static final Logger s_log = Logger.getLogger(Loader.class);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,17 +26,13 @@ import com.arsdigita.persistence.Filter;
|
||||||
import com.arsdigita.persistence.OID;
|
import com.arsdigita.persistence.OID;
|
||||||
import com.arsdigita.persistence.SessionManager;
|
import com.arsdigita.persistence.SessionManager;
|
||||||
import com.arsdigita.persistence.DataCollection;
|
import com.arsdigita.persistence.DataCollection;
|
||||||
import com.arsdigita.workflow.simple.Workflow;
|
|
||||||
import com.arsdigita.domain.DomainObjectFactory;
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
|
|
||||||
import com.arsdigita.cms.ContentPage;
|
import com.arsdigita.cms.ContentPage;
|
||||||
import com.arsdigita.cms.ContentItem;
|
import com.arsdigita.cms.ContentItem;
|
||||||
import com.arsdigita.cms.ContentSection;
|
|
||||||
import com.arsdigita.cms.ContentTypeLifecycleDefinition;
|
import com.arsdigita.cms.ContentTypeLifecycleDefinition;
|
||||||
import com.arsdigita.cms.Folder;
|
import com.arsdigita.cms.Folder;
|
||||||
import com.arsdigita.cms.lifecycle.Lifecycle;
|
|
||||||
import com.arsdigita.cms.lifecycle.LifecycleDefinition;
|
import com.arsdigita.cms.lifecycle.LifecycleDefinition;
|
||||||
import com.arsdigita.cms.lifecycle.Phase;
|
|
||||||
|
|
||||||
import org.apache.commons.cli.CommandLine;
|
import org.apache.commons.cli.CommandLine;
|
||||||
import org.apache.commons.cli.OptionBuilder;
|
import org.apache.commons.cli.OptionBuilder;
|
||||||
|
|
@ -168,10 +164,6 @@ public class BulkPublish extends Program {
|
||||||
}
|
}
|
||||||
}.run();
|
}.run();
|
||||||
|
|
||||||
final int expiryNotification = ContentSection.
|
|
||||||
getConfig().getDefaultNotificationTime();
|
|
||||||
|
|
||||||
|
|
||||||
final Iterator items = toPublish.iterator();
|
final Iterator items = toPublish.iterator();
|
||||||
while (items.hasNext()) {
|
while (items.hasNext()) {
|
||||||
final OID oid = (OID) items.next();
|
final OID oid = (OID) items.next();
|
||||||
|
|
@ -201,31 +193,7 @@ public class BulkPublish extends Program {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ContentItem pending = item.publish(def, new Date());
|
item.publish(def, new Date());
|
||||||
final Lifecycle lifecycle = pending.getLifecycle();
|
|
||||||
Date endDate = lifecycle.getEndDate();
|
|
||||||
if (expiryNotification > 0) {
|
|
||||||
|
|
||||||
if (endDate != null) {
|
|
||||||
|
|
||||||
Date notificationDate = new Date(endDate.getTime() - (long)expiryNotification * 3600000L);
|
|
||||||
|
|
||||||
Phase expirationImminentPhase =
|
|
||||||
lifecycle.addCustomPhase("expirationImminent",
|
|
||||||
new Long(notificationDate.getTime()),
|
|
||||||
new Long(endDate.getTime()));
|
|
||||||
expirationImminentPhase.
|
|
||||||
setListenerClassName("com.arsdigita.cms.lifecycle.NotifyLifecycleListener");
|
|
||||||
expirationImminentPhase.save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ContentSection.getConfig().getDeleteWorkflowAfterPublication()) {
|
|
||||||
Workflow workflow = Workflow.getObjectWorkflow(item);
|
|
||||||
if (workflow != null) {
|
|
||||||
workflow.delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -45,10 +45,12 @@ public class BulkUnpublish extends Program {
|
||||||
|
|
||||||
private static final Logger s_log = Logger.getLogger(BulkUnpublish.class);
|
private static final Logger s_log = Logger.getLogger(BulkUnpublish.class);
|
||||||
|
|
||||||
public BulkUnpublish() {
|
private int folderId;
|
||||||
super("Bulk Unpublish",
|
private String[] types;
|
||||||
"1.0.0",
|
private boolean ignoreErrors;
|
||||||
"");
|
|
||||||
|
public BulkUnpublish(String name, String version) {
|
||||||
|
super(name, version, "");
|
||||||
|
|
||||||
Options options = getOptions();
|
Options options = getOptions();
|
||||||
|
|
||||||
|
|
@ -56,13 +58,13 @@ public class BulkUnpublish extends Program {
|
||||||
OptionBuilder
|
OptionBuilder
|
||||||
.hasArgs()
|
.hasArgs()
|
||||||
.withLongOpt( "types" )
|
.withLongOpt( "types" )
|
||||||
.withDescription( "Restrict unpublishing to items of the specified content types" )
|
.withDescription( "Restrict operation to items of the specified content types" )
|
||||||
.create( "t" ) );
|
.create( "t" ) );
|
||||||
options.addOption(
|
options.addOption(
|
||||||
OptionBuilder
|
OptionBuilder
|
||||||
.hasArg()
|
.hasArg()
|
||||||
.withLongOpt( "restrictToFolderId" )
|
.withLongOpt( "restrictToFolderId" )
|
||||||
.withDescription( "Restrict publishing to items within the folder with the specified id" )
|
.withDescription( "Restrict operation to items within the folder with the specified id" )
|
||||||
.create( "f" ) );
|
.create( "f" ) );
|
||||||
|
|
||||||
options.addOption
|
options.addOption
|
||||||
|
|
@ -74,49 +76,57 @@ public class BulkUnpublish extends Program {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doRun(CommandLine cmdLine) {
|
protected void doRun(CommandLine cmdLine) {
|
||||||
final int folderId;
|
this.ignoreErrors = cmdLine.hasOption("i");
|
||||||
final String[] types;
|
|
||||||
final boolean ignoreErrors = cmdLine.hasOption("i");
|
|
||||||
|
|
||||||
if( cmdLine.hasOption( "t" ) ) {
|
if( cmdLine.hasOption( "t" ) ) {
|
||||||
types = cmdLine.getOptionValues( "t" );
|
this.types = cmdLine.getOptionValues( "t" );
|
||||||
|
|
||||||
System.out.println( "Unpublishing live items of types:" );
|
System.out.println( "Unpublishing live items of types:" );
|
||||||
for( int i = 0; i < types.length; i++ ) {
|
for( int i = 0; i < this.types.length; i++ ) {
|
||||||
System.out.println( types[i] );
|
System.out.println( this.types[i] );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
types = null;
|
this.types = null;
|
||||||
System.out.println( "Unpublishing all live items" );
|
System.out.println( "Unpublishing all live items" );
|
||||||
}
|
}
|
||||||
if (cmdLine.hasOption("f")) {
|
if (cmdLine.hasOption("f")) {
|
||||||
folderId = Integer.parseInt(cmdLine.getOptionValue("f"));
|
this.folderId = Integer.parseInt(cmdLine.getOptionValue("f"));
|
||||||
Folder folder = new Folder(new OID(Folder.BASE_DATA_OBJECT_TYPE, folderId));
|
Folder folder = new Folder(new OID(Folder.BASE_DATA_OBJECT_TYPE, this.folderId));
|
||||||
System.out.println( "Unpublishing items in folder: " + folder.getDisplayName());
|
System.out.println( "Unpublishing items in folder: " + folder.getDisplayName());
|
||||||
} else {
|
} else {
|
||||||
folderId = -1;
|
this.folderId = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
final List toUnpublish = new ArrayList();
|
final List toProcess = getListToProcess(true);
|
||||||
|
unpublish(toProcess);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
new BulkUnpublish("Bulk Unpublish","1.0.0").run(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected List getListToProcess(boolean liveOnly) {
|
||||||
|
final List toProcess = new ArrayList();
|
||||||
|
|
||||||
new Transaction() {
|
new Transaction() {
|
||||||
public void doRun() {
|
public void doRun() {
|
||||||
DataCollection items = SessionManager.getSession()
|
DataCollection items = SessionManager.getSession()
|
||||||
.retrieve(ContentPage.BASE_DATA_OBJECT_TYPE);
|
.retrieve(ContentPage.BASE_DATA_OBJECT_TYPE);
|
||||||
items.addNotEqualsFilter("type.id", null);
|
items.addNotEqualsFilter("type.id", null);
|
||||||
items.addEqualsFilter("version", ContentItem.LIVE);
|
if(liveOnly) items.addEqualsFilter("version", ContentItem.LIVE);
|
||||||
items.addOrder("title");
|
items.addOrder("title");
|
||||||
|
|
||||||
FilterFactory filterFactory = items.getFilterFactory();
|
FilterFactory filterFactory = items.getFilterFactory();
|
||||||
|
|
||||||
if (folderId >= 0) {
|
if (this.folderId >= 0) {
|
||||||
Filter filter = filterFactory.simple(" ancestors like '%/" + folderId + "/%'");
|
Filter filter = filterFactory.simple(" ancestors like '%/" + this.folderId + "/%'");
|
||||||
items.addFilter(filter);
|
items.addFilter(filter);
|
||||||
}
|
}
|
||||||
if( null != types ) {
|
if( null != this.types ) {
|
||||||
CompoundFilter or = filterFactory.or();
|
CompoundFilter or = filterFactory.or();
|
||||||
|
|
||||||
for( int i = 0; i < types.length; i++ ) {
|
for( int i = 0; i < this.types.length; i++ ) {
|
||||||
or.addFilter( filterFactory.equals( "objectType", types[i] ) );
|
or.addFilter( filterFactory.equals( "objectType", this.types[i] ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
items.addFilter( or );
|
items.addFilter( or );
|
||||||
|
|
@ -124,14 +134,23 @@ public class BulkUnpublish extends Program {
|
||||||
|
|
||||||
while (items.next()) {
|
while (items.next()) {
|
||||||
ContentPage page = (ContentPage) DomainObjectFactory.newInstance(items.getDataObject());
|
ContentPage page = (ContentPage) DomainObjectFactory.newInstance(items.getDataObject());
|
||||||
toUnpublish.add(page.getDraftVersion().getOID());
|
toProcess.add(page.getDraftVersion().getOID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.run();
|
}.run();
|
||||||
|
|
||||||
final Iterator items = toUnpublish.iterator();
|
return toProcess;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void unpublish(List toProcess) {
|
||||||
|
final Iterator items = toProcess.iterator();
|
||||||
while (items.hasNext()) {
|
while (items.hasNext()) {
|
||||||
final OID oid = (OID) items.next();
|
final OID oid = (OID) items.next();
|
||||||
|
unpublish(oid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void unpublish(OID oid) {
|
||||||
Transaction txn = new Transaction() {
|
Transaction txn = new Transaction() {
|
||||||
public void doRun() {
|
public void doRun() {
|
||||||
ContentPage item = (ContentPage)
|
ContentPage item = (ContentPage)
|
||||||
|
|
@ -146,15 +165,9 @@ public class BulkUnpublish extends Program {
|
||||||
txn.run();
|
txn.run();
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
s_log.error("Cannot unpublish " + oid, ex);
|
s_log.error("Cannot unpublish " + oid, ex);
|
||||||
if (!ignoreErrors) {
|
if (!this.ignoreErrors) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
new BulkUnpublish().run(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,11 +28,11 @@ import javax.servlet.http.HttpServletRequest;
|
||||||
* Bebop URLParameter is useless because it merely
|
* Bebop URLParameter is useless because it merely
|
||||||
* check URL form, doesn't actually return a
|
* check URL form, doesn't actually return a
|
||||||
* java.net.URL object.
|
* java.net.URL object.
|
||||||
|
*
|
||||||
|
* @version $Id: URLParameter.java 755 2005-09-02 13:42:47Z sskracic $
|
||||||
*/
|
*/
|
||||||
public class URLParameter extends ParameterModel {
|
public class URLParameter extends ParameterModel {
|
||||||
|
|
||||||
public static final String versionId = "$Id: URLParameter.java 755 2005-09-02 13:42:47Z sskracic $ by $Author: sskracic $, $DateTime: 2004/05/10 14:49:43 $";
|
|
||||||
|
|
||||||
public URLParameter(String name) {
|
public URLParameter(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue