Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   /*
    * Licensed to the Apache Software Foundation (ASF) under one or more
    * contributor license agreements.  See the NOTICE file distributed with
    * this work for additional information regarding copyright ownership.
    * The ASF licenses this file to You under the Apache License, Version 2.0
    * (the "License"); you may not use this file except in compliance with
    * the License.  You may obtain a copy of the License at
    *
    *      http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.jackrabbit.spi2dav;
  
  import java.io.Reader;
  import java.util.Arrays;
  import java.util.HashMap;
  import java.util.HashSet;
  import java.util.List;
  import java.util.Map;
  import java.util.Set;
  import java.util.UUID;
  
  import javax.jcr.Value;
  
RepositoryServiceImpl...
 
 // TODO: encapsulate URI building, escaping, unescaping...
 // TODO: TO-BE-FIXED. caches don't get adjusted upon removal/move of items
 public class RepositoryServiceImpl implements RepositoryServiceDavConstants {
 
     private static Logger log = LoggerFactory.getLogger(RepositoryServiceImpl.class);
 
     private static final SubscriptionInfo S_INFO = new SubscriptionInfo(DefaultEventType.create(..), true);

    
Key for the client map during repo creation (no sessionInfo present)
 
     private static final String CLIENT_KEY = "repoCreation";

    
Default value for the maximum number of connections per host such as configured with org.apache.commons.httpclient.params.HttpConnectionManagerParams.setDefaultMaxConnectionsPerHost(int).
 
     public static final int MAX_CONNECTIONS_DEFAULT = 20;
 
     private final IdFactory idFactory;
     private final NameFactory nameFactory;
     private final PathFactory pathFactory;
     private final QValueFactory qValueFactory;
     private final ValueFactory valueFactory;
 
     private final int itemInfoCacheSize;
 
     private final NamespaceCache nsCache;
     private final URIResolverImpl uriResolver;
 
     private final HostConfiguration hostConfig;
     private final ConcurrentMap<ObjectHttpClientclients;
     private final HttpConnectionManager connectionManager;
 
     private final Map<NameQNodeTypeDefinitionnodeTypeDefinitions = new HashMap<NameQNodeTypeDefinition>();

    
Repository descriptors.
 
     private final Map<StringQValue[]> descriptors =
             new HashMap<StringQValue[]>();

    
Observation features.
 
     private boolean remoteServerProvidesNodeTypes = false;
     private boolean remoteServerProvidesNoLocalFlag = false;
 
     /* DAV conformance levels */
     private Set<StringremoteDavComplianceClasses = null;

    
Same as RepositoryServiceImpl(java.lang.String,org.apache.jackrabbit.spi.IdFactory,org.apache.jackrabbit.spi.NameFactory,org.apache.jackrabbit.spi.PathFactory,org.apache.jackrabbit.spi.QValueFactory,int,int) using ItemInfoCacheImpl.DEFAULT_CACHE_SIZE) as size for the item cache and MAX_CONNECTIONS_DEFAULT for the maximum number of connections on the client.

