CCM NG: Some more classes for supporting WebDAV

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@5401 8810af33-2d31-482b-a856-94f89814c4df
jensp 2018-05-03 17:08:32 +00:00
parent 5f4f33444f
commit ca034a0177
8 changed files with 666 additions and 0 deletions

View File

@ -0,0 +1,83 @@
/*
* Copyright (C) 2018 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.webdav.conditions;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
* WebDAV cannot-modify-protected-property Precondition XML Element.
*
* This is a singleton. All instances are absolutely identical, hence can be
* compared using {@code ==} and share one unique hash code. Use
* {@link #CANNOT_MODIFY_PROTECTED_PROPERTY} always.
*
* The class is based on a class/interface from java.net WebDAV Project:
*
* <a href="https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java">https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java</a>
*
*
* @author Markus KARG (mkarg@java.net)
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*
* @see
* <a href="http://www.webdav.org/specs/rfc4918.html#precondition.postcondition.xml.elements">Chapter
* 16 "Precondition/Postcondition XML Elements" of RFC 4918 "HTTP Extensions for
* Web Distributed Authoring and Versioning (WebDAV)"</a>
*
*
*/
@XmlRootElement(name = "cannot-modify-protected-property")
@XmlType(factoryMethod = "createSingleton")
public final class CannotModifyProtectedProperty {
/**
* Singleton instance, providing improved performance and the ability to
* compare by <em>same</em> instance.
*
* @since 1.2
*/
public static final CannotModifyProtectedProperty CANNOT_MODIFY_PROTECTED_PROPERTY
= new CannotModifyProtectedProperty();
@SuppressWarnings("unused")
private static CannotModifyProtectedProperty createSingleton() {
return CANNOT_MODIFY_PROTECTED_PROPERTY;
}
private CannotModifyProtectedProperty() {
// For unmarshalling only.
}
@Override
public final boolean equals(final Object object) {
return object instanceof CannotModifyProtectedProperty;
}
@Override
public final int hashCode() {
return 1;
}
@Override
public final String toString() {
return getClass().getName();
}
}

View File

@ -0,0 +1,87 @@
/*
* Copyright (C) 2018 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.webdav.conditions;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
*
* WebDAV lock-token-matches-request-uri Precondition XML Element.
*
* This is a singleton. All instances are absolutely identical, hence can be
* compared using {@code ==} and share one unique hash code. Use
* {@link #LOCK_TOKEN_MATCHES_REQUEST_URI} always.
*
*
* The class is based on a class/interface from java.net WebDAV Project:
*
* <a href="https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java">https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java</a>
*
*
* @author Markus KARG (mkarg@java.net)
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*
* @see
* <a href="http://www.webdav.org/specs/rfc4918.html#precondition.postcondition.xml.elements">Chapter
* 16 "Precondition/Postcondition XML Elements" of RFC 4918 "HTTP Extensions for
* Web Distributed Authoring and Versioning (WebDAV)"</a>
*
*
*/
@XmlRootElement(name = "lock-token-matches-request-uri")
@XmlType(factoryMethod = "createSingleton")
public final class LockTokenMatchesRequestUri {
/**
* Singleton instance, providing improved performance and the ability to
* compare by <em>same</em> instance.
*
*/
public static final LockTokenMatchesRequestUri LOCK_TOKEN_MATCHES_REQUEST_URI
= new LockTokenMatchesRequestUri();
/**
* Singleton factory to be used solely by JAXB.
*/
@SuppressWarnings("unused")
private static final LockTokenMatchesRequestUri createSingleton() {
return LOCK_TOKEN_MATCHES_REQUEST_URI;
}
private LockTokenMatchesRequestUri() {
// For unmarshalling only.
}
@Override
public final boolean equals(final Object object) {
return object instanceof LockTokenMatchesRequestUri;
}
@Override
public final int hashCode() {
return 1;
}
@Override
public final String toString() {
return getClass().getName();
}
}

View File

