You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2005/02/23 23:38:24 UTC
svn commit: r155094 - in
lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases:
Deactivate.java Publish.java
Author: andreas
Date: Wed Feb 23 14:38:22 2005
New Revision: 155094
URL: http://svn.apache.org/viewcvs?view=rev&rev=155094
Log:
added preconditions to publish and deactivate
Modified:
lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Deactivate.java
lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java
Modified: lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Deactivate.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Deactivate.java?view=diff&r1=155093&r2=155094
==============================================================================
--- lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Deactivate.java (original)
+++ lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Deactivate.java Wed Feb 23 14:38:22 2005
@@ -42,14 +42,21 @@
*/
protected void doCheckPreconditions() throws Exception {
super.doCheckPreconditions();
+ if (getErrorMessages().isEmpty()) {
- String event = getEvent();
+ if (!getSourceDocument().getArea().equals(Publication.AUTHORING_AREA)) {
+ addErrorMessage("This usecase can only be invoked from the authoring area.");
+ return;
+ }
- if (!getWorkflowInstance(getSourceDocument()).canInvoke(getSituation(), event)) {
- setParameter(Publish.ALLOW_SINGLE_DOCUMENT, Boolean.toString(false));
- addInfoMessage("The single document cannot be deactivated because the workflow event cannot be invoked.");
- } else {
- setParameter(Publish.ALLOW_SINGLE_DOCUMENT, Boolean.toString(true));
+ String event = getEvent();
+
+ if (!getWorkflowInstance(getSourceDocument()).canInvoke(getSituation(), event)) {
+ setParameter(Publish.ALLOW_SINGLE_DOCUMENT, Boolean.toString(false));
+ addInfoMessage("The single document cannot be deactivated because the workflow event cannot be invoked.");
+ } else {
+ setParameter(Publish.ALLOW_SINGLE_DOCUMENT, Boolean.toString(true));
+ }
}
}
Modified: lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java?view=diff&r1=155093&r2=155094
==============================================================================
--- lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java (original)
+++ lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java Wed Feb 23 14:38:22 2005
@@ -49,39 +49,44 @@
*/
protected void doCheckPreconditions() throws Exception {
super.doCheckPreconditions();
+ if (getErrorMessages().isEmpty()) {
- String event = getEvent();
- Document document = getSourceDocument();
+ String event = getEvent();
+ Document document = getSourceDocument();
- if (!getWorkflowInstance(getSourceDocument()).canInvoke(getSituation(), event)) {
- setParameter(ALLOW_SINGLE_DOCUMENT, Boolean.toString(false));
- addInfoMessage("The single document cannot be published because the workflow event cannot be invoked.");
- }
- else {
- setParameter(ALLOW_SINGLE_DOCUMENT, Boolean.toString(true));
- }
+ if (!document.getArea().equals(Publication.AUTHORING_AREA)) {
+ addErrorMessage("This usecase can only be invoked from the authoring area.");
+ return;
+ }
+
+ if (!getWorkflowInstance(getSourceDocument()).canInvoke(getSituation(), event)) {
+ setParameter(ALLOW_SINGLE_DOCUMENT, Boolean.toString(false));
+ addInfoMessage("The single document cannot be published because the workflow event cannot be invoked.");
+ } else {
+ setParameter(ALLOW_SINGLE_DOCUMENT, Boolean.toString(true));
+ }
- Publication publication = document.getPublication();
+ Publication publication = document.getPublication();
- Document liveDocument = publication.getAreaVersion(document, Publication.LIVE_AREA);
+ Document liveDocument = publication.getAreaVersion(document, Publication.LIVE_AREA);
- List missingDocuments = new ArrayList();
+ List missingDocuments = new ArrayList();
- SiteManager manager = publication.getSiteManager(document.getIdentityMap());
- Document[] requiredDocuments = manager.getRequiredResources(liveDocument);
- for (int i = 0; i < requiredDocuments.length; i++) {
- if (!manager.containsInAnyLanguage(requiredDocuments[i])) {
- Document authoringVersion = publication.getAreaVersion(requiredDocuments[i],
- Publication.AUTHORING_AREA);
- missingDocuments.add(authoringVersion);
+ SiteManager manager = publication.getSiteManager(document.getIdentityMap());
+ Document[] requiredDocuments = manager.getRequiredResources(liveDocument);
+ for (int i = 0; i < requiredDocuments.length; i++) {
+ if (!manager.containsInAnyLanguage(requiredDocuments[i])) {
+ Document authoringVersion = publication.getAreaVersion(requiredDocuments[i],
+ Publication.AUTHORING_AREA);
+ missingDocuments.add(authoringVersion);
+ }
}
- }
- if (!missingDocuments.isEmpty()) {
- addErrorMessage("Cannot publish document unless the following documents are published:");
- setParameter(MISSING_DOCUMENTS, missingDocuments);
+ if (!missingDocuments.isEmpty()) {
+ addErrorMessage("Cannot publish document unless the following documents are published:");
+ setParameter(MISSING_DOCUMENTS, missingDocuments);
+ }
}
-
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org