exo-jcr SVN: r450 - in jcr/trunk/exo.jcr.component.webdav/src: main/java/org/exoplatform/services/jcr/webdav/command and 1 other directories.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2009-10-30 06:57:51 -0400 (Fri, 30 Oct 2009)
New Revision: 450
Added:
jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/CacheControlType.java
Modified:
jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavServiceImpl.java
jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java
jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCashing.java
Log:
EXOJCR-178 Implemented mechanizm to manage caching using regexps
Modified: jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavServiceImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavServiceImpl.java 2009-10-30 10:56:26 UTC (rev 449)
+++ jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavServiceImpl.java 2009-10-30 10:57:51 UTC (rev 450)
@@ -131,11 +131,11 @@
* Initialization "auto-version"-parameter value.
*/
public static final String INIT_PARAM_AUTO_VERSION = "auto-version";
-
+
public static final String INIT_PARAM_CACHE_CONTROL = "cache-control";
-
- public static HashMap<String, String> cacheControlMap = new HashMap<String, String>();
+ private HashMap<MediaType, String> cacheControlMap = new HashMap<MediaType, String>();
+
/**
* Logger.
*/
@@ -260,19 +260,27 @@
ValueParam pCacheControl = params.getValueParam(INIT_PARAM_CACHE_CONTROL);
if (pCacheControl != null)
{
- String cacheControlValue = pCacheControl.getValue();
- for (String element : cacheControlValue.split(";"))
+ String cacheControlConfigValue = pCacheControl.getValue();
+
+ try
{
- String contentTypes = element.split(":")[0];
- String value = element.split(":")[1];
- String[] types = contentTypes.split(",");
- for (String type : types)
+ String[] elements = cacheControlConfigValue.split(";");
+ for (String element : elements)
{
- cacheControlMap.put(type, value);
+ String cacheValue = element.split(":")[1];
+ String keys = element.split(":")[0];
+ for (String key : keys.split(","))
+ {
+ MediaType mediaType = new MediaType(key.split("/")[0], key.split("/")[1]);
+ cacheControlMap.put(mediaType, cacheValue);
+ }
}
-
}
- log.info(INIT_PARAM_CACHE_CONTROL + " = " + pCacheControl);
+ catch (Exception e)
+ {
+ log.warn("Invalid " + INIT_PARAM_CACHE_CONTROL + " parameter");
+ }
+
}
}
Modified: jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java 2009-10-30 10:56:26 UTC (rev 449)
+++ jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java 2009-10-30 10:57:51 UTC (rev 450)
@@ -18,11 +18,25 @@
*/
package org.exoplatform.services.jcr.webdav.command;
+import java.io.InputStream;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.xml.transform.stream.StreamSource;
+
import org.exoplatform.common.http.HTTPStatus;
import org.exoplatform.common.util.HierarchicalProperty;
import org.exoplatform.services.jcr.webdav.Range;
-import org.exoplatform.services.jcr.webdav.WebDavServiceImpl;
-import org.exoplatform.services.jcr.webdav.WebDavConst.CacheConstants;
import org.exoplatform.services.jcr.webdav.resource.CollectionResource;
import org.exoplatform.services.jcr.webdav.resource.FileResource;
import org.exoplatform.services.jcr.webdav.resource.Resource;
@@ -38,21 +52,8 @@
import org.exoplatform.services.log.Log;
import org.exoplatform.services.rest.ExtHttpHeaders;
import org.exoplatform.services.rest.ext.provider.XSLTStreamingOutput;
+import org.exoplatform.services.rest.impl.header.MediaTypeHelper;
-import java.io.InputStream;
-import java.net.URI;
-import java.util.HashMap;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.PathNotFoundException;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.xml.transform.stream.StreamSource;
-
/**
* Created by The eXo Platform SAS Author : <a
* href="gavrikvetal(a)gmail.com">Vitaly Guly</a>.
@@ -80,7 +81,7 @@
* @param ranges ranges
* @return the instance of javax.ws.rs.core.Response
*/
- public Response get(Session session, String path, String version, String baseURI, List<Range> ranges, String ifModifiedSince, HashMap<String, String> cahceControls)
+ public Response get(Session session, String path, String version, String baseURI, List<Range> ranges, String ifModifiedSince, HashMap<MediaType, String> cahceControls)
{
if (version == null)
@@ -267,18 +268,24 @@
* @param contentType content type
* @return Cache-Control value
*/
- private String generateCacheControl(HashMap<String, String> controls, String contentType)
+ private String generateCacheControl(HashMap<MediaType, String> cacheControlMap, String contentType)
{
+ ArrayList<MediaType> mediaTypesList = new ArrayList<MediaType>(cacheControlMap.keySet());
+ Collections.sort(mediaTypesList, MediaTypeHelper.MEDIA_TYPE_COMPARATOR);
+ String cacheControlValue = "";
- if (controls.containsKey(contentType))
+ for (MediaType mediaType : mediaTypesList)
{
- return controls.get(contentType);
+ if(contentType.equals(MediaType.WILDCARD)){
+ cacheControlValue = cacheControlMap.get(MediaType.WILDCARD_TYPE);
+ break;
+ } else if (mediaType.isCompatible(new MediaType(contentType.split("/")[0], contentType.split("/")[1]) )) {
+ cacheControlValue = cacheControlMap.get(mediaType);
+ break;
+ }
}
- else
- {
- return CacheConstants.NO_CACHE;
- }
+ return cacheControlValue;
}
}
Added: jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/CacheControlType.java
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/CacheControlType.java (rev 0)
+++ jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/CacheControlType.java 2009-10-30 10:57:51 UTC (rev 450)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.webdav.ext;
+
+/**
+ * @author <a href="mailto:dmitry.kataev@exoplatform.com">Dmytro Katayev</a>
+ * @version $Id: $
+ *
+ */
+public class CacheControlType
+{
+ private String contentType;
+ private String cacheValue;
+
+ /**
+ * @return the cacheValue
+ */
+ public String getCacheValue()
+ {
+ return cacheValue;
+ }
+
+ /**
+ * @return the contentType
+ */
+ public String getContentType()
+ {
+ return contentType;
+ }
+
+ public CacheControlType(String contentType, String cacheValue)
+ {
+ this.contentType = contentType;
+ this.cacheValue = cacheValue;
+ }
+
+
+}
Property changes on: jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/CacheControlType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCashing.java
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCashing.java 2009-10-30 10:56:26 UTC (rev 449)
+++ jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCashing.java 2009-10-30 10:57:51 UTC (rev 450)
@@ -21,6 +21,7 @@
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Locale;
import java.util.TimeZone;
@@ -43,11 +44,10 @@
*/
public class TestCashing extends BaseStandaloneTest
{
-
private String path = TestUtils.getFileName();
private String fileContent = TestUtils.getFileContent();
-
+
private Node node;
@Override
@@ -58,8 +58,8 @@
node = TestUtils.addContent(session, path, inputStream, defaultFileNodeType, "");
}
-
- public void testIfModifiedSince() throws Exception{
+ public void testIfModifiedSince() throws Exception
+ {
Node contentNode = node.getNode("jcr:content");
Property lastModifiedProperty = contentNode.getProperty("jcr:lastModified");
String formatPattern = "EEE, dd MMM yyyy HH:mm:ss z";
@@ -71,20 +71,28 @@
ContainerResponse response = service(WebDAVMethods.GET, getPathWS() + path, "", headers, null);
assertEquals(HTTPStatus.NOT_MODIFIED, response.getStatus());
}
-
- public void testCacheConf() throws Exception {
+
+ public void testCacheConf() throws Exception
+ {
+ ArrayList<CacheControlType> testValues = new ArrayList<CacheControlType>();
+ testValues.add(new CacheControlType("text/xml", "max-age=1800"));
+ testValues.add(new CacheControlType("text/pdf", "max-age=777"));
+ testValues.add(new CacheControlType("image/jpg", "max-age=3600"));
+ testValues.add(new CacheControlType("image/gif", "max-age=555"));
+ testValues.add(new CacheControlType("test/test", "no-cache"));
+ testValues.add(new CacheControlType("*/*", "no-cache"));
+
Node contentNode = node.getNode("jcr:content");
- contentNode.setProperty("jcr:mimeType", "text/xml");
- contentNode.getSession().save();
- ContainerResponse response = service(WebDAVMethods.GET, getPathWS() + path, "", null, null);
- String cacheControlHeader = response.getHttpHeaders().get(HttpHeaders.CACHE_CONTROL).toString();
- assertEquals(cacheControlHeader, "[max-age=1800]");
-
- contentNode.setProperty("jcr:mimeType", "image/jpeg");
- contentNode.getSession().save();
- response = service(WebDAVMethods.GET, getPathWS() + path, "", null, null);
- cacheControlHeader = response.getHttpHeaders().get(HttpHeaders.CACHE_CONTROL).toString();
- assertEquals(cacheControlHeader, "[max-age=3600]");
+
+ for (CacheControlType cacheControlType : testValues)
+ {
+ contentNode.setProperty("jcr:mimeType", cacheControlType.getContentType());
+ contentNode.getSession().save();
+ ContainerResponse response = service(WebDAVMethods.GET, getPathWS() + path, "", null, null);
+ String cacheControlHeader = response.getHttpHeaders().get(HttpHeaders.CACHE_CONTROL).toString();
+ cacheControlHeader = cacheControlHeader.substring(1, cacheControlHeader.length() - 1);
+ assertEquals(cacheControlHeader, cacheControlType.getCacheValue());
+ }
}
@Override
14 years, 6 months
exo-jcr SVN: r449 - ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest.
by do-not-reply@jboss.org
Author: aparfonov
Date: 2009-10-30 06:56:26 -0400 (Fri, 30 Oct 2009)
New Revision: 449
Modified:
ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/RequestHandler.java
Log:
EXOJCR-185 :
Modified: ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/RequestHandler.java
===================================================================
--- ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/RequestHandler.java 2009-10-30 10:54:42 UTC (rev 448)
+++ ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/RequestHandler.java 2009-10-30 10:56:26 UTC (rev 449)
@@ -29,11 +29,6 @@
{
/**
- * Temporary directory attribute name.
- */
- public static final String WS_RS_TMP_DIR = "ws.rs.tmpdir";
-
- /**
* Max buffer size attribute name. Entities that has size greater then
* specified will be stored in temporary directory on file system during
* entity processing.
14 years, 6 months
exo-jcr SVN: r448 - in ws/branches/2.2.x/rest/core/src: main/java/org/exoplatform/services/rest/impl/provider and 1 other directories.
by do-not-reply@jboss.org
Author: aparfonov
Date: 2009-10-30 06:54:42 -0400 (Fri, 30 Oct 2009)
New Revision: 448
Added:
ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/FileCollector.java
Modified:
ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/RequestHandlerImpl.java
ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/provider/DataSourceEntityProvider.java
ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/provider/FileEntityProvider.java
ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/provider/MultipartFormDataEntityProvider.java
ws/branches/2.2.x/rest/core/src/test/java/org/exoplatform/services/rest/impl/BaseTest.java
ws/branches/2.2.x/rest/core/src/test/java/org/exoplatform/services/rest/impl/RequestDispatcherTest.java
Log:
EXOJCR-185 :
Added: ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/FileCollector.java
===================================================================
--- ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/FileCollector.java (rev 0)
+++ ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/FileCollector.java 2009-10-30 10:54:42 UTC (rev 448)
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.rest.impl;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:andrey.parfonov@exoplatform.com">Andrey Parfonov</a>
+ * @version $Id$
+ */
+public final class FileCollector
+{
+
+ private static class FileCollectorHolder
+ {
+ private static final FileCollector INSTANCE =
+ new FileCollector(System.getProperty("java.io.tmpdir") + File.separator + "ws_jaxrs");
+ }
+
+ public static FileCollector getInstance()
+ {
+ return FileCollectorHolder.INSTANCE;
+ }
+
+ private final File store;
+
+ private FileCollector(String pathname)
+ {
+ store = new File(pathname);
+ if (!store.exists())
+ store.mkdirs();
+ Runtime.getRuntime().addShutdownHook(new Thread()
+ {
+ public void run()
+ {
+ clean();
+ }
+ });
+ }
+
+ /**
+ * Clean all files in storage.
+ */
+ public void clean()
+ {
+ for (File file : store.listFiles())
+ delete(file);
+ }
+
+ /**
+ * Create file with specified <code>fileName</code> in storage.
+ *
+ * @param fileName file name
+ * @return newly created file
+ * @throws IOException if any i/o error occurs
+ */
+ public File createFile(String fileName) throws IOException
+ {
+ return new File(store, fileName);
+ }
+
+ /**
+ * Create new file with generated name in storage.
+ *
+ * @param fileName file name
+ * @return newly created file
+ * @throws IOException if any i/o error occurs
+ */
+ public File createFile() throws IOException
+ {
+ return File.createTempFile("jaxrs", ".tmp", store);
+ }
+
+ public File getStore()
+ {
+ return store;
+ }
+
+ private void delete(File file)
+ {
+ if (file.isDirectory())
+ {
+ File[] children = file.listFiles();
+ if (children.length > 0)
+ {
+ for (File ch : children)
+ delete(ch);
+ }
+ }
+ file.delete();
+ }
+
+}
Property changes on: ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/FileCollector.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/RequestHandlerImpl.java
===================================================================
--- ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/RequestHandlerImpl.java 2009-10-30 00:11:01 UTC (rev 447)
+++ ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/RequestHandlerImpl.java 2009-10-30 10:54:42 UTC (rev 448)
@@ -18,7 +18,6 @@
*/
package org.exoplatform.services.rest.impl;
-import java.io.File;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashMap;
@@ -261,41 +260,4 @@
}
}
- /**
- * Startup initialization.
- */
- public void init()
- {
- // Directory for temporary files
- final File tmpDir;
- String tmpDirName = properties.get(WS_RS_TMP_DIR);
- if (tmpDirName == null)
- {
- tmpDir = new File(System.getProperty("java.io.tmpdir") + File.separator + "ws_jaxrs");
- properties.put(WS_RS_TMP_DIR, tmpDir.getPath());
- }
- else
- {
- tmpDir = new File(tmpDirName);
- }
-
- if (!tmpDir.exists())
- tmpDir.mkdirs();
-
- // Register Shutdown Hook for cleaning temporary files.
- Runtime.getRuntime().addShutdownHook(new Thread()
- {
- public void run()
- {
- File[] files = tmpDir.listFiles();
- for (File file : files)
- {
- if (file.exists())
- file.delete();
- }
- }
- });
-
- }
-
}
Modified: ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/provider/DataSourceEntityProvider.java
===================================================================
--- ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/provider/DataSourceEntityProvider.java 2009-10-30 00:11:01 UTC (rev 447)
+++ ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/provider/DataSourceEntityProvider.java 2009-10-30 10:54:42 UTC (rev 448)
@@ -21,6 +21,7 @@
import org.exoplatform.services.rest.ApplicationContext;
import org.exoplatform.services.rest.RequestHandler;
import org.exoplatform.services.rest.impl.ApplicationContextImpl;
+import org.exoplatform.services.rest.impl.FileCollector;
import org.exoplatform.services.rest.provider.EntityProvider;
import java.io.ByteArrayOutputStream;
@@ -138,7 +139,7 @@
return new ByteArrayDataSource(bout.toByteArray(), mimeType);
// large data, use file
- final File file = File.createTempFile("datasource", "tmp");
+ final File file = FileCollector.getInstance().createFile();
OutputStream fout = new FileOutputStream(file);
// copy data from byte array in file
Modified: ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/provider/FileEntityProvider.java
===================================================================
--- ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/provider/FileEntityProvider.java 2009-10-30 00:11:01 UTC (rev 447)
+++ ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/provider/FileEntityProvider.java 2009-10-30 10:54:42 UTC (rev 448)
@@ -18,6 +18,7 @@
*/
package org.exoplatform.services.rest.impl.provider;
+import org.exoplatform.services.rest.impl.FileCollector;
import org.exoplatform.services.rest.provider.EntityProvider;
import java.io.File;
@@ -55,7 +56,7 @@
public File readFrom(Class<File> type, Type genericType, Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException
{
- File f = File.createTempFile("ws_rs", "tmp");
+ File f = FileCollector.getInstance().createFile();
OutputStream out = new FileOutputStream(f);
try
{
Modified: ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/provider/MultipartFormDataEntityProvider.java
===================================================================
--- ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/provider/MultipartFormDataEntityProvider.java 2009-10-30 00:11:01 UTC (rev 447)
+++ ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/provider/MultipartFormDataEntityProvider.java 2009-10-30 10:54:42 UTC (rev 448)
@@ -25,6 +25,7 @@
import org.exoplatform.services.rest.ApplicationContext;
import org.exoplatform.services.rest.RequestHandler;
import org.exoplatform.services.rest.impl.ApplicationContextImpl;
+import org.exoplatform.services.rest.impl.FileCollector;
import org.exoplatform.services.rest.provider.EntityProvider;
import java.io.File;
@@ -100,9 +101,8 @@
context.getProperties().get(RequestHandler.WS_RS_BUFFER_SIZE) == null
? RequestHandler.WS_RS_BUFFER_SIZE_VALUE : Integer.parseInt((String)context.getProperties().get(
RequestHandler.WS_RS_BUFFER_SIZE));
- File repo = new File((String)context.getProperties().get(RequestHandler.WS_RS_TMP_DIR));
-
- DefaultFileItemFactory factory = new DefaultFileItemFactory(bufferSize, repo);
+
+ DefaultFileItemFactory factory = new DefaultFileItemFactory(bufferSize, FileCollector.getInstance().getStore());
FileUpload upload = new FileUpload(factory);
return upload.parseRequest(httpRequest).iterator();
}
Modified: ws/branches/2.2.x/rest/core/src/test/java/org/exoplatform/services/rest/impl/BaseTest.java
===================================================================
--- ws/branches/2.2.x/rest/core/src/test/java/org/exoplatform/services/rest/impl/BaseTest.java 2009-10-30 00:11:01 UTC (rev 447)
+++ ws/branches/2.2.x/rest/core/src/test/java/org/exoplatform/services/rest/impl/BaseTest.java 2009-10-30 10:54:42 UTC (rev 448)
@@ -47,7 +47,6 @@
{
resources = new ResourceBinderImpl();
requestHandler = new RequestHandlerImpl(resources, new SimpleDependencySupplier());
- requestHandler.init();
// reset providers to be sure it is clean
ProviderBinder.setInstance(new ProviderBinder());
Modified: ws/branches/2.2.x/rest/core/src/test/java/org/exoplatform/services/rest/impl/RequestDispatcherTest.java
===================================================================
--- ws/branches/2.2.x/rest/core/src/test/java/org/exoplatform/services/rest/impl/RequestDispatcherTest.java 2009-10-30 00:11:01 UTC (rev 447)
+++ ws/branches/2.2.x/rest/core/src/test/java/org/exoplatform/services/rest/impl/RequestDispatcherTest.java 2009-10-30 10:54:42 UTC (rev 448)
@@ -50,7 +50,6 @@
depInjector.put(InjectableComponent2.class, new InjectableComponent2());
requestHandler = new RequestHandlerImpl(resources, depInjector);
- requestHandler.init();
// reset providers to be sure it is clean
ProviderBinder.setInstance(new ProviderBinder());
14 years, 6 months
exo-jcr SVN: r447 - jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-10-29 20:11:01 -0400 (Thu, 29 Oct 2009)
New Revision: 447
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java
Log:
EXOJCR-201: cache loader
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java 2009-10-30 00:08:52 UTC (rev 446)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java 2009-10-30 00:11:01 UTC (rev 447)
@@ -49,12 +49,11 @@
* @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter Nedonosko</a>
* @version $Id$
*/
-public class ExoJCRCacheLoader
- implements CacheLoader
+public class ExoJCRCacheLoader implements CacheLoader
{
- private CacheSPI cache;
+ //private CacheSPI cache;
- private RegionManager regionManager;
+ //private RegionManager regionManager;
private IndividualCacheLoaderConfig config;
@@ -94,7 +93,7 @@
*/
public boolean exists(Fqn name) throws Exception
{
- // TODO Auto-generated method stub
+ // TODO use get(Fqn), i.e. get Node!=null
return false;
}
@@ -103,7 +102,7 @@
*/
public Map<Object, Object> get(Fqn name) throws Exception
{
- // TODO Auto-generated method stub
+ // TODO get Node
return null;
}
@@ -112,7 +111,7 @@
*/
public Set<?> getChildrenNames(Fqn fqn) throws Exception
{
- // TODO Auto-generated method stub
+ // TODO get child nodes names
return null;
}
@@ -165,7 +164,7 @@
*/
private void doModified(List<Modification> modifications) throws Exception
{
- JDBCStorageConnection jdbcConnection = (JDBCStorageConnection) dataContainer.openConnection();
+ JDBCStorageConnection jdbcConnection = (JDBCStorageConnection)dataContainer.openConnection();
try
{
@@ -175,7 +174,7 @@
switch (md.getType())
{
case PUT_KEY_VALUE :
- doModifiedAddOrUpdate(md, jdbcConnection);
+ doAddOrUpdate(md, jdbcConnection);
break;
case REMOVE_NODE :
doRemove(md, jdbcConnection, "TODO $<Node identifier>");
@@ -194,15 +193,15 @@
}
private void doRemove(Modification modification, JDBCStorageConnection jdbcConnection, String identifier)
- throws IllegalStateException, RepositoryException
+ throws IllegalStateException, RepositoryException
{
ItemData itemData = jdbcConnection.getItemData(identifier);
if (itemData instanceof NodeData)
- jdbcConnection.delete((NodeData) itemData);
+ jdbcConnection.delete((NodeData)itemData);
if (itemData instanceof PropertyData)
- jdbcConnection.delete((PropertyData) itemData);
+ jdbcConnection.delete((PropertyData)itemData);
}
/**
@@ -212,13 +211,13 @@
* @throws IllegalStateException
* @throws RepositoryException
*/
- private void doModifiedAddOrUpdate(Modification modification, JDBCStorageConnection jdbcConnection)
- throws IllegalStateException, RepositoryException
+ private void doAddOrUpdate(Modification modification, JDBCStorageConnection jdbcConnection)
+ throws IllegalStateException, RepositoryException
{
if (modification.getValue() instanceof NodeData)
{
//add or update node data
- NodeData nodeData = (NodeData) modification.getValue();
+ NodeData nodeData = (NodeData)modification.getValue();
ItemData itemData = jdbcConnection.getItemData(nodeData.getIdentifier());
@@ -236,7 +235,7 @@
else if (modification.getValue() instanceof PropertyData)
{
//add or update property data
- PropertyData propertyData = (PropertyData) modification.getValue();
+ PropertyData propertyData = (PropertyData)modification.getValue();
ItemData itemData = jdbcConnection.getItemData(propertyData.getIdentifier());
@@ -258,6 +257,7 @@
*/
public Object put(Fqn name, Object key, Object value) throws Exception
{
+ // i.e. put Property
return null;
}
@@ -266,6 +266,8 @@
*/
public void put(Fqn name, Map<Object, Object> attributes) throws Exception
{
+ // i.e. put set of Properties
+
// TODO Auto-generated method stub
}
@@ -275,6 +277,7 @@
*/
public void put(List<Modification> modifications) throws Exception
{
+
// TODO Auto-generated method stub
}
@@ -284,6 +287,7 @@
*/
public Object remove(Fqn fqn, Object key) throws Exception
{
+ // i.e. remove Property
// TODO Auto-generated method stub
return null;
}
@@ -293,6 +297,8 @@
*/
public void remove(Fqn fqn) throws Exception
{
+ // i.e. remove Node
+
// TODO Auto-generated method stub
}
@@ -302,6 +308,8 @@
*/
public void removeData(Fqn fqn) throws Exception
{
+ // i.e. remove all Properties of Node
+
// TODO Auto-generated method stub
}
@@ -319,8 +327,7 @@
*/
public void setCache(CacheSPI c)
{
- this.cache = c;
-
+ //this.cache = c;
}
/**
@@ -337,7 +344,7 @@
*/
public void setRegionManager(RegionManager manager)
{
- this.regionManager = manager;
+ //this.regionManager = manager;
}
/**
14 years, 6 months
exo-jcr SVN: r446 - in jcr/branches/1.12.0-JBC/component/core/src: test/resources/conf/standalone and 1 other directory.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-10-29 20:08:52 -0400 (Thu, 29 Oct 2009)
New Revision: 446
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-configuration.xml
Log:
EXOJCR-200: storage connection debug code
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-10-29 21:54:44 UTC (rev 445)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-10-30 00:08:52 UTC (rev 446)
@@ -129,7 +129,7 @@
{
startBatch();
cache.put(makeNodeFqn(data.getQPath()), ITEM_ID, data.getIdentifier());
- cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data);
+ cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data); // treePrint(treeRoot);
}
/**
@@ -192,6 +192,7 @@
NodeData node = (NodeData)cache.get(makeIdFqn(childId), ITEM_DATA);
if (node == null)
{
+ treePrint(treeRoot);
throw new RepositoryException("One of childs is null. Parent " + parent.getQPath().getAsString());
}
childs.add(node);
@@ -200,6 +201,22 @@
return childs;
}
+ private void treePrint(Node<Serializable, Object> node)
+ {
+ for (Node<Serializable, Object> child : node.getChildren())
+ {
+ System.out.println(child.toString());
+ for (Serializable key : child.getKeys())
+ {
+ System.out.println("\t" + key + "=" + child.get(key));
+ }
+ if (!child.isLeaf())
+ {
+ treePrint(child);
+ }
+ }
+ }
+
/**
* {@inheritDoc}
*/
@@ -358,10 +375,15 @@
*/
public void commit() throws IllegalStateException, RepositoryException
{
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("commit " + batchStarted);
+ }
+
// end batch
if (batchStarted)
{
- this.cache.endBatch(true);
+ this.cache.endBatch(true); // treePrint(treeRoot);
batchStarted = false;
}
else
@@ -376,6 +398,11 @@
*/
public void rollback() throws IllegalStateException, RepositoryException
{
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("rollback " + batchStarted);
+ }
+
// rollback batch
if (batchStarted)
{
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-configuration.xml
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-configuration.xml 2009-10-29 21:54:44 UTC (rev 445)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-configuration.xml 2009-10-30 00:08:52 UTC (rev 446)
@@ -54,18 +54,8 @@
<property name="log4j.appender.file.layout.ConversionPattern"
value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n"/>
- <property name="log4j.category.jcr.FileCleaner" value="DEBUG"/>
-
- <!-- property name="log4j.category.jcr.JDBCStorageConnection" value="DEBUG"/>
- <property name="log4j.category.jcr.NodeImpl" value="DEBUG"/ -->
-
- <!-- property name="log4j.category.jcr.WorkspaceStorageCacheImpl" value="DEBUG"/ -->
- <!-- property name="log4j.category.database.DBSchemaCreator" value="DEBUG"/ -->
- <!-- property name="log4j.category.jcr.WorkspaceDataReplicator" value="DEBUG"/ -->
-
- <!-- property name="log4j.category.jcr.WorkspaceStorageCacheImpl" value="DEBUG"/ -->
- <!-- property name="log4j.category.jcr.WorkspacePersistentDataManager" value="DEBUG"/ -->
- <!-- property name="log4j.category.jcr.SessionDataManager" value="DEBUG"/ -->
+ <property name="log4j.category.jcr.JBossCacheStorageConnection" value="DEBUG"/>
+ <!-- property name="log4j.category.jcr.NodeImpl" value="DEBUG"/ -->
</properties-param>
<!-- value-param>
14 years, 6 months
exo-jcr SVN: r445 - in kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container: definition and 1 other directory.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2009-10-29 17:54:44 -0400 (Thu, 29 Oct 2009)
New Revision: 445
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/PortalContainer.java
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/RootContainer.java
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java
Log:
EXOJCR-166: Support separated ear delivery
* The PortalContainerContext must not be used as context of a init task
* PortalContainer.getInstance(ServletContext) could return a bad value if the PortalContainer set in the ThreadLocal was not cleaned properly
* We ensure that the PortalContainer set in the ThreadLocal has been set properly
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/PortalContainer.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/PortalContainer.java 2009-10-29 16:49:03 UTC (rev 444)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/PortalContainer.java 2009-10-29 21:54:44 UTC (rev 445)
@@ -319,7 +319,7 @@
*/
public static PortalContainer getInstance()
{
- PortalContainer container = (PortalContainer)currentContainer_.get();
+ PortalContainer container = getInstanceIfPresent();
if (container == null)
{
container = RootContainer.getInstance().getPortalContainer(DEFAULT_PORTAL_CONTAINER_NAME);
@@ -334,7 +334,27 @@
*/
public static PortalContainer getInstanceIfPresent()
{
- return currentContainer_.get();
+ PortalContainer pc = currentContainer_.get();
+ if (pc != null)
+ {
+ ExoContainer container = ExoContainerContext.getCurrentContainerIfPresent();
+ if (container != pc)
+ {
+ // Clean the value of currentContainer_ since it should be equals to
+ // ExoContainerContext.getCurrentContainerIfPresent()
+ if (container instanceof PortalContainer)
+ {
+ // The current container is a PortalContainer, this value will replace the old one
+ currentContainer_.set(pc = (PortalContainer)container);
+ }
+ else
+ {
+ // The current container is not a PortalContainer, the old value must be removed
+ currentContainer_.set(pc = null);
+ }
+ }
+ }
+ return pc;
}
/**
@@ -402,9 +422,9 @@
{
return null;
}
- List<String> portalContainerNames = CONFIG.getPortalContainerNames(context.getServletContextName());
+ String portalContainerName = CONFIG.getPortalContainerName(context.getServletContextName());
RootContainer root = RootContainer.getInstance();
- return root.getPortalContainer(portalContainerNames.get(0));
+ return root.getPortalContainer(portalContainerName);
}
/**
@@ -425,14 +445,7 @@
}
else
{
- PortalContainer pContainer = PortalContainer.getInstanceIfPresent();
- if (pContainer == null)
- {
- if (log.isDebugEnabled())
- log.debug("No portal container has been set in the ThreadLoal of PortalContainer");
- pContainer = PortalContainer.getInstance(context);
- }
- return pContainer;
+ return PortalContainer.getInstance(context);
}
}
@@ -560,7 +573,7 @@
public static Object getComponent(Class key)
{
- PortalContainer pcontainer = (PortalContainer)currentContainer_.get();
+ PortalContainer pcontainer = getInstanceIfPresent();
return pcontainer.getComponentInstanceOfType(key);
}
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/RootContainer.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/RootContainer.java 2009-10-29 16:49:03 UTC (rev 444)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/RootContainer.java 2009-10-29 21:54:44 UTC (rev 445)
@@ -566,18 +566,10 @@
{
while ((context = queue.poll()) != null)
{
- if (context.getServletContextName().equals(portalContainer.getName()))
- {
- context.getTask().execute(portalContainer.getPortalContext(), portalContainer);
- }
- else
- {
- // The current servlet context is not the context of the portal
- // Set the context classloader of the related web application
- Thread.currentThread().setContextClassLoader(context.getWebappClassLoader());
- hasChanged = true;
- context.getTask().execute(context.getServletContext(), portalContainer);
- }
+ // Set the context classloader of the related web application
+ Thread.currentThread().setContextClassLoader(context.getWebappClassLoader());
+ hasChanged = true;
+ context.getTask().execute(context.getServletContext(), portalContainer);
}
}
finally
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java 2009-10-29 16:49:03 UTC (rev 444)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java 2009-10-29 21:54:44 UTC (rev 445)
@@ -219,6 +219,31 @@
}
/**
+ * Gives the portal container names for which the web application is available if several
+ * portal container are available only the fist one will be returned
+ * @param contextName the context name of the web application
+ * @return the portal container names for which the web application is available
+ */
+ public String getPortalContainerName(String contextName)
+ {
+ if (contextName == null)
+ {
+ throw new IllegalArgumentException("The context name cannot be null");
+ }
+ if (portalContainerNames.contains(contextName))
+ {
+ // The given context name is a context name of a portal container
+ return contextName;
+ }
+ final List<String> result = scopes.get(contextName);
+ if (result == null || result.isEmpty())
+ {
+ // we assume the old behavior is expected
+ return defaultPortalContainerName;
+ }
+ return result.get(0);
+ }
+ /**
* Gives all the dependencies related to the given portal container
* @param portalContainerName the name of the portal container for which we want the dependencies
* @return a list of sorted context names
14 years, 6 months
exo-jcr SVN: r444 - in jcr/branches/1.12.0-JBC/component/core/src: test/java/org/exoplatform/services/jcr/impl/storage/jbosscache and 1 other directory.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-10-29 12:49:03 -0400 (Thu, 29 Oct 2009)
New Revision: 444
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java
Log:
EXOJCR-200: storage connection getItem(s) tests
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-10-29 15:19:46 UTC (rev 443)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-10-29 16:49:03 UTC (rev 444)
@@ -214,7 +214,6 @@
List<PropertyData> childs = new ArrayList<PropertyData>();
- // TODO keys Serializable shoudl be!!!
for (Serializable key : parentNode.getKeys())
{
if (!key.equals(ITEM_ID))
@@ -255,9 +254,7 @@
// TODO check performance of Node vs Property get
- String itemName = name.getAsString(true);
-
- String propertyId = (String)parentNode.get(itemName);
+ String propertyId = (String)parentNode.get(name.getAsString());
if (propertyId != null)
{
// it's Property Item
@@ -266,7 +263,7 @@
else
{
// it's Node Item
- Node<Serializable, Object> node = parentNode.getChild(itemName); // TODO String not Fqn?
+ Node<Serializable, Object> node = parentNode.getChild(name.getAsString(true)); // TODO String not Fqn?
if (node != null)
{
String nodeId = (String)node.get(ITEM_ID);
@@ -275,7 +272,6 @@
return (NodeData)cache.get(makeIdFqn(nodeId), ITEM_DATA);
}
}
-
}
return null;
@@ -308,7 +304,6 @@
startBatch();
// TODO move Node to a new position at the tree,
// but prev location was in prev DELETE.
-
}
/**
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java 2009-10-29 15:19:46 UTC (rev 443)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java 2009-10-29 16:49:03 UTC (rev 444)
@@ -36,13 +36,11 @@
*/
package org.exoplatform.services.jcr.impl.storage.jbosscache;
-import java.io.Serializable;
-import java.util.List;
-
import junit.framework.TestCase;
import org.exoplatform.services.jcr.access.AccessControlList;
import org.exoplatform.services.jcr.datamodel.InternalQName;
+import org.exoplatform.services.jcr.datamodel.ItemData;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
@@ -55,6 +53,9 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
+import java.io.Serializable;
+import java.util.List;
+
/**
* Created by The eXo Platform SAS.
*
@@ -215,7 +216,7 @@
// check in tree
treePrint(tree);
-
+
Node<Serializable, Object> rootNode =
tree.getChild(Fqn.fromElements(Constants.ROOT_PATH.getEntries()[Constants.ROOT_PATH.getEntries().length - 1]
.getAsString(true)));
@@ -237,12 +238,12 @@
//System.out.println(key);
//index++;
}
-
+
// check in items
treePrint(items);
- assertNotNull("Property item data should exists",items.getChild(Fqn.fromElements(propId1)));
- assertNotNull("Property item data should exists",items.getChild(Fqn.fromElements(propId2)));
+ assertNotNull("Property item data should exists", items.getChild(Fqn.fromElements(propId1)));
+ assertNotNull("Property item data should exists", items.getChild(Fqn.fromElements(propId2)));
}
public void testDeleteNode() throws Exception
@@ -274,7 +275,7 @@
// check in tree
treePrint(tree);
-
+
Node<Serializable, Object> node =
rootNode.getChild(Fqn
.fromElements(node1path.getEntries()[node1path.getEntries().length - 1].getAsString(true)));
@@ -289,12 +290,12 @@
child.getFqn().getLastElementAsString());
assertEquals("Node id wrong", Constants.SYSTEM_UUID, (String)child.get(JBossCacheStorageConnection.ITEM_ID));
-
+
// check in items
treePrint(items);
assertNull("Node item data should not exists", items.getChild(Fqn.fromElements(node1id)));
- assertNotNull("Node item data should not exists", items.getChild(Fqn.fromElements(Constants.SYSTEM_UUID)));
+ assertNotNull("Node item data should exists", items.getChild(Fqn.fromElements(Constants.SYSTEM_UUID)));
}
public void testDeleteProperty() throws Exception
@@ -330,17 +331,123 @@
assertNull("Property should be deleted", rootNode.get(Constants.JCR_PRIMARYTYPE.getAsString()));
assertNotNull("Property should exists", rootNode.get(Constants.JCR_MIXINTYPES.getAsString()));
-
+
// check in items
treePrint(items);
- assertNull("Property item data should not exists",items.getChild(Fqn.fromElements(propId1)));
- assertNotNull("Property item data should not exists",items.getChild(Fqn.fromElements(propId2)));
+ assertNull("Property item data should not exists", items.getChild(Fqn.fromElements(propId1)));
+ assertNotNull("Property item data should exists", items.getChild(Fqn.fromElements(propId2)));
}
+ public void testGetNodeByName() throws Exception
+ {
+ // TODO prepare using JCR WDC API (not a right way, JBC API better... but read assumes the write works)
+ // add root (/)
+ conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
+
+ // add node (/node)
+ String node1id = "1";
+ QPath node1path = QPath.parse("[]:1[]node:1");
+ conn.add(new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
+ Constants.ROOT_UUID, new AccessControlList()));
+
+ // add /jcr:system
+ conn.add(new TransientNodeData(Constants.JCR_SYSTEM_PATH, Constants.SYSTEM_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_UUID, new AccessControlList()));
+
+ // check
+ ItemData nodeItem =
+ conn.getItemData(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()),
+ node1path.getEntries()[node1path.getEntries().length - 1]);
+
+ assertTrue("Node expected", nodeItem.isNode());
+ assertEquals("Node id wrong", node1id, nodeItem.getIdentifier());
+ assertEquals("Node path wrong", node1path, nodeItem.getQPath());
+ }
+
+ public void testGetPropertyByName() throws Exception
+ {
+ // TODO prepare using JCR WDC API (not a right way, JBC API better... but read assumes the write works)
+ // add root (/)
+ conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
+
+ // add property (/jcr:primaryType)
+ String propId1 = "1";
+ QPath propPath1 = QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_PRIMARYTYPE);
+ conn.add(new TransientPropertyData(propPath1, propId1, 1, 1, Constants.ROOT_UUID, false));
+
+ // add property (/jcr:mixinTypes)
+ String propId2 = "2";
+ QPath propPath2 = QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_MIXINTYPES);
+ conn.add(new TransientPropertyData(propPath2, propId2, 1, 1, Constants.ROOT_UUID, false));
+
+ // check
+ ItemData propItem =
+ conn.getItemData(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()),
+ propPath1.getEntries()[propPath1.getEntries().length - 1]);
+
+ assertFalse("Proeprty expected", propItem.isNode());
+ assertEquals("Proeprty id wrong", propId1, propItem.getIdentifier());
+ assertEquals("Proeprty path wrong", propPath1, propItem.getQPath());
+ }
+
+ public void testGetNodeById() throws Exception
+ {
+ // TODO prepare using JCR WDC API (not a right way, JBC API better... but read assumes the write works)
+ // add root (/)
+ conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
+
+ // add node (/node)
+ String node1id = "1";
+ QPath node1path = QPath.parse("[]:1[]node:1");
+ conn.add(new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
+ Constants.ROOT_UUID, new AccessControlList()));
+
+ // add /jcr:system
+ conn.add(new TransientNodeData(Constants.JCR_SYSTEM_PATH, Constants.SYSTEM_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_UUID, new AccessControlList()));
+
+ // check
+ ItemData nodeItem = conn.getItemData(node1id);
+
+ assertTrue("Node expected", nodeItem.isNode());
+ assertEquals("Node id wrong", node1id, nodeItem.getIdentifier());
+ assertEquals("Node path wrong", node1path, nodeItem.getQPath());
+ }
+
+ public void testGetPropertyById() throws Exception
+ {
+ // TODO prepare using JCR WDC API (not a right way, JBC API better... but read assumes the write works)
+ // add root (/)
+ conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
+
+ // add property (/jcr:primaryType)
+ String propId1 = "1";
+ QPath propPath1 = QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_PRIMARYTYPE);
+ conn.add(new TransientPropertyData(propPath1, propId1, 1, 1, Constants.ROOT_UUID, false));
+
+ // add property (/jcr:mixinTypes)
+ String propId2 = "2";
+ QPath propPath2 = QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_MIXINTYPES);
+ conn.add(new TransientPropertyData(propPath2, propId2, 1, 1, Constants.ROOT_UUID, false));
+
+ // check
+ ItemData propItem = conn.getItemData(propId1);
+
+ assertFalse("Proeprty expected", propItem.isNode());
+ assertEquals("Proeprty id wrong", propId1, propItem.getIdentifier());
+ assertEquals("Proeprty path wrong", propPath1, propItem.getQPath());
+ }
+
public void testGetChildNodes() throws Exception
{
- // prepare using JCR WDC API (not right way, JBC API better... but read assumes the write works)
+ // TODO prepare using JCR WDC API (not a right way, JBC API better... but read assumes the write works)
// add root (/)
conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
@@ -357,7 +464,7 @@
// check in tree
treePrint(tree);
-
+
List<NodeData> childs =
conn.getChildNodesData(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1,
Constants.NT_UNSTRUCTURED, new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
@@ -378,12 +485,12 @@
{
fail("Wrong Node found");
}
- }
+ }
}
public void testGetChildProperties() throws Exception
{
- // prepare using JCR WDC API (not right way, JBC API better... but read assumes the write works)
+ // TODO prepare using JCR WDC API (not a right way, JBC API better... but read assumes the write works)
// add root (/)
conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
14 years, 6 months
exo-jcr SVN: r443 - kernel/trunk/exo.kernel.commons/src/main/java/org/exoplatform/commons/utils.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-10-29 11:19:46 -0400 (Thu, 29 Oct 2009)
New Revision: 443
Modified:
kernel/trunk/exo.kernel.commons/src/main/java/org/exoplatform/commons/utils/QName.java
Log:
EXOJCR-2: comments cleanup
Modified: kernel/trunk/exo.kernel.commons/src/main/java/org/exoplatform/commons/utils/QName.java
===================================================================
--- kernel/trunk/exo.kernel.commons/src/main/java/org/exoplatform/commons/utils/QName.java 2009-10-29 15:08:09 UTC (rev 442)
+++ kernel/trunk/exo.kernel.commons/src/main/java/org/exoplatform/commons/utils/QName.java 2009-10-29 15:19:46 UTC (rev 443)
@@ -36,12 +36,10 @@
protected final int hashCode;
- // [PN] 05.02.07 use of canonical representation for the string values
- // see: http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html#intern()
public QName(String namespace, String name)
{
this.namespace = (namespace != null ? namespace : "").intern();
- this.name = (name != null ? name : ""); // [PN] 28.01.08 .intern()
+ this.name = (name != null ? name : "");
this.stringName = ("[" + this.namespace + "]" + this.name);
14 years, 6 months
exo-jcr SVN: r442 - in jcr/branches/1.12.0-JBC/component/core/src: test/java/org/exoplatform/services/jcr/impl/storage/jbosscache and 1 other directory.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-10-29 11:08:09 -0400 (Thu, 29 Oct 2009)
New Revision: 442
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java
Log:
EXOJCR-200: storage connection deletes, adds with full check
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-10-29 09:34:52 UTC (rev 441)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-10-29 15:08:09 UTC (rev 442)
@@ -165,8 +165,7 @@
{
startBatch();
// delete attr on parent by key=PropertyName
- cache.remove(makeParentFqn(data.getQPath()),
- data.getQPath().getEntries()[data.getQPath().getEntries().length - 1].getAsString(true));
+ cache.remove(makeParentFqn(data.getQPath()), data.getQPath().getName().getAsString());
cache.removeNode(makeIdFqn(data.getIdentifier()));
}
@@ -220,7 +219,7 @@
{
if (!key.equals(ITEM_ID))
{
- String propId = (String) parentNode.get(key);
+ String propId = (String)parentNode.get(key);
// TODO NodeData or PropertyData? As ItemData check then and cast.
PropertyData property = (PropertyData)cache.get(makeIdFqn(propId), ITEM_DATA);
if (property == null)
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java 2009-10-29 09:34:52 UTC (rev 441)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java 2009-10-29 15:08:09 UTC (rev 442)
@@ -158,7 +158,7 @@
conn.add(new TransientNodeData(Constants.JCR_SYSTEM_PATH, Constants.SYSTEM_UUID, 1, Constants.NT_UNSTRUCTURED,
new InternalQName[0], 0, Constants.ROOT_UUID, new AccessControlList()));
- // test
+ // check in tree
treePrint(tree);
// get root node ([]:1)
@@ -189,6 +189,12 @@
fail("Wrong Node name " + nodeName);
}
}
+
+ // check in items
+ treePrint(items);
+
+ Node<Serializable, Object> itemsNode = items.getChild(Fqn.fromElements(node1id));
+ assertNotNull("Node item data should exists", itemsNode);
}
public void testAddProperty() throws Exception
@@ -207,9 +213,9 @@
conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_MIXINTYPES), propId2,
1, 1, Constants.ROOT_UUID, false));
- // test
+ // check in tree
treePrint(tree);
-
+
Node<Serializable, Object> rootNode =
tree.getChild(Fqn.fromElements(Constants.ROOT_PATH.getEntries()[Constants.ROOT_PATH.getEntries().length - 1]
.getAsString(true)));
@@ -231,6 +237,12 @@
//System.out.println(key);
//index++;
}
+
+ // check in items
+ treePrint(items);
+
+ assertNotNull("Property item data should exists",items.getChild(Fqn.fromElements(propId1)));
+ assertNotNull("Property item data should exists",items.getChild(Fqn.fromElements(propId2)));
}
public void testDeleteNode() throws Exception
@@ -254,15 +266,15 @@
tree.getChild(Fqn.fromElements(Constants.ROOT_PATH.getEntries()[Constants.ROOT_PATH.getEntries().length - 1]
.getAsString(true)));
- assertEquals("Childs expected", 2, rootNode.getChildren().size());
+ assertEquals("Number of childs wrong", 2, rootNode.getChildren().size());
// delete /node
conn.delete(new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
Constants.ROOT_UUID, new AccessControlList()));
- // test
+ // check in tree
treePrint(tree);
-
+
Node<Serializable, Object> node =
rootNode.getChild(Fqn
.fromElements(node1path.getEntries()[node1path.getEntries().length - 1].getAsString(true)));
@@ -277,8 +289,55 @@
child.getFqn().getLastElementAsString());
assertEquals("Node id wrong", Constants.SYSTEM_UUID, (String)child.get(JBossCacheStorageConnection.ITEM_ID));
+
+ // check in items
+ treePrint(items);
+
+ assertNull("Node item data should not exists", items.getChild(Fqn.fromElements(node1id)));
+ assertNotNull("Node item data should not exists", items.getChild(Fqn.fromElements(Constants.SYSTEM_UUID)));
}
+ public void testDeleteProperty() throws Exception
+ {
+ // add root (/)
+ conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
+
+ // add property (/jcr:primaryType)
+ String propId1 = "1";
+ conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_PRIMARYTYPE), propId1,
+ 1, 1, Constants.ROOT_UUID, false));
+
+ // add property (/jcr:mixinTypes)
+ String propId2 = "2";
+ conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_MIXINTYPES), propId2,
+ 1, 1, Constants.ROOT_UUID, false));
+
+ // get root node ([]:1)
+ Node<Serializable, Object> rootNode =
+ tree.getChild(Fqn.fromElements(Constants.ROOT_PATH.getEntries()[Constants.ROOT_PATH.getEntries().length - 1]
+ .getAsString(true)));
+
+ // delete /jcr:primaryType
+ conn.delete(new TransientPropertyData(QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_PRIMARYTYPE),
+ propId1, 1, 1, Constants.ROOT_UUID, false));
+
+ // check in tree
+ treePrint(tree);
+
+ assertEquals("Number of childs wrong", 2, rootNode.getKeys().size());
+
+ assertNull("Property should be deleted", rootNode.get(Constants.JCR_PRIMARYTYPE.getAsString()));
+
+ assertNotNull("Property should exists", rootNode.get(Constants.JCR_MIXINTYPES.getAsString()));
+
+ // check in items
+ treePrint(items);
+
+ assertNull("Property item data should not exists",items.getChild(Fqn.fromElements(propId1)));
+ assertNotNull("Property item data should not exists",items.getChild(Fqn.fromElements(propId2)));
+ }
+
public void testGetChildNodes() throws Exception
{
// prepare using JCR WDC API (not right way, JBC API better... but read assumes the write works)
@@ -296,7 +355,9 @@
conn.add(new TransientNodeData(Constants.JCR_SYSTEM_PATH, Constants.SYSTEM_UUID, 1, Constants.NT_UNSTRUCTURED,
new InternalQName[0], 0, Constants.ROOT_UUID, new AccessControlList()));
- // check
+ // check in tree
+ treePrint(tree);
+
List<NodeData> childs =
conn.getChildNodesData(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1,
Constants.NT_UNSTRUCTURED, new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
@@ -317,7 +378,7 @@
{
fail("Wrong Node found");
}
- }
+ }
}
public void testGetChildProperties() throws Exception
@@ -351,7 +412,7 @@
// check
treePrint(tree);
-
+
List<PropertyData> childs =
conn.getChildPropertiesData(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1,
Constants.NT_UNSTRUCTURED, new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
14 years, 6 months
exo-jcr SVN: r441 - core/trunk.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2009-10-29 05:34:52 -0400 (Thu, 29 Oct 2009)
New Revision: 441
Modified:
core/trunk/pom.xml
Log:
EXOJCR-217 groovy-all dependency version updated to 1.6.5; was 1.5.7
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2009-10-28 19:21:30 UTC (rev 440)
+++ core/trunk/pom.xml 2009-10-29 09:34:52 UTC (rev 441)
@@ -294,7 +294,7 @@
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
- <version>1.5.7</version>
+ <version>1.6.5</version>
</dependency>
<dependency>
14 years, 6 months