Parameters:
uri The server uri.
idFactory The id factory.
nameFactory The name factory.
pathFactory The path factory.
qValueFactory The value factory.
Throws:
javax.jcr.RepositoryException If an error occurs.
 
     public RepositoryServiceImpl(String uriIdFactory idFactory,
                                  NameFactory nameFactoryPathFactory pathFactory,
                                  QValueFactory qValueFactorythrows RepositoryException {
         this(uriidFactorynameFactorypathFactoryqValueFactory.);
     }

    
Same as RepositoryServiceImpl(java.lang.String,org.apache.jackrabbit.spi.IdFactory,org.apache.jackrabbit.spi.NameFactory,org.apache.jackrabbit.spi.PathFactory,org.apache.jackrabbit.spi.QValueFactory,int,int) using MAX_CONNECTIONS_DEFAULT for the maximum number of connections on the client.

Parameters:
uri The server uri.
idFactory The id factory.
nameFactory The name factory.
pathFactory The path factory.
qValueFactory The value factory.
itemInfoCacheSize The size of the item info cache.
Throws:
javax.jcr.RepositoryException If an error occurs.
 
     public RepositoryServiceImpl(String uriIdFactory idFactory,
                                  NameFactory nameFactoryPathFactory pathFactory,
                                  QValueFactory qValueFactoryint itemInfoCacheSizethrows RepositoryException {
         this(uriidFactorynameFactorypathFactoryqValueFactoryitemInfoCacheSize);
     }

    
Creates a new instance of this repository service.

Parameters:
uri The server uri.
idFactory The id factory.
nameFactory The name factory.
pathFactory The path factory.
qValueFactory The value factory.
itemInfoCacheSize The size of the item info cache.
maximumHttpConnections A int >0 defining the maximum number of connections per host to be configured on org.apache.commons.httpclient.params.HttpConnectionManagerParams.setDefaultMaxConnectionsPerHost(int).
Throws:
javax.jcr.RepositoryException If an error occurs.
 
     public RepositoryServiceImpl(String uriIdFactory idFactory,
                                  NameFactory nameFactoryPathFactory pathFactory,
                                  QValueFactory qValueFactoryint itemInfoCacheSize,
                                  int maximumHttpConnections ) throws RepositoryException {
         if (uri == null || "".equals(uri)) {
             throw new RepositoryException("Invalid repository uri '" + uri + "'.");
         }
 
         if (idFactory == null || qValueFactory == null) {
             throw new RepositoryException("IdFactory and QValueFactory may not be null.");
         }
         this. = idFactory;
         this. = nameFactory;
         this. = pathFactory;
         this. = qValueFactory;
         this. = itemInfoCacheSize;
 
         try {
             URI repositoryUri = computeRepositoryUri(uri);
              = new HostConfiguration();
             .setHost(repositoryUri);
 
              = new NamespaceCache();
              = new URIResolverImpl(repositoryUrithis, DomUtil.createDocument());
             NamePathResolver resolver = new NamePathResolverImpl();
              = new ValueFactoryQImpl(qValueFactoryresolver);
 
         } catch (URIException e) {
             throw new RepositoryException(e);
         } catch (ParserConfigurationException e) {
             throw new RepositoryException(e);
         }
 
         if (maximumHttpConnections > 0) {
             HttpConnectionManagerParams connectionParams = .getParams();
             connectionParams.setDefaultMaxConnectionsPerHost(maximumHttpConnections);
             connectionParams.setMaxTotalConnections(maximumHttpConnections);
         }
 
         // This configuration of the clients cache assumes that the level of
         // concurrency on this map will be equal to the default number of maximum
         // connections allowed on the httpClient level.
         // TODO: review again
         int concurrencyLevel = ;
         int initialCapacity = ;
         if (maximumHttpConnections > 0) {
             concurrencyLevel = maximumHttpConnections;
             initialCapacity = maximumHttpConnections;
         }
          = new ConcurrentHashMap<ObjectHttpClient>(concurrencyLevel, .75f, initialCapacity);
     }
 
     private static void checkSessionInfo(SessionInfo sessionInfothrows RepositoryException {
         if (!(sessionInfo instanceof SessionInfoImpl)) {
             throw new RepositoryException("Unknown SessionInfo implementation.");
         }
     }

    
Resolve the given URI against a base URI (usually the request URI of an HTTP request)
 
     private static String resolve(String baseUriString relUrithrows RepositoryException {
         try {
             java.net.URI base = new java.net.URI(baseUri);
             java.net.URI rel = new java.net.URI(relUri);
             return base.resolve(rel).toString();
         }
         catch (URISyntaxException ex) {
             throw new RepositoryException(ex);
         }
     }
 
     private static void checkSubscription(Subscription subscriptionthrows RepositoryException {
         if (!(subscription instanceof EventSubscriptionImpl)) {
             throw new RepositoryException("Unknown Subscription implementation.");
         }
     }
 
     private static boolean isUnLockMethod(DavMethod method) {
         int code = DavMethods.getMethodCode(method.getName());
         return . == code;
     }
 
     protected static void initMethod(HttpMethod methodSessionInfo sessionInfoboolean addIfHeaderthrows RepositoryException {
         if (addIfHeader) {
             checkSessionInfo(sessionInfo);
             Set<StringallLockTokens = ((SessionInfoImplsessionInfo).getAllLockTokens();
             // TODO: ev. build tagged if header
             if (!allLockTokens.isEmpty()) {
                 String[] locktokens = allLockTokens.toArray(new String[allLockTokens.size()]);
                 IfHeader ifH = new IfHeader(locktokens);
                 method.setRequestHeader(ifH.getHeaderName(), ifH.getHeaderValue());
             }
         }
         
         initMethod(methodsessionInfo);
     }
 
     // set of HTTP methods that will not change the remote state
     private static final Set<StringreadMethods;
     static {
         Set<Stringtmp = new HashSet<String>();
         tmp.add("GET");
         tmp.add("HEAD");
         tmp.add("PROPFIND");
         tmp.add("POLL");
         tmp.add("REPORT");
         tmp.add("SEARCH");
          = Collections.unmodifiableSet(tmp);
     }
 
     // set headers for user data and session identification
     protected static void initMethod(HttpMethod methodSessionInfo sessionInfothrows RepositoryException {
 
         boolean isReadAccess = .contains(method.getName());
         boolean needsSessionId = !isReadAccess || "POLL".equals(method.getName());
 
         if (sessionInfo instanceof SessionInfoImpl && needsSessionId) {
             StringBuilder linkHeaderField = new StringBuilder();
 
             String sessionIdentifier = ((SessionInfoImplsessionInfo)
                     .getSessionIdentifier();
             linkHeaderField.append("<").append(sessionIdentifier).append(">; rel=\"")
                     .append(.).append("\"");
 
             String userdata = ((SessionInfoImplsessionInfo).getUserData();
             if (userdata != null && ! isReadAccess) {
                 String escaped = Text.escape(userdata);
                 linkHeaderField.append(", <data:,").append(escaped).append(">; rel=\"")
                     .append(.).append("\"");
             }
 
             method.addRequestHeader("Link"linkHeaderField.toString());
         }
     }
 
     private static void initMethod(DavMethod methodBatchImpl batchImplboolean addIfHeaderthrows RepositoryException {
         initMethod(methodbatchImpl.sessionInfo,  addIfHeader);
 
         // add batchId as separate header, TODO: could probably re-use session id Link relation
         CodedUrlHeader ch = new CodedUrlHeader(.batchImpl.batchId);
         method.setRequestHeader(ch.getHeaderName(), ch.getHeaderValue());
     }
 
     private static boolean isSameResource(String requestURIMultiStatusResponse response) {
         try {
             String href = resolve(requestURIresponse.getHref());
             if (href.endsWith("/") && !requestURI.endsWith("/")) {
                 href = href.substring(0, href.length() - 1);
             }
             return requestURI.equals(href);
         } catch (RepositoryException e) {
             return false;
         }
     }
 
     private String saveGetIdString(ItemId idSessionInfo sessionInfo) {
         NamePathResolver resolver = null;
         try {
             resolver = getNamePathResolver(sessionInfo);
         } catch (RepositoryException e) {
             // ignore.
         }
         return saveGetIdString(idresolver);
     }
 
     private String saveGetIdString(ItemId idNamePathResolver resolver) {
         StringBuffer bf = new StringBuffer();
         String uid = id.getUniqueID();
         if (uid != null) {
             bf.append(uid);
         }
         Path p = id.getPath();
         if (p != null) {
             if (resolver == null) {
                 bf.append(p.toString());
             } else {
                 try {
                     bf.append(resolver.getJCRPath(p));
                 } catch (NamespaceException e) {
                     bf.append(p.toString());
                 }
             }
         }
         return bf.toString();
     }
 
     protected NamePathResolver getNamePathResolver(SessionInfo sessionInfothrows RepositoryException {
         checkSessionInfo(sessionInfo);
         return getNamePathResolver(((SessionInfoImplsessionInfo));
     }
 
     private NamePathResolver getNamePathResolver(SessionInfoImpl sessionInfo) {
         NamePathResolver resolver = sessionInfo.getNamePathResolver();
         if (resolver == null) {
             resolver = new NamePathResolverImpl(sessionInfo);
             sessionInfo.setNamePathResolver(resolver);
         }
         return resolver;
     }

    
Returns a key for the httpClient hash. The key is either the specified SessionInfo or a marker if the session info is null (used during repository instantiation).

Parameters:
sessionInfo
Returns:
Key for the client map.
 
     private static Object getClientKey(SessionInfo sessionInfo) {
         return (sessionInfo == null) ?  : sessionInfo;
     }
 
     protected HttpClient getClient(SessionInfo sessionInfothrows RepositoryException {
         Object clientKey = getClientKey(sessionInfo);
         HttpClient client = .get(clientKey);
         if (client == null) {
             client = new HttpClient();
             client.setHostConfiguration();
             // NOTE: null credentials only work if 'missing-auth-mapping' param is
             // set on the server
             org.apache.commons.httpclient.Credentials creds = null;
             if (sessionInfo != null) {
                 checkSessionInfo(sessionInfo);
                 creds = ((SessionInfoImplsessionInfo).getCredentials().getCredentials();
                 // always send authentication not waiting for 401
                 client.getParams().setAuthenticationPreemptive(true);
             }
             client.getState().setCredentials(.creds);
             .put(clientKeyclient);
             .debug("Created Client " + client + " for SessionInfo " + sessionInfo);
         }
         return client;
     }
 
     private void removeClient(SessionInfo sessionInfo) {
         HttpClient cl = .remove(getClientKey(sessionInfo));
         .debug("Removed Client " + cl + " for SessionInfo " + sessionInfo);
     }
 
     protected String getItemUri(ItemId itemIdSessionInfo sessionInfothrows RepositoryException {
         return getItemUri(itemIdsessionInfosessionInfo.getWorkspaceName());
     }
 
     protected String getItemUri(ItemId itemIdSessionInfo sessionInfoString workspaceNamethrows RepositoryException {
         return .getItemUri(itemIdworkspaceNamesessionInfo);
     }

    
Clear all URI mappings. This is required after hierarchy operations such as e.g. MOVE.

Parameters:
sessionInfo
 
     protected void clearItemUriCache(SessionInfo sessionInfo) {
         .clearCacheEntries(sessionInfo);
     }
 
     private String getItemUri(NodeId parentIdName childName,
                               SessionInfo sessionInfothrows RepositoryException {
         String parentUri = .getItemUri(parentIdsessionInfo.getWorkspaceName(), sessionInfo);
         NamePathResolver resolver = getNamePathResolver(sessionInfo);
         // JCR-2920: don't append '/' to a trailing '/'
         if (!parentUri.endsWith("/")) {
             parentUri += "/";
         }
         return parentUri + Text.escape(resolver.getJCRName(childName));
     }
 
     private NodeId getParentId(String baseUriDavPropertySet propSetSessionInfo sessionInfo)
         throws RepositoryException {
         NodeId parentId = null;
         if (p != null) {
             HrefProperty parentProp = new HrefProperty(p);
             String parentHref = parentProp.getHrefs().get(0);
             if (parentHref != null && parentHref.length() > 0) {
                 parentId = .getNodeId(resolve(baseUriparentHref), sessionInfo);
             }
         }
         return parentId;
     }
 
     String getUniqueID(DavPropertySet propSet) {
         if (prop != null) {
             return prop.getValue().toString();
         } else {
             return null;
         }
     }
 
     Name getQName(DavPropertySet propSetNamePathResolver resolverthrows RepositoryException {
         DavProperty<?> nameProp = propSet.get(..);
         if (nameProp != null && nameProp.getValue() != null) {
             // not root node. Note that 'unespacing' is not required since
             // the jcr:name property does not provide the value in escaped form.
             String jcrName = nameProp.getValue().toString();
             try {
                 return resolver.getQName(jcrName);
             } catch (NameException e) {
                 throw new RepositoryException(e);
             }
         } else {
             return .;
         }
     }
 
     int getIndex(DavPropertySet propSet) {
         int index = .;
         DavProperty<?> indexProp = propSet.get(..);
         if (indexProp != null && indexProp.getValue() != null) {
             index = Integer.parseInt(indexProp.getValue().toString());
         }
         return index;
     }
 
     //--------------------------------------------------------------------------
     
Execute a 'Workspace' operation.

Parameters:
method
sessionInfo
Throws:
javax.jcr.RepositoryException
 
     private void execute(DavMethod methodSessionInfo sessionInfothrows RepositoryException {
         try {
             initMethod(methodsessionInfo, !isUnLockMethod(method));
 
             getClient(sessionInfo).executeMethod(method);
             method.checkSuccess();
 
         } catch (IOException e) {
             throw new RepositoryException(e);
         } catch (DavException e) {
             throw ExceptionConverter.generate(emethod);
         } finally {
             if (method != null) {
                 method.releaseConnection();
             }
         }
     }
 
     //--------------------------------------------------< RepositoryService >---
     
 
     public IdFactory getIdFactory() {
         return ;
     }

    
 
     public NameFactory getNameFactory() {
         return ;
     }

    
 
     public PathFactory getPathFactory() {
         return ;
     }
 
     public QValueFactory getQValueFactory() {
         return ;
     }
 
     public ItemInfoCache getItemInfoCache(SessionInfo sessionInfothrows RepositoryException {
         return new ItemInfoCacheImpl();
     }

    
 
     public Map<StringQValue[]> getRepositoryDescriptors() throws RepositoryException {
         if (.isEmpty()) {
             ReportMethod method = null;
             try {
                 method = new ReportMethod(.getRepositoryUri(), info);
                 int sc = getClient(null).executeMethod(method);
                 if (sc == .
                         || sc == .) {
                     // JCR-3076: Mandatory authentication prevents us from
                     // accessing the descriptors on the server, so instead
                     // of failing with an exception we simply return an empty
                     // set of descriptors
                     .warn("Authentication required to access repository descriptors");
                     return ;
                 }
 
                 method.checkSuccess();
                 Document doc = method.getResponseBodyAsDocument();
 
                 if (doc != null) {
                     Element rootElement = doc.getDocumentElement();
                     ElementIterator nsElems = DomUtil.getChildren(rootElement..);
                     while (nsElems.hasNext()) {
                         Element elem = nsElems.nextElement();
                         String key = DomUtil.getChildText(elem..);
                         ElementIterator it = DomUtil.getChildren(elem..);
                         List<QValuevs = new ArrayList<QValue>();
                         while (it.hasNext()) {
                             Element dv = it.nextElement();
                             String descriptor = DomUtil.getText(dv);
                             if (key != null && descriptor != null) {
                                 String typeStr = (DomUtil.getAttribute(dv.null));
                                 int type = (typeStr == null) ? . : PropertyType.valueFromName(typeStr);
                                 vs.add(getQValueFactory().create(descriptortype));
                             } else {
                                 .error("Invalid descriptor key / value pair: " + key + " -> " + descriptor);
                             }
 
                         }
                         .put(keyvs.toArray(new QValue[vs.size()]));
                     }
                 }
             } catch (IOException e) {
                 throw new RepositoryException(e);
             } catch (DavException e) {
                 throw ExceptionConverter.generate(e);
             } finally {
                 if (method != null) {
                     method.releaseConnection();
                 }
             }
         }
         return ;
     }

    
 
     public SessionInfo obtain(Credentials credentialsString workspaceName)
         CredentialsWrapper dc = new CredentialsWrapper(credentials);
         return obtain(dcworkspaceName);
     }
 
     public SessionInfo obtain(SessionInfo sessionInfoString workspaceName)
         checkSessionInfo(sessionInfo);
         return obtain(((SessionInfoImpl)sessionInfo).getCredentials(), workspaceName);
     }
 
     public SessionInfo impersonate(SessionInfo sessionInfoCredentials credentialsthrows LoginExceptionRepositoryException {
         throw new UnsupportedOperationException("Not implemented yet.");
     }
 
     private SessionInfo obtain(CredentialsWrapper credentialsString workspaceName)
         // check if the workspace with the given name is accessible
         PropFindMethod method = null;
         SessionInfoImpl sessionInfo = new SessionInfoImpl(credentialsworkspaceName);
         try {
             DavPropertyNameSet nameSet = new DavPropertyNameSet();
             // for backwards compat. -> retrieve DAV:workspace if the newly
             // added property (workspaceName) is not supported by the server.
             nameSet.add(.);
 
             method = new PropFindMethod(.getWorkspaceUri(workspaceName), nameSet);
             getClient(sessionInfo).executeMethod(method);
 
             MultiStatusResponse[] responses = method.getResponseBodyAsMultiStatus().getResponses();
             if (responses.length != 1) {
                 throw new LoginException("Login failed: Unknown workspace '" + workspaceName"'.");
             }
 
             DavPropertySet props = responses[0].getProperties(.);
             if (prop != null) {
                 String wspName = prop.getValue().toString();
                 if (workspaceName == null) {
                     // login with 'null' workspace name -> retrieve the effective
                     // workspace name from the property and recreate the SessionInfo.
                     sessionInfo = new SessionInfoImpl(credentialswspName);
                 } else if (!wspName.equals(workspaceName)) {
                     throw new LoginException("Login failed: Invalid workspace name '" + workspaceName + "'.");
                 }
             } else if (props.contains(.)) {
                 String wspHref = new HrefProperty(props.get(.)).getHrefs().get(0);
                 String wspName = Text.unescape(Text.getName(wspHreftrue));
                 if (!wspName.equals(workspaceName)) {
                     throw new LoginException("Login failed: Invalid workspace name " + workspaceName);
                 }
             } else {
                 throw new LoginException("Login failed: Unknown workspace '" + workspaceName"'.");
             }
         } catch (IOException e) {
             throw new RepositoryException(e.getMessage());
         } catch (DavException e) {
             throw ExceptionConverter.generate(e);
         } finally {
             if (method != null) {
                 method.releaseConnection();
             }
         }
 
         // make sure the general namespace mappings have been loaded once
         // before additional requests are executed that rely on the namespace
         // mappings.
         if (..isEmpty()) {
             try {
                 getRegisteredNamespaces(sessionInfo);
             } catch (RepositoryException e) {
                 // ignore
             }
         }
 
         // return the sessionInfo
         return sessionInfo;
     }
 
     public void dispose(SessionInfo sessionInfothrows RepositoryException {
         checkSessionInfo(sessionInfo);
         removeClient(sessionInfo);
     }

    
 
     public String[] getWorkspaceNames(SessionInfo sessionInfothrows RepositoryException {
         DavPropertyNameSet nameSet = new DavPropertyNameSet();
         nameSet.add(.);
         PropFindMethod method = null;
         try {
             method = new PropFindMethod(.getRepositoryUri(), nameSet);
             getClient(sessionInfo).executeMethod(method);
             MultiStatusResponse[] responses = method.getResponseBodyAsMultiStatus().getResponses();
             Set<StringwspNames = new HashSet<String>();
             for (MultiStatusResponse response : responses) {
                 DavPropertySet props = response.getProperties(.);
                 if (props.contains(.)) {
                     HrefProperty hp = new HrefProperty(props.get(.));
                     String wspHref = hp.getHrefs().get(0);
                     String name = Text.unescape(Text.getName(wspHreftrue));
                     wspNames.add(name);
                 }
             }
             return wspNames.toArray(new String[wspNames.size()]);
         } catch (IOException e) {
             throw new RepositoryException(e);
         } catch (DavException e) {
             throw ExceptionConverter.generate(e);
         } finally {
             if (method != null) {
                 method.releaseConnection();
             }
         }
     }

    

See also:
RepositoryService.isGranted(SessionInfo, ItemId, String[] actions)
 
     public boolean isGranted(SessionInfo sessionInfoItemId itemIdString[] actionsthrows RepositoryException {
         ReportMethod method = null;
         try {
             String uri = obtainAbsolutePathFromUri(getItemUri(itemIdsessionInfo));
             reportInfo.setContentElement(DomUtil.hrefToXml(uri, DomUtil.createDocument()));
 
             method = new ReportMethod(.getWorkspaceUri(sessionInfo.getWorkspaceName()), reportInfo);
             getClient(sessionInfo).executeMethod(method);
             method.checkSuccess();
 
             MultiStatusResponse[] responses = method.getResponseBodyAsMultiStatus().getResponses();
             if (responses.length < 1) {
                 throw new ItemNotFoundException("Unable to retrieve permissions for item " + saveGetIdString(itemIdsessionInfo));
             }
             if (p == null) {
                 return false;
             }
             // build set of privileges from given actions. NOTE: since the actions
             // have no qualifying namespace, the {@link ItemResourceConstants#NAMESPACE}
             // is used.
             Set<PrivilegerequiredPrivileges = new HashSet<Privilege>();
             for (String action : actions) {
                 requiredPrivileges.add(Privilege.getPrivilege(action.));
             }
             // build set of privileges granted to the current user.
             CurrentUserPrivilegeSetProperty privSet = new CurrentUserPrivilegeSetProperty(p);
             Collection<Privilegeprivileges = privSet.getValue();
 
             // check privileges present against required privileges.
             return privileges.containsAll(requiredPrivileges);
         } catch (IOException e) {
             throw new RepositoryException(e);
         } catch (ParserConfigurationException e) {
             throw new RepositoryException(e);
         } catch (DavException e) {
             throw ExceptionConverter.generate(e);
         } finally {
             if (method != null) {
                 method.releaseConnection();
             }
         }
     }

    
 
     public QNodeDefinition getNodeDefinition(SessionInfo sessionInfoNodeId nodeIdthrows RepositoryException {
         return (QNodeDefinitiongetItemDefinition(sessionInfonodeId);
     }

    
 
     public QPropertyDefinition getPropertyDefinition(SessionInfo sessionInfoPropertyId propertyIdthrows RepositoryException {
         return (QPropertyDefinitiongetItemDefinition(sessionInfopropertyId);
     }

    

Parameters:
sessionInfo
itemId
Returns:
Throws:
javax.jcr.RepositoryException
 
     private QItemDefinition getItemDefinition(SessionInfo sessionInfoItemId itemIdthrows RepositoryException {
         // set of properties to be retrieved
         DavPropertyNameSet nameSet = new DavPropertyNameSet();
         nameSet.add(.);
 
         DavMethodBase method = null;
         try {
             String uri = getItemUri(itemIdsessionInfo);
             method = new PropFindMethod(urinameSet);
             getClient(sessionInfo).executeMethod(method);
 
             MultiStatusResponse[] responses = method.getResponseBodyAsMultiStatus().getResponses();
             if (responses.length < 1) {
                 throw new ItemNotFoundException("Unable to retrieve the item definition for " + saveGetIdString(itemIdsessionInfo));
             }
             if (responses.length > 1) {
                 throw new RepositoryException("Internal error: ambigous item definition found '" + saveGetIdString(itemIdsessionInfo) + "'.");
             }
             DavPropertySet propertySet = responses[0].getProperties(.);
 
             // check if definition matches the type of the id
             DavProperty<?> rType = propertySet.get(.);
             if (rType.getValue() == null && itemId.denotesNode()) {
                 throw new RepositoryException("Internal error: requested node definition and got property definition.");
             }
 
             NamePathResolver resolver = getNamePathResolver(sessionInfo);
 
             // build the definition
             QItemDefinition definition = null;
             DavProperty<?> prop = propertySet.get(..);
             if (prop != null) {
                 Object value = prop.getValue();
                 if (value != null && value instanceof Element) {
                     Element idfElem = (Elementvalue;
                     if (itemId.denotesNode()) {
                         definition = DefinitionUtil.createQNodeDefinition(nullidfElemresolver);
                     } else {
                         definition = DefinitionUtil.createQPropertyDefinition(nullidfElemresolvergetQValueFactory());
                     }
                 }
             }
             if (definition == null) {
                 throw new RepositoryException("Unable to retrieve definition for item with id '" + saveGetIdString(itemIdresolver) + "'.");
             }
             return definition;
         } catch (IOException e) {
             throw new RepositoryException(e);
         } catch (DavException e) {
             throw ExceptionConverter.generate(e);
         } finally {
             if (method != null) {
                 method.releaseConnection();
             }
         }
     }

    
 
     public NodeInfo getNodeInfo(SessionInfo sessionInfoNodeId nodeIdthrows RepositoryException {
         // set of properties to be retrieved
         DavPropertyNameSet nameSet = new DavPropertyNameSet();
        nameSet.add(.);
        DavMethodBase method = null;
        try {
            String uri = getItemUri(nodeIdsessionInfo);
            method = new PropFindMethod(urinameSet);
            getClient(sessionInfo).executeMethod(method);
            method.checkSuccess();
            MultiStatusResponse[] responses = method.getResponseBodyAsMultiStatus().getResponses();
            if (responses.length < 1) {
                throw new ItemNotFoundException("Unable to retrieve the node with id " + saveGetIdString(nodeIdsessionInfo));
            }
            MultiStatusResponse nodeResponse = null;
            List<MultiStatusResponsechildResponses = new ArrayList<MultiStatusResponse>();
            for (MultiStatusResponse response : responses) {
                if (isSameResource(uriresponse)) {
                    nodeResponse = response;
                } else {
                    childResponses.add(response);
                }
            }
            if (nodeResponse == null) {
                throw new ItemNotFoundException("Unable to retrieve the node " +