/** * @see Report#init(DavResource, ReportInfo) */ public void init(DavResource resource, ReportInfo info) throws DavException { super.init(resource, info); // build the DAV:responses objects. DavProperty acl = resource.getProperty(SecurityConstants.ACL); if (!(acl instanceof AclProperty)) { throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, "DAV:acl property expected."); } DavResourceLocator loc = resource.getLocator(); Map principalMap = new HashMap(); Iterator aceIt = ((List)((AclProperty)acl).getValue()).iterator(); while (aceIt.hasNext()) { AclProperty.Ace ace = (AclProperty.Ace) aceIt.next(); String href = ace.getPrincipal().getHref(); if (href == null && principalMap.containsKey(href)) { // ignore non-href principals and principals that have been listed before continue; } // href-principal that has not been found before DavResourceLocator princLocator = loc.getFactory().createResourceLocator(loc.getPrefix(), href); DavResource principalResource = resource.getFactory().createResource(princLocator, resource.getSession()); principalMap.put(href, new MultiStatusResponse(principalResource, info.getPropertyNameSet())); } this.responses = (MultiStatusResponse[]) principalMap.values().toArray(new MultiStatusResponse[principalMap.size()]); } }
/** * @see Report#init(DavResource, ReportInfo) */ @Override public void init(DavResource resource, ReportInfo info) throws DavException { super.init(resource, info); // build the DAV:responses objects. DavProperty<?> acl = resource.getProperty(SecurityConstants.ACL); if (!(acl instanceof AclProperty)) { throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, "DAV:acl property expected."); } DavResourceLocator loc = resource.getLocator(); Map<String, MultiStatusResponse> respMap = new HashMap<String, MultiStatusResponse>(); List<AclProperty.Ace> list = (List<AclProperty.Ace>) ((AclProperty)acl).getValue(); for (AclProperty.Ace ace : list) { String href = ace.getPrincipal().getHref(); if (href == null || respMap.containsKey(href)) { // ignore non-href principals and principals that have been listed before continue; } // href-principal that has not been found before DavResourceLocator princLocator = loc.getFactory().createResourceLocator(loc.getPrefix(), href); DavResource principalResource = resource.getFactory().createResource(princLocator, resource.getSession()); respMap.put(href, new MultiStatusResponse(principalResource, info.getPropertyNameSet())); } this.responses = respMap.values().toArray(new MultiStatusResponse[respMap.size()]); } }
/** * @see Report#init(DavResource, ReportInfo) */ @Override public void init(DavResource resource, ReportInfo info) throws DavException { super.init(resource, info); // build the DAV:responses objects. DavProperty<?> acl = resource.getProperty(SecurityConstants.ACL); if (!(acl instanceof AclProperty)) { throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, "DAV:acl property expected."); } DavResourceLocator loc = resource.getLocator(); Map<String, MultiStatusResponse> respMap = new HashMap<String, MultiStatusResponse>(); List<AclProperty.Ace> list = (List<AclProperty.Ace>) ((AclProperty)acl).getValue(); for (AclProperty.Ace ace : list) { String href = ace.getPrincipal().getHref(); if (href == null || respMap.containsKey(href)) { // ignore non-href principals and principals that have been listed before continue; } // href-principal that has not been found before DavResourceLocator princLocator = loc.getFactory().createResourceLocator(loc.getPrefix(), href); DavResource principalResource = resource.getFactory().createResource(princLocator, resource.getSession()); respMap.put(href, new MultiStatusResponse(principalResource, info.getPropertyNameSet())); } this.responses = respMap.values().toArray(new MultiStatusResponse[respMap.size()]); } }
/** * Retrieve a Caldav Principal from a jackrabbit-webdav Ace. * If ace.getprincipal is set to "property", it returns directly the underlying property * @param ace Ace to retrieve the Principal from. * @return CalDav Principal associated with the Ace. */ public static Principal getDavPrincipal(AclProperty.Ace ace) { return ace.getPrincipal(); } }