diff --git a/nuxeo-features/nuxeo-automation/nuxeo-automation-server/pom.xml b/nuxeo-features/nuxeo-automation/nuxeo-automation-server/pom.xml index 9b414893af26..1eed8ab0128f 100644 --- a/nuxeo-features/nuxeo-automation/nuxeo-automation-server/pom.xml +++ b/nuxeo-features/nuxeo-automation/nuxeo-automation-server/pom.xml @@ -47,6 +47,10 @@ org.nuxeo.runtime nuxeo-runtime + + org.nuxeo.runtime + nuxeo-runtime-jtajca + org.nuxeo.common nuxeo-common @@ -153,11 +157,6 @@ jetty-util test - - org.nuxeo.runtime - nuxeo-runtime-jtajca - test - org.osgi org.osgi.compendium @@ -166,4 +165,4 @@ - \ No newline at end of file + diff --git a/nuxeo-features/nuxeo-automation/nuxeo-automation-server/src/main/java/org/nuxeo/ecm/automation/server/jaxrs/batch/BatchResource.java b/nuxeo-features/nuxeo-automation/nuxeo-automation-server/src/main/java/org/nuxeo/ecm/automation/server/jaxrs/batch/BatchResource.java index 7ab497dac8a2..a53514561399 100644 --- a/nuxeo-features/nuxeo-automation/nuxeo-automation-server/src/main/java/org/nuxeo/ecm/automation/server/jaxrs/batch/BatchResource.java +++ b/nuxeo-features/nuxeo-automation/nuxeo-automation-server/src/main/java/org/nuxeo/ecm/automation/server/jaxrs/batch/BatchResource.java @@ -61,6 +61,7 @@ import org.nuxeo.ecm.webengine.model.impl.ResourceTypeImpl; import org.nuxeo.runtime.api.Framework; import org.nuxeo.runtime.services.config.ConfigurationService; +import org.nuxeo.runtime.transaction.TransactionHelper; /** * Exposes {@link Batch} as a JAX-RS resource @@ -125,7 +126,15 @@ protected int getUploadWaitTimeout() { @POST @Path("/upload") public Object doPost(@Context HttpServletRequest request) throws IOException { + TransactionHelper.commitOrRollbackTransaction(); + try { + return uploadNoTransaction(request); + } finally { + TransactionHelper.startTransaction(); + } + } + protected Object uploadNoTransaction(@Context HttpServletRequest request) throws IOException { boolean useIFrame = false; // Parameters are passed as request header diff --git a/nuxeo-features/nuxeo-automation/nuxeo-automation-server/src/main/resources/META-INF/MANIFEST.MF b/nuxeo-features/nuxeo-automation/nuxeo-automation-server/src/main/resources/META-INF/MANIFEST.MF index d28074181d1c..79093ed3fb71 100644 --- a/nuxeo-features/nuxeo-automation/nuxeo-automation-server/src/main/resources/META-INF/MANIFEST.MF +++ b/nuxeo-features/nuxeo-automation/nuxeo-automation-server/src/main/resources/META-INF/MANIFEST.MF @@ -12,8 +12,7 @@ Nuxeo-Component: OSGI-INF/AutomationServer.xml, OSGI-INF/auth-contrib.xml, OSGI-INF/batchmanager-framework.xml, OSGI-INF/binding-contrib.xml, - OSGI-INF/pageprovider-contrib.xml, - OSGI-INF/batch-upload-filter-contrib.xml + OSGI-INF/pageprovider-contrib.xml Nuxeo-AllowOverride: true Import-Package: javax.mail, javax.mail.internet, diff --git a/nuxeo-features/nuxeo-automation/nuxeo-automation-server/src/main/resources/OSGI-INF/batch-upload-filter-contrib.xml b/nuxeo-features/nuxeo-automation/nuxeo-automation-server/src/main/resources/OSGI-INF/batch-upload-filter-contrib.xml deleted file mode 100644 index 0bff0a0f5e40..000000000000 --- a/nuxeo-features/nuxeo-automation/nuxeo-automation-server/src/main/resources/OSGI-INF/batch-upload-filter-contrib.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - ${org.nuxeo.ecm.contextPath}/site/automation/batch/upload - - - - - - - - - - - - diff --git a/nuxeo-features/rest-api/nuxeo-rest-api-server/src/main/java/org/nuxeo/ecm/restapi/server/jaxrs/BatchUploadObject.java b/nuxeo-features/rest-api/nuxeo-rest-api-server/src/main/java/org/nuxeo/ecm/restapi/server/jaxrs/BatchUploadObject.java index d4f920a7ece7..08ad2f9cf287 100644 --- a/nuxeo-features/rest-api/nuxeo-rest-api-server/src/main/java/org/nuxeo/ecm/restapi/server/jaxrs/BatchUploadObject.java +++ b/nuxeo-features/rest-api/nuxeo-rest-api-server/src/main/java/org/nuxeo/ecm/restapi/server/jaxrs/BatchUploadObject.java @@ -63,6 +63,7 @@ import org.nuxeo.ecm.webengine.model.impl.AbstractResource; import org.nuxeo.ecm.webengine.model.impl.ResourceTypeImpl; import org.nuxeo.runtime.api.Framework; +import org.nuxeo.runtime.transaction.TransactionHelper; /** * Batch upload endpoint. @@ -114,6 +115,17 @@ public Response initBatch() throws IOException { @Path("{batchId}/{fileIdx}") public Response upload(@Context HttpServletRequest request, @PathParam(REQUEST_BATCH_ID) String batchId, @PathParam(REQUEST_FILE_IDX) String fileIdx) throws IOException { + TransactionHelper.commitOrRollbackTransaction(); + try { + return uploadNoTransaction(request, batchId, fileIdx); + } finally { + TransactionHelper.startTransaction(); + } + } + + protected Response uploadNoTransaction(@Context HttpServletRequest request, + @PathParam(REQUEST_BATCH_ID) String batchId, @PathParam(REQUEST_FILE_IDX) String fileIdx) + throws IOException { BatchManager bm = Framework.getService(BatchManager.class); if (!bm.hasBatch(batchId)) { diff --git a/nuxeo-features/rest-api/nuxeo-rest-api-server/src/main/resources/META-INF/MANIFEST.MF b/nuxeo-features/rest-api/nuxeo-rest-api-server/src/main/resources/META-INF/MANIFEST.MF index c6ad5a73f5e3..233bf10377fb 100644 --- a/nuxeo-features/rest-api/nuxeo-rest-api-server/src/main/resources/META-INF/MANIFEST.MF +++ b/nuxeo-features/rest-api/nuxeo-rest-api-server/src/main/resources/META-INF/MANIFEST.MF @@ -8,5 +8,4 @@ Nuxeo-WebModule: org.nuxeo.ecm.restapi.server.jaxrs.APIModule;name=api;extends=a Nuxeo-Component: OSGI-INF/docviewurl-service-contrib.xml, OSGI-INF/auth-contrib.xml, OSGI-INF/searchadapter-pp-contrib.xml, - OSGI-INF/restapi-batch-upload-filter-contrib.xml, OSGI-INF/json-enrichers-contrib.xml diff --git a/nuxeo-features/rest-api/nuxeo-rest-api-server/src/main/resources/OSGI-INF/restapi-batch-upload-filter-contrib.xml b/nuxeo-features/rest-api/nuxeo-rest-api-server/src/main/resources/OSGI-INF/restapi-batch-upload-filter-contrib.xml deleted file mode 100644 index 95268c36238e..000000000000 --- a/nuxeo-features/rest-api/nuxeo-rest-api-server/src/main/resources/OSGI-INF/restapi-batch-upload-filter-contrib.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - diff --git a/nuxeo-webengine/nuxeo-webengine-core/src/main/java/org/nuxeo/ecm/webengine/PathDescriptor.java b/nuxeo-webengine/nuxeo-webengine-core/src/main/java/org/nuxeo/ecm/webengine/PathDescriptor.java index c84ebccf831a..745668217800 100644 --- a/nuxeo-webengine/nuxeo-webengine-core/src/main/java/org/nuxeo/ecm/webengine/PathDescriptor.java +++ b/nuxeo-webengine/nuxeo-webengine-core/src/main/java/org/nuxeo/ecm/webengine/PathDescriptor.java @@ -19,106 +19,12 @@ */ package org.nuxeo.ecm.webengine; -import org.nuxeo.common.xmap.annotation.XNode; import org.nuxeo.common.xmap.annotation.XObject; -import org.nuxeo.ecm.webengine.util.PathMatcher; /** - * Configure how a given path is handled by the WebEngine filter. - *

- * If autoTx is true (which is the default) then a transaction will be started each time a path matching the - * given path specification is requested. (the transaction is started in a filter before the JAX-RS resource is called - * and closed after the response is sent to the output stream). If false then no transaction handling is done. The - * default is to start a transaction for any path but: [^/]+/skin/.* - *

- * The value attribute is required and must be used to specify the path pattern. The path pattern is either a - * prefix or a regular expression. If the regex parameter is true (the default is false) then the value will be - * expected to be a regular expression. A prefix denotes a path starting with 'prefix'. Paths are relative to the - * webengine servlet (i.e. they correspond to the servlet path info in the JAX-RS servlet) - and always begin with a - * '/'. + * Obsolete since 8.4, transactions are always active. */ @XObject("path") -public class PathDescriptor implements Comparable { - - @XNode("@value") - protected String value; - - @XNode("@regex") - protected boolean regex = false; - - @XNode("@autoTx") - protected Boolean autoTx; - - protected PathMatcher matcher; - - public PathDescriptor() { - } - - public PathMatcher getMatcher() { - return matcher; - } - - public String getValue() { - return value; - } - - public Boolean getAutoTx() { - return autoTx; - } - - public boolean isAutoTx(boolean defaultValue) { - return autoTx == null ? defaultValue : autoTx.booleanValue(); - } - - public PathMatcher createMatcher() { - if (value != null) { - if (!value.startsWith("/")) { - value = "/" + value; - } - matcher = regex ? PathMatcher.getRegexMatcher(value) : PathMatcher.getPrefixMatcher(value); - } else { - throw new IllegalArgumentException("Path value is required"); - } - return matcher; - } - - public boolean match(String path) { - return matcher.match(path); - } - - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } - if (obj instanceof PathDescriptor) { - PathDescriptor pd = ((PathDescriptor) obj); - return value != null && value.equals(pd.value) || value == pd.value; - } - return false; - } - - @Override - public int hashCode() { - return value.hashCode(); - } - - @Override - public String toString() { - return value + "; autoTx: " + autoTx; - } - - @Override - public int compareTo(PathDescriptor o) { - if (regex != o.regex) { - return regex ? 1 : -1; - } - int len1 = value.length(); - int len2 = o.value.length(); - if (len1 == len2) { - return value.compareTo(o.value); - } - return len2 - len1; - } +public class PathDescriptor { } diff --git a/nuxeo-webengine/nuxeo-webengine-core/src/main/java/org/nuxeo/ecm/webengine/RequestConfiguration.java b/nuxeo-webengine/nuxeo-webengine-core/src/main/java/org/nuxeo/ecm/webengine/RequestConfiguration.java deleted file mode 100644 index d25b33b89283..000000000000 --- a/nuxeo-webengine/nuxeo-webengine-core/src/main/java/org/nuxeo/ecm/webengine/RequestConfiguration.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * (C) Copyright 2006-2010 Nuxeo SA (http://nuxeo.com/) and others. - * - * 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. - * - * Contributors: - * bstefanescu - */ -package org.nuxeo.ecm.webengine; - -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -import javax.servlet.http.HttpServletRequest; - -/** - * @author Bogdan Stefanescu - */ -public class RequestConfiguration { - - /** - * Synchronized list of configured paths - */ - protected Set paths; - - /** - * Thread safe cache - */ - protected volatile PathDescriptor[] cache; - - public RequestConfiguration() { - paths = Collections.synchronizedSet(new HashSet()); - } - - public void addPathDescriptor(PathDescriptor path) { - path.createMatcher(); - paths.add(path); - cache = null; - } - - public void removePathDescriptor(PathDescriptor path) { - paths.remove(path); - cache = null; - } - - public PathDescriptor[] getPaths() { - PathDescriptor[] result = cache; - if (result == null) { - result = paths.toArray(new PathDescriptor[paths.size()]); - Arrays.sort(result); - cache = result; - } - return result; - } - - public PathDescriptor getMatchingConfiguration(HttpServletRequest req) { - String pathInfo = req.getPathInfo(); - if (pathInfo == null || pathInfo.length() == 0) { - pathInfo = "/"; - } - for (PathDescriptor pd : getPaths()) { - if (pd.match(pathInfo)) { - return pd; - } - } - return null; - } - -} diff --git a/nuxeo-webengine/nuxeo-webengine-core/src/main/java/org/nuxeo/ecm/webengine/WebEngine.java b/nuxeo-webengine/nuxeo-webengine-core/src/main/java/org/nuxeo/ecm/webengine/WebEngine.java index a4abbeb864db..12f53afe0d92 100644 --- a/nuxeo-webengine/nuxeo-webengine-core/src/main/java/org/nuxeo/ecm/webengine/WebEngine.java +++ b/nuxeo-webengine/nuxeo-webengine-core/src/main/java/org/nuxeo/ecm/webengine/WebEngine.java @@ -120,8 +120,6 @@ public static WebContext getActiveContext() { protected final WebLoader webLoader; - protected RequestConfiguration requestConfig; - protected volatile boolean isDirty; public WebEngine(File root) { @@ -152,13 +150,6 @@ public WebEngine(ResourceRegistry registry, File root) { rendering = new FreemarkerEngine(); rendering.setResourceLocator(this); rendering.setSharedVariable("env", getEnvironment()); - - requestConfig = new RequestConfiguration(); - - } - - public RequestConfiguration getRequestConfiguration() { - return requestConfig; } /** diff --git a/nuxeo-webengine/nuxeo-webengine-core/src/main/java/org/nuxeo/ecm/webengine/WebEngineComponent.java b/nuxeo-webengine/nuxeo-webengine-core/src/main/java/org/nuxeo/ecm/webengine/WebEngineComponent.java index 6d6a785de296..262e68ba33c6 100644 --- a/nuxeo-webengine/nuxeo-webengine-core/src/main/java/org/nuxeo/ecm/webengine/WebEngineComponent.java +++ b/nuxeo-webengine/nuxeo-webengine-core/src/main/java/org/nuxeo/ecm/webengine/WebEngineComponent.java @@ -120,8 +120,7 @@ public void registerContribution(Object contribution, String extensionPoint, Com // Form form = (Form)contribution; // engine.getFormManager().registerForm(form); } else if (extensionPoint.equals(REQUEST_CONFIGURATION_XP)) { - PathDescriptor pd = (PathDescriptor) contribution; - engine.getRequestConfiguration().addPathDescriptor(pd); + log.warn("Extension point " + REQUEST_CONFIGURATION_XP + " is obsolete since 8.4, transactions are always active"); } } @@ -139,9 +138,6 @@ public void unregisterContribution(Object contribution, String extensionPoint, C // } else if (extensionPoint.endsWith(FORM_XP)) { // Form form = (Form)contribution; // engine.getFormManager().unregisterForm(form.getId()); - } else if (extensionPoint.equals(REQUEST_CONFIGURATION_XP)) { - PathDescriptor pd = (PathDescriptor) contribution; - engine.getRequestConfiguration().removePathDescriptor(pd); } } diff --git a/nuxeo-webengine/nuxeo-webengine-core/src/main/java/org/nuxeo/ecm/webengine/app/WebEngineFilter.java b/nuxeo-webengine/nuxeo-webengine-core/src/main/java/org/nuxeo/ecm/webengine/app/WebEngineFilter.java index a784e005a3a1..bc5969094632 100644 --- a/nuxeo-webengine/nuxeo-webengine-core/src/main/java/org/nuxeo/ecm/webengine/app/WebEngineFilter.java +++ b/nuxeo-webengine/nuxeo-webengine-core/src/main/java/org/nuxeo/ecm/webengine/app/WebEngineFilter.java @@ -35,7 +35,6 @@ import org.apache.commons.logging.LogFactory; import org.nuxeo.ecm.platform.web.common.ServletHelper; import org.nuxeo.ecm.platform.web.common.requestcontroller.filter.BufferingHttpServletResponse; -import org.nuxeo.ecm.webengine.PathDescriptor; import org.nuxeo.ecm.webengine.WebEngine; import org.nuxeo.ecm.webengine.model.WebContext; import org.nuxeo.ecm.webengine.model.impl.AbstractWebContext; @@ -82,8 +81,7 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha if (request instanceof HttpServletRequest) { HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse resp = (HttpServletResponse) response; - PathDescriptor pd = engine.getRequestConfiguration().getMatchingConfiguration(req); - Config config = new Config(req, pd); + Config config = new Config(req); AbstractWebContext ctx = initRequest(config, req, resp); if (config.txStarted) { resp = new BufferingHttpServletResponse(resp); @@ -159,7 +157,7 @@ public void cleanup(Config config, AbstractWebContext ctx, HttpServletRequest re } public void initTx(Config config, HttpServletRequest req) { - if (!config.isStatic && config.autoTx && !TransactionHelper.isTransactionActive()) { + if (!config.isStatic && !TransactionHelper.isTransactionActive()) { config.txStarted = ServletHelper.startTransaction(req); } } @@ -171,18 +169,14 @@ public void closeTx(Config config, HttpServletRequest req) { } protected static class Config { - boolean autoTx; boolean txStarted; - boolean locked; - boolean isStatic; String pathInfo; - public Config(HttpServletRequest req, PathDescriptor pd) { - autoTx = pd == null ? true : pd.isAutoTx(true); + public Config(HttpServletRequest req) { pathInfo = req.getPathInfo(); if (pathInfo == null || pathInfo.length() == 0) { pathInfo = "/"; @@ -197,8 +191,6 @@ public String toString() { sb.append("WebEngineFilter&Confi:"); sb.append("\nPath Info:"); sb.append(pathInfo); - sb.append("\nAuto TX:"); - sb.append(autoTx); sb.append("\nStatic:"); sb.append(isStatic); return sb.toString(); diff --git a/nuxeo-webengine/nuxeo-webengine-core/src/main/resources/OSGI-INF/webengine-framework.xml b/nuxeo-webengine/nuxeo-webengine-core/src/main/resources/OSGI-INF/webengine-framework.xml index e2a3deabef19..ea7143d62e67 100644 --- a/nuxeo-webengine/nuxeo-webengine-core/src/main/resources/OSGI-INF/webengine-framework.xml +++ b/nuxeo-webengine/nuxeo-webengine-core/src/main/resources/OSGI-INF/webengine-framework.xml @@ -60,28 +60,8 @@ - @author Bogdan Stefanescu (bs@nuxeo.com) - Configure how a given path is handled by the WebEngine filter. - - If autoTx is true (which is the default) then a transaction will be - started each time a path matching the given path specification is requested. - (the transaction is started in a filter before the JAX-RS resource is called - and closed after the response is sent to the output stream). If false then no - transaction handling is done. The default is to start a transaction for any - path but: [^/]+/skin/.* - - The value attribute is required and must be used to specify the path pattern. The path - pattern is either a prefix or a regular expression. If the regex parameter - is true (the default is false) then the value will be expected to be a - regular expression. A prefix denotes a path starting with 'prefix'. Paths are - relative to the webengine servlet (i.e. they correspond to the servlet path - info in the JAX-RS servlet) - and always begin with a '/'. - - - - + Obsolete since 8.4, transactions are always active. -