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/05/24 16:43:33 UTC

svn commit: r178172 - in /lenya/trunk/src/java/org/apache/lenya/cms/editors/bxe: ./ BXE.java

Author: andreas
Date: Tue May 24 07:43:31 2005
New Revision: 178172

URL: http://svn.apache.org/viewcvs?rev=178172&view=rev
Log:
added BXE usecase handler

Added:
    lenya/trunk/src/java/org/apache/lenya/cms/editors/bxe/
    lenya/trunk/src/java/org/apache/lenya/cms/editors/bxe/BXE.java

Added: lenya/trunk/src/java/org/apache/lenya/cms/editors/bxe/BXE.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/editors/bxe/BXE.java?rev=178172&view=auto
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/editors/bxe/BXE.java (added)
+++ lenya/trunk/src/java/org/apache/lenya/cms/editors/bxe/BXE.java Tue May 24 07:43:31 2005
@@ -0,0 +1,78 @@
+/*
+ * Copyright  1999-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.editors.bxe;
+
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.lenya.cms.cocoon.source.SourceUtil;
+import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.DocumentIdToPathMapper;
+import org.apache.lenya.cms.usecase.DocumentUsecase;
+import org.apache.lenya.cms.usecase.UsecaseException;
+import org.apache.lenya.cms.workflow.WorkflowManager;
+import org.apache.lenya.transaction.Transactionable;
+
+/**
+ * BXE usecase handler.
+ * 
+ * @version $Id:$
+ */
+public class BXE extends DocumentUsecase {
+
+    /**
+     * @see org.apache.lenya.cms.usecase.AbstractUsecase#doExecute()
+     */
+    protected void doExecute() throws Exception {
+        super.doExecute();
+        SourceResolver resolver = null;
+        WorkflowManager wfManager = null;
+
+        try {
+            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
+
+            Document doc = getSourceDocument();
+            DocumentIdToPathMapper mapper = doc.getPublication().getPathMapper();
+            String path = mapper.getPath(doc.getId(), getSourceDocument().getLanguage());
+            String sourceUri = doc.getSourceURI();
+            String pubId = doc.getPublication().getId();
+            String tempSourceUri = "context://lenya/pubs/" + pubId + "/work/bxe/content/"
+                    + doc.getArea() + "/" + path + ".tmp";
+            tempSourceUri = tempSourceUri.substring("lenya://".length());
+            tempSourceUri = "context://" + tempSourceUri;
+
+            if (SourceUtil.exists(tempSourceUri, this.manager)) {
+                SourceUtil.copy(resolver, tempSourceUri, sourceUri, true);
+                SourceUtil.delete(tempSourceUri, this.manager);
+            }
+
+        } finally {
+            if (resolver != null) {
+                this.manager.release(resolver);
+            }
+            if (wfManager != null) {
+                this.manager.release(wfManager);
+            }
+        }
+    }
+
+    /**
+     * @see org.apache.lenya.cms.usecase.AbstractUsecase#getObjectsToLock()
+     */
+    protected Transactionable[] getObjectsToLock() throws UsecaseException {
+        return getSourceDocument().getRepositoryNodes();
+    }
+
+}
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org