diff --git a/ccm-core/src/main/java/org/libreccm/webdav/conditions/CannotModifyProtectedProperty.java b/ccm-core/src/main/java/org/libreccm/webdav/conditions/CannotModifyProtectedProperty.java new file mode 100644 index 000000000..bdc66e4bc --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/webdav/conditions/CannotModifyProtectedProperty.java @@ -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: + * + * https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java + * + * + * @author Markus KARG (mkarg@java.net) + * @author Jens Pelzetter + * + * @see + * Chapter + * 16 "Precondition/Postcondition XML Elements" of RFC 4918 "HTTP Extensions for + * Web Distributed Authoring and Versioning (WebDAV)" + * + * + */ +@XmlRootElement(name = "cannot-modify-protected-property") +@XmlType(factoryMethod = "createSingleton") +public final class CannotModifyProtectedProperty { + + /** + * Singleton instance, providing improved performance and the ability to + * compare by same 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(); + } + +} diff --git a/ccm-core/src/main/java/org/libreccm/webdav/conditions/LockTokenMatchesRequestUri.java b/ccm-core/src/main/java/org/libreccm/webdav/conditions/LockTokenMatchesRequestUri.java new file mode 100644 index 000000000..a4db3af37 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/webdav/conditions/LockTokenMatchesRequestUri.java @@ -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: + * + * https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java + * + * + * @author Markus KARG (mkarg@java.net) + * @author Jens Pelzetter + * + * @see + * Chapter + * 16 "Precondition/Postcondition XML Elements" of RFC 4918 "HTTP Extensions for + * Web Distributed Authoring and Versioning (WebDAV)" + * + * + */ +@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 same 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(); + } + +} diff --git a/ccm-core/src/main/java/org/libreccm/webdav/conditions/LockTokenSubmitted.java b/ccm-core/src/main/java/org/libreccm/webdav/conditions/LockTokenSubmitted.java new file mode 100644 index 000000000..dd8da6bdb --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/webdav/conditions/LockTokenSubmitted.java @@ -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: + * + * https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java + * + * + * @author Markus KARG (mkarg@java.net) + * @author Jens Pelzetter + * + * + * @see + * Chapter + * 16 "Precondition/Postcondition XML Elements" of RFC 4918 "HTTP Extensions for + * Web Distributed Authoring and Versioning (WebDAV)" + * + */ +@XmlRootElement(name = "lock-token-submitted") +public final class LockTokenSubmitted { + + @XmlElement(name = "href") + private final List hRefs; + + @SuppressWarnings("unused") + private LockTokenSubmitted() { + this.hRefs = new LinkedList(); + } + + public LockTokenSubmitted(final HRef hRef, final HRef... hRefs) { + this.hRefs = createList(Objects.requireNonNull(hRef), hRefs); + } + + private static List createList(final T first, final T[] other) { + + final List list = new LinkedList<>(); + list.add(first); + Collections.addAll(list, other); + + return list; + } + + public final List 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)); + } + +} diff --git a/ccm-core/src/main/java/org/libreccm/webdav/conditions/NoConflictingLock.java b/ccm-core/src/main/java/org/libreccm/webdav/conditions/NoConflictingLock.java new file mode 100644 index 000000000..6d5c43e3d --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/webdav/conditions/NoConflictingLock.java @@ -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: + * + * https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java + * + * + * @author Markus KARG (mkarg@java.net) + * @author Jens Pelzetter + * + * @see + * Chapter + * 16 "Precondition/Postcondition XML Elements" of RFC 4918 "HTTP Extensions for + * Web Distributed Authoring and Versioning (WebDAV)" + * + * + */ +@XmlRootElement(name = "no-conflicting-lock") +public final class NoConflictingLock { + + @XmlElement(name = "href") + private final List hRefs; + + public NoConflictingLock() { + this.hRefs = new LinkedList(); + } + + public NoConflictingLock(final HRef... hRefs) { + this.hRefs = Arrays.asList(hRefs); + } + + public final List 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)); + } + +} diff --git a/ccm-core/src/main/java/org/libreccm/webdav/conditions/NoExternalEntities.java b/ccm-core/src/main/java/org/libreccm/webdav/conditions/NoExternalEntities.java new file mode 100644 index 000000000..a6af7256e --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/webdav/conditions/NoExternalEntities.java @@ -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: + * + * https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java + * + * + * @author Markus KARG (mkarg@java.net) + * @author Jens Pelzetter + * + * @see + * Chapter + * 16 "Precondition/Postcondition XML Elements" of RFC 4918 "HTTP Extensions for + * Web Distributed Authoring and Versioning (WebDAV)" + * + * + */ +@XmlRootElement(name = "no-external-entities") +@XmlType(factoryMethod = "createSingleton") +public final class NoExternalEntities { + + /** + * Singleton instance, providing improved performance and the ability to + * compare by same 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(); + } + +} diff --git a/ccm-core/src/main/java/org/libreccm/webdav/conditions/PreservedLiveProperties.java b/ccm-core/src/main/java/org/libreccm/webdav/conditions/PreservedLiveProperties.java new file mode 100644 index 000000000..2f405ca77 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/webdav/conditions/PreservedLiveProperties.java @@ -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: + * + * https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java + * + * + * @author Markus KARG (mkarg@java.net) + * @author Jens Pelzetter + * + * @see + * Chapter + * 16 "Precondition/Postcondition XML Elements" of RFC 4918 "HTTP Extensions for + * Web Distributed Authoring and Versioning (WebDAV)" + * + * + */ +@XmlRootElement(name = "preserved-live-properties") +@XmlType(factoryMethod = "createSingleton") +public final class PreservedLiveProperties { + + /** + * Singleton instance, providing improved performance and the ability to + * compare by same 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(); + } + +} diff --git a/ccm-core/src/main/java/org/libreccm/webdav/conditions/PropFindFiniteDepth.java b/ccm-core/src/main/java/org/libreccm/webdav/conditions/PropFindFiniteDepth.java new file mode 100644 index 000000000..31b91579a --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/webdav/conditions/PropFindFiniteDepth.java @@ -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: + * + * https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java + * + * + * @author Markus KARG (mkarg@java.net) + * @author Jens Pelzetter + * + * + * @author Jens Pelzetter + * + * @see + * Chapter + * 16 "Precondition/Postcondition XML Elements" of RFC 4918 "HTTP Extensions for + * Web Distributed Authoring and Versioning (WebDAV)" + * + */ +@XmlRootElement(name = "propfind-finite-depth") +@XmlType(factoryMethod = "createSingleton") +public final class PropFindFiniteDepth { + + /** + * Singleton instance, providing improved performance and the ability to + * compare by same 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(); + } + +} diff --git a/ccm-core/src/main/java/org/libreccm/webdav/conditions/package-info.java b/ccm-core/src/main/java/org/libreccm/webdav/conditions/package-info.java new file mode 100644 index 000000000..8a8824e12 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/webdav/conditions/package-info.java @@ -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: + * + * https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java + * + * @author Markus KARG (mkarg@java.net) + * @author Jens Pelzetter + * + * @see Chapter 16 "Precondition/Postcondition XML Elements" of RFC 4918 "HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV)" + * + */ +@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.*; +