PropPatchMethod.java

Index Score
org.apache.slide.webdav.method
Jakarta Slide

View: Reasons, Metrics, Source Code

These are the metrics that contribute to the Enerjy Score for this file, ranked by impact. So the metrics listed at the top influence the score to a greater extent that the metrics listed at the bottom.

MetricDescription
DECL_COMMENTSComments in declarations
SIZESize of the file in bytes
EXITSProcedure exits
DOC_COMMENTNumber of javadoc comment lines
COMMENTSComment lines
LINESNumber of lines in the source file
CYCLOMATICCyclomatic complexity
UNIQUE_OPERANDSNumber of unique operands
OPERANDSNumber of operands
PROGRAM_LENGTHHalstead program length
JAVA0034JAVA0034 Missing braces in if statement
BLOCKSNumber of blocks
OPERATORSNumber of operators
PROGRAM_VOCABHalstead program vocabulary
JAVA0254JAVA0254 Use enhanced for loop construct instead of Iterator
EXEC_COMMENTSComments in executable code
ELOCEffective lines of code
LOGICAL_LINESNumber of statements
LOCLines of code
COMPARISONSNumber of comparison operators
LINE_COMMENTNumber of line comments
JAVA0144JAVA0144 Line exceeds maximum M characters
JAVA0130JAVA0130 Non-static method does not use instance fields
JAVA0166JAVA0166 Generic exception caught
INTERFACE_COMPLEXITYInterface complexity
PARAMSNumber of formal parameter declarations
NEST_DEPTHMaximum nesting depth
JAVA0115JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
RETURNSNumber of return points from functions
WHITESPACENumber of whitespace lines
JAVA0173JAVA0173 Unused method parameter
FUNCTIONSNumber of function declarations
LOOPSNumber of loops
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0117JAVA0117 Missing javadoc: method 'method'
PROGRAM_VOLUMEHalstead program volume
JAVA0126JAVA0126 Method declares unchecked exception in throws
JAVA0109JAVA0109 Incorrect javadoc: no parameter 'parameter'
UNIQUE_OPERATORSNumber of unique operators
JAVA0075JAVA0075 Method parameter hides field
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
JAVA0145JAVA0145 Tab character used in source file
/* * $Header$ * $Revision: 208545 $ * $Date: 2005-02-25 12:07:59 -0500 (Fri, 25 Feb 2005) $ * * ==================================================================== * * Copyright 1999-2002 The Apache Software Foundation * * Licensed 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.slide.webdav.method; import java.io.IOException; import java.io.Writer; import java.util.Date; import java.util.Iterator; import java.util.List; import org.apache.slide.common.Domain; import org.apache.slide.common.NamespaceAccessToken; import org.apache.slide.common.PropertyParseException; import org.apache.slide.common.RequestedPropertiesImpl; import org.apache.slide.common.RequestedProperty; import org.apache.slide.common.RequestedPropertyImpl; import org.apache.slide.common.ServiceAccessException; import org.apache.slide.common.Uri; import org.apache.slide.content.NodeProperty; import org.apache.slide.content.NodeRevisionDescriptor; import org.apache.slide.content.NodeRevisionDescriptors; import org.apache.slide.content.NodeRevisionNumber; import org.apache.slide.content.RevisionDescriptorNotFoundException; import org.apache.slide.content.NodeProperty.NamespaceCache; import org.apache.slide.event.EventDispatcher; import org.apache.slide.structure.LinkedObjectNotFoundException; import org.apache.slide.util.Configuration; import org.apache.slide.util.XMLValue; import org.apache.slide.webdav.WebdavException; import org.apache.slide.webdav.WebdavServletConfig; import org.apache.slide.webdav.event.WebdavEvent; import org.apache.slide.webdav.util.AclConstants; import org.apache.slide.webdav.util.DeltavConstants; import org.apache.slide.webdav.util.PreconditionViolationException; import org.apache.slide.webdav.util.PropertyHelper; import org.apache.slide.webdav.util.UriHandler; import org.apache.slide.webdav.util.ViolatedPrecondition; import org.apache.slide.webdav.util.WebdavStatus; import org.apache.slide.webdav.util.resourcekind.AbstractResourceKind; import org.apache.slide.webdav.util.resourcekind.CheckedInVersionControlled; import org.apache.slide.webdav.util.resourcekind.ResourceKind; import org.apache.slide.webdav.util.resourcekind.ResourceKindManager; import org.jdom.CDATA; import org.jdom.Comment; import org.jdom.Document; import org.jdom.Element; import org.jdom.EntityRef; import org.jdom.JDOMException; import org.jdom.Namespace; import org.jdom.ProcessingInstruction; import org.jdom.Text; import org.jdom.output.Format; import org.jdom.output.XMLOutputter; /** * PROPPATCH method. * */ public class PropPatchMethod extends AbstractWebdavMethod implements DeltavConstants, AclConstants, WriteMethod, FineGrainedLockingMethod { // -------------------------------------------------------------- Constants // ----------------------------------------------------- Instance Variables protected PropertyHelper propertyHelper = null; /** * Properties to set. */ private PropPatchProperties propertiesToSet; /** * Properties to remove. */ private PropPatchProperties propertiesToRemove; /** * Resource which will have its properties updated. */ private String resourcePath; /** * If true, the last modified date will be updated. */ private boolean updateLastModified; // ----------------------------------------------------------- Constructors /** * Constructor. * * @param token the token for accessing the namespace * @param config configuration of the WebDAV servlet */ public PropPatchMethod(NamespaceAccessToken token, WebdavServletConfig config) { super(token, config); } /** * @see org.apache.slide.webdav.method.FineGrainedLockingMethod#acquireFineGrainLocks() */ public void acquireFineGrainLocks() { acquireStandardLocks(resourcePath); // lock history folder in case we have auto versioning turned on acquireHistoryLocks(resourcePath); // changes this and parent acquireLock(resourcePath, WRITE_LOCK); acquireParentLock(resourcePath, WRITE_LOCK); } // ------------------------------------------------------ Protected Methods /** * Parse the request. * * @exception WebdavException Bad request */ protected void parseRequest() throws WebdavException { propertyHelper = PropertyHelper.getPropertyHelper( slideToken, token, getConfig() ); // readRequestContent(); updateLastModified = getBooleanInitParameter( "updateLastModified" ); resourcePath = requestUri; if (resourcePath == null) { resourcePath = "/"; } propertiesToSet = new PropPatchProperties(); propertiesToRemove = new PropPatchProperties(); if (req.getContentLength() != 0) { try { Iterator childrenIterator = parseRequestContent(E_PROPERTYUPDATE).getChildren().iterator(); Element child = null; while (childrenIterator.hasNext()) { child = (Element)childrenIterator.next(); if (E_SET.equals(child.getName())) { propertiesToSet.add(getPropElement(child)); } else if (E_REMOVE.equals(child.getName())) { propertiesToRemove.add(getPropElement(child)); } else { throw new JDOMException("Expected <"+E_SET+"> or <"+E_REMOVE+"> element"); } } } catch( Exception e ) { int statusCode = getErrorCode( e ); sendError( statusCode, e ); throw new WebdavException( statusCode ); } } else { int statusCode = WebdavStatus.SC_BAD_REQUEST; sendError( statusCode, getClass().getName()+".missingRequestBody" ); throw new WebdavException( statusCode ); } } /** * Checks if the given Element has exactly one child named * <code>&lt;prop&gt;</code>. If the check succeeds the * <code>&lt;prop&gt;</code> element is returned, otherwise a * JDOMException is thrown. * * @param parent the parent Element of the <code>&lt;prop&gt;</code>. * * @return the <code>&lt;prop&gt;</code> element. * * @throws JDOMException if the check fails. */ private Element getPropElement(Element parent) throws JDOMException { List childrenList = parent.getChildren(); if ( (childrenList.size() != 1) || ( ! E_PROP.equals(((Element)childrenList.get(0)).getName()) ) ) { throw new JDOMException("Expected &lt;"+E_PROP+"&gt; element"); } return (Element)childrenList.get(0); } /** * Execute the request. * * @exception WebdavException */ protected void executeRequest() throws WebdavException, IOException { boolean allOperationsExcecuted = true; // Prevent dirty reads slideToken.setForceStoreEnlistment(true); // check lock-null resources try { if (isLockNull(resourcePath)) { int statusCode = WebdavStatus.SC_NOT_FOUND; sendError( statusCode, "lock-null resource", new Object[]{resourcePath} ); throw new WebdavException( statusCode ); } } catch (ServiceAccessException e) { int statusCode = getErrorCode((Exception)e); sendError( statusCode, e ); throw new WebdavException( statusCode ); } try { if ( WebdavEvent.PROPPATCH.isEnabled() ) EventDispatcher.getInstance().fireVetoableEvent(WebdavEvent.PROPPATCH, new WebdavEvent(this)); NodeRevisionDescriptors revisionDescriptors = content.retrieve(slideToken, resourcePath); NodeRevisionNumber revisionNumber = revisionDescriptors.getLatestRevision(); NodeRevisionDescriptor revisionDescriptor = null; if (revisionNumber != null) { try { revisionDescriptor = content.retrieve (slideToken, revisionDescriptors); } catch (RevisionDescriptorNotFoundException e) { } } if (revisionDescriptor == null) { revisionDescriptor = new NodeRevisionDescriptor(0); } ResourceKind resourceKind = AbstractResourceKind.determineResourceKind(token, resourcePath, revisionDescriptor); // check preconditions ViolatedPrecondition violatedPrecondition = getPreconditionViolation(revisionDescriptors, revisionDescriptor, resourceKind); if (violatedPrecondition != null) { throw new PreconditionViolationException(violatedPrecondition, resourcePath); } // Changed for DeltaV --start-- boolean mustCheckIn = false; if(Configuration.useVersionControl() && (resourceKind instanceof CheckedInVersionControlled) && !notVersionForPropPatch(token.getUri(slideToken, resourcePath)) && versioningHelper.mustCheckoutAutoVersionedVCR(revisionDescriptors, revisionDescriptor) ) { versioningHelper.checkout(revisionDescriptors, revisionDescriptor, false, false, true); mustCheckIn = versioningHelper.mustCheckinAutoVersionedVCR( slideToken, revisionDescriptors, revisionDescriptor); } // Modifying the properties Iterator propertyIterator = null; propertyIterator = propertiesToSet.iterator(); PropPatchProperty currentProperty = null; while (propertyIterator.hasNext()) { currentProperty = (PropPatchProperty)propertyIterator.next(); if (checkPropertyModification(currentProperty, revisionDescriptor, resourceKind)) { // Convert absolute URIs to relative ones, because Slide // converts them to absolute ones in the result of queries. String finalValue = currentProperty.getValue(); Element property = new Element(currentProperty.getName(), currentProperty.getNamespace()); String propertyValue = currentProperty.getValue(); if ( (propertyValue != null) && (propertyValue.toString().length() > 0)) { if( propertyValue.toString().indexOf('<') >= 0 ) { try { XMLValue xmlValue = new XMLValue(propertyValue.toString(), Namespace.getNamespace(currentProperty.getNamespace())); if (resourceKind.isSupportedLiveProperty(currentProperty.getPropertyName())) { convertHrefValueToRelativeURL(xmlValue, getSlideContextPath(), config); } Iterator iterator = xmlValue.iterator(); while (iterator.hasNext()) { Object o = iterator.next(); if( o instanceof Element ) property.addContent((Element)o); else if( o instanceof Text ) property.addContent((Text)o); else if( o instanceof Comment ) property.addContent((Comment)o); else if( o instanceof ProcessingInstruction ) property.addContent((ProcessingInstruction)o); else if( o instanceof CDATA ) property.addContent((CDATA)o); else if( o instanceof EntityRef ) property.addContent((EntityRef)o); } finalValue = new XMLOutputter(Format.getRawFormat()).outputString(property.getContent()); } catch (JDOMException e) { // Fallback to original value } } } NodeProperty newProperty = new NodeProperty( currentProperty.getPropertyName(), finalValue); revisionDescriptor.setProperty(newProperty); } else { allOperationsExcecuted = false; } } propertyIterator = propertiesToRemove.iterator(); while (propertyIterator.hasNext()) { currentProperty = (PropPatchProperty)propertyIterator.next(); if (checkPropertyModification(currentProperty, revisionDescriptor, resourceKind)) { revisionDescriptor.removeProperty(currentProperty.getPropertyName()); } else { allOperationsExcecuted = false; } } if (updateLastModified) { revisionDescriptor.setLastModified(new Date()); } if (allOperationsExcecuted) { content.store(slideToken, resourcePath, revisionDescriptor, null); } // Changed for DeltaV --start-- if( Configuration.useVersionControl() && mustCheckIn) { versioningHelper.checkin(revisionDescriptors, revisionDescriptor, false, false, true ); //forkOk=false, keepCheckedOut=false } // Changed for DeltaV --end-- resp.setContentType(TEXT_XML_UTF_8); resp.setStatus(WebdavStatus.SC_MULTI_STATUS); } catch (PreconditionViolationException e) { sendPreconditionViolation(e); throw e; } catch (Exception e) { int statusCode = getErrorCode( e ); sendError( statusCode, e ); throw new WebdavException( statusCode ); } // No serious errors. Printing the XML report. writeReport(); if (!allOperationsExcecuted) { throw new WebdavException( WebdavStatus.SC_ACCEPTED ); // abort the TA } } /** * Get return status based on exception type. */ protected int getErrorCode(Exception ex) { try { throw ex; } catch (LinkedObjectNotFoundException e) { return WebdavStatus.SC_NOT_FOUND; } catch (PropertyParseException e) { return WebdavStatus.SC_BAD_REQUEST; } catch (JDOMException e) { return WebdavStatus.SC_BAD_REQUEST; } catch (Exception e) { return super.getErrorCode(e); } } // -------------------------------------------------------- Private Methods /** * Check if the property is a live property which should have its value * enforced by the server. * * @param property The property object * @param rd the revision descriptor containing all properties * @param resourceKind the kind of the resource to patch. * @return <code>true</code> if the property may be modified */ private boolean checkPropertyModification(PropPatchProperty property, NodeRevisionDescriptor rd, ResourceKind resourceKind) { ViolatedPrecondition violatedPrecondition = getPropertySpecificPreconditionViolation(resourceKind, property); if (violatedPrecondition != null) { property.setViolatedPrecondition(violatedPrecondition); return false; } else { if (!isSupportedPropertyValue(property, resourceKind)) { property.setErrorMessage("Value " + property.getValue() + " is not supported by property " + property.getQualifiedNameAsElementString()); property.setStatusCode(WebdavStatus.SC_CONFLICT); return false; } return true; } } /** * Return <code>true</code> if the given <code>property</code> value is supported * for that property of the <code>resourceKind</code> * * @param property the property to check. * @param resourceKind the ResourceKind. * * @return <code>true</code> if the value is supported. */ private boolean isSupportedPropertyValue(PropPatchProperty property, ResourceKind resourceKind) { if (property.getValue() != null) { return resourceKind.isSupportedPropertyValue( property.getPropertyName(), property.getValue()); } return true; } /** * Write the report. */ private void writeReport() throws WebdavException { Element multistatus = new Element(E_MULTISTATUS, DNSP); Element response = new Element(E_RESPONSE, DNSP); multistatus.addContent(response); Element href = new Element(E_HREF, DNSP); href.setText(getFullPath(requestUri)); response.addContent(href); // Parse the two properties list, and printout their status addPropstatElements(propertiesToSet, response); addPropstatElements(propertiesToRemove, response); try { resp.setContentType(TEXT_XML_UTF_8); Writer writer = resp.getWriter(); org.jdom.output.Format format = org.jdom.output.Format.getPrettyFormat(); format.setIndent(XML_RESPONSE_INDENT); new XMLOutputter(format). output(new Document(multistatus), writer); writer.flush(); } catch (Exception e) { int statusCode = WebdavStatus.SC_INTERNAL_SERVER_ERROR; sendError( statusCode, e ); throw new WebdavException( statusCode ); } } /** * Adds the <code>&lt;propstat&gt;</code> elements for the given * <code>properties</code> to the given <code>&lt;response&gt;</code> * element. * * @param properties the PropPatchProperties for which to add the * <code>&lt;propstat&gt;</code> elements. * @param response the <code>&lt;response&gt;</code> element to add * the <code>&lt;propstat&gt;</code> elements to. */ private void addPropstatElements(PropPatchProperties properties, Element response) { Iterator propertyIterator = properties.iterator(); while(propertyIterator.hasNext()) { PropPatchProperty property = (PropPatchProperty) propertyIterator.next(); Element propstat = createPropstatElement(property); response.addContent(propstat); if (property.getViolatedPrecondition() != null) { Element responseDescription = new Element(E_RESPONSEDESCRIPTION, DNSP); responseDescription.addContent(MethodUtil.getPreconditionViolationError(property.getViolatedPrecondition())); propstat.addContent(responseDescription); } else if (property.getErrorMessage() != null) { Element responseDescription = new Element(E_RESPONSEDESCRIPTION, DNSP); responseDescription.addContent(property.getErrorMessage()); propstat.addContent(responseDescription); } } } /** * Creates a <code>&lt;propstat&gt;</code> element for the given * <code>property</code>. * * @param property the PropPatchProperty for which to create a * <code>&lt;propstat&gt;</code> element. * * @return the created <code>&lt;propstat&gt;</code> element. */ private Element createPropstatElement(PropPatchProperty property) { Element propstat = new Element(E_PROPSTAT, DNSP); Element prop = new Element(E_PROP, DNSP); propstat.addContent(prop); Namespace namespace = Namespace.NO_NAMESPACE; if (property.getNamespace() != null) { namespace = NamespaceCache.getNamespace(property.getNamespace()); } Element propertyElement = new Element(property.getName(), namespace); prop.addContent(propertyElement); Element status = new Element(E_STATUS, DNSP); status.setText("HTTP/1.1 " + property.statusCode + " " + WebdavStatus.getStatusText(property.statusCode)); propstat.addContent(status); return propstat; } /** * Checks the (DeltaV) preconditions * <ul> * <li>&lt;DAV:cannot-modify-version-controlled-property&gt;</li> * <li>&lt;DAV:cannot-modify-version&gt;</li> * <li>&lt;DAV:cannot-modify-protected-property&gt;</li> * <li>&lt;DAV:supported-live-property&gt;</li> * </ul> * * @param revisionDescriptors the NodeRevisionDescriptors of the resource * to perform the <code>PUT</code> on. * @param revisionDescriptor the NodeRevisionDescriptor of the resource * to perform the <code>PUT</code> on. * @param resourceKind the ResourceKind of the resource. * * @return the precondition that has been violated (if any). */ private ViolatedPrecondition getPreconditionViolation(NodeRevisionDescriptors revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, ResourceKind resourceKind) throws ServiceAccessException { if( Configuration.useVersionControl() ) { if (resourceKind instanceof CheckedInVersionControlled) { // check precondition DAV:cannot-modify-version-controlled-property String autoVersion = versioningHelper.getAutoVersionElementName(revisionDescriptor); if (autoVersion == null) { autoVersion = ""; } if ( !E_CHECKOUT_CHECKIN.equals(autoVersion) && !E_CHECKOUT_UNLOCKED_CHECKIN.equals(autoVersion) && !E_CHECKOUT.equals(autoVersion) && !E_CHECKOUT_IGNORE_UNLOCK.equals(autoVersion) && !E_LOCKED_CHECKOUT.equals(autoVersion) && !notVersionForPropPatch(token.getUri(slideToken, resourcePath))) { return new ViolatedPrecondition(C_CANNOT_MODIFY_VERSION_CONTROLLED_PROPERTY, WebdavStatus.SC_FORBIDDEN); } if (E_LOCKED_CHECKOUT.equals(autoVersion)) { if ( !versioningHelper.isWriteLocked(slideToken, revisionDescriptors) ) { return new ViolatedPrecondition(C_CANNOT_MODIFY_VERSION_CONTROLLED_PROPERTY, WebdavStatus.SC_FORBIDDEN); } } } // check precondition DAV:cannot-modify-version UriHandler uriHandler = UriHandler.getUriHandler(resourcePath); if (uriHandler.isVersionUri()) { return new ViolatedPrecondition(C_CANNOT_MODIFY_VERSION, WebdavStatus.SC_FORBIDDEN); } } return null; } /** * Checks the property specific preconditions * <ul> * <li>&lt;DAV:cannot-modify-protected-property&gt;</li> * <li>&lt;DAV:supported-live-property&gt;</li> * </ul> * * @param property the PropPatchProperty to check. * * @return the precondition that has been violated (if any, * otherwise <code>null</code>). */ private ViolatedPrecondition getPropertySpecificPreconditionViolation( ResourceKind resourceKind, PropPatchProperty property) { // check precondition DAV:cannot-modify-protected-property if (ResourceKindManager.isProtectedProperty(property.getPropertyName())) { return new ViolatedPrecondition(C_CANNOT_MODIFY_PROTECTED_PROPERTY, WebdavStatus.SC_CONFLICT); } // check precondition DAV:supported-live-property // ...is there any property to check here yet ? return null; } /** * If the given <code>xmlValue</code> contains <code>&lt;href&gt;</code> * elements (at any depth), absolute URIs are converted to relative ones. * * This method modifies <code>xmlValue</code> (and its children). * * @param xmlValue The XMLValue that might contain * <code>&lt;href&gt;</code> values to convert. * @param servletContextPath The prefix which when added to a relative URI * makes it an absolute one. * @param config Configuration of the WebDAV servlet. */ private static void convertHrefValueToRelativeURL (XMLValue xmlValue, String servletContextPath, WebdavServletConfig config) { if (xmlValue != null) { Iterator iterator = xmlValue.iterator(); Element element = null; while (iterator.hasNext()) { Object o = iterator.next(); if( o instanceof Element ) { element = (Element)o; convertHrefValueToRelativeURL(element, servletContextPath, config); } } } } /** * If the given <code>Element</code> contains <code>&lt;href&gt;</code> * elements (at any depth), the absolute URI is converted to a relative * one. * * This method modifies the <code>Element</code> (and its children). * * @param element The <code>Element</code> that might contain * <code>&lt;href&gt;</code> values to convert. * @param servletContextPath The prefix which when added to a relative URI * makes it an absolute one. * @param config Configuration of the WebDAV servlet. */ private static void convertHrefValueToRelativeURL (Element element, String servletContextPath, WebdavServletConfig config) { if (element.getChildren().size() > 0) { Iterator i = element.getChildren().iterator(); while (i.hasNext()) { Element child = (Element) i.next(); convertHrefValueToRelativeURL(child, servletContextPath, config); } } if ( E_HREF.equals(element.getName()) && (element.getText() != null) ) { if ( PropertyHelper.isAbsoluteURL(servletContextPath, element.getText()) ) { element.setText(element.getText().substring(servletContextPath.length())); } } } /** * <code>true</code> if unversioned PROPPATCH is allowed */ private static boolean notVersionForPropPatch(Uri resource) { return Boolean.valueOf(Domain.getParameter("no-versioning-for-proppatch", "false", resource.getStore())).booleanValue(); } /** * An extension of the RequestedProperties class manages PropPatchProperty * instead of RequestedProperty. */ public class PropPatchProperties extends RequestedPropertiesImpl { /** * Default constructor. */ public PropPatchProperties() { super(); } /** * Constructs a List of PropPatchProperty from a &lt;DAV:prop&gt; element. * * @param propElement the &lt;DAV:prop&gt; from which to create the * List of PropPatchProperty. * * @throws PropertyParseException if parsing the property fails for any reason. */ public PropPatchProperties (Element propElement) throws PropertyParseException { super(propElement); } /** * Creates a RequestedProperty from the given parameters. This method * may be overwritten by subclasses in order to create appropriate * implementations of RequestedProperty. * * @param name the name of the propery. * @param namespacePrefix the namespace prefix of the propery. * @param namespaceUri the namespace URI of the propery. * @param text the text of the propery element. * @param children the children of the propery element. * * @return the created RequestedProperty. */ protected RequestedProperty createRequestedProperty(String name, String namespacePrefix, String namespaceUri, List content) { String value = ""; if (content.size() == 1 && content.get(0) instanceof Text) { value = ((Text)content.get(0)).getText(); } else if (content.size() > 0) { XMLValue xmlVal = new XMLValue(content); if (P_GROUP_MEMBER_SET.equals(name) && S_DAV.equals(namespaceUri)) { xmlVal.stripServletContext(getSlideContextPath()); } value = xmlVal.toString(); } // register prefix/URI at NamespaceCache NamespaceCache.getNamespace(namespacePrefix, namespaceUri); return new PropPatchProperty(name, namespaceUri, value); } } /** * An extension of the RequestedProperty class which supports a property value. */ public static class PropPatchProperty extends RequestedPropertyImpl { /** * The value of the property. */ protected String value = null; /** * The status of the PropPatch operation on this property. */ protected int statusCode = WebdavStatus.SC_OK; /** * The precondition that has been violated when trying to patch this * property. */ protected ViolatedPrecondition violatedPrecondition = null; /** * If the code returned by {@link #getStatusCode getStatusCode} is not * <code>200 (OK)</code> this String provides more details about the error. */ protected String errorMessage = null; /** * Provides the qualified name of the property as an Element String, * i.e. if the name of the property is <code>munster</code> with * the namespace <code>DAV:</code> this String is * <code>&lt;munster xmlns="DAV:" /&gt;</code>. */ protected String qualifiedNameAsElement = null; /** * Constructs a PropPatchProperty using the default namespace as defined * in NodeProperty. * * @param propertyName the name of the property. */ public PropPatchProperty (String propertyName) { super(propertyName); } /** * Constructs a PropPatchProperty. * * @param propertyName the name of the property. * @param namespace the namespace of the property. */ public PropPatchProperty (String propertyName, String namespace) { super(propertyName, namespace); } /** * Constructs a PropPatchProperty. * * @param propertyName the name of the property. * @param namespace the namespace of the property. * @param value the value of the property. */ public PropPatchProperty (String propertyName, String namespace, String value) { super(propertyName, namespace); this.value = value; } /** * Returns the value of the property. * * @return the value of the property. */ public String getValue() { return value; } /** * Sets the status of the PropPatch operation on this property. * * @param statusCode the status code of the PropPatch operation * on this property. */ public void setStatusCode(int statusCode) { this.statusCode = statusCode; } /** * Returns the status of the PropPatch operation on this property. * * @return the status of the PropPatch operation on this property. */ public int getStatusCode() { return statusCode; } /** * Sets the error message of this property. * * @param errorMessage the error message. * * @see #getErrorMessage */ public void setErrorMessage(String errorMessage) { this.errorMessage = errorMessage; } /** * If the code returned by {@link #getStatusCode getStatusCode} is not * <code>200 (OK)</code> this String provides more details about the error. * * @return the error message. */ public String getErrorMessage() { return errorMessage; } /** * Sets the precondition that has been violated when trying to patch this * property. If the <code>violatedPrecondition</code> is not <code>null</code> * the status will be set to those of the ViolatedPrecondition. * * @param violatedPrecondition the precondition that has been violated * when trying to patch this property. */ public void setViolatedPrecondition(ViolatedPrecondition violatedPrecondition) { this.violatedPrecondition = violatedPrecondition; if (violatedPrecondition != null) { setStatusCode(violatedPrecondition.getStatusCode()); } } /** * Returns the precondition that has been violated when trying to patch * this property. * * @return the precondition that has been violated when trying to * patch this property. */ public ViolatedPrecondition getViolatedPrecondition() { return violatedPrecondition; } /** * Provides the qualified name of the property as an Element String, * i.e. if the name of the property is <code>munster</code> with * the namespace <code>DAV:</code> this method returns * <code>&lt;munster xmlns="DAV:" /&gt;</code>. * * @return the qualified name of the property as an Element String */ public String getQualifiedNameAsElementString() { if (qualifiedNameAsElement == null) { StringBuffer buffer = new StringBuffer(); buffer.append("<"); buffer.append(getName()); if ( (getNamespace() != null) && (getNamespace().length() > 0) ) { buffer.append(" xmlns=\""); buffer.append(getNamespace()); buffer.append("\""); buffer.append(" />"); } qualifiedNameAsElement = buffer.toString(); } return qualifiedNameAsElement; } /** * Returns a String representation of this instance. * * @return a String representation of this instance. */ public String toString() { return getNamespace()+":"+getName()+"["+getValue()+"]"; } } }

The table below shows all metrics for PropPatchMethod.java.

MetricValueDescription
BLOCKS105.00Number of blocks
BLOCK_COMMENT22.00Number of block comment lines
COMMENTS322.00Comment lines
COMMENT_DENSITY 0.81Comment density
COMPARISONS66.00Number of comparison operators
CYCLOMATIC109.00Cyclomatic complexity
DECL_COMMENTS49.00Comments in declarations
DOC_COMMENT274.00Number of javadoc comment lines
ELOC397.00Effective lines of code
EXEC_COMMENTS19.00Comments in executable code
EXITS110.00Procedure exits
FUNCTIONS31.00Number of function declarations
HALSTEAD_DIFFICULTY73.18Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY86.00Interface complexity
JAVA0001 0.00JAVA0001 Package name does not contain only lower case letters
JAVA0002 0.00JAVA0002 Package name does not begin with a top level domain name or country code
JAVA0003 0.00JAVA0003 Minimize use of on-demand (.*) imports
JAVA0004 0.00JAVA0004 Unnecessary import from java.lang
JAVA0005 0.00JAVA0005 Imports not in specified order
JAVA0006 0.00JAVA0006 Empty finally block
JAVA0007 0.00JAVA0007 Should not declare public field
JAVA0008 0.00JAVA0008 Empty catch block
JAVA0009 0.00JAVA0009 Protected member in final class
JAVA0010 0.00JAVA0010 Non-instantiable class does not contain a non-private static member
JAVA0011 0.00JAVA0011 Abstract class does not contain an abstract method
JAVA0012 0.00JAVA0012 Non-constructor method with same name as declaring class
JAVA0013 0.00JAVA0013 Non-blank final field is not static
JAVA0014 0.00JAVA0014 Class with only static members has non-private constructor
JAVA0015 0.00JAVA0015 Package class contains public nested type
JAVA0016 0.00JAVA0016 Abstract class contains public constructor
JAVA0017 0.00JAVA0017 Class name does not have required form
JAVA0018 0.00JAVA0018 Method name does not have required form
JAVA0019 0.00JAVA0019 Interface name does not have required form
JAVA0020 0.00JAVA0020 Field name does not have required form
JAVA0021 0.00JAVA0021 Interface method name does not have required form
JAVA0022 0.00JAVA0022 Static final field name does not have required form
JAVA0023 0.00JAVA0023 Empty finalize method
JAVA0024 0.00JAVA0024 Empty class
JAVA0025 0.00JAVA0025 Method override is empty
JAVA0026 0.00JAVA0026 Finalize method with parameters
JAVA0029 0.00JAVA0029 Private method not used
JAVA0030 0.00JAVA0030 Private field not used
JAVA0031 0.00JAVA0031 Case statement not properly closed
JAVA0032 0.00JAVA0032 Switch statement missing default
JAVA0033 0.00JAVA0033 default: not last case in switch statement
JAVA0034 7.00JAVA0034 Missing braces in if statement
JAVA0035 0.00JAVA0035 Missing braces in for statement
JAVA0036 0.00JAVA0036 Missing braces in while statement
JAVA0038 0.00JAVA0038 Non-case label in switch statement
JAVA0039 0.00JAVA0039 Break statement with label
JAVA0040 0.00JAVA0040 Switch statement contains N cases (maximum: M)
JAVA0041 0.00JAVA0041 Nested synchronized block
JAVA0042 0.00JAVA0042 Empty synchronized statement
JAVA0043 0.00JAVA0043 Inner class does not use outer class
JAVA0044 0.00JAVA0044 Serializable class with no instance variables
JAVA0045 0.00JAVA0045 Serializable class with only transient fields
JAVA0046 0.00JAVA0046 Name of class not derived from Exception ends with 'Exception'
JAVA0047 0.00JAVA0047 Serializable class derives from invalid base class
JAVA0048 0.00JAVA0048 Name of class derived from Exception does not end with 'Exception'
JAVA0049 1.00JAVA0049 Nested block at depth N (maximum: M)
JAVA0050 0.00JAVA0050 Class derives from java.lang.Error
JAVA0051 0.00JAVA0051 Class derives from java.lang.RuntimeException
JAVA0052 0.00JAVA0052 Class derives from java.lang.Throwable
JAVA0053 0.00JAVA0053 Unused label
JAVA0054 0.00JAVA0054 Inheritance depth N exceeds maximum M
JAVA0055 0.00JAVA0055 Class should be interface
JAVA0056 0.00JAVA0056 Unnecessary abstract modifier for interface or annotation
JAVA0057 0.00JAVA0057 Unnecessary default constructor
JAVA0058 1.00JAVA0058 Constructor calls super()
JAVA0059 0.00JAVA0059 Method override only calls super()
JAVA0061 0.00JAVA0061 Inaccessible member in anonymous class
JAVA0062 0.00JAVA0062 Public class missing public member or protected constructor
JAVA0063 0.00JAVA0063 Identifier name should not contain '$'
JAVA0064 0.00JAVA0064 N variations of identifier name (maximum: M)
JAVA0065 0.00JAVA0065 Unnecessary final modifier for method in final class
JAVA0066 0.00JAVA0066 Unnecessary modifier for interface nested type
JAVA0067 0.00JAVA0067 Array descriptor on identifier name
JAVA0068 0.00JAVA0068 Modifiers not declared in recommended order
JAVA0071 0.00JAVA0071 Strings compared with ==
JAVA0073 0.00JAVA0073 Integer division in floating-point context
JAVA0074 0.00JAVA0074 Use of Object.notify()
JAVA0075 1.00JAVA0075 Method parameter hides field
JAVA0076 0.00JAVA0076 Use of magic number
JAVA0077 0.00JAVA0077 Private field not used in declaring class
JAVA0078 0.00JAVA0078 Floating point values compared with ==
JAVA0079 0.00JAVA0079 Use of instance to reference static member
JAVA0080 0.00JAVA0080 Import declaration not used
JAVA0081 0.00JAVA0081 Boolean literal in comparison
JAVA0082 1.00JAVA0082 Unnecessary widening cast
JAVA0083 0.00JAVA0083 Unnecessary instanceof test
JAVA0084 0.00JAVA0084 Should use compound assignment operator
JAVA0085 0.00JAVA0085 Use of sun.* class
JAVA0087 0.00JAVA0087 Use of Thread.sleep()
JAVA0089 0.00JAVA0089 Use of restricted package
JAVA0092 0.00JAVA0092 Use of restricted type
JAVA0093 0.00JAVA0093 Redundant assignment
JAVA0094 0.00JAVA0094 Field hides a superclass field
JAVA0095 0.00JAVA0095 Uninitialized private field
JAVA0096 0.00JAVA0096 Field in nested class hides outer field
JAVA0098 0.00JAVA0098 Minimize use of implicit field initializers
JAVA0100 0.00JAVA0100 Class contains N non-final fields (maximum: M)
JAVA0101 0.00JAVA0101 Unnecessary modifier for field in interface
JAVA0102 0.00JAVA0102 Last statement in finalize() not super.finalize()
JAVA0103 0.00JAVA0103 Explicit call to finalize()
JAVA0104 0.00JAVA0104 finalize() only calls super.finalize()
JAVA0105 0.00JAVA0105 Duplicate import declaration
JAVA0106 0.00JAVA0106 Unnecessary import from current package
JAVA0108 3.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 2.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA0110 2.00JAVA0110 Incorrect javadoc: no @return tag
JAVA0111 0.00JAVA0111 Incorrect javadoc: @return tag for void method
JAVA0112 0.00JAVA0112 Incorrect javadoc: no exception 'exception' in throws
JAVA0113 1.00JAVA0113 Incorrect javadoc: no @author tag
JAVA0114 1.00JAVA0114 Incorrect javadoc: no @version tag
JAVA0115 3.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0116 0.00JAVA0116 Missing javadoc: field 'field'
JAVA0117 0.00JAVA0117 Missing javadoc: method 'method'
JAVA0118 0.00JAVA0118 Missing javadoc: type 'type'
JAVA0119 0.00JAVA0119 Control variable changed within body of for loop
JAVA0123 0.00JAVA0123 Use all three components of for loop
JAVA0125 0.00JAVA0125 Continue statement with label
JAVA0126 0.00JAVA0126 Method declares unchecked exception in throws
JAVA0128 0.00JAVA0128 Public constructor in non-public class
JAVA0130 4.00JAVA0130 Non-static method does not use instance fields
JAVA0131 1.00JAVA0131 Compatible method does not override base
JAVA0132 0.00JAVA0132 Method overload with compatible signature
JAVA0133 0.00JAVA0133 Non-synchronized method overrides synchronized method
JAVA0135 0.00JAVA0135 Only one of Object.equals and Object.hashCode defined: missing 'method'
JAVA0136 0.00JAVA0136 N methods defined in class (maximum: M)
JAVA0137 0.00JAVA0137 Non-abstract class missing constructor
JAVA0138 0.00JAVA0138 N parameters defined for method (maximum: M)
JAVA0139 0.00JAVA0139 Definition of main other than public static void main(java.lang.String[])
JAVA0141 0.00JAVA0141 Unnecessary modifier for method in interface
JAVA0143 0.00JAVA0143 Synchronized method
JAVA0144 5.00JAVA0144 Line exceeds maximum M characters
JAVA0145 0.00JAVA0145 Tab character used in source file
JAVA0150 0.00JAVA0150 java.lang.Error (or subclass) thrown
JAVA0153 0.00JAVA0153 Inefficient conversion of integer to string
JAVA0159 0.00JAVA0159 Inefficient conversion of string to integer
JAVA0160 0.00JAVA0160 Method does not throw specified exception
JAVA0161 0.00JAVA0161 Conditional wait() not in loop
JAVA0163 0.00JAVA0163 Empty statement
JAVA0165 0.00JAVA0165 Conflicting return statement in finally block
JAVA0166 4.00JAVA0166 Generic exception caught
JAVA0167 0.00JAVA0167 ThreadDeath not rethrown
JAVA0169 0.00JAVA0169 Unnecessary catch block: exception 'exception'
JAVA0170 0.00JAVA0170 Caught exception not derived from java.lang.Exception
JAVA0171 0.00JAVA0171 Unused local variable
JAVA0173 2.00JAVA0173 Unused method parameter
JAVA0174 0.00JAVA0174 Assigned local variable never used
JAVA0175 0.00JAVA0175 Successive assignment to variable
JAVA0176 0.00JAVA0176 Local variable name does not have required form
JAVA0177 0.00JAVA0177 Variable declaration missing initializer
JAVA0179 0.00JAVA0179 Local variable hides visible field
JAVA0233 0.00JAVA0233 Definition of serialVersionUID other than 'private static final long serialVersionUID'
JAVA0234 0.00JAVA0234 Class is Serializable but does not define serialVersionUID
JAVA0235 0.00JAVA0235 Class defines serialVersionUID but does not implement Serializable
JAVA0236 0.00JAVA0236 Attempt to clone an object which does not implement Cloneable
JAVA0237 0.00JAVA0237 Class implements Cloneable but does not have public clone method
JAVA0238 0.00JAVA0238 Clone method does not call super.clone()
JAVA0239 0.00JAVA0239 Class declares 'readObject' or 'writeObject' but does not implement Serializable
JAVA0240 0.00JAVA0240 Serializable class which declares readObject or writeObject but not both
JAVA0241 0.00JAVA0241 'readObject' or 'writeObject' should be declared private in Serializable class
JAVA0242 0.00JAVA0242 Transient field in non-Serializable class
JAVA0243 0.00JAVA0243 'readResolve' or 'writeReplace' should be declared private or protected
JAVA0244 0.00JAVA0244 Field or method name in subclass differs only by case from inherited field or method
JAVA0245 0.00JAVA0245 JUnit TestCase with non-trivial constructor
JAVA0246 0.00JAVA0246 JUnit assertXXX statement missing message parameter
JAVA0247 0.00JAVA0247 JUnit 'setUp()' and 'tearDown()' should call super method
JAVA0248 0.00JAVA0248 JUnit method 'setUp' or 'tearDown' with incorrect signature
JAVA0249 0.00JAVA0249 JUnit TestCase 'suite()' should be declared static
JAVA0250 0.00JAVA0250 JUnit TestCase declares testXXX method with incorrect signature
JAVA0251 0.00JAVA0251 Use '%n' for line breaks in printf/format for platform independence
JAVA0252 0.00JAVA0252 'enum' is a Java 1.5 reserved word
JAVA0253 0.00JAVA0253 Not all enum constants consumed in switch statement
JAVA0254 5.00JAVA0254 Use enhanced for loop construct instead of Iterator
JAVA0255 0.00JAVA0255 Result of method invocation not used
JAVA0256 0.00JAVA0256 Assignment of external collection/array to field
JAVA0257 2.00JAVA0257 Use of 'Constant Interface' anti-pattern
JAVA0258 0.00JAVA0258 Implement Iterable for foreach compatibility
JAVA0259 0.00JAVA0259 Return of collection/array field
JAVA0260 0.00JAVA0260 Use 'enum' instead of Enumerated Type pattern
JAVA0261 0.00JAVA0261 Use specialized Enum collection types
JAVA0262 0.00JAVA0262 Use of char in integer context
JAVA0263 0.00JAVA0263 Long literal ends with 'l' instead of 'L'
JAVA0264 0.00JAVA0264 Integer math in long context - check for overflow
JAVA0265 0.00JAVA0265 Use of Throwable.printStackTrace()
JAVA0266 0.00JAVA0266 Use of System.out
JAVA0267 0.00JAVA0267 Use of System.err
JAVA0269 0.00JAVA0269 Contents of StringBuffer never used
JAVA0270 0.00JAVA0270 Use Java 5.0 enhanced for loop construct to iterate over all elements in an array
JAVA0271 0.00JAVA0271 Minimize use of on-demand (.*) static imports
JAVA0272 0.00JAVA0272 Thread.run() called
JAVA0273 0.00JAVA0273 Non-final derivative of Thread calls start() in constructor
JAVA0274 0.00JAVA0274 Serializable class has a synchronized readObject()
JAVA0275 0.00JAVA0275 Serializable class has a synchronized writeObject() and no other synchronized methods
JAVA0276 0.00JAVA0276 Unnecessary use of String constructor
JAVA0277 0.00JAVA0277 Iterator.next() implementation does not throw NoSuchElementException
JAVA0278 0.00JAVA0278 Unnecessary use of Boolean constructor
JAVA0279 0.00JAVA0279 Serialization method readObject or readObjectNoData calls an overridable method
JAVA0280 0.00JAVA0280 IllegalMonitorStateException caught
JAVA0281 0.00JAVA0281 Iterator.next() not called in loop
JAVA0282 0.00JAVA0282 Call to Iterator.next() in loop which does not test Iterator.hasNext()
JAVA0283 0.00JAVA0283 Control variable not updated in loop body
JAVA0284 0.00JAVA0284 Explicit garbage collection
JAVA0285 0.00JAVA0285 Dereference of potentially null variable
JAVA0286 0.00JAVA0286 Dereference of null variable
JAVA0287 0.00JAVA0287 Unnecessary null check
JAVA0288 0.00JAVA0288 Inconsistent null check
LINES959.00Number of lines in the source file
LINE_COMMENT26.00Number of line comments
LOC498.00Lines of code
LOGICAL_LINES244.00Number of statements
LOOPS 7.00Number of loops
NEST_DEPTH 8.00Maximum nesting depth
OPERANDS1236.00Number of operands
OPERATORS2230.00Number of operators
PARAMS38.00Number of formal parameter declarations
PROGRAM_LENGTH3466.00Halstead program length
PROGRAM_VOCAB425.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS48.00Number of return points from functions
SIZE37840.00Size of the file in bytes
UNIQUE_OPERANDS380.00Number of unique operands
UNIQUE_OPERATORS45.00Number of unique operators
WHITESPACE139.00Number of whitespace lines