You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by mi...@apache.org on 2006/06/28 09:52:11 UTC
svn commit: r417688 - in /lenya/trunk/src/modules/neutron: ./
config/cocoon-xconf/ java/ java/src/ java/src/org/ java/src/org/apache/
java/src/org/apache/lenya/ java/src/org/apache/lenya/cms/
java/src/org/apache/lenya/cms/usecases/ java/src/org/apache/...
Author: michi
Date: Wed Jun 28 00:52:10 2006
New Revision: 417688
URL: http://svn.apache.org/viewvc?rev=417688&view=rev
Log:
save and checkout implemented
Added:
lenya/trunk/src/modules/neutron/config/cocoon-xconf/usecase-neutron-put.xmap
lenya/trunk/src/modules/neutron/java/
lenya/trunk/src/modules/neutron/java/src/
lenya/trunk/src/modules/neutron/java/src/org/
lenya/trunk/src/modules/neutron/java/src/org/apache/
lenya/trunk/src/modules/neutron/java/src/org/apache/lenya/
lenya/trunk/src/modules/neutron/java/src/org/apache/lenya/cms/
lenya/trunk/src/modules/neutron/java/src/org/apache/lenya/cms/usecases/
lenya/trunk/src/modules/neutron/java/src/org/apache/lenya/cms/usecases/neutron/
lenya/trunk/src/modules/neutron/java/src/org/apache/lenya/cms/usecases/neutron/Put.java
lenya/trunk/src/modules/neutron/neutron.js
Modified:
lenya/trunk/src/modules/neutron/config/cocoon-xconf/usecase-neutron.xmap
lenya/trunk/src/modules/neutron/module.xml
lenya/trunk/src/modules/neutron/sitemap.xmap
lenya/trunk/src/modules/neutron/xslt/introspection.xsl
Added: lenya/trunk/src/modules/neutron/config/cocoon-xconf/usecase-neutron-put.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/neutron/config/cocoon-xconf/usecase-neutron-put.xmap?rev=417688&view=auto
==============================================================================
--- lenya/trunk/src/modules/neutron/config/cocoon-xconf/usecase-neutron-put.xmap (added)
+++ lenya/trunk/src/modules/neutron/config/cocoon-xconf/usecase-neutron-put.xmap Wed Jun 28 00:52:10 2006
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<!--
+ This file defines the publication specific use-cases
+-->
+
+ <xconf xpath="/cocoon/usecases" unless="/cocoon/usecases/component-instance[@name = 'neutron.put']">
+ <component-instance name="neutron.put" logger="lenya.publication"
+ class="org.apache.lenya.cms.usecases.neutron.Put">
+ <!-- You can configure which resource type and extension are connected.
+ The idea is similar to the file system browser dialog that an operation system
+ offers (open with) where you can register applications to open certain file extensions-->
+ <extensions>
+ <extension resource-type="xhtml">xml</extension>
+ <extension resource-type="opendocument">odt</extension>
+ <extension resource-type="xhtml">html</extension>
+ <extension resource-type="xhtml">xhtml</extension>
+ <!--Next extension is a wildcard (all others)-->
+ <extension resource-type="xhtml">*</extension>
+ </extensions>
+ </component-instance>
+ </xconf>
Modified: lenya/trunk/src/modules/neutron/config/cocoon-xconf/usecase-neutron.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/neutron/config/cocoon-xconf/usecase-neutron.xmap?rev=417688&r1=417687&r2=417688&view=diff
==============================================================================
--- lenya/trunk/src/modules/neutron/config/cocoon-xconf/usecase-neutron.xmap (original)
+++ lenya/trunk/src/modules/neutron/config/cocoon-xconf/usecase-neutron.xmap Wed Jun 28 00:52:10 2006
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-
-<!--
- This file defines the publication specific use-cases
--->
-
- <xconf xpath="/cocoon/usecases" unless="/cocoon/usecases/component-instance[@name = 'neutron']">
-
- <component-instance name="neutron" logger="lenya.publication">
- <transaction policy="pessimistic"/>
- <!--<view template="modules/bxe/usecases/bxe.jx" menu="false"/>-->
- <exit usecase="lucene.index">
- <parameter name="indexAction" value="index"/>
- <parameter name="indexArea" value="authoring"/>
- </exit>
- </component-instance>
-
- </xconf>
Added: lenya/trunk/src/modules/neutron/java/src/org/apache/lenya/cms/usecases/neutron/Put.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/neutron/java/src/org/apache/lenya/cms/usecases/neutron/Put.java?rev=417688&view=auto
==============================================================================
--- lenya/trunk/src/modules/neutron/java/src/org/apache/lenya/cms/usecases/neutron/Put.java (added)
+++ lenya/trunk/src/modules/neutron/java/src/org/apache/lenya/cms/usecases/neutron/Put.java Wed Jun 28 00:52:10 2006
@@ -0,0 +1,301 @@
+/*
+ * Copyright 1999-2006 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.usecases.neutron;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceSelector;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.lenya.cms.cocoon.source.SourceUtil;
+import org.apache.lenya.cms.metadata.dublincore.DublinCore;
+import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.DocumentException;
+import org.apache.lenya.cms.publication.DocumentFactory;
+import org.apache.lenya.cms.publication.DocumentManager;
+import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.cms.publication.PublicationException;
+import org.apache.lenya.cms.publication.PublicationUtil;
+import org.apache.lenya.cms.publication.ResourceType;
+import org.apache.lenya.cms.publication.util.DocumentSet;
+import org.apache.lenya.cms.repository.Node;
+import org.apache.lenya.cms.site.SiteStructure;
+import org.apache.lenya.cms.site.SiteUtil;
+import org.apache.lenya.cms.site.usecases.CreateDocument;
+import org.apache.lenya.cms.usecase.UsecaseException;
+import org.apache.lenya.workflow.WorkflowManager;
+import org.apache.lenya.xml.Schema;
+
+/**
+ * Supports Neutron PUT.
+ * @version $Id: $
+ */
+public class Put extends CreateDocument {
+ // registeredExtensions contain all known extension matching to a certain resource-type.
+ private HashMap registeredExtensions = new HashMap();
+// default is xhtml and xml but you can override it with the config
+ protected String TYPE = "xhtml";
+ protected String EXTENSION = "*";
+ protected static final String ATTRIBUTE_TYPE = "resource-type";
+ protected static final String ELEMENT_ROOT = "extensions";
+ protected static final String ELEMENT_EXTENSION = "extension";
+
+ private boolean fallback = false;
+
+ public void configure(Configuration config) throws ConfigurationException {
+ super.configure(config);
+ Configuration extensionsConfig = config.getChild(ELEMENT_ROOT, false);
+ if (extensionsConfig != null) {
+ Configuration [] extensions=extensionsConfig.getChildren(ELEMENT_EXTENSION);
+ for (int i = 0; i < extensions.length; i++) {
+ Configuration extension = extensions[i];
+// add extension to register (key: extension,value: resource-type)
+ if (extension != null)
+ registeredExtensions.put(extension.getValue(),extension.getAttribute(ATTRIBUTE_TYPE));
+ }
+ }else{
+ registeredExtensions.put(this.EXTENSION,this.TYPE);
+ }
+ }
+
+ /**
+ * @see org.apache.lenya.cms.usecase.AbstractUsecase#doExecute()
+ */
+ protected void doExecute() throws Exception {
+ SourceResolver resolver = null;
+ WorkflowManager wfManager = null;
+
+ try {
+ resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
+
+ Document doc = getSourceDocument();
+ String extension= getSourceExtension();
+ // sanity check
+ if (doc == null)
+ throw new IllegalArgumentException("illegal usage, source document may not be null");
+
+ // create new doc from PUT input
+ if (!doc.exists()) {
+ DocumentManager documentManager = null;
+ ServiceSelector selector = null;
+ ResourceType resourceType = null;
+ try {
+ selector = (ServiceSelector) this.manager.lookup(ResourceType.ROLE + "Selector");
+
+ documentManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
+
+ DocumentFactory map = getDocumentIdentityMap();
+ Document document = map.get(getPublication(),
+ doc.getArea(),
+ doc.getId(),
+ doc.getLanguage());
+ //lookupResourceType(extension)
+ resourceType = lookUpExtension(extension, selector);
+ documentManager.add(document, resourceType, extension, doc.getName(), true);
+ setMetaData(document);
+ doc = document;
+ } finally {
+ if (documentManager != null) {
+ this.manager.release(documentManager);
+ }
+ if (selector != null) {
+ if (resourceType != null) {
+ selector.release(resourceType);
+ }
+ this.manager.release(selector);
+ }
+ }
+ }
+
+ String sourceUri = "cocoon:/request/PUT/" + extension;
+
+ // validate if a schema is provided and we are not using any fallback
+ if (doc.getResourceType().getSchema() != null & fallback==false){
+ validateDoc(resolver, sourceUri, doc);
+ }
+
+ if (!hasErrors()) {
+ try {
+ SourceUtil.copy(resolver, sourceUri, doc.getSourceURI(), true);
+ } catch (Exception e) {
+ addErrorMessage("invalid source xml. Full exception: "+ e);
+ }
+ }
+
+ } finally {
+ if (resolver != null) {
+ this.manager.release(resolver);
+ }
+ if (wfManager != null) {
+ this.manager.release(wfManager);
+ }
+ }
+ }
+
+
+ private ResourceType lookUpExtension(String extension, ServiceSelector selector) throws ServiceException {
+ ResourceType resourceType;
+ String resourceTypeName=(String) registeredExtensions.get(extension);
+ if (resourceTypeName==null||resourceTypeName.equals("")){
+ resourceTypeName=(String) registeredExtensions.get(this.EXTENSION);
+ this.fallback=true;
+ }
+ if (selector.isSelectable(resourceTypeName)){
+ resourceType = (ResourceType) selector.select(resourceTypeName);
+ }else{
+ //using a fallback resource type
+ // FIXME this resource tye should be a more generic one like "media-assets" or "bin"
+ resourceType = (ResourceType) selector.select(this.TYPE);
+ this.fallback=true;
+ }
+ return resourceType;
+ }
+
+ private void validateDoc(SourceResolver resolver, String uploadSourceUri, Document doc) throws Exception {
+ Source uploadSource = resolver.resolveURI(uploadSourceUri);
+ if (!uploadSource.exists()) {
+ throw new IllegalArgumentException("The upload file [" + uploadSource.getURI()
+ + "] does not exist.");
+ }
+
+ ResourceType resourceType = doc.getResourceType();
+ Schema schema = resourceType.getSchema();
+
+ // FIXME not working yet, dunno why
+ //org.w3c.dom.Document xmlDoc = DocumentHelper.readDocument(uploadSource.getInputStream());
+ //ValidationUtil.validate(this.manager, xmlDoc, schema, new UsecaseErrorHandler(this));
+ }
+
+ /**
+ * @see org.apache.lenya.cms.usecase.AbstractUsecase#getNodesToLock()
+ */
+ protected Node[] getNodesToLock() throws UsecaseException {
+ try {
+ Document doc = getSourceDocument();
+ List nodes = new ArrayList();
+
+ DocumentSet set = SiteUtil.getSubSite(this.manager, doc);
+ Document[] documents = set.getDocuments();
+ for (int i = 0; i < documents.length; i++) {
+ nodes.add(documents[i].getRepositoryNode());
+ }
+
+ SiteStructure structure = SiteUtil.getSiteStructure(this.manager, getSourceDocument());
+ nodes.add(structure.getRepositoryNode());
+ return (Node[]) nodes.toArray(new Node[nodes.size()]);
+
+ } catch (Exception e) {
+ throw new UsecaseException(e);
+ }
+ }
+ /**
+ * Sets the meta data of the created document.
+ *
+ * @param document The document.
+ * @throws DocumentException if an error occurs.
+ */
+ protected void setMetaData(Document document) throws DocumentException {
+
+ if (document == null)
+ throw new IllegalArgumentException("parameter document may not be null");
+
+ Map dcMetaData = new HashMap();
+ dcMetaData.put(DublinCore.ELEMENT_TITLE, document.getName());
+ dcMetaData.put(DublinCore.ELEMENT_CREATOR, "");
+ dcMetaData.put(DublinCore.ELEMENT_PUBLISHER, "");
+ dcMetaData.put(DublinCore.ELEMENT_SUBJECT, "");
+ dcMetaData.put(DublinCore.ELEMENT_DATE, "");
+ dcMetaData.put(DublinCore.ELEMENT_RIGHTS, "");
+ dcMetaData.put(DublinCore.ELEMENT_LANGUAGE, document.getLanguage());
+
+ document.getMetaDataManager().setDublinCoreMetaData(dcMetaData);
+ }
+
+ private Publication publication;
+
+ /**
+ * Access to the current publication. Use this when the publication is not yet known in the
+ * usecase: e.g. when creating a global asset. When adding a resource or a child to a document,
+ * access the publication via that document's interface instead.
+ *
+ * @return the publication in which the use-case is being executed
+ */
+ protected Publication getPublication() {
+ if (this.publication == null) {
+ try {
+ this.publication = PublicationUtil.getPublicationFromUrl(this.manager,
+ getSourceURL());
+ } catch (PublicationException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ return this.publication;
+ }
+
+
+ protected String getSourceExtension() {
+ String destinationUri = getParameterAsString(SOURCE_URL);
+ String extension = null;
+ if (destinationUri.indexOf(".") > 0) {
+ extension = destinationUri.substring(destinationUri.lastIndexOf(".")+1,destinationUri.length());
+ } else {
+ extension = EXTENSION;
+ }
+ return extension;
+ }
+
+
+ protected String getNewDocumentName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ protected String getNewDocumentId() {
+ Document doc = getSourceDocument();
+ return doc.getId();
+ }
+
+ protected boolean getVisibleInNav(){
+ return true;
+ }
+
+ protected String getDocumentTypeName() {
+ ResourceType resourceType = null;
+ ServiceSelector selector = null;
+ String docType="";
+ try {
+ selector = (ServiceSelector) this.manager.lookup(ResourceType.ROLE + "Selector");
+ resourceType = lookUpExtension(getSourceExtension(), selector);
+ docType=resourceType.getName();
+ } catch (ServiceException e) {
+ throw new RuntimeException(e);
+ }finally {
+ if (selector != null) {
+ this.manager.release(selector);
+ }
+ }
+ return docType;
+ }
+
+}
Modified: lenya/trunk/src/modules/neutron/module.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/neutron/module.xml?rev=417688&r1=417687&r2=417688&view=diff
==============================================================================
--- lenya/trunk/src/modules/neutron/module.xml (original)
+++ lenya/trunk/src/modules/neutron/module.xml Wed Jun 28 00:52:10 2006
@@ -19,6 +19,8 @@
<lenya:module xmlns:lenya="http://apache.org/lenya/module/1.0">
<lenya:id>org.apache.lenya.modules.neutron</lenya:id>
+ <lenya:depends module="org.apache.lenya.modules.usecase"/>
+ <lenya:depends module="org.apache.lenya.modules.sitemanagement"/>
<lenya:package>org.apache.lenya.modules</lenya:package>
<lenya:version>0.1-dev</lenya:version>
<lenya:name>Neutron Module</lenya:name>
Added: lenya/trunk/src/modules/neutron/neutron.js
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/neutron/neutron.js?rev=417688&view=auto
==============================================================================
--- lenya/trunk/src/modules/neutron/neutron.js (added)
+++ lenya/trunk/src/modules/neutron/neutron.js Wed Jun 28 00:52:10 2006
@@ -0,0 +1,264 @@
+/*
+* 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.
+*/
+
+/* Helper method to add all request parameters to a usecase */
+function passRequestParameters(flowHelper, usecase) {
+ var names = cocoon.request.getParameterNames();
+ while (names.hasMoreElements()) {
+ var name = names.nextElement();
+ if (!name.equals("lenya.usecase")
+ && !name.equals("lenya.continuation")
+ && !name.equals("submit")) {
+
+ var value = flowHelper.getRequest(cocoon).get(name);
+
+ var string = new Packages.java.lang.String();
+ if (string.getClass().isInstance(value)) {
+ usecase.setParameter(name, value);
+ }
+ else {
+ usecase.setPart(name, value);
+ }
+
+ }
+ }
+}
+
+/* Helper method to add all request headers to a usecase */
+function passRequestHeaders(flowHelper, usecase) {
+ var names = cocoon.request.getHeaderNames();
+ while (names.hasMoreElements()) {
+ var name = names.nextElement();
+ var value = flowHelper.getRequest(cocoon).getHeader(name);
+
+ var string = new Packages.java.lang.String();
+ if (string.getClass().isInstance(value)) {
+ usecase.setParameter("header-"+name, value);
+ }
+ else {
+ usecase.setPart("header-"+name, value);
+ }
+ }
+}
+
+function selectMethod() {
+ var page = cocoon.parameters["page"];
+ var requestURI = cocoon.parameters["requestURI"];
+ var method = cocoon.request.getMethod();
+ cocoon.sendPage(method+"/"+page, {"requestURI":requestURI});
+}
+
+function sendStatus(sc) {
+ cocoon.sendStatus(sc);
+}
+
+function put() {
+ var status = executeUsecase("neutron.put");
+ if(status)
+ sendStatus(204);
+ else {
+ sendStatus(415);
+ }
+}
+
+function get() {
+ var uri = new java.lang.String(cocoon.parameters["forward"]);
+ var uri = uri.substring(8, uri.length());
+ cocoon.sendPage(uri);
+}
+
+/*
+ * convert the overwrite header into a boolean type
+ */
+function isOverwrite(header) {
+ var overwrite = true;
+ if (header == 'F') {
+ overwrite = false;
+ }
+ return overwrite;
+}
+
+function executeUsecase(usecaseName) {
+ var view;
+ var proxy;
+ var menu = "nomenu";
+
+ var usecaseResolver;
+ var usecase;
+ var sourceUrl;
+
+ if (cocoon.log.isDebugEnabled())
+ cocoon.log.debug("usecases.js::executeUsecase() called, parameter lenya.usecase = [" + usecaseName + "]");
+
+ try {
+
+ var flowHelper = cocoon.getComponent("org.apache.lenya.cms.cocoon.flow.FlowHelper");
+ var request = flowHelper.getRequest(cocoon);
+ sourceUrl = Packages.org.apache.lenya.util.ServletHelper.getWebappURI(request);
+
+ usecaseResolver = cocoon.getComponent("org.apache.lenya.cms.usecase.UsecaseResolver");
+ usecase = usecaseResolver.resolve(sourceUrl, usecaseName);
+ usecase.setSourceURL(sourceUrl);
+ usecase.setName(usecaseName);
+ view = usecase.getView();
+
+ passRequestParameters(flowHelper, usecase);
+ passRequestHeaders(flowHelper, usecase);
+ usecase.checkPreconditions();
+ usecase.lockInvolvedObjects();
+ proxy = new Packages.org.apache.lenya.cms.usecase.UsecaseProxy(usecase);
+ }
+ finally {
+ /* done with usecase component, tell usecaseResolver to release it */
+ if (usecaseResolver != null) {
+ if (usecase != null) {
+ usecaseResolver.release(usecase);
+ usecase = undefined;
+ }
+ cocoon.releaseComponent(usecaseResolver);
+ }
+ }
+
+ var success = false;
+ //var targetUrl;
+ var form;
+ var scriptString;
+ var evalFunc;
+ var generic;
+
+ /*
+ * If the usecase has a view, this means we want to display something
+ * to the user before proceeding. This also means the usecase consists
+ * several steps; repeated until the user chooses to submit or cancel.
+ *
+ * If the usecase does not have a view, it is simply executed.
+ */
+
+ if (view) {
+ var ready = false;
+ while (!ready) {
+
+ try {
+ var templateUri = view.getTemplateURI();
+ if (templateUri) {
+ var viewUri = "view/" + menu + "/" + view.getTemplateURI();
+ if (cocoon.log.isDebugEnabled())
+ cocoon.log.debug("usecases.js::executeUsecase() in usecase " + usecaseName + ", creating view, calling Cocoon with viewUri = [" + viewUri + "]");
+
+ cocoon.sendPageAndWait(viewUri, {"usecase" : proxy});
+
+ }
+ else {
+ var viewUri = view.getViewURI();
+ cocoon.sendPage(viewUri);
+ return;
+ }
+ }
+ catch (exception) {
+ /* if an exception was thrown by the view, allow the usecase to rollback the transition */
+ try {
+ usecaseResolver = cocoon.getComponent("org.apache.lenya.cms.usecase.UsecaseResolver");
+ usecase = usecaseResolver.resolve(sourceUrl, usecaseName);
+ proxy.setup(usecase);
+ usecase.cancel();
+ throw exception;
+ }
+ finally {
+ if (usecaseResolver != null) {
+ if (usecase != null) {
+ usecaseResolver.release(usecase);
+ usecase = undefined;
+ }
+ cocoon.releaseComponent(usecaseResolver);
+ }
+ }
+ }
+
+ if (cocoon.log.isDebugEnabled())
+ cocoon.log.debug("usecases.js::executeUsecase() in usecase " + usecaseName + ", after view, now advancing in usecase");
+
+ try {
+ usecaseResolver = cocoon.getComponent("org.apache.lenya.cms.usecase.UsecaseResolver");
+ usecase = usecaseResolver.resolve(sourceUrl, usecaseName);
+ proxy.setup(usecase);
+
+ passRequestParameters(flowHelper, usecase);
+ usecase.advance();
+
+ if (cocoon.request.getParameter("submit")) {
+ usecase.checkExecutionConditions();
+ if (! usecase.hasErrors()) {
+ usecase.execute();
+ if (! usecase.hasErrors()) {
+ usecase.checkPostconditions();
+ if (! usecase.hasErrors()) {
+ ready = true;
+ success = true;
+ }
+ }
+ }
+ }
+ else if (cocoon.request.getParameter("cancel")) {
+ usecase.cancel();
+ ready = true;
+ }
+ proxy = new Packages.org.apache.lenya.cms.usecase.UsecaseProxy(usecase);
+ }
+ catch (exception) {
+ /* allow usecase to rollback the transition */
+ usecase.cancel();
+ throw exception;
+ }
+ finally {
+ if (usecaseResolver != null) {
+ if (usecase != null) {
+ usecaseResolver.release(usecase);
+ usecase = undefined;
+ }
+ cocoon.releaseComponent(usecaseResolver);
+ }
+ }
+ }
+ }
+ else {
+ try {
+ usecaseResolver = cocoon.getComponent("org.apache.lenya.cms.usecase.UsecaseResolver");
+ usecase = usecaseResolver.resolve(sourceUrl, usecaseName);
+ proxy.setup(usecase);
+
+ usecase.execute();
+ if (! usecase.hasErrors()) {
+ usecase.checkPostconditions();
+ if (! usecase.hasErrors()) {
+ success = true;
+ }
+ }
+ }
+ catch (exception) {
+ /* allow usecase to rollback the transition */
+ usecase.cancel();
+ throw exception;
+ }
+ finally {
+ usecaseResolver.release(usecase);
+ usecase = undefined;
+ cocoon.releaseComponent(usecaseResolver);
+ }
+ }
+
+ return success;
+
+}
Modified: lenya/trunk/src/modules/neutron/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/neutron/sitemap.xmap?rev=417688&r1=417687&r2=417688&view=diff
==============================================================================
--- lenya/trunk/src/modules/neutron/sitemap.xmap (original)
+++ lenya/trunk/src/modules/neutron/sitemap.xmap Wed Jun 28 00:52:10 2006
@@ -20,48 +20,56 @@
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
<map:components/>
+ <!-- =========================== Flow ===================================== -->
+
+ <map:flow language="javascript">
+ <map:script src="fallback://lenya/modules/neutron/neutron.js"/>
+ </map:flow>
+
+ <!-- =========================== Pipelines ================================ -->
<map:pipelines>
<!-- Introspection -->
- <map:pipeline>
- <map:match pattern="*/**/introspection.xml">
- <map:generate src="context:/lenya/content/util/empty.xml"/>
- <map:transform src="context:/lenya/modules/neutron/xslt/introspection.xsl">
- <map:parameter name="context" value="{page-envelope:context-prefix}"/>
- <map:parameter name="publication" value="{page-envelope:publication-id}"/>
- <map:parameter name="area" value="{1}"/>
- <map:parameter name="page-id" value="{2}"/>
- </map:transform>
- <map:serialize type="xml"/>
- </map:match>
- </map:pipeline>
+ <map:pipeline>
+ <map:match pattern="*/**/introspection.xml">
+ <map:generate src="context:/lenya/content/util/empty.xml"/>
+ <map:transform src="context:/lenya/modules/neutron/xslt/introspection.xsl">
+ <map:parameter name="context" value="{page-envelope:context-prefix}"/>
+ <map:parameter name="publication" value="{page-envelope:publication-id}"/>
+ <map:parameter name="area" value="{1}"/>
+ <map:parameter name="page-id" value="{2}"/>
+ </map:transform>
+ <map:serialize type="xml"/>
+ </map:match>
+ </map:pipeline>
<map:pipeline>
-
- <map:match pattern="checkout" type="step">
- <map:select type="resource-exists">
- <map:parameter name="prefix" value="context://"/>
- <map:when test="lenya/pubs/{page-envelope:publication-id}/content/authoring/{page-envelope:document-path}">
+ <map:match pattern="checkout" type="step">
+ <map:select type="resource-exists">
+ <map:parameter name="prefix" value="lenyadoc:/"/>
+ <map:when test="{page-envelope:document-language}/{page-envelope:document-id}">
<map:act type="reserved-checkout">
<map:generate src="context://lenya/content/util/empty.xml"/>
<map:serialize type="xml" status-code="423"/>
</map:act>
- <map:generate src="context://lenya/pubs/{page-envelope:publication-id}/content/authoring/{page-envelope:document-path}"/>
- <map:transform src="fallback://lenya/xslt/util/strip_namespaces.xsl" />
- <map:serialize type="xml" status-code="200" />
+ <map:read src="lenyadoc:/{page-envelope:document-language}/{page-envelope:document-id}"/>
</map:when>
<map:otherwise>
<map:generate src="context://lenya/content/util/empty.xml"/>
<map:serialize type="xml" status-code="412"/>
</map:otherwise>
</map:select>
- </map:match>
-
- <map:match pattern="checkin" type="step">
+ </map:match>
+
+ <map:match pattern="checkin" type="step">
+ <map:act type="reserved-checkin">
<map:generate src="context://lenya/content/util/empty.xml"/>
- <map:serialize type="xml"/>
- </map:match>
-
+ <map:serialize type="xml" status-code="424"/>
+ </map:act>
+ <map:call function="put" />
+ <map:generate src="context://lenya/content/util/empty.xml"/>
+ <map:serialize type="xml" status-code="204" />
+ </map:match>
</map:pipeline>
</map:pipelines>
Modified: lenya/trunk/src/modules/neutron/xslt/introspection.xsl
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/neutron/xslt/introspection.xsl?rev=417688&r1=417687&r2=417688&view=diff
==============================================================================
--- lenya/trunk/src/modules/neutron/xslt/introspection.xsl (original)
+++ lenya/trunk/src/modules/neutron/xslt/introspection.xsl Wed Jun 28 00:52:10 2006
@@ -32,7 +32,9 @@
<introspection>
<edit mime-type="application/xml" name="Body Content">
+<!--
<open url="{$context}/{$publication}/authoring/{$page-id}.xml" method="GET"/>
+-->
<checkout url="{$context}/{$publication}/authoring/{$page-id}.xml?lenya.module=neutron&lenya.step=checkout" method="GET"/>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org