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:23:00 UTC
svn commit: r155089 - in
lenya/trunk/src/java/org/apache/lenya/cms/site/usecases: ChangeLabel.java
ChangeNodeID.java Create.java DeleteLanguage.java
Author: andreas
Date: Wed Feb 23 14:22:58 2005
New Revision: 155089
URL: http://svn.apache.org/viewcvs?view=rev&rev=155089
Log:
allow certain uscases only in authoring area
Modified:
lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/ChangeLabel.java
lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/ChangeNodeID.java
lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Create.java
lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/DeleteLanguage.java
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/ChangeLabel.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/ChangeLabel.java?view=diff&r1=155088&r2=155089
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/ChangeLabel.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/ChangeLabel.java Wed Feb 23 14:22:58 2005
@@ -17,6 +17,7 @@
package org.apache.lenya.cms.site.usecases;
import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.site.SiteException;
import org.apache.lenya.cms.site.SiteManager;
import org.apache.lenya.cms.usecase.DocumentUsecase;
@@ -24,12 +25,23 @@
/**
* Change the label of a document.
*
- * @version $Id:$
+ * @version $Id$
*/
public class ChangeLabel extends DocumentUsecase {
protected static final String LABEL = "label";
protected static final String DOCUMENT_ID = "documentId";
+
+ /**
+ * @see org.apache.lenya.cms.usecase.AbstractUsecase#doCheckPreconditions()
+ */
+ protected void doCheckPreconditions() throws Exception {
+ super.doCheckPreconditions();
+
+ if (!getSourceDocument().getArea().equals(Publication.AUTHORING_AREA)) {
+ addErrorMessage("This usecase can only be invoked in the authoring area!");
+ }
+ }
/**
* @see org.apache.lenya.cms.usecase.AbstractUsecase#initParameters()
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/ChangeNodeID.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/ChangeNodeID.java?view=diff&r1=155088&r2=155089
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/ChangeNodeID.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/ChangeNodeID.java Wed Feb 23 14:22:58 2005
@@ -19,6 +19,7 @@
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentBuildException;
import org.apache.lenya.cms.publication.DocumentException;
+import org.apache.lenya.cms.publication.DocumentFactory;
import org.apache.lenya.cms.publication.DocumentIdentityMap;
import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.publication.PublicationException;
@@ -40,6 +41,24 @@
super.initParameters();
Document document = getSourceDocument();
setParameter(NODE_ID, document.getName());
+ }
+
+ /**
+ * @see org.apache.lenya.cms.usecase.AbstractUsecase#doCheckPreconditions()
+ */
+ protected void doCheckPreconditions() throws Exception {
+ super.doCheckPreconditions();
+
+ if (!getSourceDocument().getArea().equals(Publication.AUTHORING_AREA)) {
+ addErrorMessage("This usecase can only be invoked in the authoring area!");
+ } else {
+ DocumentFactory factory = getUnitOfWork().getIdentityMap().getFactory();
+ Document liveVersion = factory.getAreaVersion(getSourceDocument(),
+ Publication.LIVE_AREA);
+ if (liveVersion.exists()) {
+ addErrorMessage("This usecase cannot be invoked when the live version exists!");
+ }
+ }
}
/**
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Create.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Create.java?view=diff&r1=155088&r2=155089
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Create.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Create.java Wed Feb 23 14:22:58 2005
@@ -55,6 +55,17 @@
}
/**
+ * @see org.apache.lenya.cms.usecase.AbstractUsecase#doCheckPreconditions()
+ */
+ protected void doCheckPreconditions() throws Exception {
+ super.doCheckPreconditions();
+
+ if (!getSourceDocument().getArea().equals(Publication.AUTHORING_AREA)) {
+ addErrorMessage("This usecase can only be invoked in the authoring area!");
+ }
+ }
+
+ /**
* @see org.apache.lenya.cms.usecase.AbstractUsecase#doCheckExecutionConditions()
*/
protected void doCheckExecutionConditions() throws Exception {
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/DeleteLanguage.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/DeleteLanguage.java?view=diff&r1=155088&r2=155089
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/DeleteLanguage.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/DeleteLanguage.java Wed Feb 23 14:22:58 2005
@@ -17,6 +17,7 @@
package org.apache.lenya.cms.site.usecases;
import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.publication.util.DocumentHelper;
import org.apache.lenya.cms.site.SiteManager;
import org.apache.lenya.cms.usecase.DocumentUsecase;
@@ -24,7 +25,7 @@
/**
* Delete a language version.
*
- * @version $Id:$
+ * @version $Id$
*/
public class DeleteLanguage extends DocumentUsecase {
@@ -33,12 +34,14 @@
*/
protected void doCheckPreconditions() throws Exception {
super.doCheckPreconditions();
-
- if (getSourceDocument().getLanguages().length == 1) {
+
+ if (!getSourceDocument().getArea().equals(Publication.AUTHORING_AREA)) {
+ addErrorMessage("This usecase can only be invoked in the authoring area!");
+ } else if (getSourceDocument().getLanguages().length == 1) {
addErrorMessage("The last language version cannot be removed.");
}
}
-
+
/**
* @see org.apache.lenya.cms.usecase.AbstractUsecase#doExecute()
*/
@@ -48,13 +51,13 @@
Document document = getSourceDocument();
SiteManager _manager = document.getPublication().getSiteManager(document.getIdentityMap());
_manager.delete(document);
-
+
document.getFile().delete();
-
+
if (hasWorkflow(document)) {
getWorkflowInstance(document).getHistory().delete();
}
-
+
setTargetDocument(DocumentHelper.getExistingLanguageVersion(document));
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org
Re: externalize strings?
Posted by "Gregor J. Rothfuss" <gr...@apache.org>.
Andreas Hartmann wrote:
> Yes, I also thought about that. I guess using the actual message as
> i18n key is error-prone because one easily forgets to update the i18n
> after altering the message. Maybe we should rather use shortcut
> message keys.
+1
we should also take a look at some of the helper scripts in cocoon to
keep translations in sync
--
Gregor J. Rothfuss
COO, Wyona Content Management Solutions http://wyona.com
Apache Lenya http://lenya.apache.org
gregor.rothfuss@wyona.com gregor@apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org
Re: externalize strings?
Posted by Andreas Hartmann <an...@apache.org>.
Gregor J. Rothfuss wrote:
> andreas@apache.org wrote:
>
>> +addErrorMessage("This usecase can only be invoked in the authoring
>> area!");
>
>
> this makes me wonder how we can support i18n for these in a nice way.
> any ideas?
Yes, I also thought about that. I guess using the actual message as
i18n key is error-prone because one easily forgets to update the i18n
after altering the message. Maybe we should rather use shortcut
message keys.
-- Andreas
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org
externalize strings?
Posted by "Gregor J. Rothfuss" <gr...@apache.org>.
andreas@apache.org wrote:
> +addErrorMessage("This usecase can only be invoked in the authoring area!");
this makes me wonder how we can support i18n for these in a nice way.
any ideas?
--
Gregor J. Rothfuss
COO, Wyona Content Management Solutions http://wyona.com
Apache Lenya http://lenya.apache.org
gregor.rothfuss@wyona.com gregor@apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org