You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by dp...@apache.org on 2009/07/03 17:09:23 UTC
svn commit: r790939 - in
/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core:
config/ lock/
Author: dpfister
Date: Fri Jul 3 15:09:22 2009
New Revision: 790939
URL: http://svn.apache.org/viewvc?rev=790939&view=rev
Log:
Replace tabs with spaces
Modified:
jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java
jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/AbstractLockInfo.java
jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockImpl.java
jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManager.java
jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/XAEnvironment.java
jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/XALockManager.java
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java?rev=790939&r1=790938&r2=790939&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java Fri Jul 3 15:09:22 2009
@@ -105,7 +105,7 @@
public static final String DATA_STORE_ELEMENT = "DataStore";
/** Name of the repository lock mechanism configuration element. */
- public static final String REPOSITORY_LOCK_MECHANISM_ELEMENT =
+ public static final String REPOSITORY_LOCK_MECHANISM_ELEMENT =
"RepositoryLockMechanism";
/** Name of the persistence manager configuration element. */
@@ -263,7 +263,7 @@
// Optional data store factory
DataStoreFactory dsf = getDataStoreFactory(root, home);
-
+
RepositoryLockMechanismFactory rlf = getRepositoryLockMechanismFactory(root);
return new RepositoryConfig(home, securityConfig, fsf,
@@ -419,21 +419,21 @@
*/
public WorkspaceConfig parseWorkspaceConfig(InputSource xml)
throws ConfigurationException {
-
+
Element root = parseXML(xml);
return parseWorkspaceConfig(root);
}
-
+
/**
* Parse workspace config.
- *
+ *
* @param root root element of the workspace configuration
- *
+ *
* @see #parseWorkspaceConfig(InputSource)
*/
protected WorkspaceConfig parseWorkspaceConfig(Element root)
- throws ConfigurationException {
-
+ throws ConfigurationException {
+
// Workspace home directory
String home = getVariables().getProperty(WORKSPACE_HOME_VARIABLE);
@@ -757,11 +757,11 @@
* <p/>
* <code>RepositoryLockMechanism</code> is a
* {@link #parseBeanConfig(Element,String) bean configuration} element.
- *
+ *
* @param root the root configuration element
* @return repository lock mechanism factory
* @throws ConfigurationException if the configuration is broken
- */
+ */
protected RepositoryLockMechanismFactory getRepositoryLockMechanismFactory(final Element root) {
return new RepositoryLockMechanismFactory() {
public RepositoryLockMechanism getRepositoryLockMechanism() throws RepositoryException {
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/AbstractLockInfo.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/AbstractLockInfo.java?rev=790939&r1=790938&r2=790939&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/AbstractLockInfo.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/AbstractLockInfo.java Fri Jul 3 15:09:22 2009
@@ -30,7 +30,7 @@
* Constant for the undefined or infinite timeout.
*/
static final long TIMEOUT_INFINITE = Long.MAX_VALUE;
-
+
/**
* Constant for the expired timeout.
*/
@@ -112,26 +112,26 @@
public NodeId getId() {
return lockToken.getId();
}
-
+
/**
* {@inheritDoc}
*/
public boolean isLockHolder(Session session) {
- return lockHolder == session;
+ return lockHolder == session;
}
-
+
/**
* {@inheritDoc}
*/
public String getLockOwner() {
- return lockOwner;
+ return lockOwner;
}
-
+
/**
* {@inheritDoc}
*/
public boolean isDeep() {
- return deep;
+ return deep;
}
/**
@@ -151,24 +151,24 @@
public void setLockHolder(SessionImpl lockHolder) {
this.lockHolder = lockHolder;
}
-
+
/**
* {@inheritDoc}
*/
public String getLockToken(Session session) {
- if (isLockHolder(session)) {
+ if (isLockHolder(session)) {
return lockToken.toString();
}
return null;
}
-
+
/**
* Return the lock token.
- *
+ *
* @return lock token
*/
public String getLockToken() {
- return lockToken.toString();
+ return lockToken.toString();
}
/**
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockImpl.java?rev=790939&r1=790938&r2=790939&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockImpl.java Fri Jul 3 15:09:22 2009
@@ -138,7 +138,7 @@
*/
public boolean isLockOwningSession() {
try {
- return info.isLockHolder(node.getSession());
+ return info.isLockHolder(node.getSession());
} catch (RepositoryException e) {
return false;
}
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManager.java?rev=790939&r1=790938&r2=790939&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManager.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManager.java Fri Jul 3 15:09:22 2009
@@ -149,12 +149,12 @@
* @throws LockException if write access to the specified path is not allowed
* @throws RepositoryException if some other error occurs
*/
- void checkUnlock(Session session, NodeImpl node)
- throws LockException, RepositoryException;
-
+ void checkUnlock(Session session, NodeImpl node) throws LockException,
+ RepositoryException;
+
/**
* Invoked by a session to inform that a lock token has been added.
- *
+ *
* @param session session that has a added lock token
* @param lt added lock token
* @throws LockException
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java?rev=790939&r1=790938&r2=790939&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java Fri Jul 3 15:09:22 2009
@@ -246,7 +246,7 @@
lockMap.traverse(new PathMap.ElementVisitor() {
public void elementVisited(PathMap.Element element) {
- AbstractLockInfo info = (AbstractLockInfo) element.get();
+ AbstractLockInfo info = (AbstractLockInfo) element.get();
if (!info.isSessionScoped()) {
list.add(info);
}
@@ -260,7 +260,7 @@
writer = new BufferedWriter(
new OutputStreamWriter(locksFile.getOutputStream()));
for (int i = 0; i < list.size(); i++) {
- AbstractLockInfo info = list.get(i);
+ AbstractLockInfo info = list.get(i);
writer.write(info.getLockToken());
writer.newLine();
}
@@ -603,7 +603,7 @@
LockInfo info = (LockInfo) element.get();
if (info != null) {
if (element.hasPath(path) || info.isDeep()) {
- checkLock(info, session);
+ checkLock(info, session);
}
}
}
@@ -614,16 +614,16 @@
* lock holder itself.
* <p/>
* Default implementation allows access to the lock holder only.
- *
+ *
* @param info info to check
* @param session session
* @throws LockException if write access to the specified path is not allowed
* @throws RepositoryException if some other error occurs
*/
- protected void checkLock(LockInfo info, Session session)
- throws LockException, RepositoryException {
-
- if (!info.isLockHolder(session)) {
+ protected void checkLock(LockInfo info, Session session)
+ throws LockException, RepositoryException {
+
+ if (!info.isLockHolder(session)) {
throw new LockException("Node locked.");
}
}
@@ -632,19 +632,19 @@
* {@inheritDoc}
*/
public void checkUnlock(Session session, NodeImpl node)
- throws LockException, RepositoryException {
+ throws LockException, RepositoryException {
- // check whether node is locked by this session
- PathMap.Element element = lockMap.map(
- getPath((SessionImpl) session, node.getId()), true);
- if (element == null) {
- throw new LockException("Node not locked: " + node);
- }
- AbstractLockInfo info = (AbstractLockInfo) element.get();
- if (info == null) {
- throw new LockException("Node not locked: " + node);
- }
- checkUnlock(info, session);
+ // check whether node is locked by this session
+ PathMap.Element element = lockMap.map(getPath((SessionImpl) session,
+ node.getId()), true);
+ if (element == null) {
+ throw new LockException("Node not locked: " + node);
+ }
+ AbstractLockInfo info = (AbstractLockInfo) element.get();
+ if (info == null) {
+ throw new LockException("Node not locked: " + node);
+ }
+ checkUnlock(info, session);
}
/**
@@ -653,20 +653,21 @@
* itself.
* <p/>
* Default implementation allows unlocking to the lock holder only.
- *
+ *
* @param info info to check
* @param session session
* @throws LockException if unlocking is denied
* @throws RepositoryException if some other error occurs
*/
protected void checkUnlock(LockInfo info, Session session)
- throws LockException, RepositoryException {
-
- if (!info.isLockHolder(session)) {
- throw new LockException("Node not locked by session: " + info.getId());
- }
+ throws LockException, RepositoryException {
+
+ if (!info.isLockHolder(session)) {
+ throw new LockException("Node not locked by session: "
+ + info.getId());
+ }
}
-
+
/**
* {@inheritDoc}
*/
@@ -680,9 +681,9 @@
if (element != null) {
AbstractLockInfo info = (AbstractLockInfo) element.get();
if (info != null) {
- if (info.isLockHolder(session)) {
- // nothing to do
- } else if (info.getLockHolder() == null) {
+ if (info.isLockHolder(session)) {
+ // nothing to do
+ } else if (info.getLockHolder() == null) {
info.setLockHolder(session);
if (info instanceof InternalLockInfo) {
session.addListener((InternalLockInfo) info);
@@ -706,22 +707,22 @@
/**
* {@inheritDoc}
*/
- public void removeLockToken(SessionImpl session, String lt)
- throws LockException, RepositoryException {
-
+ public void removeLockToken(SessionImpl session, String lt)
+ throws LockException, RepositoryException {
+
try {
LockToken lockToken = LockToken.parse(lt);
- NodeImpl node = (NodeImpl)
- this.sysSession.getItemManager().getItem(lockToken.getId());
+ NodeImpl node = (NodeImpl) this.sysSession.getItemManager()
+ .getItem(lockToken.getId());
PathMap.Element element = lockMap.map(node.getPrimaryPath(), true);
if (element != null) {
AbstractLockInfo info = (AbstractLockInfo) element.get();
if (info != null) {
- if (info.isLockHolder(session)) {
+ if (info.isLockHolder(session)) {
info.setLockHolder(null);
- } else if (info.getLockHolder() == null) {
- // nothing to do
+ } else if (info.getLockHolder() == null) {
+ // nothing to do
} else {
String msg = "Cannot remove lock token: lock held by other session.";
log.warn(msg);
@@ -1068,7 +1069,7 @@
// save away non-empty children
element.traverse(new PathMap.ElementVisitor() {
public void elementVisited(PathMap.Element element) {
- AbstractLockInfo info = (AbstractLockInfo) element.get();
+ AbstractLockInfo info = (AbstractLockInfo) element.get();
infos.add(info);
}
}, false);
@@ -1079,10 +1080,10 @@
// now re-insert at appropriate location or throw away if node
// does no longer exist
for (int i = 0; i < infos.size(); i++) {
- AbstractLockInfo info = infos.get(i);
+ AbstractLockInfo info = infos.get(i);
try {
- NodeImpl node = (NodeImpl) sysSession.getItemManager().
- getItem(info.getId());
+ NodeImpl node = (NodeImpl) sysSession.getItemManager().getItem(
+ info.getId());
lockMap.put(node.getPrimaryPath(), info);
} catch (RepositoryException e) {
info.setLive(false);
@@ -1195,7 +1196,7 @@
boolean deep, String lockOwner, long timeoutHint) {
super(lockToken, sessionScoped, deep, lockOwner, timeoutHint);
}
-
+
/**
* {@inheritDoc}
* <p/>
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/XAEnvironment.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/XAEnvironment.java?rev=790939&r1=790938&r2=790939&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/XAEnvironment.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/XAEnvironment.java Fri Jul 3 15:09:22 2009
@@ -56,14 +56,14 @@
/**
* Map of locked nodes, indexed by their (internal) id.
*/
- private final Map<NodeId, XALockInfo> lockedNodesMap =
- new HashMap<NodeId, XALockInfo>();
+ private final Map<NodeId, XALockInfo> lockedNodesMap =
+ new HashMap<NodeId, XALockInfo>();
/**
* Map of unlocked nodes, indexed by their (internal) id.
*/
- private final Map<NodeId, XALockInfo> unlockedNodesMap =
- new HashMap<NodeId, XALockInfo>();
+ private final Map<NodeId, XALockInfo> unlockedNodesMap =
+ new HashMap<NodeId, XALockInfo>();
/**
* List of lock/unlock operations.
@@ -245,7 +245,7 @@
*/
public AbstractLockInfo[] getLockInfos(SessionImpl session)
throws RepositoryException {
-
+
ArrayList<AbstractLockInfo> result = new ArrayList<AbstractLockInfo>();
// get lock informations from global lock manager first
@@ -266,9 +266,9 @@
/**
* Add lock token to this environment.
- * @param session
+ * @param session
* @param lt lock token
- * @throws RepositoryException
+ * @throws RepositoryException
*/
public void addLockToken(SessionImpl session, String lt) throws RepositoryException {
try {
@@ -276,9 +276,9 @@
NodeImpl node = (NodeImpl) session.getItemManager().getItem(lockToken.getId());
AbstractLockInfo info = getLockInfo(node);
if (info != null) {
- if (info.isLockHolder(session)) {
- // nothing to do
- } else if (info.getLockHolder() == null) {
+ if (info.isLockHolder(session)) {
+ // nothing to do
+ } else if (info.getLockHolder() == null) {
info.setLockHolder(session);
} else {
String msg = "Cannot add lock token: lock already held by other session.";
@@ -297,9 +297,9 @@
/**
* Remove lock token from this environment.
- * @param session
+ * @param session
* @param lt lock token
- * @throws RepositoryException
+ * @throws RepositoryException
*/
public void removeLockToken(SessionImpl session, String lt) throws RepositoryException {
try {
@@ -308,10 +308,10 @@
NodeImpl node = (NodeImpl) session.getItemManager().getItem(lockToken.getId());
AbstractLockInfo info = getLockInfo(node);
if (info != null) {
- if (info.isLockHolder(session)) {
+ if (info.isLockHolder(session)) {
info.setLockHolder(null);
- } else if (info.getLockHolder() == null) {
- // nothing to do
+ } else if (info.getLockHolder() == null) {
+ // nothing to do
} else {
String msg = "Cannot remove lock token: lock held by other session.";
log.warn(msg);
@@ -447,9 +447,10 @@
* @param lockOwner owner of lock
*/
public XALockInfo(NodeImpl node, LockToken lockToken,
- boolean sessionScoped, boolean deep, String lockOwner) {
+ boolean sessionScoped, boolean deep, String lockOwner) {
- this(node, lockToken, sessionScoped, deep, lockOwner, TIMEOUT_INFINITE);
+ this(node, lockToken, sessionScoped, deep, lockOwner,
+ TIMEOUT_INFINITE);
}
/**
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/XALockManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/XALockManager.java?rev=790939&r1=790938&r2=790939&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/XALockManager.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/XALockManager.java Fri Jul 3 15:09:22 2009
@@ -171,7 +171,7 @@
throw new LockException("Node locked.");
}
} else {
- lockMgr.checkLock(node);
+ lockMgr.checkLock(node);
}
}
@@ -182,29 +182,29 @@
throws LockException, RepositoryException {
if (isInXA()) {
- SessionImpl sessionImpl = (SessionImpl) session;
- checkLock(sessionImpl.getItemManager().getNode(path));
+ SessionImpl sessionImpl = (SessionImpl) session;
+ checkLock(sessionImpl.getItemManager().getNode(path));
} else {
- lockMgr.checkLock(path, session);
+ lockMgr.checkLock(path, session);
}
}
-
+
/**
* {@inheritDoc}
*/
public void checkUnlock(Session session, NodeImpl node)
- throws LockException, RepositoryException {
+ throws LockException, RepositoryException {
if (isInXA()) {
AbstractLockInfo info = xaEnv.getLockInfo(node);
if (info == null || !info.getId().equals(node.getId())) {
- throw new LockException("Node not locked: " + node);
+ throw new LockException("Node not locked: " + node);
+ }
+ if (!info.isLockHolder(session)) {
+ throw new LockException("Node not locked by session: " + node);
}
- if (!info.isLockHolder(session)) {
- throw new LockException("Node not locked by session: " + node);
- }
} else {
- lockMgr.checkUnlock(session, node);
+ lockMgr.checkUnlock(session, node);
}
}