exo-jcr SVN: r2676 - in jcr/trunk/exo.jcr.component.webdav/src: test/java/org/exoplatform/services/jcr/webdav/ext and 1 other directory.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-06-22 05:23:36 -0400 (Tue, 22 Jun 2010)
New Revision: 2676
Added:
jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCaching.java
Modified:
jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java
Log:
EXOJCR-774 If-Modified-Since management fixed,
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 2010-06-21 17:06:59 UTC (rev 2675)
+++ jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java 2010-06-22 09:23:36 UTC (rev 2676)
@@ -20,7 +20,9 @@
import org.exoplatform.common.http.HTTPStatus;
import org.exoplatform.common.util.HierarchicalProperty;
+import org.exoplatform.commons.utils.ISO8601;
import org.exoplatform.services.jcr.webdav.Range;
+import org.exoplatform.services.jcr.webdav.WebDavConst;
import org.exoplatform.services.jcr.webdav.resource.CollectionResource;
import org.exoplatform.services.jcr.webdav.resource.FileResource;
import org.exoplatform.services.jcr.webdav.resource.Resource;
@@ -40,8 +42,11 @@
import java.io.InputStream;
import java.net.URI;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Date;
import java.util.HashMap;
import java.util.List;
@@ -82,7 +87,7 @@
* @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<MediaType, String> cahceControls)
+ String ifModifiedSince, HashMap<MediaType, String> cacheControls)
{
if (version == null)
{
@@ -125,9 +130,18 @@
}
// check before any other reads
- if ((ifModifiedSince != null) && (ifModifiedSince.equals(lastModifiedProperty.getValue())))
+
+ if (ifModifiedSince != null)
{
- return Response.notModified().entity("Not Modified").build();
+ DateFormat dateFormat = new SimpleDateFormat(WebDavConst.DateFormat.IF_MODIFIED_SINCE_PATTERN);
+ Date lastModifiedDate = dateFormat.parse(lastModifiedProperty.getValue());
+
+ dateFormat = new SimpleDateFormat(WebDavConst.DateFormat.MODIFICATION);
+ Date ifModifiedSinceDate = dateFormat.parse(ifModifiedSince);
+
+ if(ifModifiedSinceDate.getTime() >= lastModifiedDate.getTime()){
+ return Response.notModified().entity("Not Modified").build();
+ }
}
HierarchicalProperty contentLengthProperty = resource.getProperty(FileResource.GETCONTENTLENGTH);
@@ -148,7 +162,7 @@
return Response.ok().header(HttpHeaders.CONTENT_LENGTH, Long.toString(contentLength)).header(
ExtHttpHeaders.ACCEPT_RANGES, "bytes").header(ExtHttpHeaders.LAST_MODIFIED,
lastModifiedProperty.getValue()).header(ExtHttpHeaders.CACHE_CONTROL,
- generateCacheControl(cahceControls, contentType)).entity(istream).type(contentType).build();
+ generateCacheControl(cacheControls, contentType)).entity(istream).type(contentType).build();
}
// one range
Copied: jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCaching.java (from rev 2675, 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/TestCaching.java (rev 0)
+++ jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCaching.java 2010-06-22 09:23:36 UTC (rev 2676)
@@ -0,0 +1,128 @@
+/*
+ * 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;
+
+import org.exoplatform.common.http.HTTPStatus;
+import org.exoplatform.services.jcr.webdav.BaseStandaloneTest;
+import org.exoplatform.services.jcr.webdav.WebDavConst;
+import org.exoplatform.services.jcr.webdav.WebDavConstants.WebDAVMethods;
+import org.exoplatform.services.jcr.webdav.utils.TestUtils;
+import org.exoplatform.services.rest.ExtHttpHeaders;
+import org.exoplatform.services.rest.impl.ContainerResponse;
+import org.exoplatform.services.rest.impl.MultivaluedMapImpl;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MultivaluedMap;
+
+/**
+ * Created by The eXo Platform SAS Author : Dmytro Katayev
+ * work.visor.ck(a)gmail.com Aug 13, 2008
+ */
+public class TestCaching extends BaseStandaloneTest
+{
+ private String path = TestUtils.getFileName();
+
+ private String fileContent = TestUtils.getFileContent();
+
+ private Node node;
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ InputStream inputStream = new ByteArrayInputStream(fileContent.getBytes());
+ node = TestUtils.addContent(session, path, inputStream, defaultFileNodeType, "");
+ }
+
+ public void testNotModifiedSince() throws Exception
+ {
+ Node contentNode = node.getNode("jcr:content");
+ Property lastModifiedProperty = contentNode.getProperty("jcr:lastModified");
+
+ SimpleDateFormat dateFormat = new SimpleDateFormat(WebDavConst.DateFormat.IF_MODIFIED_SINCE_PATTERN);
+ Calendar lastModifiedDate = lastModifiedProperty.getDate();
+
+ lastModifiedDate.roll(Calendar.WEEK_OF_MONTH, -1);
+ // Rollback If-Modified-Since date a week earlier.
+ String ifModifiedDate = dateFormat.format(lastModifiedDate.getTime());
+
+ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+ headers.add(ExtHttpHeaders.IF_MODIFIED_SINCE, ifModifiedDate);
+ ContainerResponse response = service(WebDAVMethods.GET, getPathWS() + path, "", headers, null);
+
+ assertEquals(HTTPStatus.OK, response.getStatus());
+ }
+
+ public void testIfModifiedSince() throws Exception
+ {
+ Node contentNode = node.getNode("jcr:content");
+ Property lastModifiedProperty = contentNode.getProperty("jcr:lastModified");
+
+ SimpleDateFormat dateFormat = new SimpleDateFormat(WebDavConst.DateFormat.IF_MODIFIED_SINCE_PATTERN);
+ Calendar lastModifiedDate = lastModifiedProperty.getDate();
+
+ lastModifiedDate.add(Calendar.WEEK_OF_MONTH, 1);
+ String ifModifiedDate = dateFormat.format(lastModifiedDate.getTime());
+
+ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+ headers.add(ExtHttpHeaders.IF_MODIFIED_SINCE, ifModifiedDate);
+ ContainerResponse response = service(WebDAVMethods.GET, getPathWS() + path, "", headers, null);
+
+ assertEquals(HTTPStatus.NOT_MODIFIED, response.getStatus());
+ }
+
+ 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");
+
+ 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
+ protected String getRepositoryName()
+ {
+ return null;
+ }
+
+}
Property changes on: jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCaching.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
14 years
exo-jcr SVN: r2674 - in kernel/branches/2.3-ISPN: exo.kernel.commons and 12 other directories.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-06-21 12:10:38 -0400 (Mon, 21 Jun 2010)
New Revision: 2674
Modified:
kernel/branches/2.3-ISPN/exo.kernel.commons.test/pom.xml
kernel/branches/2.3-ISPN/exo.kernel.commons/pom.xml
kernel/branches/2.3-ISPN/exo.kernel.component.cache/pom.xml
kernel/branches/2.3-ISPN/exo.kernel.component.command/pom.xml
kernel/branches/2.3-ISPN/exo.kernel.component.common/pom.xml
kernel/branches/2.3-ISPN/exo.kernel.component.ext.cache.impl.jboss.v3/pom.xml
kernel/branches/2.3-ISPN/exo.kernel.container/pom.xml
kernel/branches/2.3-ISPN/exo.kernel.mc-integration/exo.kernel.mc-int-demo/pom.xml
kernel/branches/2.3-ISPN/exo.kernel.mc-integration/exo.kernel.mc-int-tests/pom.xml
kernel/branches/2.3-ISPN/exo.kernel.mc-integration/exo.kernel.mc-int/pom.xml
kernel/branches/2.3-ISPN/exo.kernel.mc-integration/exo.kernel.mc-kernel-extras/pom.xml
kernel/branches/2.3-ISPN/exo.kernel.mc-integration/pom.xml
kernel/branches/2.3-ISPN/packaging/module/pom.xml
kernel/branches/2.3-ISPN/pom.xml
Log:
Version changed from 2.3.0-Beta01-SNAPSHOT to 2.3-ISPN-SNAPSHOT
Modified: kernel/branches/2.3-ISPN/exo.kernel.commons/pom.xml
===================================================================
--- kernel/branches/2.3-ISPN/exo.kernel.commons/pom.xml 2010-06-21 16:01:10 UTC (rev 2673)
+++ kernel/branches/2.3-ISPN/exo.kernel.commons/pom.xml 2010-06-21 16:10:38 UTC (rev 2674)
@@ -17,7 +17,7 @@
<parent>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>kernel-parent</artifactId>
- <version>2.3.0-Beta01-SNAPSHOT</version>
+ <version>2.3-ISPN-SNAPSHOT</version>
</parent>
<artifactId>exo.kernel.commons</artifactId>
Modified: kernel/branches/2.3-ISPN/exo.kernel.commons.test/pom.xml
===================================================================
--- kernel/branches/2.3-ISPN/exo.kernel.commons.test/pom.xml 2010-06-21 16:01:10 UTC (rev 2673)
+++ kernel/branches/2.3-ISPN/exo.kernel.commons.test/pom.xml 2010-06-21 16:10:38 UTC (rev 2674)
@@ -17,7 +17,7 @@
<parent>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>kernel-parent</artifactId>
- <version>2.3.0-Beta01-SNAPSHOT</version>
+ <version>2.3-ISPN-SNAPSHOT</version>
</parent>
<artifactId>exo.kernel.commons.test</artifactId>
Modified: kernel/branches/2.3-ISPN/exo.kernel.component.cache/pom.xml
===================================================================
--- kernel/branches/2.3-ISPN/exo.kernel.component.cache/pom.xml 2010-06-21 16:01:10 UTC (rev 2673)
+++ kernel/branches/2.3-ISPN/exo.kernel.component.cache/pom.xml 2010-06-21 16:10:38 UTC (rev 2674)
@@ -25,7 +25,7 @@
<parent>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>kernel-parent</artifactId>
- <version>2.3.0-Beta01-SNAPSHOT</version>
+ <version>2.3-ISPN-SNAPSHOT</version>
</parent>
<artifactId>exo.kernel.component.cache</artifactId>
Modified: kernel/branches/2.3-ISPN/exo.kernel.component.command/pom.xml
===================================================================
--- kernel/branches/2.3-ISPN/exo.kernel.component.command/pom.xml 2010-06-21 16:01:10 UTC (rev 2673)
+++ kernel/branches/2.3-ISPN/exo.kernel.component.command/pom.xml 2010-06-21 16:10:38 UTC (rev 2674)
@@ -25,7 +25,7 @@
<parent>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>kernel-parent</artifactId>
- <version>2.3.0-Beta01-SNAPSHOT</version>
+ <version>2.3-ISPN-SNAPSHOT</version>
</parent>
<artifactId>exo.kernel.component.command</artifactId>
Modified: kernel/branches/2.3-ISPN/exo.kernel.component.common/pom.xml
===================================================================
--- kernel/branches/2.3-ISPN/exo.kernel.component.common/pom.xml 2010-06-21 16:01:10 UTC (rev 2673)
+++ kernel/branches/2.3-ISPN/exo.kernel.component.common/pom.xml 2010-06-21 16:10:38 UTC (rev 2674)
@@ -25,7 +25,7 @@
<parent>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>kernel-parent</artifactId>
- <version>2.3.0-Beta01-SNAPSHOT</version>
+ <version>2.3-ISPN-SNAPSHOT</version>
</parent>
<artifactId>exo.kernel.component.common</artifactId>
Modified: kernel/branches/2.3-ISPN/exo.kernel.component.ext.cache.impl.jboss.v3/pom.xml
===================================================================
--- kernel/branches/2.3-ISPN/exo.kernel.component.ext.cache.impl.jboss.v3/pom.xml 2010-06-21 16:01:10 UTC (rev 2673)
+++ kernel/branches/2.3-ISPN/exo.kernel.component.ext.cache.impl.jboss.v3/pom.xml 2010-06-21 16:10:38 UTC (rev 2674)
@@ -23,7 +23,7 @@
<parent>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>kernel-parent</artifactId>
- <version>2.3.0-Beta01-SNAPSHOT</version>
+ <version>2.3-ISPN-SNAPSHOT</version>
</parent>
<artifactId>exo.kernel.component.ext.cache.impl.jboss.v3</artifactId>
<name>eXo Kernel :: Cache Extension :: JBoss Cache Implementation</name>
Modified: kernel/branches/2.3-ISPN/exo.kernel.container/pom.xml
===================================================================
--- kernel/branches/2.3-ISPN/exo.kernel.container/pom.xml 2010-06-21 16:01:10 UTC (rev 2673)
+++ kernel/branches/2.3-ISPN/exo.kernel.container/pom.xml 2010-06-21 16:10:38 UTC (rev 2674)
@@ -12,7 +12,7 @@
<parent>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>kernel-parent</artifactId>
- <version>2.3.0-Beta01-SNAPSHOT</version>
+ <version>2.3-ISPN-SNAPSHOT</version>
</parent>
<artifactId>exo.kernel.container</artifactId>
<name>eXo Kernel :: Container</name>
Modified: kernel/branches/2.3-ISPN/exo.kernel.mc-integration/exo.kernel.mc-int/pom.xml
===================================================================
--- kernel/branches/2.3-ISPN/exo.kernel.mc-integration/exo.kernel.mc-int/pom.xml 2010-06-21 16:01:10 UTC (rev 2673)
+++ kernel/branches/2.3-ISPN/exo.kernel.mc-integration/exo.kernel.mc-int/pom.xml 2010-06-21 16:10:38 UTC (rev 2674)
@@ -6,7 +6,7 @@
<parent>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>mc-integration-parent</artifactId>
- <version>2.3.0-Beta01-SNAPSHOT</version>
+ <version>2.3-ISPN-SNAPSHOT</version>
</parent>
<artifactId>exo.kernel.mc-int</artifactId>
Modified: kernel/branches/2.3-ISPN/exo.kernel.mc-integration/exo.kernel.mc-int-demo/pom.xml
===================================================================
--- kernel/branches/2.3-ISPN/exo.kernel.mc-integration/exo.kernel.mc-int-demo/pom.xml 2010-06-21 16:01:10 UTC (rev 2673)
+++ kernel/branches/2.3-ISPN/exo.kernel.mc-integration/exo.kernel.mc-int-demo/pom.xml 2010-06-21 16:10:38 UTC (rev 2674)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>mc-integration-parent</artifactId>
- <version>2.3.0-Beta01-SNAPSHOT</version>
+ <version>2.3-ISPN-SNAPSHOT</version>
</parent>
<artifactId>exo.kernel.mc-int-demo</artifactId>
Modified: kernel/branches/2.3-ISPN/exo.kernel.mc-integration/exo.kernel.mc-int-tests/pom.xml
===================================================================
--- kernel/branches/2.3-ISPN/exo.kernel.mc-integration/exo.kernel.mc-int-tests/pom.xml 2010-06-21 16:01:10 UTC (rev 2673)
+++ kernel/branches/2.3-ISPN/exo.kernel.mc-integration/exo.kernel.mc-int-tests/pom.xml 2010-06-21 16:10:38 UTC (rev 2674)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>mc-integration-parent</artifactId>
- <version>2.3.0-Beta01-SNAPSHOT</version>
+ <version>2.3-ISPN-SNAPSHOT</version>
</parent>
<artifactId>exo.kernel.mc-int-tests</artifactId>
Modified: kernel/branches/2.3-ISPN/exo.kernel.mc-integration/exo.kernel.mc-kernel-extras/pom.xml
===================================================================
--- kernel/branches/2.3-ISPN/exo.kernel.mc-integration/exo.kernel.mc-kernel-extras/pom.xml 2010-06-21 16:01:10 UTC (rev 2673)
+++ kernel/branches/2.3-ISPN/exo.kernel.mc-integration/exo.kernel.mc-kernel-extras/pom.xml 2010-06-21 16:10:38 UTC (rev 2674)
@@ -6,7 +6,7 @@
<parent>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>mc-integration-parent</artifactId>
- <version>2.3.0-Beta01-SNAPSHOT</version>
+ <version>2.3-ISPN-SNAPSHOT</version>
</parent>
<artifactId>exo.kernel.mc-kernel-extras</artifactId>
Modified: kernel/branches/2.3-ISPN/exo.kernel.mc-integration/pom.xml
===================================================================
--- kernel/branches/2.3-ISPN/exo.kernel.mc-integration/pom.xml 2010-06-21 16:01:10 UTC (rev 2673)
+++ kernel/branches/2.3-ISPN/exo.kernel.mc-integration/pom.xml 2010-06-21 16:10:38 UTC (rev 2674)
@@ -6,7 +6,7 @@
<parent>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>kernel-parent</artifactId>
- <version>2.3.0-Beta01-SNAPSHOT</version>
+ <version>2.3-ISPN-SNAPSHOT</version>
</parent>
<artifactId>mc-integration-parent</artifactId>
Modified: kernel/branches/2.3-ISPN/packaging/module/pom.xml
===================================================================
--- kernel/branches/2.3-ISPN/packaging/module/pom.xml 2010-06-21 16:01:10 UTC (rev 2673)
+++ kernel/branches/2.3-ISPN/packaging/module/pom.xml 2010-06-21 16:10:38 UTC (rev 2674)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>kernel-parent</artifactId>
- <version>2.3.0-Beta01-SNAPSHOT</version>
+ <version>2.3-ISPN-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: kernel/branches/2.3-ISPN/pom.xml
===================================================================
--- kernel/branches/2.3-ISPN/pom.xml 2010-06-21 16:01:10 UTC (rev 2673)
+++ kernel/branches/2.3-ISPN/pom.xml 2010-06-21 16:10:38 UTC (rev 2674)
@@ -30,7 +30,7 @@
<groupId>org.exoplatform.kernel</groupId>
<artifactId>kernel-parent</artifactId>
- <version>2.3.0-Beta01-SNAPSHOT</version>
+ <version>2.3-ISPN-SNAPSHOT</version>
<packaging>pom</packaging>
<name>eXo Kernel</name>
14 years
exo-jcr SVN: r2673 - kernel/branches.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-06-21 12:01:10 -0400 (Mon, 21 Jun 2010)
New Revision: 2673
Added:
kernel/branches/2.3-ISPN/
Removed:
kernel/branches/2.3.0-ISPN/
Log:
Renamed to 2.3-ISPN
Copied: kernel/branches/2.3-ISPN (from rev 2672, kernel/branches/2.3.0-ISPN)
14 years
exo-jcr SVN: r2672 - kernel/branches.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-06-21 11:59:25 -0400 (Mon, 21 Jun 2010)
New Revision: 2672
Added:
kernel/branches/2.3.0-ISPN/
Log:
2.3.0-ISPN Branch added
Copied: kernel/branches/2.3.0-ISPN (from rev 2671, kernel/trunk)
14 years
exo-jcr SVN: r2671 - in jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services: jcr/impl/core and 1 other directories.
by do-not-reply@jboss.org
Author: natasha.vakulenko
Date: 2010-06-21 10:00:38 -0400 (Mon, 21 Jun 2010)
New Revision: 2671
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/ext/action/InvocationContext.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/ext/action/SessionActionInterceptor.java
Log:
JCR-1078: Was extended interface of postSetProperty() method in class SessionActionInterceptor (added parameter with previous value of property). From the calling of his method doUpdateProperty() (in class ItemImpl) comes previous value of property. In class InvocationContext was added field with previous item.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/ext/action/InvocationContext.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/ext/action/InvocationContext.java 2010-06-21 12:41:26 UTC (rev 2670)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/ext/action/InvocationContext.java 2010-06-21 14:00:38 UTC (rev 2671)
@@ -45,6 +45,11 @@
public static final String CURRENT_ITEM = "currentItem".intern();
/**
+ * Current item.
+ */
+ public static final String PREVIOUS_ITEM = "previousItem".intern();
+
+ /**
* Context event.
*/
public static final String EVENT = "event".intern();
@@ -88,6 +93,14 @@
}
/**
+ * @return Previous item.
+ */
+ public final Item getPreviousItem()
+ {
+ return (Item)get(PREVIOUS_ITEM);
+ }
+
+ /**
* @return Context event
*/
public final int getEventType()
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java 2010-06-21 12:41:26 UTC (rev 2670)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java 2010-06-21 14:00:38 UTC (rev 2671)
@@ -111,15 +111,12 @@
protected ValueFactoryImpl valueFactory;
/**
- * ItemImpl constructor.
- *
- * @param data
- * ItemData object
- * @param session
- * Session object
- * @throws RepositoryException
- * if any Exception is occurred
- */
+ * ItemImpl constructor.
+ *
+ * @param data ItemData object
+ * @param session Session object
+ * @throws RepositoryException if any Exception is occurred
+ */
ItemImpl(ItemData data, SessionImpl session) throws RepositoryException
{
@@ -137,7 +134,8 @@
}
/**
- * Return a status of the item state. If the state is invalid the item can't be used anymore.
+ * Return a status of the item state. If the state is invalid the item can't
+ * be used anymore.
*
* @return boolean flag, true if an item is usable in the session.
*/
@@ -147,7 +145,8 @@
}
/**
- * Checking if this item has valid item state, i.e. wasn't removed (and saved).
+ * Checking if this item has valid item state, i.e. wasn't removed (and
+ * saved).
*
* @return true or throws an InvalidItemStateException exception otherwise
* @throws InvalidItemStateException
@@ -353,8 +352,8 @@
}
/**
- * Check when it's a Node and is versionable will a version history removed. Case of last version
- * in version history.
+ * Check when it's a Node and is versionable will a version history removed.
+ * Case of last version in version history.
*
* @throws RepositoryException
* @throws ConstraintViolationException
@@ -423,6 +422,7 @@
NodeTypeDataManager ntm = session.getWorkspace().getNodeTypesHolder();
NodeData parentData = (NodeData)parentNode.getData();
boolean isMultiValue = multiValue;
+ PropertyImpl prevProperty = null;
if (prevItem == null || prevItem.isNode())
{ // new property
identifier = IdGenerator.generate();
@@ -446,6 +446,7 @@
{
// update of the property
prevProp = (PropertyImpl)prevItem;
+ prevProperty = new PropertyImpl(prevProp.getData(), prevProp.parentData(), prevProp.getSession());
isMultiValue = prevProp.isMultiValued();
defs =
ntm.getPropertyDefinitions(propertyName, parentData.getPrimaryTypeName(), parentData.getMixinTypeNames());
@@ -569,7 +570,7 @@
PropertyImpl prop;
if (state != ItemState.DELETED)
{
- // add or update
+ // add or update
TransientPropertyData newData =
new TransientPropertyData(qpath, identifier, version, propType, parentNode.getInternalIdentifier(),
multiValue, valueDataList);
@@ -578,7 +579,7 @@
prop = (PropertyImpl)dataManager.update(itemState, true);
// launch event: post-set
- session.getActionHandler().postSetProperty(prop, state);
+ session.getActionHandler().postSetProperty(prevProperty, prop, state);
}
else
{
@@ -734,8 +735,7 @@
* Get parent node item.
*
* @return parent item
- * @throws RepositoryException
- * if parent item is null
+ * @throws RepositoryException if parent item is null
*/
protected NodeImpl parent() throws RepositoryException
{
@@ -753,8 +753,7 @@
* Get and return parent node data.
*
* @return parent node data
- * @throws RepositoryException
- * if parent item is null
+ * @throws RepositoryException if parent item is null
*/
public NodeData parentData() throws RepositoryException
{
@@ -815,29 +814,25 @@
/**
* Loads data.
- *
- * @param data
- * source item data
- * @throws RepositoryException
- * if errors occurs
+ *
+ * @param data source item data
+ * @throws RepositoryException if errors occurs
*/
abstract void loadData(ItemData data) throws RepositoryException;
/**
- * Loads data using existing parent data (used primary and mixin types for Item Definition discovery).
- *
- * @param data
- * source item data
- * @param parent NodeData
- * Items's parent
- * @throws RepositoryException
- * if errors occurs
+ * Loads data using existing parent data (used primary and mixin types for
+ * Item Definition discovery).
+ *
+ * @param data source item data
+ * @param parent NodeData Items's parent
+ * @throws RepositoryException if errors occurs
*/
abstract void loadData(ItemData data, NodeData parent) throws RepositoryException;
/**
* Returns Item definition data.
- *
+ *
* @return
*/
abstract ItemDefinitionData getItemDefinitionData();
@@ -898,7 +893,7 @@
ValueData vd;
if (value instanceof BaseValue || value instanceof ExtendedValue)
{
- // create Transient copy
+ // create Transient copy
vd = ((BaseValue)getSession().getValueFactory().createValue(value.getStream())).getInternalData();
}
else
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/ext/action/SessionActionInterceptor.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/ext/action/SessionActionInterceptor.java 2010-06-21 12:41:26 UTC (rev 2670)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/ext/action/SessionActionInterceptor.java 2010-06-21 14:00:38 UTC (rev 2671)
@@ -254,13 +254,14 @@
}
}
- public void postSetProperty(PropertyImpl property, int state) throws RepositoryException
+ public void postSetProperty(PropertyImpl previousProperty, PropertyImpl currentProperty, int state)
+ throws RepositoryException
{
if (catalog == null)
return;
if (activeItem == null)
- activeItem = property;
+ activeItem = currentProperty;
else
return;
@@ -284,11 +285,12 @@
Condition conditions = new Condition();
conditions.put(SessionEventMatcher.EVENTTYPE_KEY, event);
- conditions.put(SessionEventMatcher.PATH_KEY, property.getInternalPath());
- conditions.put(SessionEventMatcher.NODETYPES_KEY, readNodeTypeNames(property.parentData()));
+ conditions.put(SessionEventMatcher.PATH_KEY, currentProperty.getInternalPath());
+ conditions.put(SessionEventMatcher.NODETYPES_KEY, readNodeTypeNames(currentProperty.parentData()));
InvocationContext ctx = new InvocationContext();
- ctx.put(InvocationContext.CURRENT_ITEM, property);
+ ctx.put(InvocationContext.CURRENT_ITEM, currentProperty);
+ ctx.put(InvocationContext.PREVIOUS_ITEM, previousProperty);
ctx.put(InvocationContext.EXO_CONTAINER, container);
ctx.put(InvocationContext.EVENT, event);
launch(conditions, ctx);
14 years
exo-jcr SVN: r2670 - in ws/trunk/exo.ws.rest.core/src: test/java/org/exoplatform/services/rest/impl/method and 1 other directory.
by do-not-reply@jboss.org
Author: aparfonov
Date: 2010-06-21 08:41:26 -0400 (Mon, 21 Jun 2010)
New Revision: 2670
Modified:
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/RequestDispatcher.java
ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/MethodReturnTypeTest.java
Log:
EXOJCR-713 :
Modified: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/RequestDispatcher.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/RequestDispatcher.java 2010-06-21 12:20:03 UTC (rev 2669)
+++ ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/RequestDispatcher.java 2010-06-21 12:41:26 UTC (rev 2670)
@@ -126,11 +126,11 @@
}
/**
- * Get last element from path parameters. This element will be used as request
- * path for child resources.
+ * Get last element from path parameters. This element will be used as
+ * request path for child resources.
*
* @param parameterValues See
- * {@link ApplicationContextImpl#getParameterValues()}
+ * {@link ApplicationContextImpl#getParameterValues()}
* @return last element from given list or empty string if last element is
* null
*/
@@ -141,18 +141,18 @@
}
/**
- * Process resource methods, sub-resource methods and sub-resource locators to
- * find the best one for serve request.
+ * Process resource methods, sub-resource methods and sub-resource locators
+ * to find the best one for serve request.
*
* @param request See {@link GenericContainerRequest}
* @param response See {@link GenericContainerResponse}
* @param context See {@link ApplicationContextImpl}
* @param resourceFactory the root resource factory or resource factory which
- * was created by previous sub-resource locator
+ * was created by previous sub-resource locator
* @param resource instance of resource class
* @param requestPath request path, it is relative path to the base URI or
- * other resource which was called before (one of sub-resource
- * locators)
+ * other resource which was called before (one of sub-resource
+ * locators)
*/
private void dispatch(GenericContainerRequest request, GenericContainerResponse response,
ApplicationContext context, ObjectFactory<AbstractResourceDescriptor> resourceFactory, Object resource,
@@ -322,14 +322,15 @@
}
/**
- * Compare two sub-resources. One of it is {@link SubResourceMethodDescriptor}
- * and other one id {@link SubResourceLocatorDescriptor}. First compare
- * UriPattern, see {@link UriPattern#URIPATTERN_COMPARATOR}. NOTE URI
- * comparator compare UriPattrens for descending sorting. So it it return
- * negative integer then it minds SubResourceMethodDescriptor has higher
- * priority by UriPattern comparison. If comparator return positive integer
- * then SubResourceLocatorDescriptor has higher priority. And finally if zero
- * was returned then UriPattern is equals, in this case
+ * Compare two sub-resources. One of it is
+ * {@link SubResourceMethodDescriptor} and other one id
+ * {@link SubResourceLocatorDescriptor}. First compare UriPattern, see
+ * {@link UriPattern#URIPATTERN_COMPARATOR}. NOTE URI comparator compare
+ * UriPattrens for descending sorting. So it it return negative integer then
+ * it minds SubResourceMethodDescriptor has higher priority by UriPattern
+ * comparison. If comparator return positive integer then
+ * SubResourceLocatorDescriptor has higher priority. And finally if zero was
+ * returned then UriPattern is equals, in this case
* SubResourceMethodDescriptor must be selected.
*
* @param srmd See {@link SubResourceMethodDescriptor}
@@ -414,7 +415,7 @@
if (rmds == null || rmds.size() == 0)
{
response.setResponse(Response.status(405).header("Allow", HeaderHelper.convertToString(rmm.getAllow()))
- .build());
+ .entity("Method not allowed.").type(MediaType.TEXT_PLAIN).build());
return false;
}
MediaType contentType = request.getMediaType();
@@ -435,7 +436,8 @@
if (methods.isEmpty())
{
- response.setResponse(Response.status(Response.Status.UNSUPPORTED_MEDIA_TYPE).build());
+ response.setResponse(Response.status(Response.Status.UNSUPPORTED_MEDIA_TYPE).entity(
+ "Media type " + contentType + " is not supported.").type(MediaType.TEXT_PLAIN).build());
return false;
}
@@ -477,7 +479,8 @@
return true;
}
- response.setResponse(Response.status(Response.Status.NOT_ACCEPTABLE).build());
+ response.setResponse(Response.status(Response.Status.NOT_ACCEPTABLE).entity("Not Acceptable").type(
+ MediaType.TEXT_PLAIN).build());
return false;
}
@@ -489,7 +492,7 @@
* @param request See {@link GenericContainerRequest}
* @param response See {@link GenericContainerResponse}
* @param capturingValues the list for keeping template values. See
- * {@link javax.ws.rs.core.UriInfo#getPathParameters()}
+ * {@link javax.ws.rs.core.UriInfo#getPathParameters()}
* @param methods list for method resources
* @return true if at least one sub-resource method found false otherwise
*/
@@ -516,7 +519,8 @@
if (rmm == null)
{
- response.setResponse(Response.status(Status.NOT_FOUND).build());
+ response.setResponse(Response.status(Status.NOT_FOUND).entity(
+ "There is no any resources matched to request path " + requestedPath).type(MediaType.TEXT_PLAIN).build());
return false;
}
@@ -609,7 +613,8 @@
}
// Stop here, there is no matched root resource
- throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build());
+ throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).entity(
+ "There is no any resources matched to request path " + requestPath).type(MediaType.TEXT_PLAIN).build());
}
else
{
Modified: ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/MethodReturnTypeTest.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/MethodReturnTypeTest.java 2010-06-21 12:20:03 UTC (rev 2669)
+++ ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/MethodReturnTypeTest.java 2010-06-21 12:41:26 UTC (rev 2670)
@@ -30,7 +30,7 @@
/**
* Created by The eXo Platform SAS. <br/>
* Date: 20 Jan 2009
- *
+ *
* @author <a href="mailto:dmitry.kataev@exoplatform.com.ua">Dmytro Katayev</a>
* @version $Id: ResourceReturnTypeTest.java
*/
@@ -93,7 +93,7 @@
// void Results in an empty entity body with a 204 status code.
assertEquals(204, service("GET", "/a/0", "", null, null).getStatus());
- assertNull(service("GET", "/a/o", "", null, null).getEntity());
+ assertNull(service("GET", "/a/0", "", null, null).getEntity());
// Response Results in an entity body mapped from the entity property of the
// Response
14 years
exo-jcr SVN: r2669 - ws/trunk/exo.ws.rest.ext.
by do-not-reply@jboss.org
Author: aparfonov
Date: 2010-06-21 08:20:03 -0400 (Mon, 21 Jun 2010)
New Revision: 2669
Modified:
ws/trunk/exo.ws.rest.ext/pom.xml
Log:
Modified: ws/trunk/exo.ws.rest.ext/pom.xml
===================================================================
--- ws/trunk/exo.ws.rest.ext/pom.xml 2010-06-21 12:19:21 UTC (rev 2668)
+++ ws/trunk/exo.ws.rest.ext/pom.xml 2010-06-21 12:20:03 UTC (rev 2669)
@@ -1,4 +1,3 @@
-
<!--
Copyright (C) 2009 eXo Platform SAS.
14 years
exo-jcr SVN: r2668 - ws/trunk/exo.ws.rest.ext.
by do-not-reply@jboss.org
Author: aparfonov
Date: 2010-06-21 08:19:21 -0400 (Mon, 21 Jun 2010)
New Revision: 2668
Modified:
ws/trunk/exo.ws.rest.ext/pom.xml
Log:
EXOJCR-793 :
Modified: ws/trunk/exo.ws.rest.ext/pom.xml
===================================================================
--- ws/trunk/exo.ws.rest.ext/pom.xml 2010-06-21 12:18:03 UTC (rev 2667)
+++ ws/trunk/exo.ws.rest.ext/pom.xml 2010-06-21 12:19:21 UTC (rev 2668)
@@ -118,7 +118,7 @@
</goals>
<configuration>
<tasks>
- <echo>***** Creating Access Policy for tests ***** ${project.build.directory}/../..</echo>
+ <echo>***** Creating Access Policy for tests *****</echo>
<makeurl file="${settings.localRepository}" property="localRepositoryURL" />
<makeurl file="${project.build.outputDirectory}" property="outputDirectoryURL" />
<makeurl file="${project.build.testOutputDirectory}" property="testOutputDirectoryURL" />
14 years
exo-jcr SVN: r2667 - in ws/trunk/exo.ws.rest.ext: src/test/resources and 1 other directory.
by do-not-reply@jboss.org
Author: aparfonov
Date: 2010-06-21 08:18:03 -0400 (Mon, 21 Jun 2010)
New Revision: 2667
Modified:
ws/trunk/exo.ws.rest.ext/pom.xml
ws/trunk/exo.ws.rest.ext/src/test/resources/test.policy
Log:
EXOJCR-793 :
Modified: ws/trunk/exo.ws.rest.ext/pom.xml
===================================================================
--- ws/trunk/exo.ws.rest.ext/pom.xml 2010-06-21 10:20:31 UTC (rev 2666)
+++ ws/trunk/exo.ws.rest.ext/pom.xml 2010-06-21 12:18:03 UTC (rev 2667)
@@ -1,10 +1,23 @@
<!--
- 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.
+ 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.
+
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
@@ -90,7 +103,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
- <argLine>-Djava.security.manager=default -Djava.security.policy=${project.build.directory}/test-classes/test.policy</argLine>
+ <argLine>-Djava.security.manager=default -Djava.security.policy=${project.build.directory}/test-classes/test.policy -Djava.security.debug=denied</argLine>
</configuration>
</plugin>
<plugin>
@@ -105,10 +118,12 @@
</goals>
<configuration>
<tasks>
- <echo>***** Creating Access Policy for tests *****</echo>
+ <echo>***** Creating Access Policy for tests ***** ${project.build.directory}/../..</echo>
<makeurl file="${settings.localRepository}" property="localRepositoryURL" />
<makeurl file="${project.build.outputDirectory}" property="outputDirectoryURL" />
<makeurl file="${project.build.testOutputDirectory}" property="testOutputDirectoryURL" />
+ <makeurl file="${project.build.directory}/../../" property="parentDirectoryURL" />
+<!-- <echo>***** ${parentDirectory}</echo>-->
<copy todir="${project.build.testOutputDirectory}" overwrite="true">
<fileset dir="${project.basedir}/src/test/resources/">
<include name="test.policy" />
@@ -117,6 +132,7 @@
<filter token="MAVEN_REPO" value="${localRepositoryURL}" />
<filter token="MAIN_CLASSES" value="${outputDirectoryURL}" />
<filter token="TEST_CLASSES" value="${testOutputDirectoryURL}" />
+ <filter token="PARENT" value="${parentDirectoryURL}" />
</filterset>
</copy>
</tasks>
Modified: ws/trunk/exo.ws.rest.ext/src/test/resources/test.policy
===================================================================
--- ws/trunk/exo.ws.rest.ext/src/test/resources/test.policy 2010-06-21 10:20:31 UTC (rev 2666)
+++ ws/trunk/exo.ws.rest.ext/src/test/resources/test.policy 2010-06-21 12:18:03 UTC (rev 2667)
@@ -9,6 +9,9 @@
grant codeBase "@TEST_CLASSES@-" {
permission java.security.AllPermission;
};
+grant codeBase "@PARENT@-" {
+ permission java.security.AllPermission;
+};
grant codeBase "file:/groovy/script" {
// be sure only /groovy/script/jaxrs is restricted
14 years