You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ju...@apache.org on 2009/07/08 15:57:46 UTC
svn commit: r792142 [4/35] - in /jackrabbit/sandbox/JCR-1456: ./
jackrabbit-api/src/main/java/org/apache/jackrabbit/api/
jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security/
jackrabbit-core/ jackrabbit-core/src/main/java/org/apache/jackrabb...
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java Wed Jul 8 13:57:13 2009
@@ -28,7 +28,6 @@
import javax.jcr.Property;
import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
-import javax.jcr.UnsupportedRepositoryOperationException;
import javax.jcr.Value;
import javax.jcr.ValueFactory;
import javax.jcr.ValueFormatException;
@@ -43,7 +42,6 @@
import org.apache.jackrabbit.core.state.ItemState;
import org.apache.jackrabbit.core.state.ItemStateException;
import org.apache.jackrabbit.core.state.PropertyState;
-import org.apache.jackrabbit.core.value.BLOBFileValue;
import org.apache.jackrabbit.core.value.InternalValue;
import org.apache.jackrabbit.spi.Name;
import org.apache.jackrabbit.spi.Path;
@@ -187,34 +185,18 @@
* @see javax.jcr.Property#getLengths()
*/
protected long getLength(InternalValue value) throws RepositoryException {
- // TODO maybe move method to InternalValue
+ long length;
switch (value.getType()) {
- case PropertyType.STRING:
- case PropertyType.LONG:
- case PropertyType.DOUBLE:
- case PropertyType.DATE:
- case PropertyType.REFERENCE:
- case PropertyType.BOOLEAN:
- case PropertyType.DECIMAL:
- case PropertyType.URI:
- case PropertyType.WEAKREFERENCE:
- return value.toString().length();
-
case PropertyType.NAME:
- Name name = value.getQName();
- return session.getJCRName(name).length();
-
case PropertyType.PATH:
- Path path = value.getPath();
- return session.getJCRPath(path).length();
-
- case PropertyType.BINARY:
- BLOBFileValue blob = value.getBLOBFileValue();
- return blob.getLength();
-
+ String str = ValueFormat.getJCRString(value, session);
+ length = str.length();
+ break;
default:
- return -1;
+ length = value.getLength();
+ break;
}
+ return length;
}
/**
@@ -296,7 +278,7 @@
if (old != null && old.getType() == PropertyType.BINARY) {
// make sure temporarily allocated data is discarded
// before overwriting it
- old.getBLOBFileValue().discard();
+ old.discard();
}
}
}
@@ -557,19 +539,19 @@
}
public BigDecimal getDecimal() throws RepositoryException {
- throw new UnsupportedRepositoryOperationException("JCR-1609");
+ return getValue().getDecimal();
}
public void setValue(BigDecimal value) throws RepositoryException {
- throw new UnsupportedRepositoryOperationException("JCR-1609");
+ setValue(session.getValueFactory().createValue(value));
}
public Binary getBinary() throws RepositoryException {
- throw new UnsupportedRepositoryOperationException("JCR-2056");
+ return getValue().getBinary();
}
public void setValue(Binary value) throws RepositoryException {
- throw new UnsupportedRepositoryOperationException("JCR-2056");
+ setValue(session.getValueFactory().createValue(value));
}
public void setValue(Calendar value) throws RepositoryException {
@@ -754,10 +736,16 @@
internalSetValue(internalValues, reqType);
}
+ /**
+ * {@inheritDoc}
+ */
public long getLength() throws RepositoryException {
return getLength(internalGetValue());
}
+ /**
+ * {@inheritDoc}
+ */
public long[] getLengths() throws RepositoryException {
InternalValue[] values = internalGetValues();
long[] lengths = new long[values.length];
@@ -777,10 +765,23 @@
return data.getPropertyDefinition();
}
+ /**
+ * {@inheritDoc}
+ */
public int getType() throws RepositoryException {
return getPropertyState().getType();
}
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isMultiple() throws RepositoryException {
+ // check state of this instance
+ sanityCheck();
+
+ return data.getPropertyDefinition().isMultiple();
+ }
+
//-----------------------------------------------------------------< Item >
/**
* {@inheritDoc}
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ProtectedItemModifier.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ProtectedItemModifier.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ProtectedItemModifier.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ProtectedItemModifier.java Wed Jul 8 13:57:13 2009
@@ -130,6 +130,10 @@
itemImpl.internalRemove(true);
}
+ protected void markModified(NodeImpl parentImpl) throws RepositoryException {
+ parentImpl.getOrCreateTransientItemState();
+ }
+
private void checkPermission(ItemImpl item, int perm) throws RepositoryException {
if (perm > Permission.NONE) {
SessionImpl sImpl = (SessionImpl) item.getSession();
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryFactoryImpl.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryFactoryImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryFactoryImpl.java Wed Jul 8 13:57:13 2009
@@ -18,7 +18,6 @@
import java.util.Map;
import java.util.HashMap;
-import java.io.IOException;
import javax.jcr.Repository;
import javax.jcr.RepositoryException;
@@ -48,7 +47,7 @@
* Map of repository instances. Key = repository home, value = repository
* instance.
*/
- private static final Map REPOSITORY_INSTANCES = new HashMap();
+ private static final Map<String, JackrabbitRepository> REPOSITORY_INSTANCES = new HashMap<String, JackrabbitRepository>();
public Repository getRepository(Map parameters) throws RepositoryException {
JackrabbitRepository repo;
@@ -81,7 +80,7 @@
private JackrabbitRepository getOrCreateRepository(String conf,
String home)
throws RepositoryException {
- JackrabbitRepository repo = (JackrabbitRepository) REPOSITORY_INSTANCES.get(home);
+ JackrabbitRepository repo = REPOSITORY_INSTANCES.get(home);
if (repo == null) {
if (home == null) {
repo = new TransientRepository();
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java Wed Jul 8 13:57:13 2009
@@ -39,6 +39,7 @@
import org.apache.jackrabbit.core.config.VersioningConfig;
import org.apache.jackrabbit.core.config.WorkspaceConfig;
import org.apache.jackrabbit.core.data.DataStore;
+import org.apache.jackrabbit.core.data.DataStoreException;
import org.apache.jackrabbit.core.fs.BasedFileSystem;
import org.apache.jackrabbit.core.fs.FileSystem;
import org.apache.jackrabbit.core.fs.FileSystemException;
@@ -48,6 +49,7 @@
import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
import org.apache.jackrabbit.core.nodetype.virtual.VirtualNodeTypeStateManager;
import org.apache.jackrabbit.core.observation.DelegatingObservationDispatcher;
+import org.apache.jackrabbit.core.observation.EventState;
import org.apache.jackrabbit.core.observation.EventStateCollection;
import org.apache.jackrabbit.core.observation.ObservationDispatcher;
import org.apache.jackrabbit.core.persistence.PMContext;
@@ -63,7 +65,6 @@
import org.apache.jackrabbit.core.state.ManagedMLRUItemStateCacheFactory;
import org.apache.jackrabbit.core.state.SharedItemStateManager;
import org.apache.jackrabbit.core.util.RepositoryLockMechanism;
-import org.apache.jackrabbit.core.value.InternalValue;
import org.apache.jackrabbit.core.version.VersionManager;
import org.apache.jackrabbit.core.version.VersionManagerImpl;
import org.apache.jackrabbit.core.xml.ClonedInputSource;
@@ -131,6 +132,11 @@
public static final NodeId VERSION_STORAGE_NODE_ID = NodeId.valueOf("deadbeef-face-babe-cafe-babecafebabe");
/**
+ * hardcoded id of the "/jcr:system/jcr:versionStorage/jcr:activities" node
+ */
+ public static final NodeId ACTIVITIES_NODE_ID = NodeId.valueOf("deadbeef-face-babe-ac71-babecafebabe");
+
+ /**
* hardcoded id of the "/jcr:system/jcr:nodeTypes" node
*/
public static final NodeId NODETYPES_NODE_ID = NodeId.valueOf("deadbeef-cafe-cafe-cafe-babecafebabe");
@@ -191,7 +197,7 @@
/**
* map of workspace names and <code>WorkspaceInfo<code>s.
*/
- private final HashMap wspInfos = new HashMap();
+ private final HashMap<String, WorkspaceInfo> wspInfos = new HashMap<String, WorkspaceInfo>();
/**
* active sessions (weak references)
@@ -200,11 +206,11 @@
new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.WEAK);
// misc. statistics
- private long nodesCount = 0;
- private long propsCount = 0;
+ private long nodesCount;
+ private long propsCount;
// flag indicating if repository has been shut down
- private boolean disposed = false;
+ private boolean disposed;
/**
* The repository lock mechanism ensures that a repository is only instantiated once.
@@ -290,14 +296,9 @@
ntReg = createNodeTypeRegistry(nsReg, new BasedFileSystem(repStore, "/nodetypes"));
dataStore = repConfig.getDataStore();
- if (dataStore != null) {
- assert InternalValue.USE_DATA_STORE;
- }
// init workspace configs
- Iterator iter = repConfig.getWorkspaceConfigs().iterator();
- while (iter.hasNext()) {
- WorkspaceConfig config = (WorkspaceConfig) iter.next();
+ for (WorkspaceConfig config : repConfig.getWorkspaceConfigs()) {
WorkspaceInfo info = createWorkspaceInfo(config);
wspInfos.put(config.getName(), info);
}
@@ -309,7 +310,7 @@
clusterNode = createClusterNode();
nsReg.setEventChannel(clusterNode);
ntReg.setEventChannel(clusterNode);
-
+
createWorkspaceEventChannel = clusterNode;
clusterNode.setListener(this);
}
@@ -466,7 +467,10 @@
ISMLocking ismLocking = vConfig.getISMLocking();
return new VersionManagerImpl(pm, fs, ntReg, delegatingDispatcher,
- VERSION_STORAGE_NODE_ID, SYSTEM_ROOT_NODE_ID, cacheFactory,
+ SYSTEM_ROOT_NODE_ID,
+ VERSION_STORAGE_NODE_ID,
+ ACTIVITIES_NODE_ID,
+ cacheFactory,
ismLocking);
}
@@ -485,7 +489,7 @@
secWspName = smc.getWorkspaceName();
}
try {
- ((WorkspaceInfo) wspInfos.get(wspName)).initialize();
+ (wspInfos.get(wspName)).initialize();
if (secWspName != null && !wspInfos.containsKey(secWspName)) {
createWorkspace(secWspName);
log.info("created system workspace: {}", secWspName);
@@ -703,7 +707,7 @@
*/
protected String[] getWorkspaceNames() {
synchronized (wspInfos) {
- return (String[]) wspInfos.keySet().toArray(new String[wspInfos.keySet().size()]);
+ return wspInfos.keySet().toArray(new String[wspInfos.keySet().size()]);
}
}
@@ -724,7 +728,7 @@
WorkspaceInfo wspInfo;
synchronized (wspInfos) {
- wspInfo = (WorkspaceInfo) wspInfos.get(workspaceName);
+ wspInfo = wspInfos.get(workspaceName);
if (wspInfo == null) {
throw new NoSuchWorkspaceException(workspaceName);
}
@@ -780,7 +784,7 @@
/**
* Creates a workspace with the given name and given workspace configuration
* template.
- *
+ *
* The difference between this method and {@link #createWorkspace(String, InputSource)}
* is that the later notifies the other cluster node that workspace has been created
* whereas this method only creates the workspace.
@@ -807,7 +811,7 @@
wspInfos.put(workspaceName, info);
}
}
-
+
/**
* Creates a workspace with the given name and given workspace configuration
* template.
@@ -825,9 +829,7 @@
if (createWorkspaceEventChannel == null) {
createWorkspaceInternal(workspaceName, configTemplate);
- }
- else {
-
+ } else {
ClonedInputSource template = new ClonedInputSource(configTemplate);
createWorkspaceInternal(workspaceName, template.cloneInputSource());
createWorkspaceEventChannel.workspaceCreated(workspaceName, template);
@@ -1108,8 +1110,8 @@
synchronized (activeSessions) {
int cnt = 0;
sa = new SessionImpl[activeSessions.size()];
- for (Iterator it = activeSessions.values().iterator(); it.hasNext(); cnt++) {
- sa[cnt] = (SessionImpl) it.next();
+ for (Iterator<SessionImpl> it = activeSessions.values().iterator(); it.hasNext(); cnt++) {
+ sa[cnt] = it.next();
}
}
for (int i = 0; i < sa.length; i++) {
@@ -1125,8 +1127,7 @@
// shut down workspaces
synchronized (wspInfos) {
- for (Iterator it = wspInfos.values().iterator(); it.hasNext();) {
- WorkspaceInfo wspInfo = (WorkspaceInfo) it.next();
+ for (WorkspaceInfo wspInfo : wspInfos.values()) {
wspInfo.dispose();
}
}
@@ -1148,6 +1149,15 @@
}
}
+ if (dataStore != null) {
+ try {
+ // close the datastore
+ dataStore.close();
+ } catch (DataStoreException e) {
+ log.error("error while closing datastore", e);
+ }
+ }
+
if (repStore != null) {
try {
// close repository file system
@@ -1169,7 +1179,7 @@
repLock.release();
} catch (RepositoryException e) {
log.error("failed to release the repository lock", e);
- }
+ }
}
log.info("Repository has been shutdown");
@@ -1414,7 +1424,7 @@
* {@inheritDoc}
*/
public String[] getDescriptorKeys() {
- String[] keys = (String[]) repProps.keySet().toArray(new String[repProps.keySet().size()]);
+ String[] keys = repProps.keySet().toArray(new String[repProps.keySet().size()]);
Arrays.sort(keys);
return keys;
}
@@ -2168,7 +2178,7 @@
* {@inheritDoc}
*/
public void externalUpdate(ChangeLog external,
- List events,
+ List<EventState> events,
long timestamp,
String userData) throws RepositoryException {
try {
@@ -2181,7 +2191,7 @@
getItemStateProvider().externalUpdate(external, esc);
} catch (IllegalStateException e) {
String msg = "Unable to deliver events: " + e.getMessage();
- throw new RepositoryException(msg);
+ throw new RepositoryException(msg, e);
}
}
@@ -2242,9 +2252,9 @@
}
}
// get names of workspaces
- Set wspNames;
+ Set<String> wspNames;
synchronized (wspInfos) {
- wspNames = new HashSet(wspInfos.keySet());
+ wspNames = new HashSet<String>(wspInfos.keySet());
}
// remove default workspace (will never be shutdown when idle)
wspNames.remove(repConfig.getDefaultWorkspaceName());
@@ -2259,10 +2269,10 @@
// remaining names denote workspaces which currently have not
// active sessions
- for (Iterator it = wspNames.iterator(); it.hasNext();) {
+ for (String wspName : wspNames) {
WorkspaceInfo wspInfo;
synchronized (wspInfos) {
- wspInfo = (WorkspaceInfo) wspInfos.get(it.next());
+ wspInfo = wspInfos.get(wspName);
}
wspInfo.disposeIfIdle(maxIdleTime);
}
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SearchManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SearchManager.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SearchManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SearchManager.java Wed Jul 8 13:57:13 2009
@@ -85,11 +85,6 @@
public static final String NS_XS_URI = "http://www.w3.org/2001/XMLSchema";
/**
- * Name of the parameter that indicates the query implementation class.
- */
- private static final String PARAM_QUERY_IMPL = "queryClass";
-
- /**
* The search configuration.
*/
private final SearchConfig config;
@@ -274,9 +269,12 @@
*
* @param session the session of the user executing the query.
* @param itemMgr the item manager of the user executing the query. Needed
- * to return <code>Node</code> instances in the result set.
+ * to return <code>Node</code> instances in the result
+ * set.
* @param statement the actual query statement.
* @param language the syntax of the query statement.
+ * @param node a nt:query node where the query was read from or
+ * <code>null</code> if it is not a stored query.
* @return a <code>Query</code> instance to execute.
* @throws InvalidQueryException if the query is malformed or the
* <code>language</code> is unknown.
@@ -285,10 +283,11 @@
public Query createQuery(SessionImpl session,
ItemManager itemMgr,
String statement,
- String language)
+ String language,
+ Node node)
throws InvalidQueryException, RepositoryException {
AbstractQueryImpl query = createQueryInstance();
- query.init(session, itemMgr, handler, statement, language);
+ query.init(session, itemMgr, handler, statement, language, node);
return query;
}
@@ -298,6 +297,8 @@
* @param session the session of the user executing the query.
* @param qomTree the query object model tree, representing the query.
* @param langugage the original language of the query statement.
+ * @param node a nt:query node where the query was read from or
+ * <code>null</code> if it is not a stored query.
* @return the query object model for the query.
* @throws InvalidQueryException the the query object model tree is
* considered invalid by the query handler
@@ -306,32 +307,27 @@
*/
public QueryObjectModel createQueryObjectModel(SessionImpl session,
QueryObjectModelTree qomTree,
- String langugage)
+ String langugage,
+ Node node)
throws InvalidQueryException, RepositoryException {
QueryObjectModelImpl qom = new QueryObjectModelImpl();
- qom.init(session, session.getItemManager(), handler, qomTree, langugage);
+ qom.init(session, session.getItemManager(), handler, qomTree, langugage, node);
return qom;
}
/**
- * Creates a query object from a node that can be executed on the workspace.
+ * Returns the ids of the nodes that refer to the node with <code>id</code>
+ * by weak references.
*
- * @param session the session of the user executing the query.
- * @param itemMgr the item manager of the user executing the query. Needed
- * to return <code>Node</code> instances in the result set.
- * @param node a node of type nt:query.
- * @return a <code>Query</code> instance to execute.
- * @throws InvalidQueryException if <code>absPath</code> is not a valid
- * persisted query (that is, a node of type nt:query)
- * @throws RepositoryException if any other error occurs.
- */
- public Query createQuery(SessionImpl session,
- ItemManager itemMgr,
- Node node)
- throws InvalidQueryException, RepositoryException {
- AbstractQueryImpl query = createQueryInstance();
- query.init(session, itemMgr, handler, node);
- return query;
+ * @param id the id of the target node.
+ * @return the ids of the referring nodes.
+ * @throws RepositoryException if an error occurs.
+ * @throws IOException if an error occurs while reading from the
+ * index.
+ */
+ public Iterable<NodeId> getWeaklyReferringNodes(NodeId id)
+ throws RepositoryException, IOException {
+ return handler.getWeaklyReferringNodes(id);
}
/**
@@ -372,11 +368,11 @@
long time = System.currentTimeMillis();
// nodes that need to be removed from the index.
- final Set removedNodes = new HashSet();
+ final Set<NodeId> removedNodes = new HashSet<NodeId>();
// nodes that need to be added to the index.
- final Map addedNodes = new HashMap();
+ final Map<NodeId, EventImpl> addedNodes = new HashMap<NodeId, EventImpl>();
// property events
- List propEvents = new ArrayList();
+ List<EventImpl> propEvents = new ArrayList<EventImpl>();
while (events.hasNext()) {
EventImpl e = (EventImpl) events.nextEvent();
@@ -407,8 +403,7 @@
}
// sort out property events
- for (int i = 0; i < propEvents.size(); i++) {
- EventImpl e = (EventImpl) propEvents.get(i);
+ for (EventImpl e : propEvents) {
NodeId nodeId = e.getParentId();
if (e.getType() == Event.PROPERTY_ADDED) {
if (addedNodes.put(nodeId, e) == null) {
@@ -452,7 +447,7 @@
} catch (ItemStateException ise) {
// check whether this item state change originated from
// an external event
- EventImpl e = (EventImpl) addedNodes.get(id);
+ EventImpl e = addedNodes.get(id);
if (e == null || !e.isExternal()) {
log.error("Unable to index node " + id + ": does not exist");
} else {
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java Wed Jul 8 13:57:13 2009
@@ -210,7 +210,7 @@
* Retention and Hold Manager
*/
private RetentionManager retentionManager;
-
+
/**
* The stack trace knows who opened this session. It is logged
* if the session is finalized, but Session.logout() was never called.
@@ -473,7 +473,7 @@
/**
* Returns the internal retention manager used for evaluation of effective
* retention policies and holds.
- *
+ *
* @return internal retention manager
* @throws RepositoryException
*/
@@ -679,7 +679,7 @@
}
IterablePersistenceManager[] ipmList = new IterablePersistenceManager[pmList.size()];
for (int i = 0; i < pmList.size(); i++) {
- pm = (PersistenceManager) pmList.get(i);
+ pm = pmList.get(i);
if (!(pm instanceof IterablePersistenceManager)) {
ipmList = null;
break;
@@ -1220,10 +1220,9 @@
/**
* {@inheritDoc}
*/
- public ValueFactory getValueFactory()
- throws UnsupportedRepositoryOperationException, RepositoryException {
+ public ValueFactory getValueFactory() {
if (valueFactory == null) {
- valueFactory = new ValueFactoryImpl(this);
+ valueFactory = new ValueFactoryImpl(this, rep.getDataStore());
}
return valueFactory;
}
@@ -1246,7 +1245,7 @@
* {@inheritDoc}
*/
public String[] getAttributeNames() {
- return (String[]) attributes.keySet().toArray(new String[attributes.size()]);
+ return attributes.keySet().toArray(new String[attributes.size()]);
}
/**
@@ -1558,10 +1557,10 @@
ps.println();
itemStateMgr.dump(ps);
}
-
+
/**
- * Finalize the session. If the application doesn't close Session.logout(),
- * the session is closed automatically; however a warning is written to the log file,
+ * Finalize the session. If the application doesn't call Session.logout(),
+ * the session is closed automatically; however a warning is written to the log file,
* together with the stack trace of where the session was opened.
*/
public void finalize() {
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SystemSession.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SystemSession.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SystemSession.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SystemSession.java Wed Jul 8 13:57:13 2009
@@ -141,7 +141,6 @@
* {@inheritDoc}
*
* @throws AccessDeniedException is never thrown
- * @throws ItemNotFoundException is never thrown
* @throws RepositoryException is never thrown
*/
public void checkPermission(ItemId id, int permissions)
@@ -160,7 +159,6 @@
* {@inheritDoc}
*
* @return always <code>true</code>
- * @throws ItemNotFoundException is never thrown
* @throws RepositoryException is never thrown
*/
public boolean isGranted(ItemId id, int permissions) throws RepositoryException {
@@ -202,7 +200,6 @@
* {@inheritDoc}
*
* @return always <code>true</code>
- * @throws NoSuchWorkspaceException is never thrown
* @throws RepositoryException is never thrown
*/
public boolean canAccess(String workspaceName) throws RepositoryException {
@@ -249,7 +246,7 @@
//-------------------------------------------< AccessControlManager >---
/**
- * @see AccessControlManager#hasPrivileges(String, Privilege[])
+ * @see javax.jcr.security.AccessControlManager#hasPrivileges(String, Privilege[])
*/
public boolean hasPrivileges(String absPath, Privilege[] privileges)
throws PathNotFoundException, RepositoryException {
@@ -259,7 +256,7 @@
}
/**
- * @see AccessControlManager#getPrivileges(String)
+ * @see javax.jcr.security.AccessControlManager#getPrivileges(String)
*/
public Privilege[] getPrivileges(String absPath)
throws PathNotFoundException, RepositoryException {
@@ -268,12 +265,12 @@
}
/**
- * @see AccessControlManager#getEffectivePolicies(String)
+ * @see javax.jcr.security.AccessControlManager#getEffectivePolicies(String)
*/
public AccessControlPolicy[] getEffectivePolicies(String absPath) throws
PathNotFoundException, AccessDeniedException, RepositoryException {
- // TODO
- throw new UnsupportedOperationException();
+ // cannot determine the effective policies for the system session.
+ return new AccessControlPolicy[0];
}
}
}
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TransactionContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TransactionContext.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TransactionContext.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TransactionContext.java Wed Jul 8 13:57:13 2009
@@ -52,7 +52,7 @@
/**
* The per thread associated Xid
*/
- private static ThreadLocal CURRENT_XID = new ThreadLocal();
+ private static final ThreadLocal<Xid> CURRENT_XID = new ThreadLocal<Xid>();
/**
* Create a global timer for all transaction contexts.
@@ -73,11 +73,11 @@
* The Xid
*/
private final Xid xid;
-
+
/**
* Transaction attributes.
*/
- private final Map attributes = new HashMap();
+ private final Map<String, Object> attributes = new HashMap<String, Object>();
/**
* Status.
@@ -315,7 +315,7 @@
public void setSuspended(boolean suspended) {
this.suspended = suspended;
}
-
+
/**
* Helper Method to bind the {@link Xid} associated with this {@link TransactionContext}
* to the {@link #CURRENT_XID} ThreadLocal.
@@ -331,25 +331,25 @@
private void cleanCurrentXid() {
CURRENT_XID.set(null);
}
-
+
/**
* Returns the {@link Xid} bind to the {@link #CURRENT_XID} ThreadLocal
* @return current Xid or null
*/
public static Xid getCurrentXid() {
- return (Xid) CURRENT_XID.get();
+ return CURRENT_XID.get();
}
-
+
/**
* Helper Method to check if the given {@link Xid} has the same globalTransactionId
* as the current {@link Xid} bind to the {@link #CURRENT_XID} ThreadLocal
* @param xid Xid to check
- * @param fallback if either the given {@link Xid} or the current {@link Xid} is null we can not check if they
+ * @param fallback if either the given {@link Xid} or the current {@link Xid} is null we can not check if they
* are same, the fallback value will be returned
* @return true if the same otherwise false
*/
public static boolean isCurrentXid(Xid xid, boolean fallback) {
- Xid currentXid = (Xid) CURRENT_XID.get();
- return fallback ? true : (currentXid == null || xid == null) ? fallback : Arrays.equals(xid.getGlobalTransactionId(), currentXid.getGlobalTransactionId());
+ Xid currentXid = CURRENT_XID.get();
+ return fallback ? true : (currentXid == null || xid == null) ? fallback : Arrays.equals(xid.getGlobalTransactionId(), currentXid.getGlobalTransactionId());
}
}
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TransientRepository.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TransientRepository.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TransientRepository.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TransientRepository.java Wed Jul 8 13:57:13 2009
@@ -284,7 +284,7 @@
*
* @param key descriptor key
* @return descriptor value
- * @see Repository#getDescriptor(String)
+ * @see javax.jcr.Repository#getDescriptor(String)
*/
public synchronized String getDescriptor(String key) {
if (repository != null) {
@@ -331,7 +331,7 @@
* @param workspaceName workspace name
* @return new session
* @throws RepositoryException if the session could not be created
- * @see Repository#login(Credentials,String)
+ * @see javax.jcr.Repository#login(Credentials,String)
*/
public synchronized Session login(
Credentials credentials, String workspaceName)
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java Wed Jul 8 13:57:13 2009
@@ -17,7 +17,6 @@
package org.apache.jackrabbit.core;
import java.util.HashMap;
-import java.util.Iterator;
import javax.jcr.AccessDeniedException;
import javax.jcr.InvalidItemStateException;
@@ -199,35 +198,7 @@
//--------------------------------------------------< new JSR 283 methods >
/**
- * Creates a new <code>Workspace</code> with the specified <code>name</code>
- * initialized with a <code>clone</code> of the content of the workspace
- * <code>srcWorkspace</code>. Semantically, this method is equivalent to
- * creating a new workspace and manually cloning <code>srcWorkspace</code>
- * to it; however, this method may assist some implementations in optimizing
- * subsequent <code>Node.update</code> and <code>Node.merge</code> calls
- * between the new workspace and its source.
- * <p/>
- * The new workspace can be accessed through a <code>login</code>
- * specifying its name.
- * <p/>
- * Throws an <code>AccessDeniedException</code> if the session through which
- * this <code>Workspace</code> object was acquired does not have permission
- * to create the new workspace.
- * <p/>
- * Throws an <code>UnsupportedRepositoryOperationException</code> if the repository does
- * not support the creation of workspaces.
- * <p/>
- * A <code>RepositoryException</code> is thrown if another error occurs.
- *
- * @param name A <code>String</code>, the name of the new workspace.
- * @param srcWorkspace The name of the workspace from which the new workspace is to be cloned.
- * @throws AccessDeniedException if the session through which
- * this <code>Workspace</code> object was acquired does not have permission
- * to create the new workspace.
- * @throws UnsupportedRepositoryOperationException if the repository does
- * not support the creation of workspaces.
- * @throws RepositoryException if another error occurs.
- * @since JCR 2.0
+ * {@inheritDoc}
*/
public void createWorkspace(String name, String srcWorkspace)
throws AccessDeniedException, UnsupportedRepositoryOperationException,
@@ -253,24 +224,10 @@
}
/**
- * Deletes the workspace with the specified <code>name</code> from the
- * repository, deleting all content within it.
- * <p/>
- * Throws an <code>AccessDeniedException</code> if the session through which
- * this <code>Workspace</code> object was acquired does not have permission
- * to remove the workspace.
+ * {@inheritDoc}
* <p/>
- * Throws an <code>UnsupportedRepositoryOperationException</code> if the
- * repository does not support the removal of workspaces.
- *
- * @param name A <code>String</code>, the name of the workspace to be deleted.
- * @throws AccessDeniedException if the session through which
- * this <code>Workspace</code> object was acquired does not have permission
- * to remove the workspace.
- * @throws UnsupportedRepositoryOperationException if the
- * repository does not support the removal of workspaces.
- * @throws RepositoryException if another error occurs.
- * @since JCR 2.0
+ * Always throws <code>UnsupportedRepositoryOperationException</code> since
+ * removal of workspaces is currently not supported.
*/
public void deleteWorkspace(String name) throws AccessDeniedException,
UnsupportedRepositoryOperationException, RepositoryException {
@@ -836,22 +793,21 @@
sanityCheck();
// add all versions to map of versions to restore
- final HashMap toRestore = new HashMap();
- for (int i = 0; i < versions.length; i++) {
- VersionImpl v = (VersionImpl) versions[i];
+ final HashMap<String, VersionImpl> toRestore = new HashMap<String, VersionImpl>();
+ for (Version v : versions) {
VersionHistory vh = v.getContainingHistory();
// check for collision
if (toRestore.containsKey(vh.getUUID())) {
throw new VersionException("Unable to restore. Two or more versions have same version history.");
}
- toRestore.put(vh.getUUID(), v);
+ toRestore.put(vh.getUUID(), (VersionImpl) v);
}
// create a version selector to the set of versions
VersionSelector vsel = new VersionSelector() {
public Version select(VersionHistory versionHistory) throws RepositoryException {
// try to select version as specified
- Version v = (Version) toRestore.get(versionHistory.getUUID());
+ Version v = toRestore.get(versionHistory.getUUID());
if (v == null) {
// select latest one
v = DateVersionSelector.selectByDate(versionHistory, null);
@@ -873,15 +829,13 @@
int numRestored = 0;
while (toRestore.size() > 0) {
Version[] restored = null;
- Iterator iter = toRestore.values().iterator();
- while (iter.hasNext()) {
- VersionImpl v = (VersionImpl) iter.next();
+ for (VersionImpl v : toRestore.values()) {
try {
NodeImpl node = (NodeImpl) session.getNodeByUUID(v.getInternalFrozenNode().getFrozenUUID());
restored = node.internalRestore(v, vsel, removeExisting);
// remove restored versions from set
- for (int i = 0; i < restored.length; i++) {
- toRestore.remove(restored[i].getContainingHistory().getUUID());
+ for (Version r : restored) {
+ toRestore.remove(r.getContainingHistory().getUUID());
}
numRestored += restored.length;
break;
@@ -959,7 +913,7 @@
* @return local item state manager
*/
protected LocalItemStateManager createItemStateManager(SharedItemStateManager shared) {
- return new LocalItemStateManager(shared, this, rep.getItemStateCacheFactory());
+ return LocalItemStateManager.createInstance(shared, this, rep.getItemStateCacheFactory());
}
//------------------------------------------< EventStateCollectionFactory >
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/XASessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/XASessionImpl.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/XASessionImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/XASessionImpl.java Wed Jul 8 13:57:13 2009
@@ -16,6 +16,7 @@
*/
package org.apache.jackrabbit.core;
+import org.apache.jackrabbit.api.XASession;
import org.apache.jackrabbit.core.config.WorkspaceConfig;
import org.apache.jackrabbit.core.lock.LockManager;
import org.apache.jackrabbit.core.lock.LockManagerImpl;
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/XAWorkspace.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/XAWorkspace.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/XAWorkspace.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/XAWorkspace.java Wed Jul 8 13:57:13 2009
@@ -45,6 +45,6 @@
* {@inheritDoc}
*/
protected LocalItemStateManager createItemStateManager(SharedItemStateManager shared) {
- return new XAItemStateManager(shared, this, rep.getItemStateCacheFactory());
+ return XAItemStateManager.createInstance(shared, this, null, rep.getItemStateCacheFactory());
}
}
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java Wed Jul 8 13:57:13 2009
@@ -855,6 +855,9 @@
} catch (RepositoryException e) {
String msg = "Unable to deliver update events: " + e.getMessage();
log.error(msg);
+ if (e.getCause() instanceof IllegalStateException) {
+ throw (IllegalStateException) e.getCause();
+ }
}
}
@@ -890,6 +893,9 @@
} catch (RepositoryException e) {
String msg = "Unable to deliver lock event: " + e.getMessage();
log.error(msg);
+ if (e.getCause() instanceof IllegalStateException) {
+ throw (IllegalStateException) e.getCause();
+ }
}
}
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/UpdateEventListener.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/UpdateEventListener.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/UpdateEventListener.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/UpdateEventListener.java Wed Jul 8 13:57:13 2009
@@ -17,6 +17,8 @@
package org.apache.jackrabbit.core.cluster;
import java.util.List;
+
+import org.apache.jackrabbit.core.observation.EventState;
import org.apache.jackrabbit.core.state.ChangeLog;
import javax.jcr.RepositoryException;
@@ -34,7 +36,7 @@
* @param userData the user data associated with this update.
* @throws RepositoryException if the update cannot be processed
*/
- void externalUpdate(ChangeLog changes, List events, long timestamp, String userData)
+ void externalUpdate(ChangeLog changes, List<EventState> events, long timestamp, String userData)
throws RepositoryException;
}
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java Wed Jul 8 13:57:13 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,7 +419,20 @@
*/
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 {
// Workspace home directory
String home = getVariables().getProperty(WORKSPACE_HOME_VARIABLE);
@@ -744,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/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/GarbageCollector.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/GarbageCollector.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/GarbageCollector.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/GarbageCollector.java Wed Jul 8 13:57:13 2009
@@ -34,6 +34,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
import javax.jcr.Item;
import javax.jcr.Node;
@@ -84,6 +85,9 @@
private final IterablePersistenceManager[] pmList;
private final Session[] sessionList;
+ private final SessionListener sessionListener;
+
+ private final AtomicBoolean closed = new AtomicBoolean();
private boolean persistenceManagerScan;
@@ -94,25 +98,26 @@
* This method is usually not called by the application, it is called
* by SessionImpl.createDataStoreGarbageCollector().
*
+ * @param session the session that created this object
* @param list the persistence managers
+ * @param sessionList the sessions to access the workspaces
*/
- public GarbageCollector(final SessionImpl session, IterablePersistenceManager[] list, final Session[] sessionList) {
+ public GarbageCollector(SessionImpl session, IterablePersistenceManager[] list, Session[] sessionList) {
RepositoryImpl rep = (RepositoryImpl) session.getRepository();
store = rep.getDataStore();
this.pmList = list;
this.persistenceManagerScan = list != null;
this.sessionList = sessionList;
-
- // log out each session as soon as the main session logs out
- session.addListener(new SessionListener() {
+
+ // Auto-close if the main session logs out
+ this.sessionListener = new SessionListener() {
public void loggedOut(SessionImpl session) {
- for (Session s: sessionList) {
- s.logout();
- }
}
public void loggingOut(SessionImpl session) {
+ close();
}
- });
+ };
+ session.addListener(sessionListener);
}
/**
@@ -226,7 +231,9 @@
PropertyState ps = pm.load(pid);
if (ps.getType() == PropertyType.BINARY) {
for (InternalValue v : ps.getValues()) {
- v.getBLOBFileValue().getLength();
+ // getLength will update the last modified date
+ // if the persistence manager scan is running
+ v.getLength();
}
}
}
@@ -241,6 +248,10 @@
}
}
+ /**
+ * The repository was scanned. This method will stop the observation
+ * listener.
+ */
public void stopScan() throws RepositoryException {
checkScanStarted();
for (Listener listener : listeners) {
@@ -253,6 +264,11 @@
listeners.clear();
}
+ /**
+ * Delete all unused items in the data store.
+ *
+ * @return the number of deleted items
+ */
public int deleteUnused() throws RepositoryException {
checkScanStarted();
checkScanStopped();
@@ -271,6 +287,11 @@
}
}
+ /**
+ * Get the data store if one is used.
+ *
+ * @return the data store, or null
+ */
public DataStore getDataStore() {
return store;
}
@@ -340,10 +361,32 @@
* We can't use node path for this, UUIDs are required as nodes could be
* moved around.
*
+ * This mechanism requires that all data stores update the last modified
+ * date when calling addRecord and that record already exists.
+ *
*/
}
/**
+ * Cleanup resources used internally by this instance.
+ */
+ public void close() {
+ if (!closed.getAndSet(true)) {
+ for (Session s : sessionList) {
+ s.logout();
+ }
+ }
+ }
+
+ /**
+ * Auto-close in case the application didn't call it explicitly.
+ */
+ protected void finalize() throws Throwable {
+ close();
+ super.finalize();
+ }
+
+ /**
* Event listener to detect moved nodes.
* A SynchronousEventListener is used to make sure this method is called before the main iteration ends.
*/
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/LazyFileInputStream.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/LazyFileInputStream.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/LazyFileInputStream.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/LazyFileInputStream.java Wed Jul 8 13:57:13 2009
@@ -17,13 +17,12 @@
package org.apache.jackrabbit.core.data;
import java.io.File;
+import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.apache.commons.io.input.AutoCloseInputStream;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* This input stream delays opening the file until the first byte is read, and
@@ -32,7 +31,10 @@
*/
public class LazyFileInputStream extends AutoCloseInputStream {
- private static Logger log = LoggerFactory.getLogger(LazyFileInputStream.class);
+ /**
+ * The file descriptor to use.
+ */
+ protected final FileDescriptor fd;
/**
* The file to read from.
@@ -47,83 +49,119 @@
protected boolean opened;
/**
- * Create a lazy input stream for the given file.
+ * Creates a new <code>LazyFileInputStream</code> for the given file. If the
+ * file is unreadable, a FileNotFoundException is thrown.
* The file is not opened until the first byte is read from the stream.
- *
+ *
* @param file the file
+ * @throws java.io.FileNotFoundException
*/
- public LazyFileInputStream(File file) throws FileNotFoundException {
+ public LazyFileInputStream(File file)
+ throws FileNotFoundException {
super(null);
if (!file.canRead()) {
throw new FileNotFoundException(file.getPath());
- }
+ }
this.file = file;
+ this.fd = null;
+ }
+
+ /**
+ * Creates a new <code>LazyFileInputStream</code> for the given file
+ * descriptor.
+ * The file is not opened until the first byte is read from the stream.
+ *
+ * @param fdObj
+ */
+ public LazyFileInputStream(FileDescriptor fd) {
+ super(null);
+ this.file = null;
+ this.fd = fd;
+ }
+
+ /**
+ * Creates a new <code>LazyFileInputStream</code> for the given file. If the
+ * file is unreadable, a FileNotFoundException is thrown.
+ *
+ * @param name
+ * @throws java.io.FileNotFoundException
+ */
+ public LazyFileInputStream(String name) throws FileNotFoundException {
+ this(new File(name));
}
/**
* Open the stream if required.
- *
- * @throws IOException
+ *
+ * @throws java.io.IOException
*/
- protected void openStream() throws IOException {
+ protected void open() throws IOException {
if (!opened) {
opened = true;
- in = new FileInputStream(file);
+ if (fd != null) {
+ in = new FileInputStream(fd);
+ } else {
+ in = new FileInputStream(file);
+ }
}
}
-
+
public int read() throws IOException {
- openStream();
+ open();
return super.read();
}
- public int read(byte[] b) throws IOException {
- return read(b, 0, b.length);
- }
-
- public int read(byte[] b, int off, int len) throws IOException {
- openStream();
- return super.read(b, off, len);
+ public int available() throws IOException {
+ open();
+ return super.available();
}
public void close() throws IOException {
// make sure the file is not opened afterwards
opened = true;
- super.close();
+
+ // only close the file if it was in fact opened
+ if (in != null) {
+ super.close();
+ }
}
- public long skip(long n) throws IOException {
- openStream();
- return super.skip(n);
+ public synchronized void reset() throws IOException {
+ open();
+ super.reset();
}
- public int available() throws IOException {
- openStream();
- return super.available();
+ public boolean markSupported() {
+ try {
+ open();
+ } catch (IOException e) {
+ throw new IllegalStateException(e.toString());
+ }
+ return super.markSupported();
}
- public void mark(int readlimit) {
+ public synchronized void mark(int readlimit) {
try {
- openStream();
+ open();
} catch (IOException e) {
- log.info("Error getting underlying stream: ", e);
+ throw new IllegalStateException(e.toString());
}
super.mark(readlimit);
}
- public void reset() throws IOException {
- openStream();
- super.reset();
+ public long skip(long n) throws IOException {
+ open();
+ return super.skip(n);
}
- public boolean markSupported() {
- try {
- openStream();
- } catch (IOException e) {
- log.info("Error getting underlying stream: ", e);
- return false;
- }
- return super.markSupported();
+ public int read(byte[] b) throws IOException {
+ open();
+ return super.read(b, 0, b.length);
+ }
+
+ public int read(byte[] b, int off, int len) throws IOException {
+ open();
+ return super.read(b, off, len);
}
}
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java Wed Jul 8 13:57:13 2009
@@ -828,7 +828,7 @@
/**
* {@inheritDoc}
*/
- public synchronized void close() {
+ public synchronized void close() throws DataStoreException {
ArrayList<ConnectionRecoveryManager> list = connectionPool.getAll();
for (ConnectionRecoveryManager conn : list) {
conn.close();
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/OracleFileSystem.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/OracleFileSystem.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/OracleFileSystem.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/OracleFileSystem.java Wed Jul 8 13:57:13 2009
@@ -81,7 +81,7 @@
*/
private static Logger log = LoggerFactory.getLogger(OracleFileSystem.class);
- private Class blobClass;
+ private Class< ? > blobClass;
private Integer durationSessionConstant;
private Integer modeReadWriteConstant;
@@ -574,7 +574,7 @@
open.invoke(blob, new Object[]{modeReadWriteConstant});
Method getBinaryOutputStream =
blobClass.getMethod("getBinaryOutputStream", new Class[0]);
- OutputStream out = (OutputStream) getBinaryOutputStream.invoke(blob, null);
+ OutputStream out = (OutputStream) getBinaryOutputStream.invoke(blob);
try {
IOUtils.copy(in, out);
} finally {
@@ -585,7 +585,7 @@
out.close();
}
Method close = blobClass.getMethod("close", new Class[0]);
- close.invoke(blob, null);
+ close.invoke(blob);
return (Blob) blob;
}
@@ -595,6 +595,6 @@
protected void freeTemporaryBlob(Object blob) throws Exception {
// blob.freeTemporary();
Method freeTemporary = blobClass.getMethod("freeTemporary", new Class[0]);
- freeTemporary.invoke(blob, null);
+ freeTemporary.invoke(blob);
}
}
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/local/HandleMonitor.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/local/HandleMonitor.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/local/HandleMonitor.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/local/HandleMonitor.java Wed Jul 8 13:57:13 2009
@@ -26,7 +26,6 @@
import java.io.InputStream;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
/**
* This Class implements a very simple open handle monitor for the local
@@ -44,7 +43,7 @@
/**
* the map of open handles (key=File, value=Handle)
*/
- private HashMap openHandles = new HashMap();
+ private HashMap<File, Handle> openHandles = new HashMap<File, Handle>();
/**
* Opens a file and returns an InputStream
@@ -82,7 +81,7 @@
* @return
*/
private Handle getHandle(File file) {
- Handle handle = (Handle) openHandles.get(file);
+ Handle handle = openHandles.get(file);
if (handle == null) {
handle = new Handle(file);
openHandles.put(file, handle);
@@ -95,10 +94,8 @@
*/
public void dump() {
log.info("Number of open files: " + openHandles.size());
- Iterator iter = openHandles.keySet().iterator();
- while (iter.hasNext()) {
- File file = (File) iter.next();
- Handle handle = (Handle) openHandles.get(file);
+ for (File file : openHandles.keySet()) {
+ Handle handle = openHandles.get(file);
handle.dump();
}
}
@@ -108,7 +105,7 @@
* @param file
*/
public void dump(File file) {
- Handle handle = (Handle) openHandles.get(file);
+ Handle handle = openHandles.get(file);
if (handle != null) {
handle.dump(true);
}
@@ -127,7 +124,7 @@
/**
* all open streams of this handle
*/
- private HashSet streams = new HashSet();
+ private HashSet<Handle.MonitoredInputStream> streams = new HashSet<Handle.MonitoredInputStream>();
/**
* Creates a new handle for a file
@@ -172,9 +169,7 @@
private void dump(boolean detailed) {
if (detailed) {
log.info("- " + file.getPath() + ", " + streams.size());
- Iterator iter = streams.iterator();
- while (iter.hasNext()) {
- Handle.MonitoredInputStream in = (Handle.MonitoredInputStream) iter.next();
+ for (Handle.MonitoredInputStream in : streams) {
in.dump();
}
} else {
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/local/LocalFileSystem.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/local/LocalFileSystem.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/local/LocalFileSystem.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/local/LocalFileSystem.java Wed Jul 8 13:57:13 2009
@@ -41,7 +41,7 @@
private File root;
- private HandleMonitor monitor = null;
+ private HandleMonitor monitor;
/**
* Default constructor
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractJournal.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractJournal.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractJournal.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractJournal.java Wed Jul 8 13:57:13 2009
@@ -210,7 +210,12 @@
} else {
RecordConsumer consumer = getConsumer(record.getProducerId());
if (consumer != null) {
- consumer.consume(record);
+ try {
+ consumer.consume(record);
+ } catch (IllegalStateException e) {
+ log.error("Could not synchronize to revision: " + record.getRevision() + " due illegal state of RecordConsumer.");
+ return;
+ }
}
}
stopRevision = record.getRevision();
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java Wed Jul 8 13:57:13 2009
@@ -16,30 +16,32 @@
*/
package org.apache.jackrabbit.core.journal;
-import org.apache.jackrabbit.spi.commons.conversion.MalformedPathException;
-import org.apache.jackrabbit.spi.commons.conversion.NameException;
-import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.Collection;
+
+import javax.jcr.NamespaceException;
+
+import org.apache.commons.collections.BidiMap;
+import org.apache.commons.collections.bidimap.DualHashBidiMap;
import org.apache.jackrabbit.core.NodeId;
import org.apache.jackrabbit.core.PropertyId;
import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
-import org.apache.jackrabbit.core.nodetype.compact.CompactNodeTypeDefReader;
-import org.apache.jackrabbit.core.nodetype.compact.CompactNodeTypeDefWriter;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
+import org.apache.jackrabbit.spi.commons.conversion.MalformedPathException;
+import org.apache.jackrabbit.spi.commons.conversion.NameException;
+import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
import org.apache.jackrabbit.spi.commons.name.PathFactoryImpl;
import org.apache.jackrabbit.spi.commons.namespace.NamespaceMapping;
import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
+import org.apache.jackrabbit.spi.commons.nodetype.compact.CompactNodeTypeDefReader;
+import org.apache.jackrabbit.spi.commons.nodetype.compact.CompactNodeTypeDefWriter;
import org.apache.jackrabbit.spi.commons.nodetype.compact.ParseException;
-import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.spi.Path;
import org.apache.jackrabbit.uuid.Constants;
import org.apache.jackrabbit.uuid.UUID;
-import org.apache.commons.collections.BidiMap;
-import org.apache.commons.collections.bidimap.DualHashBidiMap;
-
-import javax.jcr.NamespaceException;
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.util.List;
/**
* Base implementation for a record.
@@ -73,6 +75,8 @@
/**
* Create a new instance of this class.
+ * @param nsResolver the namespace resolver
+ * @param resolver the name-path resolver
*/
public AbstractRecord(NamespaceResolver nsResolver, NamePathResolver resolver) {
this.nsResolver = nsResolver;
@@ -144,8 +148,8 @@
public void writeNodeTypeDef(NodeTypeDef ntd) throws JournalException {
try {
StringWriter sw = new StringWriter();
- CompactNodeTypeDefWriter writer = new CompactNodeTypeDefWriter(sw, nsResolver, resolver, true);
- writer.write(ntd);
+ CompactNodeTypeDefWriter writer = new CompactNodeTypeDefWriter(sw, nsResolver, resolver);
+ writer.write(ntd.getQNodeTypeDefinition());
writer.close();
writeString(sw.toString());
@@ -219,13 +223,13 @@
if (index == -1) {
return null;
} else {
- return (NodeId) nodeIdIndex.getKey(new Integer(index));
+ return (NodeId) nodeIdIndex.getKey(index);
}
} else if (uuidType == UUID_LITERAL) {
byte[] b = new byte[Constants.UUID_BYTE_LENGTH];
readFully(b);
NodeId nodeId = new NodeId(new UUID(b));
- nodeIdIndex.put(nodeId, new Integer(nodeIdIndex.size()));
+ nodeIdIndex.put(nodeId, nodeIdIndex.size());
return nodeId;
} else {
String msg = "Unknown UUID type found: " + uuidType;
@@ -246,14 +250,13 @@
public NodeTypeDef readNodeTypeDef() throws JournalException {
try {
StringReader sr = new StringReader(readString());
-
CompactNodeTypeDefReader reader = new CompactNodeTypeDefReader(
sr, "(internal)", new NamespaceMapping(nsResolver));
- List ntds = reader.getNodeTypeDefs();
+ Collection<QNodeTypeDefinition> ntds = reader.getNodeTypeDefinitions();
if (ntds.size() != 1) {
throw new JournalException("Expected one node type definition: got " + ntds.size());
}
- return (NodeTypeDef) ntds.get(0);
+ return new NodeTypeDef(ntds.iterator().next());
} catch (ParseException e) {
String msg = "Parse error while reading node type definition.";
throw new JournalException(msg, e);
@@ -269,10 +272,10 @@
private int getOrCreateIndex(NodeId nodeId) {
Integer index = (Integer) nodeIdIndex.get(nodeId);
if (index == null) {
- nodeIdIndex.put(nodeId, new Integer(nodeIdIndex.size()));
+ nodeIdIndex.put(nodeId, nodeIdIndex.size());
return -1;
} else {
- return index.intValue();
+ return index;
}
}
}
\ No newline at end of file
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/DatabaseJournal.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/DatabaseJournal.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/DatabaseJournal.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/DatabaseJournal.java Wed Jul 8 13:57:13 2009
@@ -394,7 +394,7 @@
/**
* Creates a new database connection. This method is called inside
- * {@link #init(String, org.apache.jackrabbit.name.NamespaceResolver)} or
+ * {@link #init(String, org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver)} or
* when a connection has been dropped and must be reacquired. Base
* implementation uses <code>java.sql.DriverManager</code> to get the
* connection. May be overridden by subclasses.
@@ -961,7 +961,7 @@
/**
* Get the database type.
* @deprecated
- * This method is deprecated; {@link getDatabaseType} should be used instead.
+ * This method is deprecated; {@link #getDatabaseType} should be used instead.
*
* @return the database type
*/
@@ -1020,7 +1020,7 @@
/**
* Set the database type.
* @deprecated
- * This method is deprecated; {@link getDatabaseType} should be used instead.
+ * This method is deprecated; {@link #getDatabaseType} should be used instead.
*
* @param databaseType the database type
*/
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/LockableFileRevision.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/LockableFileRevision.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/LockableFileRevision.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/LockableFileRevision.java Wed Jul 8 13:57:13 2009
@@ -77,7 +77,7 @@
*
* @param shared whether to allow other readers or not
*/
- public void lock(boolean shared) throws JournalException {
+ public synchronized void lock(boolean shared) throws JournalException {
if (lock == null) {
try {
raf = new RandomAccessFile(file, shared ? "r" : "rw");
@@ -103,7 +103,7 @@
/**
* Unlock underlying file.
*/
- public void unlock() {
+ public synchronized void unlock() {
if (lock != null && --locks == 0) {
try {
lock.release();
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/AbstractLockInfo.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/AbstractLockInfo.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/AbstractLockInfo.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/AbstractLockInfo.java Wed Jul 8 13:57:13 2009
@@ -24,12 +24,13 @@
/**
* Common information about a lock.
*/
-public abstract class AbstractLockInfo {
+abstract class AbstractLockInfo implements LockInfo {
/**
* Constant for the undefined or infinite timeout.
*/
static final long TIMEOUT_INFINITE = Long.MAX_VALUE;
+
/**
* Constant for the expired timeout.
*/
@@ -56,14 +57,14 @@
protected final String lockOwner;
/**
- * Session currently holding lock
+ * Flag indicating whether this lock is live
*/
- protected SessionImpl lockHolder;
+ private boolean live;
/**
- * Flag indicating whether this lock is live
+ * Session currently holding lock
*/
- protected boolean live;
+ private SessionImpl lockHolder;
/**
* Create a new instance of this class.
@@ -113,6 +114,27 @@
}
/**
+ * {@inheritDoc}
+ */
+ public boolean isLockHolder(Session session) {
+ return lockHolder == session;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getLockOwner() {
+ return lockOwner;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isDeep() {
+ return deep;
+ }
+
+ /**
* Return the session currently holding the lock
*
* @return session currently holding the lock
@@ -131,21 +153,25 @@
}
/**
- * Return the lock token as seen by the session passed as parameter. If
- * this session is currently holding the lock, it will get the lock token
- * itself, otherwise a <code>null</code> string.
- *
- * @param session The session asking for the lock token.
- * @return lock token.
+ * {@inheritDoc}
*/
public String getLockToken(Session session) {
- if (session.equals(lockHolder)) {
+ if (isLockHolder(session)) {
return lockToken.toString();
}
return null;
}
/**
+ * Return the lock token.
+ *
+ * @return lock token
+ */
+ public String getLockToken() {
+ return lockToken.toString();
+ }
+
+ /**
* Return a flag indicating whether the lock is live
*
* @return <code>true</code> if the lock is live; otherwise <code>false</code>
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockImpl.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockImpl.java Wed Jul 8 13:57:13 2009
@@ -33,7 +33,7 @@
/**
* Lock info containing latest information
*/
- protected final AbstractLockInfo info;
+ protected final LockInfo info;
/**
* Node holding lock
@@ -46,7 +46,7 @@
* @param info lock information
* @param node node holding lock
*/
- public LockImpl(AbstractLockInfo info, Node node) {
+ public LockImpl(LockInfo info, Node node) {
this.info = info;
this.node = node;
}
@@ -57,14 +57,14 @@
* {@inheritDoc}
*/
public String getLockOwner() {
- return info.lockOwner;
+ return info.getLockOwner();
}
/**
* {@inheritDoc}
*/
public boolean isDeep() {
- return info.deep;
+ return info.isDeep();
}
/**
@@ -138,7 +138,7 @@
*/
public boolean isLockOwningSession() {
try {
- return node.getSession().equals(info.getLockHolder());
+ return info.isLockHolder(node.getSession());
} catch (RepositoryException e) {
return false;
}
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManager.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManager.java Wed Jul 8 13:57:13 2009
@@ -102,20 +102,6 @@
boolean holdsLock(NodeImpl node) throws RepositoryException;
/**
- * Returns <code>true</code> if the specified session holds a lock on the
- * given node; otherwise returns <code>false</code>.
- * <p/>
- * Note that <code>isLockHolder(session, node)==true</code> implies
- * <code>holdsLock(node)==true</code>.
- * @param session session
- * @param node node
- * @return if the specified session holds a lock on the given node;
- * otherwise returns <code>false</code>
- * @throws javax.jcr.RepositoryException If an exception occurs.
- */
- boolean isLockHolder(Session session, NodeImpl node) throws RepositoryException;
-
- /**
* Returns <code>true</code> if this node is locked either as a result
* of a lock held by this node or by a deep lock on a node above this
* node; otherwise returns <code>false</code>
@@ -154,14 +140,27 @@
throws LockException, RepositoryException;
/**
+ * Returns <code>true</code> if the specified session is allowed to unlock
+ * the node; otherwise returns <code>false</code>.
+ * @param session session
+ * @param node node
+ * @return <code>true</code> if the session is allowed access to the node;
+ * <code>false</code> otherwise
+ * @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;
+
+ /**
* 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
* @throws RepositoryException
*/
- void lockTokenAdded(SessionImpl session, String lt) throws LockException, RepositoryException;
+ void addLockToken(SessionImpl session, String lt) throws LockException, RepositoryException;
/**
* Invoked by a session to inform that a lock token has been removed.
@@ -171,5 +170,5 @@
* @throws LockException
* @throws RepositoryException
*/
- void lockTokenRemoved(SessionImpl session, String lt) throws LockException, RepositoryException;
+ void removeLockToken(SessionImpl session, String lt) throws LockException, RepositoryException;
}