Author: bcarothers
Date: 2009-12-26 22:18:45 -0500 (Sat, 26 Dec 2009)
New Revision: 1481
Added:
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleJpaConnectorNotWritableTest.java
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/GraphI18n.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/inmemory/InMemoryRepositorySource.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapRepositoryConnection.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapRepositorySource.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapRequestProcessor.java
trunk/dna-graph/src/main/resources/org/jboss/dna/graph/GraphI18n.properties
trunk/docs/reference/src/main/docbook/en-US/content/connectors/infinispan.xml
trunk/docs/reference/src/main/docbook/en-US/content/connectors/jboss_cache.xml
trunk/docs/reference/src/main/docbook/en-US/content/connectors/jdbc_storage.xml
trunk/extensions/dna-connector-infinispan/src/main/java/org/jboss/dna/connector/infinispan/InfinispanSource.java
trunk/extensions/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheSource.java
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/JpaSource.java
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleJpaConnection.java
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleRequestProcessor.java
Log:
DNA-578 JPA Connector Simple Model Does Not Support "supportsUpdates" Property
Applied patch that requires support for "allowsUpdates" property in
MapRepositorySource implementations and adds a default implementation in
MapRequestProcessor. The patch also adds the property to the Infinispan and JBoss Cache
connectors and the simple model in the JPA connector. Finally, the patch adds a test case
for the JPA source and updates the documentation accordingly.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/GraphI18n.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/GraphI18n.java 2009-12-23 02:21:59
UTC (rev 1480)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/GraphI18n.java 2009-12-27 03:18:45
UTC (rev 1481)
@@ -99,9 +99,11 @@
public static I18n nodeDoesNotExist;
public static I18n errorSerializingInMemoryCachePolicyInSource;
public static I18n inMemoryConnectorRequestsMustHavePathOrUuid;
+ public static I18n inMemoryConnectorMustAllowUpdates;
public static I18n pathConnectorRequestsMustHavePath;
public static I18n workspaceDoesNotExistInRepository;
public static I18n workspaceAlreadyExistsInRepository;
+ public static I18n sourceIsReadOnly;
/* Federation Connection */
public static I18n namePropertyIsRequiredForFederatedRepositorySource;
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/inmemory/InMemoryRepositorySource.java
===================================================================
---
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/inmemory/InMemoryRepositorySource.java 2009-12-23
02:21:59 UTC (rev 1480)
+++
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/inmemory/InMemoryRepositorySource.java 2009-12-27
03:18:45 UTC (rev 1481)
@@ -367,7 +367,28 @@
return CAPABILITIES;
}
+ @Override
+ public boolean areUpdatesAllowed() {
+ return true;
+ }
+
/**
+ * In-memory connectors aren't shared and cannot be loaded from external sources
if updates are not allowed. Therefore, in
+ * order to avoid setting up an in-memory connector that is permanently empty
(presumably, not a desired outcome), all
+ * in-memory connectors must allow updates.
+ *
+ * @param updatesAllowed must be true
+ * @throws RepositorySourceException if {@code updatesAllowed != true}.
+ */
+ @Override
+ public void setUpdatesAllowed( boolean updatesAllowed ) {
+ if (updatesAllowed == false) {
+ throw new
RepositorySourceException(GraphI18n.inMemoryConnectorMustAllowUpdates.text(this.name));
+ }
+
+ }
+
+ /**
* {@inheritDoc}
*
* @see java.lang.Object#toString()
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapRepositoryConnection.java
===================================================================
---
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapRepositoryConnection.java 2009-12-23
02:21:59 UTC (rev 1480)
+++
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapRepositoryConnection.java 2009-12-27
03:18:45 UTC (rev 1481)
@@ -104,7 +104,7 @@
// Do any commands update/write?
RepositoryContext repositoryContext = this.source.getRepositoryContext();
Observer observer = repositoryContext != null ? repositoryContext.getObserver() :
null;
- RequestProcessor processor = new MapRequestProcessor(context, this.repository,
observer);
+ RequestProcessor processor = new MapRequestProcessor(context, this.repository,
observer, source.areUpdatesAllowed());
boolean commit = true;
MapRepositoryTransaction txn =
repository.startTransaction(request.isReadOnly());
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapRepositorySource.java
===================================================================
---
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapRepositorySource.java 2009-12-23
02:21:59 UTC (rev 1480)
+++
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapRepositorySource.java 2009-12-27
03:18:45 UTC (rev 1481)
@@ -34,13 +34,32 @@
public interface MapRepositorySource extends RepositorySource {
/**
- * Returns the {@link CachePolicy cache policy} for the repository source
+ * Get whether this source allows updates.
+ *
+ * @return true if this source allows updates by clients, or false if no updates are
allowed
+ * @see #setUpdatesAllowed(boolean)
+ */
+ boolean areUpdatesAllowed();
+
+ /**
+ * Set whether this source allows updates to data within workspaces
+ *
+ * @param updatesAllowed true if this source allows updates to data within workspaces
clients, or false if updates are not
+ * allowed.
+ * @see #areUpdatesAllowed()
+ */
+ void setUpdatesAllowed( boolean updatesAllowed );
+
+ /**
+ * Returns the {@link CachePolicy cache policy} for the repository source
+ *
* @return the {@link CachePolicy cache policy} for the repository source
*/
CachePolicy getDefaultCachePolicy();
/**
* Returns the {@link RepositoryContext repository context} for the repository
source
+ *
* @return the {@link RepositoryContext repository context} for the repository
source
*/
RepositoryContext getRepositoryContext();
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapRequestProcessor.java
===================================================================
---
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapRequestProcessor.java 2009-12-23
02:21:59 UTC (rev 1480)
+++
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapRequestProcessor.java 2009-12-27
03:18:45 UTC (rev 1481)
@@ -57,6 +57,7 @@
import org.jboss.dna.graph.request.DestroyWorkspaceRequest;
import org.jboss.dna.graph.request.FullTextSearchRequest;
import org.jboss.dna.graph.request.GetWorkspacesRequest;
+import org.jboss.dna.graph.request.InvalidRequestException;
import org.jboss.dna.graph.request.InvalidWorkspaceException;
import org.jboss.dna.graph.request.LockBranchRequest;
import org.jboss.dna.graph.request.MoveBranchRequest;
@@ -75,14 +76,17 @@
private final PathFactory pathFactory;
private final PropertyFactory propertyFactory;
private final MapRepository repository;
+ private final boolean updatesAllowed;
public MapRequestProcessor( ExecutionContext context,
MapRepository repository,
- Observer observer ) {
+ Observer observer,
+ boolean updatesAllowed ) {
super(repository.getSourceName(), context, observer);
this.repository = repository;
pathFactory = context.getValueFactories().getPathFactory();
propertyFactory = context.getPropertyFactory();
+ this.updatesAllowed = updatesAllowed;
}
/**
@@ -156,6 +160,8 @@
*/
@Override
public void process( CloneBranchRequest request ) {
+ if (!updatesAllowed(request)) return;
+
MapWorkspace workspace = getWorkspace(request, request.fromWorkspace());
MapWorkspace newWorkspace = getWorkspace(request, request.intoWorkspace());
if (workspace == null || newWorkspace == null) return;
@@ -189,6 +195,8 @@
*/
@Override
public void process( CopyBranchRequest request ) {
+ if (!updatesAllowed(request)) return;
+
MapWorkspace workspace = getWorkspace(request, request.fromWorkspace());
MapWorkspace newWorkspace = getWorkspace(request, request.intoWorkspace());
if (workspace == null || newWorkspace == null) return;
@@ -214,6 +222,8 @@
*/
@Override
public void process( CreateNodeRequest request ) {
+ if (!updatesAllowed(request)) return;
+
MapWorkspace workspace = getWorkspace(request, request.inWorkspace());
if (workspace == null) return;
Path parent = request.under().getPath();
@@ -224,8 +234,7 @@
MapNode parentNode = workspace.getNode(parent);
if (parentNode == null) {
Path lowestExisting = workspace.getLowestExistingPath(parent);
- request.setError(new PathNotFoundException(request.under(), lowestExisting,
- GraphI18n.nodeDoesNotExist.text(parent)));
+ request.setError(new PathNotFoundException(request.under(), lowestExisting,
GraphI18n.nodeDoesNotExist.text(parent)));
return;
}
@@ -286,6 +295,8 @@
*/
@Override
public void process( DeleteBranchRequest request ) {
+ if (!updatesAllowed(request)) return;
+
MapWorkspace workspace = getWorkspace(request, request.inWorkspace());
if (workspace == null) return;
MapNode node = getTargetNode(workspace, request, request.at());
@@ -303,6 +314,8 @@
*/
@Override
public void process( MoveBranchRequest request ) {
+ if (!updatesAllowed(request)) return;
+
MapWorkspace workspace = getWorkspace(request, request.inWorkspace());
if (workspace == null) return;
@@ -352,6 +365,8 @@
*/
@Override
public void process( UpdatePropertiesRequest request ) {
+ if (!updatesAllowed(request)) return;
+
MapWorkspace workspace = getWorkspace(request, request.inWorkspace());
MapNode node = getTargetNode(workspace, request, request.on());
if (node == null) return;
@@ -383,6 +398,8 @@
*/
@Override
public void process( CreateWorkspaceRequest request ) {
+ if (!updatesAllowed(request)) return;
+
MapWorkspace workspace = repository.createWorkspace(getExecutionContext(),
request.desiredNameOfNewWorkspace(),
request.conflictBehavior());
@@ -405,6 +422,8 @@
*/
@Override
public void process( DestroyWorkspaceRequest request ) {
+ if (!updatesAllowed(request)) return;
+
MapWorkspace workspace = repository.getWorkspace(request.workspaceName());
if (workspace != null) {
MapNode root = workspace.getRoot();
@@ -450,6 +469,8 @@
*/
@Override
public void process( CloneWorkspaceRequest request ) {
+ if (!updatesAllowed(request)) return;
+
// Find the original workspace that we're cloning ...
final ExecutionContext context = getExecutionContext();
String targetWorkspaceName = request.desiredNameOfTargetWorkspace();
@@ -561,6 +582,13 @@
return workspace;
}
+ protected boolean updatesAllowed( Request request ) {
+ if (!updatesAllowed) {
+ request.setError(new
InvalidRequestException(GraphI18n.sourceIsReadOnly.text(getSourceName())));
+ }
+ return !request.hasError();
+ }
+
protected MapNode getTargetNode( MapWorkspace workspace,
Request request,
Location location ) {
Modified: trunk/dna-graph/src/main/resources/org/jboss/dna/graph/GraphI18n.properties
===================================================================
--- trunk/dna-graph/src/main/resources/org/jboss/dna/graph/GraphI18n.properties 2009-12-23
02:21:59 UTC (rev 1480)
+++ trunk/dna-graph/src/main/resources/org/jboss/dna/graph/GraphI18n.properties 2009-12-27
03:18:45 UTC (rev 1481)
@@ -87,9 +87,11 @@
nodeDoesNotExist = Could not find an existing node at {0}
errorSerializingInMemoryCachePolicyInSource = Error serializing a {0} instance owned by
the {1} in-memory repository
inMemoryConnectorRequestsMustHavePathOrUuid = In-Memory connector can only process
requests with a path and/or UUID
+inMemoryConnectorMustAllowUpdates = In-Memory connector "{0}" must allow
updates.
pathConnectorRequestsMustHavePath = Path connectors can only process requests with a
path
workspaceDoesNotExistInRepository = The workspace "{0}" does not exist in the
"{1}" in-memory repository
workspaceAlreadyExistsInRepository = The workspace "{0}" already exists in the
"{1}" in-memory repository
+sourceIsReadOnly = The repository source "{0}" does not allow updates. Set the
"updatesAllowed" property to "true" on the repository source to allow
updates.
# Federation connector
namePropertyIsRequiredForFederatedRepositorySource = The "{0}" property is
required on each federated repository source
Modified: trunk/docs/reference/src/main/docbook/en-US/content/connectors/infinispan.xml
===================================================================
---
trunk/docs/reference/src/main/docbook/en-US/content/connectors/infinispan.xml 2009-12-23
02:21:59 UTC (rev 1480)
+++
trunk/docs/reference/src/main/docbook/en-US/content/connectors/infinispan.xml 2009-12-27
03:18:45 UTC (rev 1481)
@@ -91,6 +91,11 @@
<entry>Optional property that, if used, specifies the UUID that should be used
for the root node of each workspace. If no value is
specified, a random UUID is generated each time that the repository is
started.</entry>
</row>
+ <row>
+ <entry>updatesAllowed</entry>
+ <entry>Determines whether the content in the connector is can be updated
("true"), or if the content may only be read ("false").
+ The default value is "true".</entry>
+ </row>
</tbody>
</tgroup>
</table>
Modified: trunk/docs/reference/src/main/docbook/en-US/content/connectors/jboss_cache.xml
===================================================================
---
trunk/docs/reference/src/main/docbook/en-US/content/connectors/jboss_cache.xml 2009-12-23
02:21:59 UTC (rev 1480)
+++
trunk/docs/reference/src/main/docbook/en-US/content/connectors/jboss_cache.xml 2009-12-27
03:18:45 UTC (rev 1481)
@@ -106,6 +106,11 @@
<entry>Optional property that, if used, defines the property that should be
used to find the UUID value for each node
in the cache. "<code>dna:uuid</code>" is the
default.</entry>
</row>
+ <row>
+ <entry>updatesAllowed</entry>
+ <entry>Determines whether the content in the connector is can be updated
("true"), or if the content may only be read ("false").
+ The default value is "true".</entry>
+ </row>
</tbody>
</tgroup>
Modified: trunk/docs/reference/src/main/docbook/en-US/content/connectors/jdbc_storage.xml
===================================================================
---
trunk/docs/reference/src/main/docbook/en-US/content/connectors/jdbc_storage.xml 2009-12-23
02:21:59 UTC (rev 1480)
+++
trunk/docs/reference/src/main/docbook/en-US/content/connectors/jdbc_storage.xml 2009-12-27
03:18:45 UTC (rev 1481)
@@ -56,9 +56,9 @@
<entry>The name of the repository source, which is used by the
&RepositoryService; when obtaining a &RepositoryConnection; by
name.</entry>
</row>
<row>
- <entry>supportsUpdates (Basic Model Only)</entry>
+ <entry>updatesAllowed</entry>
<entry>Determines whether the content in the database is can be updated
("true"), or if the content may only be read ("false").
- The default value is "true". This property is ignored by the Simple
Model (q.v., the model property below)</entry>
+ The default value is "true".</entry>
</row>
<row>
<entry>rootNodeUuid</entry>
@@ -204,7 +204,7 @@
<entry>model</entry>
<entry>
An advanced property that dictates the type of storage schema that is used.
Currently, the only supported values are "Basic" and "Simple".
- The Basic model supports a read-only mode (q.v., the "supportsUpdates"
property) and database-level
+ The Basic model supports a read-only mode (q.v., the "updatesAllowed"
property) and database-level
enforcement of referential integrity (q.v., the
"referentialIntegrityEnforced" property above), but does not fully support all
JCR functions.
As a result, the Simple model is now the default model, but DNA repositories that
were created under the Basic model will continue to use
the "Basic" model regardless of the value of this property. Repositories
can be converted from the Basic model to the Simple model by exporting
Modified:
trunk/extensions/dna-connector-infinispan/src/main/java/org/jboss/dna/connector/infinispan/InfinispanSource.java
===================================================================
---
trunk/extensions/dna-connector-infinispan/src/main/java/org/jboss/dna/connector/infinispan/InfinispanSource.java 2009-12-23
02:21:59 UTC (rev 1480)
+++
trunk/extensions/dna-connector-infinispan/src/main/java/org/jboss/dna/connector/infinispan/InfinispanSource.java 2009-12-27
03:18:45 UTC (rev 1481)
@@ -88,6 +88,11 @@
*/
public static final String DEFAULT_NAME_OF_DEFAULT_WORKSPACE = "default";
+ /**
+ * The initial value for whether updates are allowed is "{@value} ", unless
otherwise specified.
+ */
+ public static final boolean DEFAULT_UPDATES_ALLOWED = true;
+
protected static final String ROOT_NODE_UUID = "rootNodeUuid";
protected static final String SOURCE_NAME = "sourceName";
protected static final String DEFAULT_CACHE_POLICY = "defaultCachePolicy";
@@ -97,6 +102,7 @@
protected static final String DEFAULT_WORKSPACE = "defaultWorkspace";
protected static final String PREDEFINED_WORKSPACE_NAMES =
"predefinedWorkspaceNames";
protected static final String ALLOW_CREATING_WORKSPACES =
"allowCreatingWorkspaces";
+ protected static final String UPDATES_ALLOWED = "updatesAllowed";
private volatile String name;
private volatile UUID rootNodeUuid = UUID.randomUUID();
@@ -105,6 +111,7 @@
private volatile String cacheManagerJndiName;
private volatile int retryLimit = DEFAULT_RETRY_LIMIT;
private volatile String defaultWorkspace;
+ private volatile boolean updatesAllowed = DEFAULT_UPDATES_ALLOWED;
private volatile String[] predefinedWorkspaces = new String[] {};
private volatile RepositorySourceCapabilities capabilities = new
RepositorySourceCapabilities(true, true, false, true, false);
private transient InfinispanRepository repository;
@@ -448,6 +455,14 @@
this.jndiContext = context;
}
+ public boolean areUpdatesAllowed() {
+ return this.updatesAllowed;
+ }
+
+ public void setUpdatesAllowed( boolean updatesAllowed ) {
+ this.updatesAllowed = updatesAllowed;
+ }
+
/**
* {@inheritDoc}
*/
@@ -480,6 +495,7 @@
ref.add(new StringRefAddr(CACHE_CONFIGURATION_NAME,
getCacheConfigurationName()));
ref.add(new StringRefAddr(RETRY_LIMIT, Integer.toString(getRetryLimit())));
ref.add(new StringRefAddr(DEFAULT_WORKSPACE, getDefaultWorkspaceName()));
+ ref.add(new StringRefAddr(UPDATES_ALLOWED,
String.valueOf(areUpdatesAllowed())));
ref.add(new StringRefAddr(ALLOW_CREATING_WORKSPACES,
Boolean.toString(isCreatingWorkspacesAllowed())));
String[] workspaceNames = getPredefinedWorkspaceNames();
if (workspaceNames != null && workspaceNames.length != 0) {
@@ -537,6 +553,7 @@
String retryLimit = (String)values.get(RETRY_LIMIT);
String defaultWorkspace = (String)values.get(DEFAULT_WORKSPACE);
String createWorkspaces = (String)values.get(ALLOW_CREATING_WORKSPACES);
+ String updatesAllowed = (String)values.get(UPDATES_ALLOWED);
String combinedWorkspaceNames =
(String)values.get(PREDEFINED_WORKSPACE_NAMES);
String[] workspaceNames = null;
@@ -558,6 +575,7 @@
if (defaultWorkspace != null)
source.setDefaultWorkspaceName(defaultWorkspace);
if (createWorkspaces != null)
source.setCreatingWorkspacesAllowed(Boolean.parseBoolean(createWorkspaces));
if (workspaceNames != null && workspaceNames.length != 0)
source.setPredefinedWorkspaceNames(workspaceNames);
+ if (updatesAllowed != null)
source.setUpdatesAllowed(Boolean.valueOf(updatesAllowed));
return source;
}
return null;
Modified:
trunk/extensions/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheSource.java
===================================================================
---
trunk/extensions/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheSource.java 2009-12-23
02:21:59 UTC (rev 1480)
+++
trunk/extensions/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheSource.java 2009-12-27
03:18:45 UTC (rev 1481)
@@ -97,6 +97,11 @@
*/
public static final String DEFAULT_NAME_OF_DEFAULT_WORKSPACE = "default";
+ /**
+ * The initial value for whether updates are allowed is "{@value} ", unless
otherwise specified.
+ */
+ public static final boolean DEFAULT_UPDATES_ALLOWED = true;
+
protected static final String ROOT_NODE_UUID = "rootNodeUuid";
protected static final String SOURCE_NAME = "sourceName";
protected static final String DEFAULT_CACHE_POLICY = "defaultCachePolicy";
@@ -107,6 +112,7 @@
protected static final String DEFAULT_WORKSPACE = "defaultWorkspace";
protected static final String PREDEFINED_WORKSPACE_NAMES =
"predefinedWorkspaceNames";
protected static final String ALLOW_CREATING_WORKSPACES =
"allowCreatingWorkspaces";
+ protected static final String UPDATES_ALLOWED = "updatesAllowed";
private volatile String name;
private volatile UUID rootNodeUuid = UUID.randomUUID();
@@ -116,6 +122,7 @@
private volatile String cacheJndiName;
private volatile int retryLimit = DEFAULT_RETRY_LIMIT;
private volatile String defaultWorkspace;
+ private volatile boolean updatesAllowed = DEFAULT_UPDATES_ALLOWED;
private volatile String[] predefinedWorkspaces = new String[] {};
private volatile RepositorySourceCapabilities capabilities = new
RepositorySourceCapabilities(true, true, false, true, false);
private transient JBossCacheRepository repository;
@@ -553,6 +560,14 @@
this.jndiContext = context;
}
+ public boolean areUpdatesAllowed() {
+ return this.updatesAllowed;
+ }
+
+ public void setUpdatesAllowed( boolean updatesAllowed ) {
+ this.updatesAllowed = updatesAllowed;
+ }
+
/**
* {@inheritDoc}
*/
@@ -586,6 +601,7 @@
ref.add(new StringRefAddr(CACHE_CONFIGURATION_NAME,
getCacheConfigurationName()));
ref.add(new StringRefAddr(RETRY_LIMIT, Integer.toString(getRetryLimit())));
ref.add(new StringRefAddr(DEFAULT_WORKSPACE, getDefaultWorkspaceName()));
+ ref.add(new StringRefAddr(UPDATES_ALLOWED,
String.valueOf(areUpdatesAllowed())));
ref.add(new StringRefAddr(ALLOW_CREATING_WORKSPACES,
Boolean.toString(isCreatingWorkspacesAllowed())));
String[] workspaceNames = getPredefinedWorkspaceNames();
if (workspaceNames != null && workspaceNames.length != 0) {
@@ -644,6 +660,7 @@
String retryLimit = (String)values.get(RETRY_LIMIT);
String defaultWorkspace = (String)values.get(DEFAULT_WORKSPACE);
String createWorkspaces = (String)values.get(ALLOW_CREATING_WORKSPACES);
+ String updatesAllowed = (String)values.get(UPDATES_ALLOWED);
String combinedWorkspaceNames =
(String)values.get(PREDEFINED_WORKSPACE_NAMES);
String[] workspaceNames = null;
@@ -666,6 +683,7 @@
if (defaultWorkspace != null)
source.setDefaultWorkspaceName(defaultWorkspace);
if (createWorkspaces != null)
source.setCreatingWorkspacesAllowed(Boolean.parseBoolean(createWorkspaces));
if (workspaceNames != null && workspaceNames.length != 0)
source.setPredefinedWorkspaceNames(workspaceNames);
+ if (updatesAllowed != null)
source.setUpdatesAllowed(Boolean.valueOf(updatesAllowed));
return source;
}
return null;
Modified:
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/JpaSource.java
===================================================================
---
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/JpaSource.java 2009-12-23
02:21:59 UTC (rev 1480)
+++
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/JpaSource.java 2009-12-27
03:18:45 UTC (rev 1481)
@@ -138,10 +138,10 @@
*/
protected static final boolean SUPPORTS_REFERENCES = true;
/**
- * This source supports udpates by default, but each instance may be configured to
{@link #setSupportsUpdates(boolean) be
+ * This source supports updates by default, but each instance may be configured to
{@link #setAllowsUpdates(boolean) be
* read-only or updateable}.
*/
- public static final boolean DEFAULT_SUPPORTS_UPDATES = true;
+ public static final boolean DEFAULT_ALLOWS_UPDATES = true;
/**
* This source does not output executed SQL by default, but this can be overridden by
calling {@link #setShowSql(boolean)}.
*/
@@ -211,7 +211,7 @@
private volatile String[] predefinedWorkspaces = new String[] {};
private volatile RepositorySourceCapabilities capabilities = new
RepositorySourceCapabilities(
SUPPORTS_SAME_NAME_SIBLINGS,
-
DEFAULT_SUPPORTS_UPDATES,
+
DEFAULT_ALLOWS_UPDATES,
SUPPORTS_EVENTS,
DEFAULT_SUPPORTS_CREATING_WORKSPACES,
SUPPORTS_REFERENCES);
@@ -255,22 +255,21 @@
}
/**
- * Get whether this source supports updates.
+ * Get whether this source allows updates.
*
- * @return true if this source supports updates, or false if this source only
supports reading content.
+ * @return true if this source allows updates, or false if this source only supports
reading content.
*/
- public boolean getSupportsUpdates() {
+ public boolean areUpdatesAllowed() {
return capabilities.supportsUpdates();
}
/**
- * Set whether this source supports updates.
+ * Set whether this source allows updates.
*
- * @param supportsUpdates true if this source supports updating content, or false if
this source only supports reading
- * content.
+ * @param allowsUpdates true if this source allows updating content, or false if this
source only allows reading content.
*/
- public synchronized void setSupportsUpdates( boolean supportsUpdates ) {
- capabilities = new
RepositorySourceCapabilities(capabilities.supportsSameNameSiblings(), supportsUpdates,
+ public synchronized void setAllowsUpdates( boolean allowsUpdates ) {
+ capabilities = new
RepositorySourceCapabilities(capabilities.supportsSameNameSiblings(), allowsUpdates,
capabilities.supportsEvents(),
capabilities.supportsCreatingWorkspaces(),
capabilities.supportsReferences());
}
Modified:
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleJpaConnection.java
===================================================================
---
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleJpaConnection.java 2009-12-23
02:21:59 UTC (rev 1480)
+++
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleJpaConnection.java 2009-12-27
03:18:45 UTC (rev 1481)
@@ -103,7 +103,7 @@
}
// Do any commands update/write?
Observer observer = this.source.getRepositoryContext().getObserver();
- RequestProcessor processor = new SimpleRequestProcessor(context, this.repository,
observer);
+ RequestProcessor processor = new SimpleRequestProcessor(context, this.repository,
observer, source.areUpdatesAllowed());
boolean commit = true;
MapRepositoryTransaction txn =
repository.startTransaction(request.isReadOnly());
Modified:
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleRequestProcessor.java
===================================================================
---
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleRequestProcessor.java 2009-12-23
02:21:59 UTC (rev 1480)
+++
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleRequestProcessor.java 2009-12-27
03:18:45 UTC (rev 1481)
@@ -31,8 +31,9 @@
public SimpleRequestProcessor( ExecutionContext context,
SimpleJpaRepository repository,
- Observer observer ) {
- super(context, repository, observer);
+ Observer observer,
+ boolean updatesAllowed ) {
+ super(context, repository, observer, updatesAllowed);
this.repository = repository;
this.pathFactory = context.getValueFactories().getPathFactory();
@@ -126,6 +127,8 @@
@Override
public void process( CreateWorkspaceRequest request ) {
+ if (!updatesAllowed(request)) return;
+
if (!repository.creatingWorkspacesAllowed()) {
String msg =
JpaConnectorI18n.unableToCreateWorkspaces.text(getSourceName());
request.setError(new InvalidRequestException(msg));
@@ -137,6 +140,8 @@
@Override
public void process( CloneWorkspaceRequest request ) {
+ if (!updatesAllowed(request)) return;
+
if (!repository.creatingWorkspacesAllowed()) {
String msg =
JpaConnectorI18n.unableToCreateWorkspaces.text(getSourceName());
request.setError(new InvalidRequestException(msg));
Added:
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleJpaConnectorNotWritableTest.java
===================================================================
---
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleJpaConnectorNotWritableTest.java
(rev 0)
+++
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleJpaConnectorNotWritableTest.java 2009-12-27
03:18:45 UTC (rev 1481)
@@ -0,0 +1,67 @@
+package org.jboss.dna.connector.store.jpa.model.simple;
+
+/*
+ * JBoss DNA (
http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+import org.jboss.dna.connector.store.jpa.JpaSource;
+import org.jboss.dna.connector.store.jpa.TestEnvironment;
+import org.jboss.dna.graph.Graph;
+import org.jboss.dna.graph.connector.RepositorySource;
+import org.jboss.dna.graph.connector.test.NotWritableConnectorTest;
+
+public class SimpleJpaConnectorNotWritableTest extends NotWritableConnectorTest {
+
+ private JpaSource source;
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.connector.test.AbstractConnectorTest#setUpSource()
+ */
+ @Override
+ protected RepositorySource setUpSource() {
+ // Set the connection properties using the environment defined in the POM files
...
+ source = TestEnvironment.configureJpaSource("Test Repository", this);
+ source.setModel(JpaSource.Models.SIMPLE.getName());
+
+ // Override the inherited properties ...
+ source.setCompressData(true);
+
+ return source;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.graph.connector.test.AbstractConnectorTest#initializeContent(org.jboss.dna.graph.Graph)
+ */
+ @Override
+ protected void initializeContent( Graph graph ) {
+ graph.create("/testNode").and();
+
+ source.setAllowsUpdates(false);
+
+ }
+
+}
Property changes on:
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleJpaConnectorNotWritableTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF