private QName propNameToQName(DavPropertyName name) { if (name == null) { final String msg = "name cannot be null"; throw new IllegalArgumentException(msg); } Namespace ns = name.getNamespace(); String uri = ns != null ? ns.getURI() : ""; return entityFactory.createQName(uri, name.getName()); }
while (iter2.hasNext()) { DavProperty property = iter2.next(); if (!attributes.containsKey(property.getName().getName())) { property = getProperty(fileName, property.getName()); if (property != null) {
private QName propNameToQName(DavPropertyName name) { if (name == null) { final String msg = "name cannot be null"; throw new IllegalArgumentException(msg); } Namespace ns = name.getNamespace(); String uri = ns != null ? ns.getURI() : ""; return entityFactory.createQName(uri, name.getName()); }
while (iter2.hasNext()) { DavProperty property = iter2.next(); if (!attributes.containsKey(property.getName().getName())) { property = getProperty(fileName, property.getName()); if (property != null) {
if (value == null) { return new PropertyValue(davPropertyName.getNamespace().getURI(), davPropertyName.getName()); } else if (field.isMultivalued) { StringBuilder buffer = new StringBuilder(); buffer.append("</v>"); return new PropertyValue(davPropertyName.getNamespace().getURI(), davPropertyName.getName(), buffer.toString()); } else if (field.isBooleanValue) { if ("true".equals(value)) { return new PropertyValue(davPropertyName.getNamespace().getURI(), davPropertyName.getName(), "1", "boolean"); } else if ("false".equals(value)) { return new PropertyValue(davPropertyName.getNamespace().getURI(), davPropertyName.getName(), "0", "boolean"); } else { throw new RuntimeException("Invalid value for " + field.alias + ": " + value); return new PropertyValue(davPropertyName.getNamespace().getURI(), davPropertyName.getName(), StringUtil.xmlEncode(value), "float"); } else if (field.isIntValue) { return new PropertyValue(field.updatePropertyName.getNamespace().getURI(), field.updatePropertyName.getName(), StringUtil.xmlEncode(value), "int"); } else if (field.isDateValue) { return new PropertyValue(field.updatePropertyName.getNamespace().getURI(), field.updatePropertyName.getName(), StringUtil.xmlEncode(value), "dateTime.tz"); } else { return new PropertyValue(davPropertyName.getNamespace().getURI(), davPropertyName.getName(), StringUtil.xmlEncode(value));
while (iter2.hasNext()) { DavProperty property = iter2.next(); if (!attributes.containsKey(property.getName().getName())) { property = getProperty(fileName, property.getName()); if (property != null) {
&& DomUtil.hasChildElement(root, ObservationConstants.SUBSCRIPTIONDISCOVERY.getName(), ObservationConstants.SUBSCRIPTIONDISCOVERY.getNamespace())) { throw new DavException(response.getStatusLine().getStatusCode(), Element sde = DomUtil.getChildElement(root, ObservationConstants.SUBSCRIPTIONDISCOVERY.getName(), ObservationConstants.SUBSCRIPTIONDISCOVERY.getNamespace()); SubscriptionDiscovery sd = SubscriptionDiscovery.createFromXml(sde);
/** * Wrap the specified <code>DavProperty</code> in a new <code>ValuesProperty</code>. * * @param property * @param defaultType default type of the values to be deserialized. If however * the {@link #XML_VALUE 'value'} elements provide a {@link #ATTR_VALUE_TYPE 'type'} * attribute, the default value is ignored. * @param valueFactory Factory used to retrieve JCR values from the value * of the given <code>DavProperty</code>. */ public ValuesProperty(DavProperty<?> property, int defaultType, ValueFactory valueFactory) throws RepositoryException, DavException { super(property.getName(), false); if (!(JCR_VALUES.equals(property.getName()) || JCR_VALUE.equals(getName()))) { throw new DavException(DavServletResponse.SC_BAD_REQUEST, "ValuesProperty may only be created with a property that has name="+JCR_VALUES.getName()); } jcrValues = ValueUtil.valuesFromXml(property.getValue(), defaultType, valueFactory); }
public static SubscriptionDiscovery createFromXml(Element sDiscoveryElement) { if (!DomUtil.matches(sDiscoveryElement, ObservationConstants.SUBSCRIPTIONDISCOVERY.getName(), ObservationConstants.SUBSCRIPTIONDISCOVERY.getNamespace())) { throw new IllegalArgumentException("'subscriptiondiscovery' element expected.");
&& DomUtil.hasChildElement(root, ObservationConstants.SUBSCRIPTIONDISCOVERY.getName(), ObservationConstants.SUBSCRIPTIONDISCOVERY.getNamespace())) { throw new DavException(response.getStatusLine().getStatusCode(), Element sde = DomUtil.getChildElement(root, ObservationConstants.SUBSCRIPTIONDISCOVERY.getName(), ObservationConstants.SUBSCRIPTIONDISCOVERY.getNamespace()); SubscriptionDiscovery sd = SubscriptionDiscovery.createFromXml(sde);
/** * Build a new <code>AclProperty</code> object from the request body of the * ACL method call. * * @param aclElement * @return new <code>AclProperty</code> * @throws DavException */ public static AclProperty createFromXml(Element aclElement) throws DavException { if (!DomUtil.matches(aclElement, SecurityConstants.ACL.getName(), SecurityConstants.ACL.getNamespace())) { throw new DavException(DavServletResponse.SC_BAD_REQUEST, "ACL request requires a DAV:acl body."); } List<Ace> aces = new ArrayList<Ace>(); ElementIterator it = DomUtil.getChildren(aclElement, Ace.XML_ACE, SecurityConstants.NAMESPACE); while (it.hasNext()) { Element aceElem = it.nextElement(); aces.add(Ace.createFromXml(aceElem)); } return new AclProperty(aces); }
public static SubscriptionDiscovery createFromXml(Element sDiscoveryElement) { if (!DomUtil.matches(sDiscoveryElement, ObservationConstants.SUBSCRIPTIONDISCOVERY.getName(), ObservationConstants.SUBSCRIPTIONDISCOVERY.getNamespace())) { throw new IllegalArgumentException("'subscriptiondiscovery' element expected.");
/** * Build a new <code>AclProperty</code> object from the request body of the * ACL method call. * * @param aclElement * @return new <code>AclProperty</code> * @throws DavException */ public static AclProperty createFromXml(Element aclElement) throws DavException { if (!DomUtil.matches(aclElement, SecurityConstants.ACL.getName(), SecurityConstants.ACL.getNamespace())) { throw new DavException(DavServletResponse.SC_BAD_REQUEST, "ACL request requires a DAV:acl body."); } List<Ace> aces = new ArrayList<Ace>(); ElementIterator it = DomUtil.getChildren(aclElement, Ace.XML_ACE, SecurityConstants.NAMESPACE); while (it.hasNext()) { Element aceElem = it.nextElement(); aces.add(Ace.createFromXml(aceElem)); } return new AclProperty(aces); }
/** * Build a new <code>AclProperty</code> object from the request body of the * ACL method call. * * @param aclElement * @return new <code>AclProperty</code> * @throws DavException */ public static AclProperty createFromXml(Element aclElement) throws DavException { if (!DomUtil.matches(aclElement, SecurityConstants.ACL.getName(), SecurityConstants.ACL.getNamespace())) { throw new DavException(DavServletResponse.SC_BAD_REQUEST, "ACL request requires a DAV:acl body."); } List aces = new ArrayList(); ElementIterator it = DomUtil.getChildren(aclElement, Ace.XML_ACE, SecurityConstants.NAMESPACE); while (it.hasNext()) { Element aceElem = it.nextElement(); aces.add(Ace.createFromXml(aceElem)); } return new AclProperty(aces); }
public static SubscriptionDiscovery createFromXml(Element sDiscoveryElement) { if (!DomUtil.matches(sDiscoveryElement, ObservationConstants.SUBSCRIPTIONDISCOVERY.getName(), ObservationConstants.SUBSCRIPTIONDISCOVERY.getNamespace())) { throw new IllegalArgumentException("'subscriptiondiscovery' element expected.");
/** * @see Report#init(DavResource, ReportInfo) */ @Override public void init(DavResource resource, ReportInfo info) throws DavException { // general validation checks super.init(resource, info); // specific for this report: a workspace href must be provided Element workspace = info.getContentElement(DeltaVConstants.WORKSPACE.getName(), DeltaVConstants.WORKSPACE.getNamespace()); String workspaceHref = DomUtil.getChildTextTrim(workspace, DavConstants.XML_HREF, DavConstants.NAMESPACE); if (workspaceHref == null || "".equals(workspaceHref)) { throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Request body must define the href of a source workspace"); } // retrieve href of the corresponding resource in the other workspace try { this.correspHref = getCorrespondingResourceHref(resource, getRepositorySession(), workspaceHref); } catch (RepositoryException e) { throw new JcrDavException(e); } }
/** * Build jcr property name from dav property name. If the property name * defines a namespace uri, that has not been registered yet, an attempt * is made to register the uri with the prefix defined. * * @param propName name of the dav property * @param session repository session * @return jcr name * @throws RepositoryException if an error during repository access occurs. */ private String getJcrName(DavPropertyName propName, Session session) throws RepositoryException { // remove any encoding necessary for xml compliance String pName = ISO9075.decode(propName.getName()); Namespace propNamespace = propName.getNamespace(); if (!Namespace.EMPTY_NAMESPACE.equals(propNamespace)) { NamespaceHelper helper = new NamespaceHelper(session); String prefix = helper.registerNamespace( propNamespace.getPrefix(), propNamespace.getURI()); pName = prefix + ":" + pName; } return pName; }