@ -0,0 +1,109 @@
/*
* Copyright (C) 2018 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.webdav.conditions;
import org.libreccm.webdav.xml.elements.HRef;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import static java.util.Collections.*;
/**
*
* WebDAV lock-token-submitted Precondition XML Element.
*
* The class is based on a class/interface from java.net WebDAV Project:
*
* <a href="https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java">https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java</a>
*
*
* @author Markus KARG (mkarg@java.net)
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*
*
* @see
* <a href="http://www.webdav.org/specs/rfc4918.html#precondition.postcondition.xml.elements">Chapter
* 16 "Precondition/Postcondition XML Elements" of RFC 4918 "HTTP Extensions for
* Web Distributed Authoring and Versioning (WebDAV)"</a>
*
*/
@XmlRootElement(name = "lock-token-submitted")
public final class LockTokenSubmitted {
@XmlElement(name = "href")
private final List<HRef> hRefs;
@SuppressWarnings("unused")
private LockTokenSubmitted() {
this.hRefs = new LinkedList<HRef>();
}
public LockTokenSubmitted(final HRef hRef, final HRef... hRefs) {
this.hRefs = createList(Objects.requireNonNull(hRef), hRefs);
}
private static <T> List<T> createList(final T first, final T[] other) {
final List<T> list = new LinkedList<>();
list.add(first);
Collections.addAll(list, other);
return list;
}
public final List<HRef> getHRefs() {
return unmodifiableList(hRefs);
}
@Override
public int hashCode() {
int hash = 7;
hash = 29 * hash + Objects.hashCode(hRefs);
return hash;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof LockTokenSubmitted)) {
return false;
}
final LockTokenSubmitted other = (LockTokenSubmitted) obj;
return Objects.equals(hRefs, other.getHRefs());
}
@Override
public final String toString() {
return String.format("%s{ hrefs = %s }",
super.toString(),
Objects.toString(hRefs));
}
}

View File

@ -0,0 +1,98 @@
/*
* Copyright (C) 2018 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.webdav.conditions;
import org.libreccm.webdav.xml.elements.HRef;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
/**
* WebDAV no-conflicting-lock Precondition XML Element.
*
* The class is based on a class/interface from java.net WebDAV Project:
*
* <a href="https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java">https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java</a>
*
*
* @author Markus KARG (mkarg@java.net)
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*
* @see
* <a href="http://www.webdav.org/specs/rfc4918.html#precondition.postcondition.xml.elements">Chapter
* 16 "Precondition/Postcondition XML Elements" of RFC 4918 "HTTP Extensions for
* Web Distributed Authoring and Versioning (WebDAV)"</a>
*
*
*/
@XmlRootElement(name = "no-conflicting-lock")
public final class NoConflictingLock {
@XmlElement(name = "href")
private final List<HRef> hRefs;
public NoConflictingLock() {
this.hRefs = new LinkedList<HRef>();
}
public NoConflictingLock(final HRef... hRefs) {
this.hRefs = Arrays.asList(hRefs);
}
public final List<HRef> getHRefs() {
return Collections.unmodifiableList(this.hRefs);
}
@Override
public int hashCode() {
int hash = 7;
hash = 79 * hash + Objects.hashCode(this.hRefs);
return hash;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof NoConflictingLock)) {
return false;
}
final NoConflictingLock other = (NoConflictingLock) obj;
return Objects.equals(this.hRefs, other.getHRefs());
}
@Override
public final String toString() {
return String.format("%s{ %s }",
super.toString(),
Objects.toString(hRefs));
}
}

View File

@ -0,0 +1,81 @@
/*
* Copyright (C) 2018 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.webdav.conditions;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
* WebDAV no-external-entities Precondition XML Element.
*
* This is a singleton. All instances are absolutely identical, hence can be
* compared using {@code ==} and share one unique hash code. Use
* {@link #NO_EXTERNAL_ENTITIES} always.
*
* The class is based on a class/interface from java.net WebDAV Project:
*
* <a href="https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java">https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java</a>
*
*
* @author Markus KARG (mkarg@java.net)
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*
* @see
* <a href="http://www.webdav.org/specs/rfc4918.html#precondition.postcondition.xml.elements">Chapter
* 16 "Precondition/Postcondition XML Elements" of RFC 4918 "HTTP Extensions for
* Web Distributed Authoring and Versioning (WebDAV)"</a>
*
*
*/
@XmlRootElement(name = "no-external-entities")
@XmlType(factoryMethod = "createSingleton")
public final class NoExternalEntities {
/**
* Singleton instance, providing improved performance and the ability to
* compare by <em>same</em> instance.
*
*/
public static final NoExternalEntities NO_EXTERNAL_ENTITIES
= new NoExternalEntities();
private NoExternalEntities() {
// For unmarshalling only.
}
private static NoExternalEntities createSingleton() {
return NO_EXTERNAL_ENTITIES;
}
@Override
public final boolean equals(final Object object) {
return object instanceof NoExternalEntities;
}
@Override
public final int hashCode() {
return 1;
}
@Override
public final String toString() {
return getClass().getName();
}
}

