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.
|
||||
*
|
||||
* @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 void run(final ScriptContext ctx) {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
package com.arsdigita.london.terms;
|
||||
|
||||
import com.arsdigita.persistence.DataQuery;
|
||||
import com.arsdigita.domain.DomainCollection;
|
||||
import com.arsdigita.persistence.SessionManager;
|
||||
import com.arsdigita.util.UncheckedWrapperException;
|
||||
import com.arsdigita.web.Application;
|
||||
|
|
@ -33,5 +34,24 @@ public class Util {
|
|||
|
||||
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.Term;
|
||||
import com.arsdigita.london.terms.Terms;
|
||||
import com.arsdigita.london.terms.Util;
|
||||
import com.arsdigita.london.util.ui.parameters.DomainObjectParameter;
|
||||
import com.arsdigita.util.UncheckedWrapperException;
|
||||
|
||||
|
|
@ -146,7 +147,7 @@ public class TermForm extends Form {
|
|||
|
||||
if (term == null) {
|
||||
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_desc.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)
|
||||
* @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 TermsSuite() {
|
||||
|
|
|
|||
|
|
@ -42,13 +42,9 @@ import java.util.Iterator;
|
|||
* Recursively copies a domain object.
|
||||
*
|
||||
* @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 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);
|
||||
|
||||
|
|
|
|||
|
|
@ -31,13 +31,9 @@ import org.apache.log4j.Logger;
|
|||
* The CMS initializer.
|
||||
*
|
||||
* @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 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
|
||||
(Initializer.class);
|
||||
|
|
|
|||
|
|
@ -27,13 +27,9 @@ import org.apache.log4j.Logger;
|
|||
* Loader.
|
||||
*
|
||||
* @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 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);
|
||||
|
||||
|
|
|
|||
|
|
@ -26,17 +26,13 @@ import com.arsdigita.persistence.Filter;
|
|||
import com.arsdigita.persistence.OID;
|
||||
import com.arsdigita.persistence.SessionManager;
|
||||
import com.arsdigita.persistence.DataCollection;
|
||||
import com.arsdigita.workflow.simple.Workflow;
|
||||
import com.arsdigita.domain.DomainObjectFactory;
|
||||
|
||||
import com.arsdigita.cms.ContentPage;
|
||||
import com.arsdigita.cms.ContentItem;
|
||||
import com.arsdigita.cms.ContentSection;
|
||||
import com.arsdigita.cms.ContentTypeLifecycleDefinition;
|
||||
import com.arsdigita.cms.Folder;
|
||||
import com.arsdigita.cms.lifecycle.Lifecycle;
|
||||
import com.arsdigita.cms.lifecycle.LifecycleDefinition;
|
||||
import com.arsdigita.cms.lifecycle.Phase;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.OptionBuilder;
|
||||
|
|
@ -168,10 +164,6 @@ public class BulkPublish extends Program {
|
|||
}
|
||||
}.run();
|
||||
|
||||
final int expiryNotification = ContentSection.
|
||||
getConfig().getDefaultNotificationTime();
|
||||
|
||||
|
||||
final Iterator items = toPublish.iterator();
|
||||
while (items.hasNext()) {
|
||||
final OID oid = (OID) items.next();
|
||||
|
|
@ -201,31 +193,7 @@ public class BulkPublish extends Program {
|
|||
return;
|
||||
}
|
||||
|
||||
ContentItem pending = 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();
|
||||
}
|
||||
}
|
||||
|
||||
item.publish(def, new Date());
|
||||
}
|
||||
};
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -45,10 +45,12 @@ public class BulkUnpublish extends Program {
|
|||
|
||||
private static final Logger s_log = Logger.getLogger(BulkUnpublish.class);
|
||||
|
||||
public BulkUnpublish() {
|
||||
super("Bulk Unpublish",
|
||||
"1.0.0",
|
||||
"");
|
||||
private int folderId;
|
||||
private String[] types;
|
||||
private boolean ignoreErrors;
|
||||
|
||||
public BulkUnpublish(String name, String version) {
|
||||
super(name, version, "");
|
||||
|
||||
Options options = getOptions();
|
||||
|
||||
|
|
@ -56,14 +58,14 @@ public class BulkUnpublish extends Program {
|
|||
OptionBuilder
|
||||
.hasArgs()
|
||||
.withLongOpt( "types" )
|
||||
.withDescription( "Restrict unpublishing to items of the specified content types" )
|
||||
.withDescription( "Restrict operation to items of the specified content types" )
|
||||
.create( "t" ) );
|
||||
options.addOption(
|
||||
OptionBuilder
|
||||
.hasArg()
|
||||
.withLongOpt( "restrictToFolderId" )
|
||||
.withDescription( "Restrict publishing to items within the folder with the specified id" )
|
||||
.create( "f" ) );
|
||||
OptionBuilder
|
||||
.hasArg()
|
||||
.withLongOpt( "restrictToFolderId" )
|
||||
.withDescription( "Restrict operation to items within the folder with the specified id" )
|
||||
.create( "f" ) );
|
||||
|
||||
options.addOption
|
||||
(OptionBuilder
|
||||
|
|
@ -74,49 +76,57 @@ public class BulkUnpublish extends Program {
|
|||
}
|
||||
|
||||
protected void doRun(CommandLine cmdLine) {
|
||||
final int folderId;
|
||||
final String[] types;
|
||||
final boolean ignoreErrors = cmdLine.hasOption("i");
|
||||
this.ignoreErrors = cmdLine.hasOption("i");
|
||||
|
||||
if( cmdLine.hasOption( "t" ) ) {
|
||||
types = cmdLine.getOptionValues( "t" );
|
||||
this.types = cmdLine.getOptionValues( "t" );
|
||||
|
||||
System.out.println( "Unpublishing live items of types:" );
|
||||
for( int i = 0; i < types.length; i++ ) {
|
||||
System.out.println( types[i] );
|
||||
for( int i = 0; i < this.types.length; i++ ) {
|
||||
System.out.println( this.types[i] );
|
||||
}
|
||||
} else {
|
||||
types = null;
|
||||
this.types = null;
|
||||
System.out.println( "Unpublishing all live items" );
|
||||
}
|
||||
if (cmdLine.hasOption("f")) {
|
||||
folderId = Integer.parseInt(cmdLine.getOptionValue("f"));
|
||||
Folder folder = new Folder(new OID(Folder.BASE_DATA_OBJECT_TYPE, folderId));
|
||||
this.folderId = Integer.parseInt(cmdLine.getOptionValue("f"));
|
||||
Folder folder = new Folder(new OID(Folder.BASE_DATA_OBJECT_TYPE, this.folderId));
|
||||
System.out.println( "Unpublishing items in folder: " + folder.getDisplayName());
|
||||
} 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() {
|
||||
public void doRun() {
|
||||
DataCollection items = SessionManager.getSession()
|
||||
.retrieve(ContentPage.BASE_DATA_OBJECT_TYPE);
|
||||
items.addNotEqualsFilter("type.id", null);
|
||||
items.addEqualsFilter("version", ContentItem.LIVE);
|
||||
if(liveOnly) items.addEqualsFilter("version", ContentItem.LIVE);
|
||||
items.addOrder("title");
|
||||
|
||||
FilterFactory filterFactory = items.getFilterFactory();
|
||||
|
||||
if (folderId >= 0) {
|
||||
Filter filter = filterFactory.simple(" ancestors like '%/" + folderId + "/%'");
|
||||
items.addFilter(filter);
|
||||
}
|
||||
if( null != types ) {
|
||||
if (this.folderId >= 0) {
|
||||
Filter filter = filterFactory.simple(" ancestors like '%/" + this.folderId + "/%'");
|
||||
items.addFilter(filter);
|
||||
}
|
||||
if( null != this.types ) {
|
||||
CompoundFilter or = filterFactory.or();
|
||||
|
||||
for( int i = 0; i < types.length; i++ ) {
|
||||
or.addFilter( filterFactory.equals( "objectType", types[i] ) );
|
||||
for( int i = 0; i < this.types.length; i++ ) {
|
||||
or.addFilter( filterFactory.equals( "objectType", this.types[i] ) );
|
||||
}
|
||||
|
||||
items.addFilter( or );
|
||||
|
|
@ -124,14 +134,23 @@ public class BulkUnpublish extends Program {
|
|||
|
||||
while (items.next()) {
|
||||
ContentPage page = (ContentPage) DomainObjectFactory.newInstance(items.getDataObject());
|
||||
toUnpublish.add(page.getDraftVersion().getOID());
|
||||
toProcess.add(page.getDraftVersion().getOID());
|
||||
}
|
||||
}
|
||||
}.run();
|
||||
|
||||
final Iterator items = toUnpublish.iterator();
|
||||
return toProcess;
|
||||
}
|
||||
|
||||
protected void unpublish(List toProcess) {
|
||||
final Iterator items = toProcess.iterator();
|
||||
while (items.hasNext()) {
|
||||
final OID oid = (OID) items.next();
|
||||
unpublish(oid);
|
||||
}
|
||||
}
|
||||
|
||||
protected void unpublish(OID oid) {
|
||||
Transaction txn = new Transaction() {
|
||||
public void doRun() {
|
||||
ContentPage item = (ContentPage)
|
||||
|
|
@ -146,15 +165,9 @@ public class BulkUnpublish extends Program {
|
|||
txn.run();
|
||||
} catch (Throwable ex) {
|
||||
s_log.error("Cannot unpublish " + oid, ex);
|
||||
if (!ignoreErrors) {
|
||||
if (!this.ignoreErrors) {
|
||||
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
|
||||
* check URL form, doesn't actually return a
|
||||
* java.net.URL object.
|
||||
*
|
||||
* @version $Id: URLParameter.java 755 2005-09-02 13:42:47Z sskracic $
|
||||
*/
|
||||
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) {
|
||||
super(name);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue