You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2012/03/20 16:09:57 UTC
svn commit: r1302928 - in /chemistry/opencmis/trunk:
chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/
chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/...
Author: fmui
Date: Tue Mar 20 15:09:56 2012
New Revision: 1302928
URL: http://svn.apache.org/viewvc?rev=1302928&view=rev
Log:
CMIS-514: added configuration for threshold and temp directory
Browser Binding: changed transaction response according to the CMIS TC discussion
Added:
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/CmisWebServicesServlet.java (with props)
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/AbstractLocalService.java
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/server/CallContext.java
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/server/CmisServiceFactory.java
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/server/AbstractServiceFactory.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/CallContextImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/CmisRepositoryContextListener.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomEntryParser.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/MultiFilingService.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/PolicyService.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/VersioningService.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserBindingUtils.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/POSTHttpServletRequestWrapper.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/HttpUtils.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/WEB-INF/web.xml
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/test/java/org/apache/chemistry/opencmis/server/impl/AtomEntryParserTest.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/ConfigConstants.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DummyCallContext.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceFactoryImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/webapp/WEB-INF/classes/repository.properties
Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/AbstractLocalService.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/AbstractLocalService.java?rev=1302928&r1=1302927&r2=1302928&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/AbstractLocalService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/AbstractLocalService.java Tue Mar 20 15:09:56 2012
@@ -20,6 +20,7 @@
*/
package org.apache.chemistry.opencmis.client.bindings.spi.local;
+import java.io.File;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;
@@ -136,5 +137,13 @@ public abstract class AbstractLocalServi
public boolean isObjectInfoRequired() {
return false;
}
+
+ public File getTempDirectory() {
+ return null;
+ }
+
+ public int getMemoryThreshold() {
+ return 0;
+ }
}
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/server/CallContext.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/server/CallContext.java?rev=1302928&r1=1302927&r2=1302928&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/server/CallContext.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/server/CallContext.java Tue Mar 20 15:09:56 2012
@@ -18,6 +18,7 @@
*/
package org.apache.chemistry.opencmis.commons.server;
+import java.io.File;
import java.math.BigInteger;
/**
@@ -43,6 +44,9 @@ public interface CallContext {
String HTTP_SERVLET_REQUEST = "httpServletRequest";
String HTTP_SERVLET_RESPONSE = "httpServletResponse";
+ String TEMP_DIR = "tempDir";
+ String MEMORY_THRESHOLD = "memoryThreshold";
+
/**
* Returns the binding. Usually it returns
* {@link CallContext#BINDING_ATOMPUB},
@@ -94,4 +98,14 @@ public interface CallContext {
* Returns the content length if set, <code>null</code> otherwise
*/
BigInteger getLength();
+
+ /**
+ * Returns the temp directory.
+ */
+ File getTempDirectory();
+
+ /**
+ * Returns the memory threshold.
+ */
+ int getMemoryThreshold();
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/server/CmisServiceFactory.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/server/CmisServiceFactory.java?rev=1302928&r1=1302927&r2=1302928&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/server/CmisServiceFactory.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/server/CmisServiceFactory.java Tue Mar 20 15:09:56 2012
@@ -20,6 +20,7 @@
*/
package org.apache.chemistry.opencmis.commons.server;
+import java.io.File;
import java.util.Map;
/**
@@ -44,4 +45,22 @@ public interface CmisServiceFactory {
* {@link CmisService#close()} will be called.
*/
CmisService getService(CallContext context);
+
+ /**
+ * Returns the absolute path of the directory that should be used for
+ * temporary files.
+ *
+ * @return absolute path of temp directory
+ */
+ File getTempDirectory();
+
+ /**
+ * Returns up to which size content should be kept in memory. Documents
+ * bigger than this threshold will be cached in a temporary directory.
+ *
+ * @return the threshold in bytes
+ *
+ * @see CmisServiceFactory#getTempDirectory()
+ */
+ int getMemoryThreshold();
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/server/AbstractServiceFactory.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/server/AbstractServiceFactory.java?rev=1302928&r1=1302927&r2=1302928&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/server/AbstractServiceFactory.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/server/AbstractServiceFactory.java Tue Mar 20 15:09:56 2012
@@ -18,6 +18,7 @@
*/
package org.apache.chemistry.opencmis.commons.impl.server;
+import java.io.File;
import java.util.Map;
import org.apache.chemistry.opencmis.commons.server.CallContext;
@@ -33,4 +34,19 @@ public abstract class AbstractServiceFac
}
public abstract CmisService getService(CallContext context);
+
+ /**
+ * Returns the Java temp directory.
+ */
+ public File getTempDirectory() {
+ String tempDir = System.getProperty("java.io.tmpdir");
+ return new File(tempDir);
+ }
+
+ /**
+ * Returns a threshold of 4 MiB.
+ */
+ public int getMemoryThreshold() {
+ return 4 * 1024 * 1024;
+ }
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/CallContextImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/CallContextImpl.java?rev=1302928&r1=1302927&r2=1302928&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/CallContextImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/CallContextImpl.java Tue Mar 20 15:09:56 2012
@@ -18,6 +18,7 @@
*/
package org.apache.chemistry.opencmis.server.impl;
+import java.io.File;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;
@@ -75,6 +76,14 @@ public class CallContextImpl implements
return (BigInteger) get(LENGTH);
}
+ public File getTempDirectory() {
+ return (File) get(TEMP_DIR);
+ }
+
+ public int getMemoryThreshold() {
+ return (Integer) get(MEMORY_THRESHOLD);
+ }
+
/**
* Adds a parameter.
*/
@@ -88,5 +97,4 @@ public class CallContextImpl implements
public Object remove(String key) {
return parameter.remove(key);
}
-
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/CmisRepositoryContextListener.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/CmisRepositoryContextListener.java?rev=1302928&r1=1302927&r2=1302928&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/CmisRepositoryContextListener.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/CmisRepositoryContextListener.java Tue Mar 20 15:09:56 2012
@@ -125,7 +125,7 @@ public class CmisRepositoryContextListen
factory.init(parameters);
- log.info("Initialized Services Factory: " + parameters);
+ log.info("Initialized Services Factory: " + factory.getClass().getName());
return factory;
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomEntryParser.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomEntryParser.java?rev=1302928&r1=1302927&r2=1302928&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomEntryParser.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomEntryParser.java Tue Mar 20 15:09:56 2012
@@ -79,6 +79,9 @@ public class AtomEntryParser {
protected boolean ignoreAtomContentSrc;
+ private File tempDir;
+ private int memoryThreshold;
+
private ObjectData object;
private ContentStreamImpl atomContentStream;
private ContentStreamImpl cmisContentStream;
@@ -86,13 +89,16 @@ public class AtomEntryParser {
/**
* Constructor.
*/
- public AtomEntryParser() {
+ public AtomEntryParser(File tempDir, int memoryThreshold) {
+ this.tempDir = tempDir;
+ this.memoryThreshold = memoryThreshold;
}
/**
* Constructor that immediately parses the given stream.
*/
- public AtomEntryParser(InputStream stream) throws Exception {
+ public AtomEntryParser(InputStream stream, File tempDir, int memoryThreshold) throws Exception {
+ this(tempDir, memoryThreshold);
parse(stream);
}
@@ -382,8 +388,8 @@ public class AtomEntryParser {
/**
* Parses a tag that contains base64 encoded content.
*/
- private static ThresholdOutputStream readBase64(XMLStreamReader parser) throws Exception {
- ThresholdOutputStream bufferStream = new ThresholdOutputStream();
+ private ThresholdOutputStream readBase64(XMLStreamReader parser) throws Exception {
+ ThresholdOutputStream bufferStream = new ThresholdOutputStream(64 * 1024, tempDir, memoryThreshold);
Base64.OutputStream b64stream = new Base64.OutputStream(bufferStream, Base64.DECODE);
next(parser);
@@ -580,23 +586,25 @@ public class AtomEntryParser {
private static class ThresholdOutputStream extends OutputStream {
private static final int MAX_GROW = 10 * 1024 * 1024;
- // TODO: make threshold configurable
- private static final int THRESHOLD = 4 * 1024 * 1024;
+ private static final int DEFAULT_THRESHOLD = 4 * 1024 * 1024;
+
+ private File tempDir;
+ private int memoryThreshold;
private byte[] buf = null;
private int bufSize = 0;
private long size;
- private File tmpFile;
+ private File tempFile;
private OutputStream tmpStream;
- public ThresholdOutputStream() {
- this(64 * 1024);
- }
-
- public ThresholdOutputStream(int initSize) {
+ public ThresholdOutputStream(int initSize, File tempDir, int memoryThreshold) {
if (initSize < 0) {
throw new IllegalArgumentException("Negative initial size: " + initSize);
}
+
+ this.tempDir = tempDir;
+ this.memoryThreshold = (memoryThreshold < 0 ? DEFAULT_THRESHOLD : memoryThreshold);
+
buf = new byte[initSize];
}
@@ -605,15 +613,15 @@ public class AtomEntryParser {
return;
}
- if (bufSize + nextBufferSize > THRESHOLD) {
+ if (bufSize + nextBufferSize > memoryThreshold) {
if (tmpStream == null) {
- tmpFile = File.createTempFile("opencmis", null);
- tmpStream = new FileOutputStream(tmpFile);
+ tempFile = File.createTempFile("opencmis", null, tempDir);
+ tmpStream = new FileOutputStream(tempFile);
}
tmpStream.write(buf, 0, bufSize);
- if (buf.length != THRESHOLD) {
- buf = new byte[THRESHOLD];
+ if (buf.length != memoryThreshold) {
+ buf = new byte[memoryThreshold];
}
bufSize = 0;
@@ -685,8 +693,8 @@ public class AtomEntryParser {
// ignore
}
- if (tmpFile != null) {
- tmpFile.delete();
+ if (tempFile != null) {
+ tempFile.delete();
}
buf = null;
@@ -769,7 +777,7 @@ public class AtomEntryParser {
private boolean isDeleted = false;
public InternalTempFileInputStream() throws FileNotFoundException {
- super(new BufferedInputStream(new FileInputStream(tmpFile), THRESHOLD));
+ super(new BufferedInputStream(new FileInputStream(tempFile), 64 * 1024));
}
@Override
@@ -783,7 +791,7 @@ public class AtomEntryParser {
if (b == -1 && !isDeleted) {
super.close();
- isDeleted = tmpFile.delete();
+ isDeleted = tempFile.delete();
}
return b;
@@ -800,7 +808,7 @@ public class AtomEntryParser {
if (n == -1 && !isDeleted) {
super.close();
- isDeleted = tmpFile.delete();
+ isDeleted = tempFile.delete();
}
return n;
@@ -810,7 +818,7 @@ public class AtomEntryParser {
public void close() throws IOException {
if (!isDeleted) {
super.close();
- isDeleted = tmpFile.delete();
+ isDeleted = tempFile.delete();
}
}
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java?rev=1302928&r1=1302927&r2=1302928&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java Tue Mar 20 15:09:56 2012
@@ -43,6 +43,7 @@ import static org.apache.chemistry.openc
import static org.apache.chemistry.opencmis.server.shared.Dispatcher.METHOD_POST;
import static org.apache.chemistry.opencmis.server.shared.Dispatcher.METHOD_PUT;
+import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
@@ -91,6 +92,9 @@ public class CmisAtomPubServlet extends
private static final long serialVersionUID = 1L;
+ private File tempDir;
+ private int memoryThreshold;
+
private Dispatcher dispatcher;
private CallContextHandler callContextHandler;
@@ -109,6 +113,13 @@ public class CmisAtomPubServlet extends
}
}
+ // get memory threshold and temp directory
+ CmisServiceFactory factory = (CmisServiceFactory) config.getServletContext().getAttribute(
+ CmisRepositoryContextListener.SERVICES_FACTORY);
+
+ tempDir = factory.getTempDirectory();
+ memoryThreshold = factory.getMemoryThreshold();
+
// initialize the dispatcher
dispatcher = new Dispatcher();
@@ -163,7 +174,7 @@ public class CmisAtomPubServlet extends
CallContext context = null;
try {
context = HttpUtils.createContext(request, response, getServletContext(), CallContext.BINDING_ATOMPUB,
- callContextHandler);
+ callContextHandler, tempDir, memoryThreshold);
dispatch(context, request, response);
} catch (Exception e) {
if (e instanceof CmisPermissionDeniedException) {
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/MultiFilingService.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/MultiFilingService.java?rev=1302928&r1=1302927&r2=1302928&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/MultiFilingService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/MultiFilingService.java Tue Mar 20 15:09:56 2012
@@ -53,7 +53,7 @@ public class MultiFilingService {
// get parameters
String removeFrom = getStringParameter(request, Constants.PARAM_REMOVE_FROM);
- AtomEntryParser parser = new AtomEntryParser();
+ AtomEntryParser parser = new AtomEntryParser(context.getTempDirectory(), context.getMemoryThreshold());
parser.setIgnoreAtomContentSrc(true); // needed for some clients
parser.parse(request.getInputStream());
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java?rev=1302928&r1=1302927&r2=1302928&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java Tue Mar 20 15:09:56 2012
@@ -81,7 +81,7 @@ public final class ObjectService {
VersioningState versioningState = getEnumParameter(request, Constants.PARAM_VERSIONIG_STATE,
VersioningState.class);
- AtomEntryParser parser = new AtomEntryParser();
+ AtomEntryParser parser = new AtomEntryParser(context.getTempDirectory(), context.getMemoryThreshold());
parser.setIgnoreAtomContentSrc(true); // needed for some clients
parser.parse(request.getInputStream());
@@ -137,7 +137,8 @@ public final class ObjectService {
public static void createRelationship(CallContext context, CmisService service, String repositoryId,
HttpServletRequest request, HttpServletResponse response) throws Exception {
// get parameters
- AtomEntryParser parser = new AtomEntryParser(request.getInputStream());
+ AtomEntryParser parser = new AtomEntryParser(request.getInputStream(), context.getTempDirectory(),
+ context.getMemoryThreshold());
// execute
String newObjectId = service.createRelationship(repositoryId, parser.getProperties(), parser.getPolicyIds(),
@@ -447,7 +448,8 @@ public final class ObjectService {
String checkinComment = getStringParameter(request, Constants.PARAM_CHECKIN_COMMENT);
Boolean major = getBooleanParameter(request, Constants.PARAM_MAJOR);
- AtomEntryParser parser = new AtomEntryParser(request.getInputStream());
+ AtomEntryParser parser = new AtomEntryParser(request.getInputStream(), context.getTempDirectory(),
+ context.getMemoryThreshold());
// execute
Holder<String> objectIdHolder = new Holder<String>(objectId);
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/PolicyService.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/PolicyService.java?rev=1302928&r1=1302927&r2=1302928&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/PolicyService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/PolicyService.java Tue Mar 20 15:09:56 2012
@@ -110,7 +110,8 @@ public class PolicyService {
// get parameters
String objectId = getStringParameter(request, Constants.PARAM_ID);
- AtomEntryParser parser = new AtomEntryParser(request.getInputStream());
+ AtomEntryParser parser = new AtomEntryParser(request.getInputStream(), context.getTempDirectory(),
+ context.getMemoryThreshold());
// execute
service.applyPolicy(repositoryId, parser.getId(), objectId, null);
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/VersioningService.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/VersioningService.java?rev=1302928&r1=1302927&r2=1302928&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/VersioningService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/VersioningService.java Tue Mar 20 15:09:56 2012
@@ -53,7 +53,7 @@ public class VersioningService {
public static void checkOut(CallContext context, CmisService service, String repositoryId,
HttpServletRequest request, HttpServletResponse response) throws Exception {
// get parameters
- AtomEntryParser parser = new AtomEntryParser();
+ AtomEntryParser parser = new AtomEntryParser(context.getTempDirectory(), context.getMemoryThreshold());
parser.setIgnoreAtomContentSrc(true); // needed for some clients
parser.parse(request.getInputStream());
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserBindingUtils.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserBindingUtils.java?rev=1302928&r1=1302927&r2=1302928&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserBindingUtils.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserBindingUtils.java Tue Mar 20 15:09:56 2012
@@ -72,6 +72,7 @@ import org.apache.chemistry.opencmis.ser
public class BrowserBindingUtils {
public static final String JSON_MIME_TYPE = "application/json";
+ public static final String HTML_MIME_TYPE = "text/html";
public static final String ROOT_PATH_FRAGMENT = "root";
@@ -463,21 +464,28 @@ public class BrowserBindingUtils {
*/
public static void writeJSON(JSONStreamAware json, HttpServletRequest request, HttpServletResponse response)
throws IOException {
- response.setContentType(JSON_MIME_TYPE);
- response.setCharacterEncoding("UTF-8");
+ String transaction = getStringParameter(request, Constants.PARAM_TRANSACTION);
- String callback = getStringParameter(request, Constants.PARAM_CALLBACK);
- if (callback != null) {
- if (!callback.matches("[A-Za-z0-9._\\[\\]]*")) {
- throw new CmisInvalidArgumentException("Invalid callback name!");
+ if (transaction == null) {
+ response.setContentType(JSON_MIME_TYPE);
+ response.setCharacterEncoding("UTF-8");
+
+ String callback = getStringParameter(request, Constants.PARAM_CALLBACK);
+ if (callback != null) {
+ if (!callback.matches("[A-Za-z0-9._\\[\\]]*")) {
+ throw new CmisInvalidArgumentException("Invalid callback name!");
+ }
+ response.getWriter().print(callback + "(");
}
- response.getWriter().print(callback + "(");
- }
- json.writeJSONString(response.getWriter());
+ json.writeJSONString(response.getWriter());
- if (callback != null) {
- response.getWriter().print(");");
+ if (callback != null) {
+ response.getWriter().print(");");
+ }
+ } else {
+ response.setContentType(HTML_MIME_TYPE);
+ response.setContentLength(0);
}
response.getWriter().flush();
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java?rev=1302928&r1=1302927&r2=1302928&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java Tue Mar 20 15:09:56 2012
@@ -66,6 +66,7 @@ import static org.apache.chemistry.openc
import static org.apache.chemistry.opencmis.commons.impl.JSONConstants.ERROR_STACKTRACE;
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CONTEXT_BASETYPE_ID;
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CONTEXT_TRANSACTION;
+import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.HTML_MIME_TYPE;
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.JSON_MIME_TYPE;
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.createCookieValue;
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.prepareContext;
@@ -76,6 +77,7 @@ import static org.apache.chemistry.openc
import static org.apache.chemistry.opencmis.server.shared.Dispatcher.METHOD_POST;
import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getStringParameter;
+import java.io.File;
import java.io.IOException;
import javax.servlet.ServletConfig;
@@ -122,6 +124,9 @@ public class CmisBrowserBindingServlet e
private static final Log LOG = LogFactory.getLog(CmisBrowserBindingServlet.class.getName());
+ private File tempDir;
+ private int memoryThreshold;
+
private Dispatcher repositoryDispatcher;
private Dispatcher rootDispatcher;
private CallContextHandler callContextHandler;
@@ -141,6 +146,13 @@ public class CmisBrowserBindingServlet e
}
}
+ // get memory threshold and temp directory
+ CmisServiceFactory factory = (CmisServiceFactory) config.getServletContext().getAttribute(
+ CmisRepositoryContextListener.SERVICES_FACTORY);
+
+ tempDir = factory.getTempDirectory();
+ memoryThreshold = factory.getMemoryThreshold();
+
// initialize the dispatchers
repositoryDispatcher = new Dispatcher(false);
rootDispatcher = new Dispatcher(false);
@@ -232,7 +244,7 @@ public class CmisBrowserBindingServlet e
CallContext context = null;
try {
context = HttpUtils.createContext(request, response, getServletContext(), CallContext.BINDING_BROWSER,
- callContextHandler);
+ callContextHandler, tempDir, memoryThreshold);
dispatch(context, request, response);
} catch (Exception e) {
if (e instanceof CmisPermissionDeniedException) {
@@ -334,7 +346,8 @@ public class CmisBrowserBindingServlet e
response);
}
} else if (METHOD_POST.equals(method)) {
- POSTHttpServletRequestWrapper postRequest = new POSTHttpServletRequestWrapper(request);
+ POSTHttpServletRequestWrapper postRequest = new POSTHttpServletRequestWrapper(request, tempDir,
+ memoryThreshold);
String cmisaction = getStringParameter(postRequest, Constants.CONTROL_CMISACTION);
String objectId = getStringParameter(postRequest, Constants.CONTROL_OBJECT_ID);
@@ -419,26 +432,35 @@ public class CmisBrowserBindingServlet e
LOG.error(ex.getMessage(), ex);
}
- setStatus(request, response, statusCode);
- response.setContentType(JSON_MIME_TYPE);
- if (context != null) {
- setCookie(request, response, context.getRepositoryId(), (String) context.get(CONTEXT_TRANSACTION),
- createCookieValue(statusCode, null, exceptionName, ex.getMessage()));
- }
+ String transaction = (context == null ? null : (String) context.get(CONTEXT_TRANSACTION));
- JSONObject jsonResponse = new JSONObject();
- jsonResponse.put(ERROR_EXCEPTION, exceptionName);
- jsonResponse.put(ERROR_MESSAGE, ex.getMessage());
-
- String st = ExceptionHelper.getStacktraceAsString(ex);
- if (st != null) {
- jsonResponse.put(ERROR_STACKTRACE, st);
- }
+ if (transaction == null) {
+ setStatus(request, response, statusCode);
+ response.setContentType(JSON_MIME_TYPE);
+
+ JSONObject jsonResponse = new JSONObject();
+ jsonResponse.put(ERROR_EXCEPTION, exceptionName);
+ jsonResponse.put(ERROR_MESSAGE, ex.getMessage());
+
+ String st = ExceptionHelper.getStacktraceAsString(ex);
+ if (st != null) {
+ jsonResponse.put(ERROR_STACKTRACE, st);
+ }
- try {
- writeJSON(jsonResponse, request, response);
- } catch (Exception e) {
- LOG.error(e.getMessage(), e);
+ try {
+ writeJSON(jsonResponse, request, response);
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ }
+ } else {
+ setStatus(request, response, HttpServletResponse.SC_OK);
+ response.setContentType(HTML_MIME_TYPE);
+ response.setContentLength(0);
+
+ if (context != null) {
+ setCookie(request, response, context.getRepositoryId(), transaction,
+ createCookieValue(statusCode, null, exceptionName, ex.getMessage()));
+ }
}
}
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/POSTHttpServletRequestWrapper.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/POSTHttpServletRequestWrapper.java?rev=1302928&r1=1302927&r2=1302928&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/POSTHttpServletRequestWrapper.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/POSTHttpServletRequestWrapper.java Tue Mar 20 15:09:56 2012
@@ -18,6 +18,7 @@
*/
package org.apache.chemistry.opencmis.server.impl.browser;
+import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
@@ -48,11 +49,8 @@ public class POSTHttpServletRequestWrapp
private BigInteger size;
private InputStream stream;
- public POSTHttpServletRequestWrapper(HttpServletRequest request) throws Exception {
- this(request, 4 * 1024 * 1024);
- }
-
- public POSTHttpServletRequestWrapper(HttpServletRequest request, int memoryThreshold) throws Exception {
+ public POSTHttpServletRequestWrapper(HttpServletRequest request, File tempDir, int memoryThreshold)
+ throws Exception {
super(request);
parameters = new HashMap<String, String[]>();
@@ -66,8 +64,7 @@ public class POSTHttpServletRequestWrapp
if (isMultipart) {
if (true) {
// multipart processing - the safe way
- DiskFileItemFactory itemFactory = new DiskFileItemFactory();
- itemFactory.setSizeThreshold(memoryThreshold);
+ DiskFileItemFactory itemFactory = new DiskFileItemFactory(memoryThreshold, tempDir);
ServletFileUpload upload = new ServletFileUpload(itemFactory);
@SuppressWarnings("unchecked")
Added: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/CmisWebServicesServlet.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/CmisWebServicesServlet.java?rev=1302928&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/CmisWebServicesServlet.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/CmisWebServicesServlet.java Tue Mar 20 15:09:56 2012
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.chemistry.opencmis.server.impl.webservices;
+
+import javax.servlet.ServletConfig;
+import javax.xml.ws.WebServiceFeature;
+
+import org.apache.chemistry.opencmis.commons.server.CmisServiceFactory;
+import org.apache.chemistry.opencmis.server.impl.CmisRepositoryContextListener;
+
+import com.sun.xml.ws.api.WSFeatureList;
+import com.sun.xml.ws.developer.StreamingAttachmentFeature;
+import com.sun.xml.ws.transport.http.servlet.ServletAdapter;
+import com.sun.xml.ws.transport.http.servlet.WSServlet;
+import com.sun.xml.ws.transport.http.servlet.WSServletDelegate;
+
+public class CmisWebServicesServlet extends WSServlet {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected WSServletDelegate getDelegate(ServletConfig servletConfig) {
+ WSServletDelegate delegate = super.getDelegate(servletConfig);
+
+ // set temp directory and the threshold for all services with a
+ // StreamingAttachment annotation
+ if (delegate.adapters != null) {
+ // get the CmisService factory
+ CmisServiceFactory factory = (CmisServiceFactory) getServletContext().getAttribute(
+ CmisRepositoryContextListener.SERVICES_FACTORY);
+
+ // iterate of all adapters
+ for (ServletAdapter adapter : delegate.adapters) {
+ WSFeatureList wsfl = adapter.getEndpoint().getBinding().getFeatures();
+ for (WebServiceFeature ft : wsfl) {
+ if (ft instanceof StreamingAttachmentFeature) {
+ ((StreamingAttachmentFeature) ft).setDir(factory.getTempDirectory().getAbsolutePath());
+ ((StreamingAttachmentFeature) ft).setMemoryThreshold(factory.getMemoryThreshold());
+ }
+ }
+ }
+ }
+
+ return delegate;
+ }
+}
Propchange: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/CmisWebServicesServlet.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/HttpUtils.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/HttpUtils.java?rev=1302928&r1=1302927&r2=1302928&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/HttpUtils.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/HttpUtils.java Tue Mar 20 15:09:56 2012
@@ -18,6 +18,7 @@
*/
package org.apache.chemistry.opencmis.server.shared;
+import java.io.File;
import java.lang.reflect.Method;
import java.math.BigInteger;
import java.util.Map;
@@ -43,7 +44,8 @@ public class HttpUtils {
* Creates a {@link CallContext} object from a servlet request.
*/
public static CallContext createContext(HttpServletRequest request, HttpServletResponse response,
- ServletContext servletContext, String binding, CallContextHandler callContextHandler) {
+ ServletContext servletContext, String binding, CallContextHandler callContextHandler, File tempDir,
+ int memoryThreshold) {
String[] pathFragments = splitPath(request);
String repositoryId = null;
@@ -68,6 +70,10 @@ public class HttpUtils {
context.put(CallContext.HTTP_SERVLET_REQUEST, request);
context.put(CallContext.HTTP_SERVLET_RESPONSE, response);
+ // temp files
+ context.put(CallContext.TEMP_DIR, tempDir);
+ context.put(CallContext.MEMORY_THRESHOLD, memoryThreshold);
+
// decode range
String rangeHeader = request.getHeader("Range");
if (rangeHeader != null) {
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/WEB-INF/web.xml?rev=1302928&r1=1302927&r2=1302928&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/WEB-INF/web.xml (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/WEB-INF/web.xml Tue Mar 20 15:09:56 2012
@@ -91,7 +91,7 @@
<servlet>
<servlet-name>cmisws</servlet-name>
- <servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
+ <servlet-class>org.apache.chemistry.opencmis.server.impl.webservices.CmisWebServicesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/test/java/org/apache/chemistry/opencmis/server/impl/AtomEntryParserTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/test/java/org/apache/chemistry/opencmis/server/impl/AtomEntryParserTest.java?rev=1302928&r1=1302927&r2=1302928&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/test/java/org/apache/chemistry/opencmis/server/impl/AtomEntryParserTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/test/java/org/apache/chemistry/opencmis/server/impl/AtomEntryParserTest.java Tue Mar 20 15:09:56 2012
@@ -38,6 +38,8 @@ import org.junit.Test;
*/
public class AtomEntryParserTest {
+ private static final int THRESHOLD = 4 * 1024 * 1024;
+
private static final String CMIS_ENTRY_CONTENT = "This is my content!";
private static final String CMIS_ENTRY = "<?xml version='1.0' encoding='utf-8'?>"
+ "<atom:entry xmlns:atom=\"http://www.w3.org/2005/Atom\" xmlns:cmis=\"http://docs.oasis-open.org/ns/cmis/core/200908/\" xmlns:cmisra=\"http://docs.oasis-open.org/ns/cmis/restatom/200908/\">"
@@ -169,7 +171,7 @@ public class AtomEntryParserTest {
@Test
public void testAtomTitle() throws Exception {
- AtomEntryParser aep = new AtomEntryParser(new ByteArrayInputStream(ATOM_ENTRY_NAME.getBytes()));
+ AtomEntryParser aep = new AtomEntryParser(new ByteArrayInputStream(ATOM_ENTRY_NAME.getBytes()), null, THRESHOLD);
assertNotNull(aep);
assertNotNull(aep.getObject());
@@ -177,15 +179,15 @@ public class AtomEntryParserTest {
assertNotNull(aep.getObject().getProperties().getProperties());
assertNotNull(aep.getObject().getProperties().getProperties().get(PropertyIds.NAME) instanceof PropertyString);
- PropertyString nameProperty = (PropertyString) aep.getObject().getProperties().getProperties().get(
- PropertyIds.NAME);
+ PropertyString nameProperty = (PropertyString) aep.getObject().getProperties().getProperties()
+ .get(PropertyIds.NAME);
assertEquals("atom.title", nameProperty.getFirstValue());
}
@Test
public void testNullStream() throws Exception {
- AtomEntryParser aep = new AtomEntryParser(null);
+ AtomEntryParser aep = new AtomEntryParser(null, null, THRESHOLD);
assertNotNull(aep);
assertNull(aep.getId());
@@ -196,7 +198,7 @@ public class AtomEntryParserTest {
@Test
public void testEmptyStream() throws Exception {
- AtomEntryParser aep = new AtomEntryParser(new ByteArrayInputStream(new byte[0]));
+ AtomEntryParser aep = new AtomEntryParser(new ByteArrayInputStream(new byte[0]), null, THRESHOLD);
assertNotNull(aep);
assertNull(aep.getId());
@@ -206,7 +208,7 @@ public class AtomEntryParserTest {
}
private static byte[] parse(byte[] entry) throws Exception {
- AtomEntryParser aep = new AtomEntryParser(new ByteArrayInputStream(entry));
+ AtomEntryParser aep = new AtomEntryParser(new ByteArrayInputStream(entry), null, THRESHOLD);
ContentStream contentStream = aep.getContentStream();
assertNotNull(contentStream);
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/ConfigConstants.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/ConfigConstants.java?rev=1302928&r1=1302927&r2=1302928&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/ConfigConstants.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/ConfigConstants.java Tue Mar 20 15:09:56 2012
@@ -25,6 +25,8 @@ public class ConfigConstants {
public static final String REPOSITORY_INFO_CREATOR_CLASS = "InMemoryServer.RepositoryInfoCreatorClass";
public static final String REPOSITORY_CLASS = "InMemoryServer.Class";
public static final String OVERRIDE_CALL_CONTEXT = "InMemoryServer.OverrideCallContext";
+ public static final String MEMORY_THRESHOLD = "InMemoryServer.MemoryThreshold";
+ public static final String TEMP_DIR = "InMemoryServer.TempDir";
// Helper constants that allow to fill a repository with data on
// initialization
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DummyCallContext.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DummyCallContext.java?rev=1302928&r1=1302927&r2=1302928&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DummyCallContext.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DummyCallContext.java Tue Mar 20 15:09:56 2012
@@ -20,6 +20,7 @@
*/
package org.apache.chemistry.opencmis.inmemory;
+import java.io.File;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;
@@ -68,7 +69,7 @@ public class DummyCallContext implements
public BigInteger getLength() {
return (BigInteger) get(LENGTH);
}
-
+
public String getPassword() {
return (String) get(PASSWORD);
}
@@ -80,4 +81,12 @@ public class DummyCallContext implements
public void put(String key, String value) {
fParameter.put(key, value);
}
+
+ public File getTempDirectory() {
+ return null;
+ }
+
+ public int getMemoryThreshold() {
+ return 4 * 1024 * 1024;
+ }
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceFactoryImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceFactoryImpl.java?rev=1302928&r1=1302927&r2=1302928&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceFactoryImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceFactoryImpl.java Tue Mar 20 15:09:56 2012
@@ -18,6 +18,7 @@
*/
package org.apache.chemistry.opencmis.inmemory.server;
+import java.io.File;
import java.io.InputStream;
import java.math.BigInteger;
import java.text.SimpleDateFormat;
@@ -76,6 +77,10 @@ public class InMemoryServiceFactoryImpl
private boolean fUseOverrideCtx = false;
private StoreManager storeManager; // singleton root of everything
private CleanManager cleanManager = null;
+
+ private File tempDir;
+ private int memoryThreshold;
+
@Override
public void init(Map<String, String> parameters) {
@@ -98,6 +103,12 @@ public class InMemoryServiceFactoryImpl
storeManager = StoreManagerFactory.createInstance(repositoryClassName);
}
+ String tempDirStr = parameters.get(ConfigConstants.TEMP_DIR);
+ tempDir = (tempDirStr == null ? super.getTempDirectory() : new File(tempDirStr));
+
+ String memoryThresholdStr = parameters.get(ConfigConstants.MEMORY_THRESHOLD);
+ memoryThreshold = (memoryThresholdStr == null ? super.getMemoryThreshold(): Integer.parseInt(memoryThresholdStr));
+
Date deploymentTime = new Date();
String strDate = new SimpleDateFormat("EEE MMM dd hh:mm:ss a z yyyy", Locale.US).format(deploymentTime);
@@ -107,7 +118,8 @@ public class InMemoryServiceFactoryImpl
fillRepositoryIfConfigured(parameters);
- Long cleanInterval = ConfigurationSettings.getConfigurationValueAsLong(ConfigConstants.CLEAN_REPOSITORY_INTERVAL);
+ Long cleanInterval = ConfigurationSettings
+ .getConfigurationValueAsLong(ConfigConstants.CLEAN_REPOSITORY_INTERVAL);
if (null != cleanInterval && cleanInterval > 0) {
scheduleCleanRepositoryJob(cleanInterval);
}
@@ -121,31 +133,42 @@ public class InMemoryServiceFactoryImpl
@Override
public CmisService getService(CallContext context) {
- LOG.debug("start getService()");
+ LOG.debug("start getService()");
+
+ // Attach the CallContext to a thread local context that can be
+ // accessed from everywhere
+ // Some unit tests set their own context. So if we find one then we use
+ // this one and ignore the provided one. Otherwise we set a new context.
+ if (fUseOverrideCtx && null != OVERRIDE_CTX) {
+ context = OVERRIDE_CTX;
+ }
- // Attach the CallContext to a thread local context that can be
- // accessed from everywhere
- // Some unit tests set their own context. So if we find one then we use
- // this one and ignore the provided one. Otherwise we set a new context.
- if (fUseOverrideCtx && null != OVERRIDE_CTX) {
- context = OVERRIDE_CTX;
- }
-
- CmisServiceWrapper<InMemoryService> wrapperService = threadLocalService.get();
- if (wrapperService == null) {
- wrapperService = new CmisServiceWrapper<InMemoryService>(new InMemoryService(
- inMemoryServiceParameters, storeManager), DEFAULT_MAX_ITEMS_TYPES, DEFAULT_DEPTH_TYPES,
- DEFAULT_MAX_ITEMS_OBJECTS, DEFAULT_DEPTH_OBJECTS);
- threadLocalService.set(wrapperService);
- }
-
- wrapperService.getWrappedService().setCallContext(context);
-
- LOG.debug("stop getService()");
- return wrapperService.getWrappedService(); // wrapperService;
- }
+ CmisServiceWrapper<InMemoryService> wrapperService = threadLocalService.get();
+ if (wrapperService == null) {
+ wrapperService = new CmisServiceWrapper<InMemoryService>(new InMemoryService(inMemoryServiceParameters,
+ storeManager), DEFAULT_MAX_ITEMS_TYPES, DEFAULT_DEPTH_TYPES, DEFAULT_MAX_ITEMS_OBJECTS,
+ DEFAULT_DEPTH_OBJECTS);
+ threadLocalService.set(wrapperService);
+ }
+
+ wrapperService.getWrappedService().setCallContext(context);
+
+ LOG.debug("stop getService()");
+ return wrapperService.getWrappedService(); // wrapperService;
+ }
@Override
+ public File getTempDirectory() {
+ return tempDir;
+ }
+
+ @Override
+ public int getMemoryThreshold() {
+ return memoryThreshold;
+ }
+
+
+ @Override
public void destroy() {
if (null != cleanManager) {
cleanManager.stopCleanRepositoryJob();
@@ -156,7 +179,7 @@ public class InMemoryServiceFactoryImpl
public StoreManager getStoreManger() {
return storeManager;
}
-
+
private void initStorageManager(Map<String, String> parameters) {
// initialize in-memory management
String repositoryClassName = (String) parameters.get(ConfigConstants.REPOSITORY_CLASS);
@@ -187,7 +210,8 @@ public class InMemoryServiceFactoryImpl
}
}
- // check if a type definitions XML file is configured. if yes import type definitions
+ // check if a type definitions XML file is configured. if yes import
+ // type definitions
String typeDefsFileName = parameters.get(ConfigConstants.TYPE_XML);
if (null == typeDefsFileName)
LOG.info("No file name for type definitions given, no types will be created.");
@@ -204,7 +228,7 @@ public class InMemoryServiceFactoryImpl
}
private void importTypesFromFile(TypeManagerCreatable tmc, String typeDefsFileName) {
-
+
InputStream is = this.getClass().getResourceAsStream("/" + typeDefsFileName);
if (null == is) {
@@ -217,11 +241,12 @@ public class InMemoryServiceFactoryImpl
TypeDefinition typeDef = null;
Unmarshaller u = InMemoryJaxbHelper.createUnmarshaller();
JAXBElement<TypeDefinitions> types = (JAXBElement<TypeDefinitions>) u.unmarshal(is);
- for (CmisTypeDefinitionType td: types.getValue().getTypeDefinitions()) {
+ for (CmisTypeDefinitionType td : types.getValue().getTypeDefinitions()) {
LOG.debug("Found type in file: " + td.getLocalName());
typeDef = Converter.convert(td);
if (typeDef.getPropertyDefinitions() == null) {
- ((AbstractTypeDefinition)typeDef).setPropertyDefinitions( new LinkedHashMap<String, PropertyDefinition<?>>());
+ ((AbstractTypeDefinition) typeDef)
+ .setPropertyDefinitions(new LinkedHashMap<String, PropertyDefinition<?>>());
}
tmc.addTypeDefinition(typeDef);
}
@@ -231,173 +256,188 @@ public class InMemoryServiceFactoryImpl
}
private static List<String> readPropertiesToSetFromConfig(Map<String, String> parameters, String keyPrefix) {
- List<String> propsToSet = new ArrayList<String>();
- for (int i = 0;; ++i) {
- String propertyKey = keyPrefix + Integer.toString(i);
- String propertyToAdd = parameters.get(propertyKey);
- if (null == propertyToAdd) {
- break;
- } else {
- propsToSet.add(propertyToAdd);
+ List<String> propsToSet = new ArrayList<String>();
+ for (int i = 0;; ++i) {
+ String propertyKey = keyPrefix + Integer.toString(i);
+ String propertyToAdd = parameters.get(propertyKey);
+ if (null == propertyToAdd) {
+ break;
+ } else {
+ propsToSet.add(propertyToAdd);
+ }
}
- }
- return propsToSet;
+ return propsToSet;
}
-
private void fillRepositoryIfConfigured(Map<String, String> parameters) {
- class DummyCallContext implements CallContext {
-
- public String get(String key) {
- return null;
- }
+ class DummyCallContext implements CallContext {
- public String getBinding() {
- return null;
- }
+ public String get(String key) {
+ return null;
+ }
- public boolean isObjectInfoRequired() {
- return false;
- }
+ public String getBinding() {
+ return null;
+ }
- public String getRepositoryId() {
- return null;
- }
+ public boolean isObjectInfoRequired() {
+ return false;
+ }
- public String getLocale() {
- return null;
- }
+ public String getRepositoryId() {
+ return null;
+ }
- public BigInteger getOffset() {
- return null;
- }
+ public String getLocale() {
+ return null;
+ }
- public BigInteger getLength() {
- return null;
- }
+ public BigInteger getOffset() {
+ return null;
+ }
- public String getPassword() {
- return null;
- }
+ public BigInteger getLength() {
+ return null;
+ }
- public String getUsername() {
- return null;
- }
- }
+ public String getPassword() {
+ return null;
+ }
-// List<String> allAvailableRepositories = storeManager.getAllRepositoryIds();
- String repositoryId = parameters.get(ConfigConstants.REPOSITORY_ID);
- String doFillRepositoryStr = parameters.get(ConfigConstants.USE_REPOSITORY_FILER);
- String contentKindStr = parameters.get(ConfigConstants.CONTENT_KIND);
- boolean doFillRepository = doFillRepositoryStr == null ? false : Boolean.parseBoolean(doFillRepositoryStr);
+ public String getUsername() {
+ return null;
+ }
- if (doFillRepository /* && !allAvailableRepositories.contains(repositoryId) */ ) {
+ public File getTempDirectory() {
- // create an initial temporary service instance to fill the repository
+ return null;
+ }
- InMemoryService svc = new InMemoryService(inMemoryServiceParameters, storeManager);
+ public int getMemoryThreshold() {
+ return 0;
+ }
+ }
- BindingsObjectFactory objectFactory = new BindingsObjectFactoryImpl();
+ // List<String> allAvailableRepositories =
+ // storeManager.getAllRepositoryIds();
+ String repositoryId = parameters.get(ConfigConstants.REPOSITORY_ID);
+ String doFillRepositoryStr = parameters.get(ConfigConstants.USE_REPOSITORY_FILER);
+ String contentKindStr = parameters.get(ConfigConstants.CONTENT_KIND);
+ boolean doFillRepository = doFillRepositoryStr == null ? false : Boolean.parseBoolean(doFillRepositoryStr);
+
+ if (doFillRepository /*
+ * &&
+ * !allAvailableRepositories.contains(repositoryId)
+ */) {
+
+ // create an initial temporary service instance to fill the
+ // repository
+
+ InMemoryService svc = new InMemoryService(inMemoryServiceParameters, storeManager);
+
+ BindingsObjectFactory objectFactory = new BindingsObjectFactoryImpl();
+
+ String levelsStr = parameters.get(ConfigConstants.FILLER_DEPTH);
+ int levels = 1;
+ if (null != levelsStr) {
+ levels = Integer.parseInt(levelsStr);
+ }
- String levelsStr = parameters.get(ConfigConstants.FILLER_DEPTH);
- int levels = 1;
- if (null != levelsStr) {
- levels = Integer.parseInt(levelsStr);
- }
+ String docsPerLevelStr = parameters.get(ConfigConstants.FILLER_DOCS_PER_FOLDER);
+ int docsPerLevel = 1;
+ if (null != docsPerLevelStr) {
+ docsPerLevel = Integer.parseInt(docsPerLevelStr);
+ }
- String docsPerLevelStr = parameters.get(ConfigConstants.FILLER_DOCS_PER_FOLDER);
- int docsPerLevel = 1;
- if (null != docsPerLevelStr) {
- docsPerLevel = Integer.parseInt(docsPerLevelStr);
- }
+ String childrenPerLevelStr = parameters.get(ConfigConstants.FILLER_FOLDERS_PER_FOLDER);
+ int childrenPerLevel = 2;
+ if (null != childrenPerLevelStr) {
+ childrenPerLevel = Integer.parseInt(childrenPerLevelStr);
+ }
- String childrenPerLevelStr = parameters.get(ConfigConstants.FILLER_FOLDERS_PER_FOLDER);
- int childrenPerLevel = 2;
- if (null != childrenPerLevelStr) {
- childrenPerLevel = Integer.parseInt(childrenPerLevelStr);
- }
+ String documentTypeId = parameters.get(ConfigConstants.FILLER_DOCUMENT_TYPE_ID);
+ if (null == documentTypeId) {
+ documentTypeId = BaseTypeId.CMIS_DOCUMENT.value();
+ }
- String documentTypeId = parameters.get(ConfigConstants.FILLER_DOCUMENT_TYPE_ID);
- if (null == documentTypeId) {
- documentTypeId = BaseTypeId.CMIS_DOCUMENT.value();
- }
+ String folderTypeId = parameters.get(ConfigConstants.FILLER_FOLDER_TYPE_ID);
+ if (null == folderTypeId) {
+ folderTypeId = BaseTypeId.CMIS_FOLDER.value();
+ }
- String folderTypeId = parameters.get(ConfigConstants.FILLER_FOLDER_TYPE_ID);
- if (null == folderTypeId) {
- folderTypeId = BaseTypeId.CMIS_FOLDER.value();
- }
+ int contentSizeKB = 0;
+ String contentSizeKBStr = parameters.get(ConfigConstants.FILLER_CONTENT_SIZE);
+ if (null != contentSizeKBStr) {
+ contentSizeKB = Integer.parseInt(contentSizeKBStr);
+ }
- int contentSizeKB = 0;
- String contentSizeKBStr = parameters.get(ConfigConstants.FILLER_CONTENT_SIZE);
- if (null != contentSizeKBStr) {
- contentSizeKB = Integer.parseInt(contentSizeKBStr);
- }
-
- ObjectGenerator.CONTENT_KIND contentKind;
- if (null == contentKindStr)
- contentKind = ObjectGenerator.CONTENT_KIND.LoremIpsumText;
- else {
- if (contentKindStr.equals("static/text"))
- contentKind = ObjectGenerator.CONTENT_KIND.StaticText;
- else if (contentKindStr.equals("lorem/text"))
+ ObjectGenerator.CONTENT_KIND contentKind;
+ if (null == contentKindStr)
contentKind = ObjectGenerator.CONTENT_KIND.LoremIpsumText;
- else if (contentKindStr.equals("lorem/html"))
- contentKind = ObjectGenerator.CONTENT_KIND.LoremIpsumHtml;
- else if (contentKindStr.equals("fractal/jpeg"))
- contentKind = ObjectGenerator.CONTENT_KIND.ImageFractalJpeg;
- else
- contentKind = ObjectGenerator.CONTENT_KIND.StaticText;
- }
- // Create a hierarchy of folders and fill it with some documents
- ObjectGenerator gen = new ObjectGenerator(objectFactory, svc, svc, svc, repositoryId,
- contentKind);
-
- gen.setNumberOfDocumentsToCreatePerFolder(docsPerLevel);
-
- // Set the type id for all created documents:
- gen.setDocumentTypeId(documentTypeId);
-
- // Set the type id for all created folders:
- gen.setFolderTypeId(folderTypeId);
-
- // Set contentSize
- gen.setContentSizeInKB(contentSizeKB);
-
- // set properties that need to be filled
- // set the properties the generator should fill with values for
- // documents:
- // Note: must be valid properties in configured document and folder type
-
- List<String> propsToSet = readPropertiesToSetFromConfig(parameters, ConfigConstants.FILLER_DOCUMENT_PROPERTY);
- if (null != propsToSet) {
- gen.setDocumentPropertiesToGenerate(propsToSet);
- }
-
- propsToSet = readPropertiesToSetFromConfig(parameters, ConfigConstants.FILLER_FOLDER_PROPERTY);
- if (null != propsToSet) {
- gen.setFolderPropertiesToGenerate(propsToSet);
- }
-
- // Simulate a runtime context with configuration parameters
- // Attach the CallContext to a thread local context that can be accessed
- // from everywhere
- DummyCallContext ctx = new DummyCallContext();
- svc.setCallContext(ctx);
-
- // Build the tree
- RepositoryInfo rep = svc.getRepositoryInfo(repositoryId, null);
- String rootFolderId = rep.getRootFolderId();
-
- try {
- gen.createFolderHierachy(levels, childrenPerLevel, rootFolderId);
- // Dump the tree
- gen.dumpFolder(rootFolderId, "*");
- } catch (Exception e) {
- LOG.error("Could not create folder hierarchy with documents. " + e);
- e.printStackTrace();
- }
- } // if
+ else {
+ if (contentKindStr.equals("static/text"))
+ contentKind = ObjectGenerator.CONTENT_KIND.StaticText;
+ else if (contentKindStr.equals("lorem/text"))
+ contentKind = ObjectGenerator.CONTENT_KIND.LoremIpsumText;
+ else if (contentKindStr.equals("lorem/html"))
+ contentKind = ObjectGenerator.CONTENT_KIND.LoremIpsumHtml;
+ else if (contentKindStr.equals("fractal/jpeg"))
+ contentKind = ObjectGenerator.CONTENT_KIND.ImageFractalJpeg;
+ else
+ contentKind = ObjectGenerator.CONTENT_KIND.StaticText;
+ }
+ // Create a hierarchy of folders and fill it with some documents
+ ObjectGenerator gen = new ObjectGenerator(objectFactory, svc, svc, svc, repositoryId, contentKind);
+
+ gen.setNumberOfDocumentsToCreatePerFolder(docsPerLevel);
+
+ // Set the type id for all created documents:
+ gen.setDocumentTypeId(documentTypeId);
+
+ // Set the type id for all created folders:
+ gen.setFolderTypeId(folderTypeId);
+
+ // Set contentSize
+ gen.setContentSizeInKB(contentSizeKB);
+
+ // set properties that need to be filled
+ // set the properties the generator should fill with values for
+ // documents:
+ // Note: must be valid properties in configured document and folder
+ // type
+
+ List<String> propsToSet = readPropertiesToSetFromConfig(parameters,
+ ConfigConstants.FILLER_DOCUMENT_PROPERTY);
+ if (null != propsToSet) {
+ gen.setDocumentPropertiesToGenerate(propsToSet);
+ }
+
+ propsToSet = readPropertiesToSetFromConfig(parameters, ConfigConstants.FILLER_FOLDER_PROPERTY);
+ if (null != propsToSet) {
+ gen.setFolderPropertiesToGenerate(propsToSet);
+ }
+
+ // Simulate a runtime context with configuration parameters
+ // Attach the CallContext to a thread local context that can be
+ // accessed
+ // from everywhere
+ DummyCallContext ctx = new DummyCallContext();
+ svc.setCallContext(ctx);
+
+ // Build the tree
+ RepositoryInfo rep = svc.getRepositoryInfo(repositoryId, null);
+ String rootFolderId = rep.getRootFolderId();
+
+ try {
+ gen.createFolderHierachy(levels, childrenPerLevel, rootFolderId);
+ // Dump the tree
+ gen.dumpFolder(rootFolderId, "*");
+ } catch (Exception e) {
+ LOG.error("Could not create folder hierarchy with documents. " + e);
+ e.printStackTrace();
+ }
+ } // if
} // fillRepositoryIfConfigured
@@ -406,12 +446,12 @@ public class InMemoryServiceFactoryImpl
private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
ScheduledFuture<?> cleanerHandle = null;
- public void startCleanRepositoryJob (long intervalInMinutes) {
+ public void startCleanRepositoryJob(long intervalInMinutes) {
final Runnable cleaner = new Runnable() {
public void run() {
LOG.info("Cleaning repository as part of a scheduled maintenance job.");
- for(String repositoryId: storeManager.getAllRepositoryIds()) {
+ for (String repositoryId : storeManager.getAllRepositoryIds()) {
ObjectStore store = storeManager.getObjectStore(repositoryId);
store.clear();
fillRepositoryIfConfigured(ConfigurationSettings.getParameters());
@@ -422,8 +462,8 @@ public class InMemoryServiceFactoryImpl
};
LOG.info("Repository Clean Job starting clean job, interval " + intervalInMinutes + " min");
- cleanerHandle =
- scheduler.scheduleAtFixedRate(cleaner, intervalInMinutes, intervalInMinutes, TimeUnit.MINUTES);
+ cleanerHandle = scheduler.scheduleAtFixedRate(cleaner, intervalInMinutes, intervalInMinutes,
+ TimeUnit.MINUTES);
}
public void stopCleanRepositoryJob() {
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/webapp/WEB-INF/classes/repository.properties
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/webapp/WEB-INF/classes/repository.properties?rev=1302928&r1=1302927&r2=1302928&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/webapp/WEB-INF/classes/repository.properties (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/webapp/WEB-INF/classes/repository.properties Tue Mar 20 15:09:56 2012
@@ -26,6 +26,9 @@ InMemoryServer.Password=dummysecret
InMemoryServer.TypesCreatorClass=org.apache.chemistry.opencmis.inmemory.types.DefaultTypeSystemCreator
InMemoryServer.TypeDefinitionsFile=types.xml
+# InMemoryServer.MemoryThreshold=10485760
+# InMemoryServer.TempDir=/path/to/your/tmp
+
# settings for init repository with data
# enable or disable
RepositoryFiller.Enable=true