View File

@ -0,0 +1,83 @@
/*
* Copyright (C) 2018 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.webdav.conditions;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
*
* WebDAV preserved-live-propertes Postcondition XML Element.
*
* This is a singleton. All instances are absolutely identical, hence can be
* compared using {@code ==} and share one unique hash code. Use
* {@link #PRESERVED_LIVE_PROPERTIES} always.
*
*
* The class is based on a class/interface from java.net WebDAV Project:
*
* <a href="https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java">https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java</a>
*
*
* @author Markus KARG (mkarg@java.net)
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*
* @see
* <a href="http://www.webdav.org/specs/rfc4918.html#precondition.postcondition.xml.elements">Chapter
* 16 "Precondition/Postcondition XML Elements" of RFC 4918 "HTTP Extensions for
* Web Distributed Authoring and Versioning (WebDAV)"</a>
*
*
*/
@XmlRootElement(name = "preserved-live-properties")
@XmlType(factoryMethod = "createSingleton")
public final class PreservedLiveProperties {
/**
* Singleton instance, providing improved performance and the ability to
* compare by <em>same</em> instance.
*
*/
public static final PreservedLiveProperties PRESERVED_LIVE_PROPERTIES
= new PreservedLiveProperties();
private PreservedLiveProperties() {
// For unmarshalling only.
}
private static PreservedLiveProperties createSingleton() {
return PRESERVED_LIVE_PROPERTIES;
}
@Override
public final boolean equals(final Object object) {
return object instanceof PreservedLiveProperties;
}
@Override
public final int hashCode() {
return 1;
}
@Override
public final String toString() {
return getClass().getName();
}
}

View File

@ -0,0 +1,83 @@
/*
* Copyright (C) 2018 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.webdav.conditions;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
* WebDAV propfind-finite-depth Precondition XML Element.
*
* This is a singleton. All instances are absolutely identical, hence can be
* compared using {@code ==} and share one unique hash code. Use
* {@link #PROPFIND_FINITE_DEPTH} always.
*
* The class is based on a class/interface from java.net WebDAV Project:
*
* <a href="https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java">https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java</a>
*
*
* @author Markus KARG (mkarg@java.net)
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*
* @see
* <a href="http://www.webdav.org/specs/rfc4918.html#precondition.postcondition.xml.elements">Chapter
* 16 "Precondition/Postcondition XML Elements" of RFC 4918 "HTTP Extensions for
* Web Distributed Authoring and Versioning (WebDAV)"</a>
*
*/
@XmlRootElement(name = "propfind-finite-depth")
@XmlType(factoryMethod = "createSingleton")
public final class PropFindFiniteDepth {
/**
* Singleton instance, providing improved performance and the ability to
* compare by <em>same</em> instance.
*
*/
public static final PropFindFiniteDepth PROPFIND_FINITE_DEPTH
= new PropFindFiniteDepth();
private PropFindFiniteDepth() {
// For unmarshalling only.
}
private static PropFindFiniteDepth createInstance() {
return PROPFIND_FINITE_DEPTH;
}
@Override
public final boolean equals(final Object object) {
return object instanceof PropFindFiniteDepth;
}
@Override
public final int hashCode() {
return 1;
}
@Override
public final String toString() {
return getClass().getName();
}
}

View File

@ -0,0 +1,42 @@
/*
* Copyright (C) 2018 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
/**
* This package contains WebDAV Precondition / Postcondition XML Elements.
*
* The classes in this package are based on a class/interface from java.net WebDAV Project:
*
* <a href="https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java">https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java</a>
*
* @author Markus KARG (mkarg@java.net)
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*
* @see <a href="http://www.webdav.org/specs/rfc4918.html#precondition.postcondition.xml.elements">Chapter 16 "Precondition/Postcondition XML Elements" of RFC 4918 "HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV)"</a>
*
*/
@XmlSchema(namespace = "DAV:",
xmlns = @XmlNs(prefix = "D",
namespaceURI = "DAV:"),
elementFormDefault = QUALIFIED)
package org.libreccm.webdav.conditions;
import javax.xml.bind.annotation.XmlNs;
import javax.xml.bind.annotation.XmlSchema;
import static javax.xml.bind.annotation.XmlNsForm.*;