Author: dkatayev
Date: 2010-09-01 06:12:38 -0400 (Wed, 01 Sep 2010)
New Revision: 3039
Modified:
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/PropFindCommand.java
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/dasl/SearchResultResponseEntity.java
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/deltav/report/VersionTreeResponseEntity.java
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/propfind/PropFindResponseEntity.java
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/util/PropertyConstants.java
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/xml/PropstatGroupedRepresentation.java
Log:
EXOJCR-935 dav:isreadonly property management added
Modified:
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/PropFindCommand.java
===================================================================
---
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/PropFindCommand.java 2010-09-01
10:11:32 UTC (rev 3038)
+++
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/PropFindCommand.java 2010-09-01
10:12:38 UTC (rev 3039)
@@ -142,15 +142,15 @@
if (request.getType().equalsIgnoreCase("allprop"))
{
- response = new PropFindResponseEntity(depth, resource, null, false);
+ response = new PropFindResponseEntity(depth, resource, null, false, session);
}
else if (request.getType().equalsIgnoreCase("propname"))
{
- response = new PropFindResponseEntity(depth, resource, null, true);
+ response = new PropFindResponseEntity(depth, resource, null, true, session);
}
else if (request.getType().equalsIgnoreCase("prop"))
{
- response = new PropFindResponseEntity(depth, resource, propertyNames(body),
false);
+ response = new PropFindResponseEntity(depth, resource, propertyNames(body),
false, session);
}
else
{
Modified:
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/dasl/SearchResultResponseEntity.java
===================================================================
---
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/dasl/SearchResultResponseEntity.java 2010-09-01
10:11:32 UTC (rev 3038)
+++
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/dasl/SearchResultResponseEntity.java 2010-09-01
10:12:38 UTC (rev 3039)
@@ -176,7 +176,7 @@
xmlStreamWriter.writeCharacters(URLDecoder.decode(resource.getIdentifier().toASCIIString(),
"UTF-8"));
xmlStreamWriter.writeEndElement();
- PropstatGroupedRepresentation propstat = new
PropstatGroupedRepresentation(resource, properties, false);
+ PropstatGroupedRepresentation propstat = new
PropstatGroupedRepresentation(resource, properties, false, null);
PropertyWriteUtil.writePropStats(xmlStreamWriter, propstat.getPropStats());
Modified:
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/deltav/report/VersionTreeResponseEntity.java
===================================================================
---
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/deltav/report/VersionTreeResponseEntity.java 2010-09-01
10:11:32 UTC (rev 3038)
+++
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/deltav/report/VersionTreeResponseEntity.java 2010-09-01
10:12:38 UTC (rev 3039)
@@ -120,7 +120,7 @@
xmlStreamWriter.writeEndElement();
PropstatGroupedRepresentation propstat =
- new PropstatGroupedRepresentation(versionResource, properties, false);
+ new PropstatGroupedRepresentation(versionResource, properties, false,
null);
PropertyWriteUtil.writePropStats(xmlStreamWriter, propstat.getPropStats());
xmlStreamWriter.writeEndElement();
Modified:
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/propfind/PropFindResponseEntity.java
===================================================================
---
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/propfind/PropFindResponseEntity.java 2010-09-01
10:11:32 UTC (rev 3038)
+++
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/propfind/PropFindResponseEntity.java 2010-09-01
10:12:38 UTC (rev 3039)
@@ -36,6 +36,7 @@
import java.util.Set;
import javax.jcr.RepositoryException;
+import javax.jcr.Session;
import javax.ws.rs.core.StreamingOutput;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLOutputFactory;
@@ -91,6 +92,11 @@
* Boolean flag, shows if only property names a requested.
*/
protected final boolean propertyNamesOnly;
+
+ /**
+ * Session.
+ */
+ protected final Session session;
/**
* Constructor.
@@ -100,13 +106,14 @@
* @param propertyNames the list of properties requested
* @param propertyNamesOnly if only property names a requested
*/
- public PropFindResponseEntity(int depth, Resource rootResource, Set<QName>
propertyNames, boolean propertyNamesOnly)
+ public PropFindResponseEntity(int depth, Resource rootResource, Set<QName>
propertyNames, boolean propertyNamesOnly, Session session)
{
this.rootResource = rootResource;
this.namespaceContext = rootResource.getNamespaceContext();
this.propertyNames = propertyNames;
this.depth = depth;
this.propertyNamesOnly = propertyNamesOnly;
+ this.session = session;
}
/**
@@ -173,7 +180,7 @@
xmlStreamWriter.writeEndElement();
PropstatGroupedRepresentation propstat =
- new PropstatGroupedRepresentation(resource, propertyNames, propertyNamesOnly);
+ new PropstatGroupedRepresentation(resource, propertyNames, propertyNamesOnly,
session);
PropertyWriteUtil.writePropStats(xmlStreamWriter, propstat.getPropStats());
Modified:
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/util/PropertyConstants.java
===================================================================
---
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/util/PropertyConstants.java 2010-09-01
10:11:32 UTC (rev 3038)
+++
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/util/PropertyConstants.java 2010-09-01
10:12:38 UTC (rev 3039)
@@ -202,6 +202,11 @@
QName JCR_CONTENT = new QName("jcr:", "content");
/**
+ * dav:isreadonly property for MicroSoft Webfolders extension.
+ */
+ QName IS_READ_ONLY = new QName("DAV:", "isreadonly");
+
+ /**
* Creation date pattern.
*/
String CREATION_PATTERN = "yyyy-MM-dd'T'HH:mm:ss'Z'";
Modified:
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/xml/PropstatGroupedRepresentation.java
===================================================================
---
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/xml/PropstatGroupedRepresentation.java 2010-09-01
10:11:32 UTC (rev 3038)
+++
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/xml/PropstatGroupedRepresentation.java 2010-09-01
10:12:38 UTC (rev 3039)
@@ -20,11 +20,14 @@
import org.exoplatform.common.http.HTTPStatus;
import org.exoplatform.common.util.HierarchicalProperty;
+import org.exoplatform.services.jcr.access.PermissionType;
import org.exoplatform.services.jcr.webdav.WebDavConst;
import org.exoplatform.services.jcr.webdav.resource.Resource;
+import org.exoplatform.services.jcr.webdav.util.PropertyConstants;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
+import java.security.AccessControlException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -35,6 +38,7 @@
import javax.jcr.ItemNotFoundException;
import javax.jcr.PathNotFoundException;
import javax.jcr.RepositoryException;
+import javax.jcr.Session;
import javax.xml.namespace.QName;
/**
@@ -74,15 +78,21 @@
protected final Resource resource;
/**
+ * seesion.
+ */
+ protected final Session session;
+
+ /**
* @param resource resource
* @param propNames properties names
* @param namesOnly Boolean flag. Shows if only properties names are required
* (true) or properties and values (false).
* @throws RepositoryException {@link RepositoryException}
*/
- public PropstatGroupedRepresentation(final Resource resource, final Set<QName>
propNames, boolean namesOnly)
- throws RepositoryException
+ public PropstatGroupedRepresentation(final Resource resource, final Set<QName>
propNames, boolean namesOnly,
+ final Session session) throws RepositoryException
{
+ this.session = session;
this.namesOnly = namesOnly;
this.resource = resource;
this.propStats = new HashMap<String, Set<HierarchicalProperty>>();
@@ -122,8 +132,23 @@
HierarchicalProperty prop = new HierarchicalProperty(propName);
try
{
- prop = resource.getProperty(propName);
- statname = WebDavConst.getStatusDescription(HTTPStatus.OK);
+ if (propName.equals(PropertyConstants.IS_READ_ONLY))
+ {
+ if (isReadOnly())
+ {
+ prop.setValue("1");
+ }
+ else
+ {
+ prop.setValue("0");
+ }
+ statname = WebDavConst.getStatusDescription(HTTPStatus.OK);
+ }
+ else
+ {
+ prop = resource.getProperty(propName);
+ statname = WebDavConst.getStatusDescription(HTTPStatus.OK);
+ }
}
catch (AccessDeniedException exc)
@@ -158,4 +183,41 @@
return propStats;
}
+ private boolean isReadOnly()
+ {
+
+ String resourcePath = resource.getIdentifier().getPath();
+ String workspace = session.getWorkspace().getName();
+ String path = resourcePath.substring(resourcePath.indexOf(workspace) +
workspace.length());
+
+ try
+ {
+ session.checkPermission(path, PermissionType.READ);
+ }
+ catch (AccessControlException e1)
+ {
+ return false;
+ }
+ catch (RepositoryException e1)
+ {
+ return false;
+ }
+
+ // Node must not have any permission except "set_property" so checking
for this permission
+ // must throw AccessControlException
+ try
+ {
+ session.checkPermission(path, PermissionType.SET_PROPERTY);
+ return false;
+ }
+ catch (AccessControlException e)
+ {
+ return true;
+ }
+ catch (RepositoryException e)
+ {
+ return false;
+ }
+ }
+
}