diff --git a/source/java/org/alfresco/repo/webdav/LockInfo.java b/source/java/org/alfresco/repo/webdav/LockInfoImpl.java similarity index 94% rename from source/java/org/alfresco/repo/webdav/LockInfo.java rename to source/java/org/alfresco/repo/webdav/LockInfoImpl.java index cf8b15a1b0..1db0239b8a 100644 --- a/source/java/org/alfresco/repo/webdav/LockInfo.java +++ b/source/java/org/alfresco/repo/webdav/LockInfoImpl.java @@ -33,7 +33,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock; * @author Ivan Rybnikov * */ -public final class LockInfo implements Serializable +public final class LockInfoImpl implements Serializable, LockInfo { private static final long serialVersionUID = 1L; @@ -61,7 +61,7 @@ public final class LockInfo implements Serializable * Default constructor * */ - public LockInfo() + public LockInfoImpl() { } @@ -72,7 +72,7 @@ public final class LockInfo implements Serializable * @param scope Lock scope (shared/exclusive) * @param depth Lock depth (0/infinity) */ - public LockInfo(String token, String scope, String depth) + public LockInfoImpl(String token, String scope, String depth) { this.exclusiveLockToken = token; this.scope = scope; @@ -88,6 +88,7 @@ public final class LockInfo implements Serializable * * @return */ + @Override public ReentrantReadWriteLock getRWLock() { return rwLock; @@ -98,6 +99,7 @@ public final class LockInfo implements Serializable * * @return boolean */ + @Override public boolean isLocked() { return (isExclusive() || isShared()); @@ -108,6 +110,7 @@ public final class LockInfo implements Serializable * * @param token Lock token */ + @Override public void setExclusiveLockToken(String token) { this.exclusiveLockToken = token; @@ -118,6 +121,7 @@ public final class LockInfo implements Serializable * * @return String */ + @Override public String getExclusiveLockToken() { checkLockState(); @@ -129,6 +133,7 @@ public final class LockInfo implements Serializable * * @param scope */ + @Override public void setScope(String scope) { this.scope = scope; @@ -139,6 +144,7 @@ public final class LockInfo implements Serializable * * @return lock scope */ + @Override public String getScope() { return scope == null ? WebDAV.XML_EXCLUSIVE : scope; @@ -149,6 +155,7 @@ public final class LockInfo implements Serializable * * @param depth lock depth */ + @Override public void setDepth(String depth) { this.depth = depth; @@ -159,6 +166,7 @@ public final class LockInfo implements Serializable * * @return lock depth */ + @Override public String getDepth() { return depth; @@ -169,6 +177,7 @@ public final class LockInfo implements Serializable * * @return LinkedList */ + @Override public Set getSharedLockTokens() { checkLockState(); @@ -180,6 +189,7 @@ public final class LockInfo implements Serializable * * @param sharedLockTokens */ + @Override public void setSharedLockTokens(Set sharedLockTokens) { this.sharedLockTokens.clear(); @@ -191,6 +201,7 @@ public final class LockInfo implements Serializable * * @param token The token to add. */ + @Override public void addSharedLockToken(String token) { sharedLockTokens.add(token); @@ -201,6 +212,7 @@ public final class LockInfo implements Serializable * * @return true if shared. */ + @Override public boolean isShared() { return (!sharedLockTokens.isEmpty()); @@ -212,6 +224,7 @@ public final class LockInfo implements Serializable * * @return String */ + @Override public String toString() { StringBuilder str = new StringBuilder(); @@ -242,6 +255,7 @@ public final class LockInfo implements Serializable * * @return true if expired. */ + @Override public boolean isExpired() { if (expires == null) @@ -257,6 +271,7 @@ public final class LockInfo implements Serializable * * @return true if exclusive. */ + @Override public boolean isExclusive() { return (exclusiveLockToken != null && exclusiveLockToken.length() > 0); @@ -267,6 +282,7 @@ public final class LockInfo implements Serializable * * @return the owner */ + @Override public String getOwner() { return owner; @@ -277,6 +293,7 @@ public final class LockInfo implements Serializable * * @param owner Owner's username */ + @Override public void setOwner(String owner) { this.owner = owner; @@ -287,6 +304,7 @@ public final class LockInfo implements Serializable * * @param expires the expires to set */ + @Override public void setExpires(Date expires) { this.expires = expires; @@ -297,6 +315,7 @@ public final class LockInfo implements Serializable * * @return the expires */ + @Override public Date getExpires() { return expires; @@ -319,6 +338,7 @@ public final class LockInfo implements Serializable * * @param lockTimeout */ + @Override public void setTimeoutSeconds(int lockTimeout) { if (lockTimeout == WebDAV.TIMEOUT_INFINITY) diff --git a/source/java/org/alfresco/repo/webdav/LockMethod.java b/source/java/org/alfresco/repo/webdav/LockMethod.java index 9ba07c4729..340ab384f8 100644 --- a/source/java/org/alfresco/repo/webdav/LockMethod.java +++ b/source/java/org/alfresco/repo/webdav/LockMethod.java @@ -56,7 +56,7 @@ public class LockMethod extends WebDAVMethod protected int m_timeoutDuration = WebDAV.TIMEOUT_INFINITY; - protected LockInfo lockInfo = new LockInfo(); + protected LockInfo lockInfo = new LockInfoImpl(); protected boolean createExclusive; diff --git a/source/java/org/alfresco/repo/webdav/LockStore.java b/source/java/org/alfresco/repo/webdav/LockStore.java deleted file mode 100644 index 2565c50ad1..0000000000 --- a/source/java/org/alfresco/repo/webdav/LockStore.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2005-2012 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco 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 3 of the License, or - * (at your option) any later version. - * - * Alfresco 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 Alfresco. If not, see . - */ -package org.alfresco.repo.webdav; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Provides storage for WebDAV {@link LockInfo lock information}. - *

- * Note: the existence of LockInfo does NOT mean that a node is necessarily locked. It may have timed-out, - * been unlocked, or be left in an invalid state for some reason. The LockInfo is a record of a requested lock - - * the actual values should be examined as necessary. - *

- * Implementations of this interface should be fast, ideally an in-memory map. Implementations should also be thread- - * and cluster-safe. - * - * @author Matt Ward - */ -public interface LockStore -{ - /** - * Provide LockInfo about a specific node to the LockStore. - * - * @param nodeToLock - * @param lockInfo - */ - void put(NodeRef nodeToLock, LockInfo lockInfo); - - /** - * Retrieves LockInfo for as given nodeRef. The LockInfo may specify that a node is - * NOT locked, so the LockInfo should always be checked for validity. - *

- * The presence of LockInfo does not imply that a node is locked. - * - * @param nodeRef - * @return - */ - LockInfo get(NodeRef nodeRef); - - - /** - * Remove LockInfo for the specified NodeRef. The LockInfo cannot be considered locked - * once removed from the LockStore. - * - * @param nodeRef - */ - void remove(NodeRef nodeRef); -} diff --git a/source/java/org/alfresco/repo/webdav/LockStoreFactory.java b/source/java/org/alfresco/repo/webdav/LockStoreFactory.java deleted file mode 100644 index 207ede744e..0000000000 --- a/source/java/org/alfresco/repo/webdav/LockStoreFactory.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2005-2012 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco 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 3 of the License, or - * (at your option) any later version. - * - * Alfresco 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 Alfresco. If not, see . - */ -package org.alfresco.repo.webdav; - - -/** - * Factory to create {@link LockStore} instances. - * - * @author Matt Ward - */ -public interface LockStoreFactory -{ - LockStore getLockStore(); -} diff --git a/source/java/org/alfresco/repo/webdav/LockStoreFactoryImpl.java b/source/java/org/alfresco/repo/webdav/LockStoreFactoryImpl.java deleted file mode 100644 index 59521b07d1..0000000000 --- a/source/java/org/alfresco/repo/webdav/LockStoreFactoryImpl.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2005-2012 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco 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 3 of the License, or - * (at your option) any later version. - * - * Alfresco 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 Alfresco. If not, see . - */ -package org.alfresco.repo.webdav; - -import java.util.concurrent.ConcurrentMap; - -import org.alfresco.service.cmr.repository.NodeRef; - -import com.hazelcast.core.HazelcastInstance; - - -/** - * Default implementation of the {@link LockStoreFactory} interface. Creates {@link LockStore}s - * backed by a Hazelcast distributed {@link java.util.Map Map}. - * - * @see LockStoreFactory - * @see LockStoreImpl - * @author Matt Ward - */ -public class LockStoreFactoryImpl implements LockStoreFactory -{ - private HazelcastInstance hazelcast; - - @Override - public LockStore getLockStore() - { - ConcurrentMap map = hazelcast.getMap("webdav-locks"); - return new LockStoreImpl(map); - } - - /** - * @param hazelcast the hazelcast to set - */ - public void setHazelcast(HazelcastInstance hazelcast) - { - this.hazelcast = hazelcast; - } -} diff --git a/source/java/org/alfresco/repo/webdav/LockStoreImpl.java b/source/java/org/alfresco/repo/webdav/LockStoreImpl.java deleted file mode 100644 index f21ee18f6d..0000000000 --- a/source/java/org/alfresco/repo/webdav/LockStoreImpl.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2005-2012 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco 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 3 of the License, or - * (at your option) any later version. - * - * Alfresco 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 Alfresco. If not, see . - */ -package org.alfresco.repo.webdav; - -import java.util.concurrent.ConcurrentMap; - -import org.alfresco.service.cmr.repository.NodeRef; - - -/** - * The default {@link LockStore} implementation. This is based upon a ConcurrentMap intended to be supplied by - * Hazelcast (or a similar, distributed data structure library). - * - * @see LockStore - * @author Matt Ward - */ -public class LockStoreImpl implements LockStore -{ - private final ConcurrentMap lockInfoMap; - - public LockStoreImpl(ConcurrentMap lockInfoMap) - { - this.lockInfoMap = lockInfoMap; - } - - @Override - public void put(NodeRef nodeToLock, LockInfo lockInfo) - { - lockInfoMap.put(nodeToLock, lockInfo); - } - - @Override - public LockInfo get(NodeRef nodeRef) - { - return lockInfoMap.get(nodeRef); - } - - @Override - public void remove(NodeRef nodeRef) - { - lockInfoMap.remove(nodeRef); - } -} diff --git a/source/java/org/alfresco/repo/webdav/WebDAVMethod.java b/source/java/org/alfresco/repo/webdav/WebDAVMethod.java index cd56e019ca..6e06407aca 100644 --- a/source/java/org/alfresco/repo/webdav/WebDAVMethod.java +++ b/source/java/org/alfresco/repo/webdav/WebDAVMethod.java @@ -1161,7 +1161,7 @@ public abstract class WebDAVMethod if (parent == null) { // Node has no lock and Lock token - return new LockInfo(); + return new LockInfoImpl(); } lockInfo = m_parentLockInfo.get(parent); @@ -1196,7 +1196,7 @@ public abstract class WebDAVMethod { if (lockInfo == null) { - lockInfo = new LockInfo(); + lockInfo = new LockInfoImpl(); } // temporarily cache - for this request m_parentLockInfo.put(parent, lockInfo);