CPD Results

The following document contains the results of PMD's CPD 4.2.2.

Duplications

File Line
org/abstracthorizon/danube/webdav/BaseWebDAVResourceConnectionHandler.java 1018
org/abstracthorizon/danube/webdav/BaseWebDAVResourceConnectionHandler.java 1129
        if (depth != Depth.INFINITY) {
            // MOVE MUST have infinity as a depth
            httpConnection.setResponseStatus(Status.BAD_REQUEST);
            return;
        }

        Object fromResource = findResource(httpConnection);

        boolean overwrite = !"F".equals(httpConnection.getRequestHeaders().getOnly("Overwrite"));
        String destHeader = httpConnection.getRequestHeaders().getOnly("Destination");
        Object destResource = URIUtils.uriToResource(httpConnection, adapter, destHeader);

        if (destResource == null) {
            httpConnection.setResponseStatus(Status.FORBIDDEN);
            return;
        }

        if (adapter.exists(destResource) && !overwrite) {
            httpConnection.setResponseStatus(Status.PRECONDITION_FAILED);
            return;
        }

        Object destParentResource = adapter.findParentResource(destResource);
        if ((destParentResource != null) && !adapter.exists(destParentResource)) {
            httpConnection.setResponseStatus(Status.CONFLICT);
            return;
        }

        LockingMechanism lockingMechanism = adapter.getLockingMechanism();
        boolean destLocked = false;
        boolean destParentLocked = false;
        IF lockDetails = null;

        if (lockingMechanism != null) {
            lockDetails = new IF();

File Line
org/abstracthorizon/danube/webdav/xml/dav/Owner.java 26
org/abstracthorizon/danube/webdav/xml/dav/request/Owner.java 26
public class Owner extends AbstractSimpleXMLHandler {

    /** Owner */
    protected Object owner;

    /**
     * Constructor
     * @param parent parent
     */
    public Owner(XMLParserHandler parent) {
        super(parent);
    }

    @Override
    public Object start(Object current, String tag, Attributes attributes) throws SAXException {
        if ("href".equals(tag)) {
            owner = new HRef(this);
            return owner;
        } else {
            return super.start(current, tag, attributes);
        }
    }

    @Override
    public Object end(Object current, String tag, String value) throws SAXException {
        if (this.owner == null) {
            this.owner = value;
        }
        return super.end(current, tag, value);
    }

    /**
     * Returns owner
     * @return owner
     */
    public Object getOwner() {
        return owner;
    }

    @Override
    public String toString() {
        if (owner != null) {
            return "Owner[" + owner + "]";
        } else {
            return "Owner[]";
        }
    }

}

File Line
org/abstracthorizon/danube/webdav/xml/dav/LockScope.java 26
org/abstracthorizon/danube/webdav/xml/dav/request/LockScope.java 26
public class LockScope extends AbstractSimpleXMLHandler {

    /** Is exclusive scope or shared */
    protected boolean exclusive = false;

    /**
     * Constructor
     * @param parent parent parser handler
     */
    public LockScope(XMLParserHandler parent) {
        super(parent);
    }

    @Override
    public Object start(Object current, String tag, Attributes attributes) throws SAXException {
        if ("exclusive".equals(tag)) {
            exclusive = true;
            return this;
        } else if ("shared".equals(tag)) {
            exclusive = false;
            return this;
        } else {
            return super.start(current, tag, attributes);
        }
    }

    @Override
    public Object end(Object current, String tag, String value) throws SAXException {
        if ("exclusive".equals(tag)) {
            exclusive = true;
            return this;
        } else if ("shared".equals(tag)) {
            exclusive = false;
            return this;
        } else {
            return super.end(current, tag, value);
        }
    }

File Line
org/abstracthorizon/danube/webdav/BaseWebDAVResourceConnectionHandler.java 529
org/abstracthorizon/danube/webdav/BaseWebDAVResourceConnectionHandler.java 947
        boolean resourceLocked = false;
        boolean parentLocked = false;
        LockingMechanism lockingMechanism = adapter.getLockingMechanism();
        if (lockingMechanism != null) {
            IF lockDetails = new IF();
            resourceLocked = lockingMechanism.isLocked(resource);
            if (parentResource != null) {
                parentLocked = lockingMechanism.isLocked(parentResource);
            }

            boolean ok;
            if (parentLocked) {
                ok = lockDetails.parse(httpConnection, adapter, resource, parentResource);
            } else {
                ok = lockDetails.parse(httpConnection, adapter, resource, null);
            }
            if (!ok) {
                httpConnection.setResponseStatus(Status.PRECONDITION_FAILED);
                return;
            }

            if ((lockDetails.token == null) && resourceLocked) {
                httpConnection.setResponseStatus(STATUS_LOCKED);
                return;
            } else if ((lockDetails.token != null) && !resourceLocked) {
                httpConnection.setResponseStatus(Status.PRECONDITION_FAILED);
                return;
            }

File Line
org/abstracthorizon/danube/webdav/BaseWebDAVResourceConnectionHandler.java 717
org/abstracthorizon/danube/webdav/BaseWebDAVResourceConnectionHandler.java 878
                Status status = responseProperty.getStatus();
                if (status == Status.OK) {
                    if (positive == null) {
                        positive = new Propstat(response);
                        positive.setStatus(Status.OK);
                    }
                    positive.getProp().getProperties().add(responseProperty);
                } else {
                    if (responses == null) {
                        responses = new HashMap<String, Propstat>();
                    }
                    Propstat propstat = responses.get(status.getCode());
                    if (propstat == null) {
                        propstat = new Propstat(response);
                        propstat.setStatus(responseProperty.getStatus());
                        responses.put(propstat.getStatus().getCode(), propstat);
                    }
                    propstat.getProp().getProperties().add(responseProperty);
                }
            }

File Line
org/abstracthorizon/danube/webdav/xml/dav/LockType.java 26
org/abstracthorizon/danube/webdav/xml/dav/request/LockType.java 27
public class LockType extends AbstractSimpleXMLHandler {

    /**
     * Constructor
     * @param parent
     */
    public LockType(XMLParserHandler parent) {
        super(parent);
    }

    @Override
    public Object start(Object current, String tag, Attributes attributes) throws SAXException {
        if ("write".equals(tag)) {
            return this;
        } else {
            return super.start(current, tag, attributes);
        }
    }

    @Override
    public Object end(Object current, String tag, String value) throws SAXException {
        if ("write".equals(tag)) {
            return this;
        } else {
            return super.end(current, tag, value);
        }
    }

    @Override
    public String toString() {
        return "LockType[write]";
    }

}

File Line
org/abstracthorizon/danube/webdav/fs/FileSystemWebDAVResourceAdapter.java 82
org/abstracthorizon/danube/webdav/fs/FileSystemWebDAVResourceAdapter.java 93
        new org.abstracthorizon.danube.webdav.xml.dav.request.properties.DisplayName(null),
        new org.abstracthorizon.danube.webdav.xml.dav.request.properties.GetETag(null),
        new org.abstracthorizon.danube.webdav.fs.properties.GetLastModified(null),
        new org.abstracthorizon.danube.webdav.xml.dav.request.properties.LockDiscovery(null),
        new org.abstracthorizon.danube.webdav.xml.dav.request.properties.ResourceType(null),
        new org.abstracthorizon.danube.webdav.xml.dav.request.properties.SupportedLock(null, null)
    };

    /** Namespace provider to be used with this adapter */
    protected NamespacesProvider namespacesProvider = new SimpleNamespacesProvider();