/** * Adds a new property to this set. * * @param property The property to add * * @return The previously assigned property or <code>null</code>. */ public DavProperty add(DavProperty property) { return (DavProperty) map.put(property.getName(), property); }
/** * Adds a new property to this set. * * @param property The property to add * * @return The previously assigned property or <code>null</code>. */ public DavProperty<?> add(DavProperty<?> property) { return map.put(property.getName(), property); }
/** * Adds a new property to this set. * * @param property The property to add * * @return The previously assigned property or <code>null</code>. */ public DavProperty<?> add(DavProperty<?> property) { return map.put(property.getName(), property); }
/** * Seeks for the next valid property */ private void seek() { while (iterator.hasNext()) { next = iterator.next(); if (namespace == null || namespace.equals(next.getName().getNamespace())) { return; } } next = null; } }
/** * Seeks for the next valid property */ private void seek() { while (iterator.hasNext()) { next = iterator.next(); if (namespace == null || namespace.equals(next.getName().getNamespace())) { return; } } next = null; } }
/** * Seeks for the next valid property */ private void seek() { while (iterator.hasNext()) { next = (DavProperty) iterator.next(); if (namespace == null || namespace.equals(next.getName().getNamespace())) { return; } } next = null; } }
public ProppatchInfo(List<? extends PropEntry> changeList) { if (changeList == null || changeList.isEmpty()) { throw new IllegalArgumentException("PROPPATCH cannot be executed without properties to be set or removed."); } this.changeList = changeList; this.setProperties = null; this.removeProperties = null; for (PropEntry entry : changeList) { if (entry instanceof DavPropertyName) { // DAV:remove this.propertyNames.add((DavPropertyName) entry); } else if (entry instanceof DavProperty) { // DAV:set DavProperty<?> setProperty = (DavProperty<?>) entry; this.propertyNames.add(setProperty.getName()); } else { throw new IllegalArgumentException("ChangeList may only contain DavPropertyName and DavProperty elements."); } } }
public ProppatchInfo(List<? extends PropEntry> changeList) { if (changeList == null || changeList.isEmpty()) { throw new IllegalArgumentException("PROPPATCH cannot be executed without properties to be set or removed."); } this.changeList = changeList; this.setProperties = null; this.removeProperties = null; for (PropEntry entry : changeList) { if (entry instanceof DavPropertyName) { // DAV:remove this.propertyNames.add((DavPropertyName) entry); } else if (entry instanceof DavProperty) { // DAV:set DavProperty<?> setProperty = (DavProperty<?>) entry; this.propertyNames.add(setProperty.getName()); } else { throw new IllegalArgumentException("ChangeList may only contain DavPropertyName and DavProperty elements."); } } }
/** * Create a new <code>NodeTypeProperty</code> from the specified general * DavProperty object. * * @param property */ public NodeTypeProperty(DavProperty<?> property) { super(property.getName(), property.isInvisibleInAllprop()); if (property instanceof NodeTypeProperty) { nodetypeNames.addAll(((NodeTypeProperty) property).nodetypeNames); } else { nodetypeNames.addAll(NodeTypeUtil.ntNamesFromXml(property.getValue())); } }
/** * Wrap the specified <code>DavProperty</code> in a new <code>SearchResultProperty</code>. * * @param property * @param valueFactory factory used to deserialize the xml value to a JCR value. * @throws RepositoryException if an error occurs while build the property value * @throws IllegalArgumentException if the specified property does have the * required form. * @see #getValues() */ public SearchResultProperty(DavProperty<?> property, ValueFactory valueFactory) throws RepositoryException { super(property.getName(), true); if (!SEARCH_RESULT_PROPERTY.equals(getName())) { throw new IllegalArgumentException("SearchResultProperty may only be created from a property named " + SEARCH_RESULT_PROPERTY.toString()); } List<String> colList = new ArrayList<String>(); List<String> selList = new ArrayList<String>(); List<Value> valList = new ArrayList<Value>(); QueryUtil.parseResultPropertyValue(property.getValue(), colList, selList, valList, valueFactory); columnNames = colList.toArray(new String[colList.size()]); selectorNames = selList.toArray(new String[selList.size()]); values = valList.toArray(new Value[valList.size()]); }
/** * @param property Property containing the {@link CalDAVConstants#ELEM_GETETAG} * @return Returns the ETag from the specified Property, null otherwise. */ public static String getEtagfromProperty(DavProperty property){ if(property == null || property.getValue() == null || !property.getName().equals(DavPropertyName.GETETAG)) return null; return property.getValue().toString(); } }
/** * Always return a {@link org.apache.jackrabbit.webdav.MultiStatusResponse} with entries having status code * {@link javax.servlet.http.HttpServletResponse#SC_FORBIDDEN}. */ public MultiStatusResponse alterProperties(List changeList) throws DavException { MultiStatusResponse msr = new MultiStatusResponse(getHref(), null); Iterator it = changeList.iterator(); while (it.hasNext()) { Object o = it.next(); int statusCode = DavServletResponse.SC_FORBIDDEN; if (o instanceof DavProperty) { msr.add(((DavProperty) o).getName(), statusCode); } else { msr.add((DavPropertyName) o, statusCode); } } return msr; }
/** * @param property dav property * @param contentNode the content node * @throws RepositoryException if an error during repository access occurs. */ private void setJcrProperty(DavProperty<?> property, Node contentNode) throws RepositoryException { // Retrieve the property value. Note, that a 'null' value is replaced // by empty string, since setting a jcr property value to 'null' // would be equivalent to its removal. String value = ""; if (property.getValue() != null) { value = property.getValue().toString(); } DavPropertyName davName = property.getName(); if (DavPropertyName.GETCONTENTTYPE.equals(davName)) { String mimeType = IOUtil.getMimeType(value); String encoding = IOUtil.getEncoding(value); contentNode.setProperty(JcrConstants.JCR_MIMETYPE, mimeType); contentNode.setProperty(JcrConstants.JCR_ENCODING, encoding); } else { contentNode.setProperty(getJcrName(davName, contentNode.getSession()), value); } }
/** * Handles an attempt to set {@link ItemResourceConstants#JCR_NAMESPACES} * and forwards any other set or remove requests to the super class. * * @see #setProperty(DavProperty) * @see DefaultItemCollection#alterProperties(List) */ @Override public MultiStatusResponse alterProperties(List<? extends PropEntry> changeList) throws DavException { if (changeList.size() == 1) { PropEntry propEntry = changeList.get(0); // only modification of prop is allowed. removal is not possible if (propEntry instanceof DavProperty && (ItemResourceConstants.JCR_NAMESPACES.equals(((DavProperty<?>)propEntry).getName()) || ItemResourceConstants.JCR_NODETYPES_CND.equals(((DavProperty<?>)propEntry).getName()))) { setProperty((DavProperty<?>) propEntry); } else { // attempt to remove the namespace property throw new DavException(DavServletResponse.SC_CONFLICT); } } else { // change list contains more than the jcr:namespaces property // TODO: build multistatus instead throw new DavException(DavServletResponse.SC_CONFLICT); } return new MultiStatusResponse(getHref(), DavServletResponse.SC_OK); }
/** * Create a new <code>CurrentUserPrivilegeSetProperty</code> from a DavProperty * as obtained from a MultiStatusResponse. * * @param xmlDavProperty * @throws DavException */ public CurrentUserPrivilegeSetProperty(DavProperty<?> xmlDavProperty) throws DavException { super(xmlDavProperty.getName(), true); if (!SecurityConstants.CURRENT_USER_PRIVILEGE_SET.equals(getName())) { throw new DavException(DavServletResponse.SC_BAD_REQUEST, "DAV:current-user-privilege-set expected."); } privileges = new HashSet<Privilege>(); // parse property value Object value = xmlDavProperty.getValue(); if (value != null) { if (value instanceof Element) { privileges.add(Privilege.getPrivilege((Element)value)); } else if (value instanceof Collection) { for (Object entry : ((Collection<?>) value)) { if (entry instanceof Element) { privileges.add(Privilege.getPrivilege((Element) entry)); } } } } }
/** * 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); }
/** * Checks if this property has the same {@link DavPropertyName name} * and value as the given one. * * @param obj the object to compare to * @return <code>true</code> if the 2 objects are equal; * <code>false</code> otherwise */ @Override public boolean equals(Object obj) { if (obj instanceof DavProperty) { DavProperty<?> prop = (DavProperty<?>) obj; boolean equalName = getName().equals(prop.getName()); boolean equalValue = (getValue() == null) ? prop.getValue() == null : getValue().equals(prop.getValue()); return equalName && equalValue; } return false; }
/** * Checks if this property has the same {@link DavPropertyName name} * and value as the given one. * * @param obj the object to compare to * @return <code>true</code> if the 2 objects are equal; * <code>false</code> otherwise */ public boolean equals(Object obj) { if (obj instanceof DavProperty) { DavProperty prop = (DavProperty) obj; boolean equalName = getName().equals(prop.getName()); boolean equalValue = (getValue() == null) ? prop.getValue() == null : getValue().equals(prop.getValue()); return equalName && equalValue; } return false; }
/** * Checks if this property has the same {@link DavPropertyName name} * and value as the given one. * * @param obj the object to compare to * @return <code>true</code> if the 2 objects are equal; * <code>false</code> otherwise */ @Override public boolean equals(Object obj) { if (obj instanceof DavProperty) { DavProperty<?> prop = (DavProperty<?>) obj; boolean equalName = getName().equals(prop.getName()); boolean equalValue = (getValue() == null) ? prop.getValue() == null : getValue().equals(prop.getValue()); return equalName && equalValue; } return false; }
/** * Internal method that performs the setting or adding of properties * * @param property * @throws DavException * @see #setProperty(DavProperty) * @see #alterProperties(List) */ private void internalSetProperty(DavProperty<?> property) throws DavException { if (!exists()) { throw new DavException(DavServletResponse.SC_NOT_FOUND); } try { Property prop = (Property) item; int defaultType = prop.getType(); ValueFactory vfact = getRepositorySession().getValueFactory(); ValuesProperty vp = new ValuesProperty(property, defaultType, vfact); if (property.getName().equals(JCR_VALUE)) { prop.setValue(vp.getJcrValue(vp.getValueType(), vfact)); } else if (property.getName().equals(JCR_VALUES)) { prop.setValue(vp.getJcrValues()); } else { throw new DavException(DavServletResponse.SC_CONFLICT); } } catch (RepositoryException e) { throw new JcrDavException(e); } }