ALF-12866: remove repository's dependency on remote-api.

* A dependency of the repository project on the remote-api project had crept in.
* The dependency was stopping junit tests from being run in the Eclipse, since it does not define a dependency on remote-api by repository.




git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@34213 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Matt Ward
2012-02-24 14:45:45 +00:00
parent 894056132b
commit 1cb0e9bdd4
7 changed files with 26 additions and 213 deletions

View File

@@ -33,7 +33,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
* @author Ivan Rybnikov * @author Ivan Rybnikov
* *
*/ */
public final class LockInfo implements Serializable public final class LockInfoImpl implements Serializable, LockInfo
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -61,7 +61,7 @@ public final class LockInfo implements Serializable
* Default constructor * Default constructor
* *
*/ */
public LockInfo() public LockInfoImpl()
{ {
} }
@@ -72,7 +72,7 @@ public final class LockInfo implements Serializable
* @param scope Lock scope (shared/exclusive) * @param scope Lock scope (shared/exclusive)
* @param depth Lock depth (0/infinity) * @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.exclusiveLockToken = token;
this.scope = scope; this.scope = scope;
@@ -88,6 +88,7 @@ public final class LockInfo implements Serializable
* *
* @return * @return
*/ */
@Override
public ReentrantReadWriteLock getRWLock() public ReentrantReadWriteLock getRWLock()
{ {
return rwLock; return rwLock;
@@ -98,6 +99,7 @@ public final class LockInfo implements Serializable
* *
* @return boolean * @return boolean
*/ */
@Override
public boolean isLocked() public boolean isLocked()
{ {
return (isExclusive() || isShared()); return (isExclusive() || isShared());
@@ -108,6 +110,7 @@ public final class LockInfo implements Serializable
* *
* @param token Lock token * @param token Lock token
*/ */
@Override
public void setExclusiveLockToken(String token) public void setExclusiveLockToken(String token)
{ {
this.exclusiveLockToken = token; this.exclusiveLockToken = token;
@@ -118,6 +121,7 @@ public final class LockInfo implements Serializable
* *
* @return String * @return String
*/ */
@Override
public String getExclusiveLockToken() public String getExclusiveLockToken()
{ {
checkLockState(); checkLockState();
@@ -129,6 +133,7 @@ public final class LockInfo implements Serializable
* *
* @param scope * @param scope
*/ */
@Override
public void setScope(String scope) public void setScope(String scope)
{ {
this.scope = scope; this.scope = scope;
@@ -139,6 +144,7 @@ public final class LockInfo implements Serializable
* *
* @return lock scope * @return lock scope
*/ */
@Override
public String getScope() public String getScope()
{ {
return scope == null ? WebDAV.XML_EXCLUSIVE : scope; return scope == null ? WebDAV.XML_EXCLUSIVE : scope;
@@ -149,6 +155,7 @@ public final class LockInfo implements Serializable
* *
* @param depth lock depth * @param depth lock depth
*/ */
@Override
public void setDepth(String depth) public void setDepth(String depth)
{ {
this.depth = depth; this.depth = depth;
@@ -159,6 +166,7 @@ public final class LockInfo implements Serializable
* *
* @return lock depth * @return lock depth
*/ */
@Override
public String getDepth() public String getDepth()
{ {
return depth; return depth;
@@ -169,6 +177,7 @@ public final class LockInfo implements Serializable
* *
* @return LinkedList<String> * @return LinkedList<String>
*/ */
@Override
public Set<String> getSharedLockTokens() public Set<String> getSharedLockTokens()
{ {
checkLockState(); checkLockState();
@@ -180,6 +189,7 @@ public final class LockInfo implements Serializable
* *
* @param sharedLockTokens * @param sharedLockTokens
*/ */
@Override
public void setSharedLockTokens(Set<String> sharedLockTokens) public void setSharedLockTokens(Set<String> sharedLockTokens)
{ {
this.sharedLockTokens.clear(); this.sharedLockTokens.clear();
@@ -191,6 +201,7 @@ public final class LockInfo implements Serializable
* *
* @param token The token to add. * @param token The token to add.
*/ */
@Override
public void addSharedLockToken(String token) public void addSharedLockToken(String token)
{ {
sharedLockTokens.add(token); sharedLockTokens.add(token);
@@ -201,6 +212,7 @@ public final class LockInfo implements Serializable
* *
* @return true if shared. * @return true if shared.
*/ */
@Override
public boolean isShared() public boolean isShared()
{ {
return (!sharedLockTokens.isEmpty()); return (!sharedLockTokens.isEmpty());
@@ -212,6 +224,7 @@ public final class LockInfo implements Serializable
* *
* @return String * @return String
*/ */
@Override
public String toString() public String toString()
{ {
StringBuilder str = new StringBuilder(); StringBuilder str = new StringBuilder();
@@ -242,6 +255,7 @@ public final class LockInfo implements Serializable
* *
* @return true if expired. * @return true if expired.
*/ */
@Override
public boolean isExpired() public boolean isExpired()
{ {
if (expires == null) if (expires == null)
@@ -257,6 +271,7 @@ public final class LockInfo implements Serializable
* *
* @return true if exclusive. * @return true if exclusive.
*/ */
@Override
public boolean isExclusive() public boolean isExclusive()
{ {
return (exclusiveLockToken != null && exclusiveLockToken.length() > 0); return (exclusiveLockToken != null && exclusiveLockToken.length() > 0);
@@ -267,6 +282,7 @@ public final class LockInfo implements Serializable
* *
* @return the owner * @return the owner
*/ */
@Override
public String getOwner() public String getOwner()
{ {
return owner; return owner;
@@ -277,6 +293,7 @@ public final class LockInfo implements Serializable
* *
* @param owner Owner's username * @param owner Owner's username
*/ */
@Override
public void setOwner(String owner) public void setOwner(String owner)
{ {
this.owner = owner; this.owner = owner;
@@ -287,6 +304,7 @@ public final class LockInfo implements Serializable
* *
* @param expires the expires to set * @param expires the expires to set
*/ */
@Override
public void setExpires(Date expires) public void setExpires(Date expires)
{ {
this.expires = expires; this.expires = expires;
@@ -297,6 +315,7 @@ public final class LockInfo implements Serializable
* *
* @return the expires * @return the expires
*/ */
@Override
public Date getExpires() public Date getExpires()
{ {
return expires; return expires;
@@ -319,6 +338,7 @@ public final class LockInfo implements Serializable
* *
* @param lockTimeout * @param lockTimeout
*/ */
@Override
public void setTimeoutSeconds(int lockTimeout) public void setTimeoutSeconds(int lockTimeout)
{ {
if (lockTimeout == WebDAV.TIMEOUT_INFINITY) if (lockTimeout == WebDAV.TIMEOUT_INFINITY)

View File

@@ -56,7 +56,7 @@ public class LockMethod extends WebDAVMethod
protected int m_timeoutDuration = WebDAV.TIMEOUT_INFINITY; protected int m_timeoutDuration = WebDAV.TIMEOUT_INFINITY;
protected LockInfo lockInfo = new LockInfo(); protected LockInfo lockInfo = new LockInfoImpl();
protected boolean createExclusive; protected boolean createExclusive;

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.webdav;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* Provides storage for WebDAV {@link LockInfo lock information}.
* <p>
* 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.
* <p>
* 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
* <strong>NOT</strong> locked, so the LockInfo should always be checked for validity.
* <p>
* 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);
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.webdav;
/**
* Factory to create {@link LockStore} instances.
*
* @author Matt Ward
*/
public interface LockStoreFactory
{
LockStore getLockStore();
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
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<NodeRef, LockInfo> map = hazelcast.getMap("webdav-locks");
return new LockStoreImpl(map);
}
/**
* @param hazelcast the hazelcast to set
*/
public void setHazelcast(HazelcastInstance hazelcast)
{
this.hazelcast = hazelcast;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
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<NodeRef, LockInfo> lockInfoMap;
public LockStoreImpl(ConcurrentMap<NodeRef, LockInfo> 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);
}
}

View File

@@ -1161,7 +1161,7 @@ public abstract class WebDAVMethod
if (parent == null) if (parent == null)
{ {
// Node has no lock and Lock token // Node has no lock and Lock token
return new LockInfo(); return new LockInfoImpl();
} }
lockInfo = m_parentLockInfo.get(parent); lockInfo = m_parentLockInfo.get(parent);
@@ -1196,7 +1196,7 @@ public abstract class WebDAVMethod
{ {
if (lockInfo == null) if (lockInfo == null)
{ {
lockInfo = new LockInfo(); lockInfo = new LockInfoImpl();
} }
// temporarily cache - for this request // temporarily cache - for this request
m_parentLockInfo.put(parent, lockInfo); m_parentLockInfo.put(parent, lockInfo);