You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by re...@apache.org on 2015/01/12 20:27:13 UTC
[4/4] clerezza git commit: Adapted to updated RDF Commons draft
Adapted to updated RDF Commons draft
Project: http://git-wip-us.apache.org/repos/asf/clerezza/repo
Commit: http://git-wip-us.apache.org/repos/asf/clerezza/commit/9ae0a1bc
Tree: http://git-wip-us.apache.org/repos/asf/clerezza/tree/9ae0a1bc
Diff: http://git-wip-us.apache.org/repos/asf/clerezza/diff/9ae0a1bc
Branch: refs/heads/rdf-commons
Commit: 9ae0a1bc9649afd410d416e6d130dccf84f236f9
Parents: 29f822c
Author: Reto Gm?r <re...@apache.org>
Authored: Mon Jan 12 19:19:20 2015 +0000
Committer: Reto Gm?r <re...@apache.org>
Committed: Mon Jan 12 19:19:20 2015 +0000
----------------------------------------------------------------------
.../rdf/core/access/GraphServiceFactory.java | 59 -----
.../access/ImmutableGraphServiceFactory.java | 59 +++++
.../rdf/core/access/LockableMGraph.java | 10 +-
.../rdf/core/access/LockableMGraphWrapper.java | 18 +-
.../rdf/core/access/NoSuchEntityException.java | 2 +-
.../rdf/core/access/QueryableTcProvider.java | 6 +-
.../rdf/core/access/ReadOnlyException.java | 6 +-
.../clerezza/rdf/core/access/SecuredGraph.java | 185 +++++++++++++
.../clerezza/rdf/core/access/SecuredMGraph.java | 12 +-
.../core/access/SecuredTripleCollection.java | 178 -------------
.../clerezza/rdf/core/access/TcManager.java | 118 ++++-----
.../clerezza/rdf/core/access/TcProvider.java | 114 ++++----
.../rdf/core/access/TcProviderMultiplexer.java | 76 +++---
.../clerezza/rdf/core/access/package.html | 4 +-
.../access/security/TcAccessController.java | 94 +++----
.../rdf/core/access/security/TcPermission.java | 6 +-
.../clerezza/rdf/core/impl/AbstractGraph.java | 235 +++++++++++++----
.../rdf/core/impl/AbstractImmutableGraph.java | 112 ++++++++
.../clerezza/rdf/core/impl/AbstractMGraph.java | 10 +-
.../rdf/core/impl/AbstractTripleCollection.java | 251 ------------------
.../rdf/core/impl/DelayedNotificator.java | 2 +-
.../clerezza/rdf/core/impl/SimpleGraph.java | 198 ++++++++++++--
.../rdf/core/impl/SimpleImmutableGraph.java | 78 ++++++
.../clerezza/rdf/core/impl/SimpleMGraph.java | 8 +-
.../rdf/core/impl/SimpleTripleCollection.java | 213 ---------------
.../rdf/core/impl/WriteBlockedGraph.java | 137 ++++++++++
.../rdf/core/impl/WriteBlockedMGraph.java | 23 +-
.../core/impl/WriteBlockedTripleCollection.java | 131 ----------
.../core/impl/graphmatching/GraphMatcher.java | 16 +-
.../core/impl/graphmatching/HashMatching.java | 22 +-
.../core/impl/util/PrivilegedGraphWrapper.java | 244 ++++++++++++++++-
.../util/PrivilegedImmuatbleGraphWrapper.java | 36 +++
.../core/impl/util/PrivilegedMGraphWrapper.java | 43 ---
.../util/PrivilegedTripleCollectionWrapper.java | 261 -------------------
.../rdf/core/serializedform/Parser.java | 34 +--
.../core/serializedform/ParsingProvider.java | 10 +-
.../rdf/core/serializedform/Serializer.java | 12 +-
.../serializedform/SerializingProvider.java | 8 +-
.../clerezza/rdf/core/sparql/QueryEngine.java | 14 +-
.../clerezza/rdf/core/sparql/ResultSet.java | 2 +-
.../sparql/query/AlternativeGraphPattern.java | 2 +-
.../core/sparql/query/BasicGraphPattern.java | 4 +-
.../clerezza/rdf/core/sparql/query/DataSet.java | 4 +-
.../core/sparql/query/GraphGraphPattern.java | 4 +-
.../rdf/core/sparql/query/GraphPattern.java | 2 +-
.../core/sparql/query/GroupGraphPattern.java | 6 +-
.../core/sparql/query/MinusGraphPattern.java | 4 +-
.../core/sparql/query/OptionalGraphPattern.java | 8 +-
.../query/PathSupportedBasicGraphPattern.java | 4 +-
.../sparql/query/PatternExistenceCondition.java | 6 +-
.../clerezza/rdf/core/sparql/query/Query.java | 6 +-
.../core/sparql/query/ServiceGraphPattern.java | 2 +-
.../query/impl/SimpleGraphGraphPattern.java | 14 +-
.../query/impl/SimpleGroupGraphPattern.java | 12 +-
.../query/impl/SimpleMinusGraphPattern.java | 4 +-
.../query/impl/SimpleOptionalGraphPattern.java | 4 +-
.../query/impl/SimpleServiceGraphPattern.java | 2 +-
.../query/impl/SimpleStringQuerySerializer.java | 2 +-
.../core/sparql/update/impl/AddOperation.java | 4 +-
.../sparql/update/impl/BaseUpdateOperation.java | 10 +-
.../core/sparql/update/impl/LoadOperation.java | 6 +-
.../sparql/update/impl/ModifyOperation.java | 6 +-
.../rdf/core/sparql/update/impl/Quad.java | 8 +-
.../update/impl/UpdateOperationWithQuads.java | 12 +-
.../main/resources/META-INF/documentation.nt | 14 +-
.../clerezza/combined/tutorial/TutorialApp.java | 26 +-
.../clerezza/scb/tutorial1/Tutorial1App.java | 32 +--
rdf.core/src/site/xsite/content/overview.xhtml | 22 +-
.../xsite/content/scb-triaxrs-tutorial.xhtml | 42 +--
.../src/site/xsite/content/tutorial_1.xhtml | 88 +++----
.../clerezza/rdf/core/access/SecurityTest.java | 28 +-
.../clerezza/rdf/core/access/TcManagerTest.java | 62 ++---
.../rdf/core/access/providers/WeightedA.java | 23 +-
.../rdf/core/access/providers/WeightedA1.java | 26 +-
.../core/access/providers/WeightedAHeavy.java | 24 +-
.../core/access/providers/WeightedBlight.java | 32 +--
.../core/access/providers/WeightedDummy.java | 62 ++---
.../rdf/core/events/NotificationTest.java | 6 +-
.../clerezza/rdf/core/impl/SimpleGraphTest.java | 107 ++++++++
.../core/impl/SimpleTripleCollectionTest.java | 107 --------
.../impl/graphmatching/GraphMatcherTest.java | 62 ++---
.../impl/graphmatching/HashMatchingTest.java | 6 +-
.../core/impl/graphmatching/Utils4Testing.java | 6 +-
.../rdf/core/serializedform/ParserTest.java | 6 +-
.../rdf/core/serializedform/SerializerTest.java | 6 +-
.../TestServiceManagedProvider.java | 4 +-
.../rdf/core/sparql/SparqlPreParserTest.java | 48 ++--
87 files changed, 2000 insertions(+), 2022 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/clerezza/blob/9ae0a1bc/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/GraphServiceFactory.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/GraphServiceFactory.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/GraphServiceFactory.java
deleted file mode 100644
index af8a6e0..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/GraphServiceFactory.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.clerezza.rdf.core.access;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.ServiceFactory;
-import org.osgi.framework.ServiceRegistration;
-import org.apache.commons.rdf.TripleCollection;
-import org.apache.commons.rdf.Iri;
-import org.apache.clerezza.rdf.core.access.security.TcAccessController;
-import org.apache.clerezza.rdf.core.impl.SimpleGraph;
-
-/**
- * @see <a href="http://www.osgi.org/javadoc/r4v41/org/osgi/framework/ServiceFactory.html">
- * Interface ServiceFactory</a>
- *
- * @author mir
- */
-public class GraphServiceFactory implements ServiceFactory {
-
- private final TcManager tcManager;
- private final Iri name;
- private final TcAccessController tcAccessController;
-
- GraphServiceFactory(TcManager tcManager, Iri name,
- TcAccessController tcAccessController) {
- this.tcManager = tcManager;
- this.name = name;
- this.tcAccessController = tcAccessController;
- }
-
- @Override
- public Object getService(Bundle arg0, ServiceRegistration arg1) {
- TripleCollection tc =
- new SecuredTripleCollection(tcManager.getGraph(name), name,
- tcAccessController);
- return new SimpleGraph(tc);
- }
-
- @Override
- public void ungetService(Bundle arg0, ServiceRegistration arg1, Object arg2) {
- }
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/9ae0a1bc/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/ImmutableGraphServiceFactory.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/ImmutableGraphServiceFactory.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/ImmutableGraphServiceFactory.java
new file mode 100644
index 0000000..23ba3f2
--- /dev/null
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/ImmutableGraphServiceFactory.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.clerezza.rdf.core.access;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceFactory;
+import org.osgi.framework.ServiceRegistration;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.Iri;
+import org.apache.clerezza.rdf.core.access.security.TcAccessController;
+import org.apache.clerezza.rdf.core.impl.SimpleImmutableGraph;
+
+/**
+ * @see <a href="http://www.osgi.org/javadoc/r4v41/org/osgi/framework/ServiceFactory.html">
+ * Interface ServiceFactory</a>
+ *
+ * @author mir
+ */
+public class ImmutableGraphServiceFactory implements ServiceFactory {
+
+ private final TcManager tcManager;
+ private final Iri name;
+ private final TcAccessController tcAccessController;
+
+ ImmutableGraphServiceFactory(TcManager tcManager, Iri name,
+ TcAccessController tcAccessController) {
+ this.tcManager = tcManager;
+ this.name = name;
+ this.tcAccessController = tcAccessController;
+ }
+
+ @Override
+ public Object getService(Bundle arg0, ServiceRegistration arg1) {
+ Graph tc =
+ new SecuredGraph(tcManager.getGraph(name), name,
+ tcAccessController);
+ return new SimpleImmutableGraph(tc);
+ }
+
+ @Override
+ public void ungetService(Bundle arg0, ServiceRegistration arg1, Object arg2) {
+ }
+}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/9ae0a1bc/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/LockableMGraph.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/LockableMGraph.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/LockableMGraph.java
index ab837a2..64b6fdf 100644
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/LockableMGraph.java
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/LockableMGraph.java
@@ -19,23 +19,23 @@
package org.apache.clerezza.rdf.core.access;
import java.util.concurrent.locks.ReadWriteLock;
-import org.apache.commons.rdf.MGraph;
+import org.apache.commons.rdf.Graph;
/**
*
- * Represents an <code>MGraph</code> that can be locked for reading/writing.
+ * Represents an <code>Graph</code> that can be locked for reading/writing.
*
* @author rbn
*/
-public interface LockableMGraph extends MGraph {
+public interface LockableMGraph extends Graph {
/**
* The lock provided by this methods allows to create read- and write-locks
* that span individual method calls. Having a read locks prevents other
- * threads from writing to this MGraph, having a write-lock prevents other
+ * threads from writing to this Graph, having a write-lock prevents other
* threads from reading and writing.
*
- * @return the lock of this MGraph
+ * @return the lock of this Graph
*/
ReadWriteLock getLock();
}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/9ae0a1bc/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/LockableMGraphWrapper.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/LockableMGraphWrapper.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/LockableMGraphWrapper.java
index c796a48..59d97fa 100644
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/LockableMGraphWrapper.java
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/LockableMGraphWrapper.java
@@ -23,8 +23,8 @@ import java.util.Iterator;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
+import org.apache.commons.rdf.ImmutableGraph;
import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.MGraph;
import org.apache.commons.rdf.BlankNodeOrIri;
import org.apache.commons.rdf.RdfTerm;
import org.apache.commons.rdf.Triple;
@@ -34,7 +34,7 @@ import org.apache.commons.rdf.event.FilterTriple;
import org.apache.commons.rdf.event.GraphListener;
/**
- * Wrappes an MGraph as a LockableMGraph, this class is used by TcManager to
+ * Wrappes an Graph as a LockableMGraph, this class is used by TcManager to
* support TcProviders that do not privide <code>LockableMGraph</code>.
*
* @author rbn
@@ -46,14 +46,14 @@ public class LockableMGraphWrapper implements LockableMGraph {
private final Lock readLock;
private final Lock writeLock;
- private final MGraph wrapped;
+ private final Graph wrapped;
/**
- * Constructs a LocalbleMGraph for an MGraph.
+ * Constructs a LocalbleMGraph for an Graph.
*
- * @param providedMGraph a non-lockable mgraph
+ * @param providedMGraph a non-lockable graph
*/
- public LockableMGraphWrapper(final MGraph providedMGraph) {
+ public LockableMGraphWrapper(final Graph providedMGraph) {
this.wrapped = providedMGraph;
{
String debugMode = System.getProperty(DEBUG_MODE);
@@ -67,7 +67,7 @@ public class LockableMGraphWrapper implements LockableMGraph {
writeLock = lock.writeLock();
}
- public LockableMGraphWrapper(final MGraph providedMGraph, final ReadWriteLock lock) {
+ public LockableMGraphWrapper(final Graph providedMGraph, final ReadWriteLock lock) {
this.wrapped = providedMGraph;
this.lock = lock;
readLock = lock.readLock();
@@ -80,10 +80,10 @@ public class LockableMGraphWrapper implements LockableMGraph {
}
@Override
- public Graph getGraph() {
+ public ImmutableGraph getImmutableGraph() {
readLock.lock();
try {
- return wrapped.getGraph();
+ return wrapped.getImmutableGraph();
} finally {
readLock.unlock();
}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/9ae0a1bc/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/NoSuchEntityException.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/NoSuchEntityException.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/NoSuchEntityException.java
index 1fce6c5..3678d2f 100644
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/NoSuchEntityException.java
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/NoSuchEntityException.java
@@ -22,7 +22,7 @@ import org.apache.commons.rdf.Iri;
/**
* is thrown on an attempt to perform an operation on an entity (i.e. a
- * <code>Graph</code> or <code>MGraph</code> that does not exist.
+ * <code>ImmutableGraph</code> or <code>Graph</code> that does not exist.
*
* @author reto
*/
http://git-wip-us.apache.org/repos/asf/clerezza/blob/9ae0a1bc/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/QueryableTcProvider.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/QueryableTcProvider.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/QueryableTcProvider.java
index d0c8bac..e4e9cc1 100644
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/QueryableTcProvider.java
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/QueryableTcProvider.java
@@ -18,7 +18,7 @@
*/
package org.apache.clerezza.rdf.core.access;
-import org.apache.commons.rdf.TripleCollection;
+import org.apache.commons.rdf.Graph;
import org.apache.commons.rdf.Iri;
import org.apache.clerezza.rdf.core.sparql.query.Query;
@@ -34,9 +34,9 @@ public interface QueryableTcProvider extends TcProvider {
* @param query
* the sparql query to execute
* @param defaultGraph
- * the default graph against which to execute the query if not
+ * the default ImmutableGraph against which to execute the query if not
* FROM clause is present
- * @return the resulting ResultSet, Graph or Boolean value
+ * @return the resulting ResultSet, ImmutableGraph or Boolean value
*/
public Object executeSparqlQuery(String query, Iri defaultGraphUri);
http://git-wip-us.apache.org/repos/asf/clerezza/blob/9ae0a1bc/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/ReadOnlyException.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/ReadOnlyException.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/ReadOnlyException.java
index 9c8db74..4991dc4 100644
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/ReadOnlyException.java
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/ReadOnlyException.java
@@ -22,7 +22,7 @@ import java.security.AccessControlException;
/**
* is thrown on an attempt to add or remove triples to a
- * read-only mutable graph
+ * read-only mutable ImmutableGraph
*
* @author tsuy
*/
@@ -31,12 +31,12 @@ public class ReadOnlyException extends AccessControlException {
private String action;
/**
- * creates an exception indicating that the mutable graph is read-only
+ * creates an exception indicating that the mutable ImmutableGraph is read-only
*
* @param action
*/
public ReadOnlyException(String action) {
- super("read only mutable graph, not allowed to "+action);
+ super("read only mutable ImmutableGraph, not allowed to "+action);
this.action = action;
}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/9ae0a1bc/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/SecuredGraph.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/SecuredGraph.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/SecuredGraph.java
new file mode 100644
index 0000000..3c35497
--- /dev/null
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/SecuredGraph.java
@@ -0,0 +1,185 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.clerezza.rdf.core.access;
+
+import java.util.Collection;
+import java.util.Iterator;
+import org.apache.commons.rdf.BlankNodeOrIri;
+import org.apache.commons.rdf.RdfTerm;
+import org.apache.commons.rdf.Triple;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.Iri;
+import org.apache.clerezza.rdf.core.access.security.TcAccessController;
+import org.apache.clerezza.rdf.core.impl.SimpleImmutableGraph;
+import org.apache.commons.rdf.ImmutableGraph;
+import org.apache.commons.rdf.event.FilterTriple;
+import org.apache.commons.rdf.event.GraphListener;
+
+/**
+ * A Secured triple collection wraps a triple collection checking each access
+ * for the rights on a the ImmutableGraph for which the uri is passed to the
+ * constructor.
+ *
+ * @author mir, hasan
+ */
+public class SecuredGraph implements Graph {
+
+ private final Graph wrapped;
+ private final Iri name;
+ private final TcAccessController tcAccessController;
+
+ public SecuredGraph(Graph wrapped, Iri name,
+ TcAccessController tcAccessController) {
+ this.wrapped = wrapped;
+ this.name = name;
+ this.tcAccessController = tcAccessController;
+ }
+
+ @Override
+ public Iterator<Triple> filter(final BlankNodeOrIri subject, final Iri predicate, final RdfTerm object) {
+ final Iterator<Triple> baseIter = wrapped.filter(subject, predicate, object);
+ return new Iterator<Triple>() {
+
+ @Override
+ public boolean hasNext() {
+ checkRead();
+ return baseIter.hasNext();
+ }
+
+ @Override
+ public Triple next() {
+ checkRead();
+ return baseIter.next();
+ }
+
+ @Override
+ public void remove() {
+ checkWrite();
+ baseIter.remove();
+ }
+ };
+ }
+
+ @Override
+ public int size() {
+ checkRead();
+ return wrapped.size();
+ }
+
+ @Override
+ public boolean isEmpty() {
+ checkRead();
+ return wrapped.isEmpty();
+ }
+
+ @Override
+ public Object[] toArray() {
+ checkRead();
+ return wrapped.toArray();
+ }
+
+ @Override
+ public <T> T[] toArray(T[] a) {
+ checkRead();
+ return wrapped.toArray(a);
+ }
+
+ @Override
+ public boolean add(Triple e) {
+ checkWrite();
+ return wrapped.add(e);
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ checkWrite();
+ return wrapped.remove(o);
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends Triple> c) {
+ checkWrite();
+ return wrapped.addAll(c);
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> c) {
+ checkWrite();
+ return wrapped.removeAll(c);
+ }
+
+ @Override
+ public boolean retainAll(Collection<?> c) {
+ checkWrite();
+ return wrapped.retainAll(c);
+ }
+
+ @Override
+ public void clear() {
+ checkWrite();
+ wrapped.clear();
+ }
+
+ void checkRead() {
+ tcAccessController.checkReadPermission(name);
+ }
+
+ void checkWrite() {
+ tcAccessController.checkReadWritePermission(name);
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ checkRead();
+ return wrapped.contains((Triple) o);
+ }
+
+ @Override
+ public void addGraphListener(GraphListener listener, FilterTriple filter, long delay) {
+ checkRead();
+ wrapped.addGraphListener(listener, filter, delay);
+ }
+
+ @Override
+ public void addGraphListener(GraphListener listener, FilterTriple filter) {
+ checkRead();
+ wrapped.addGraphListener(listener, filter);
+ }
+
+ @Override
+ public void removeGraphListener(GraphListener listener) {
+ wrapped.removeGraphListener(listener);
+ }
+
+ @Override
+ public Iterator<Triple> iterator() {
+ return filter(null, null, null);
+ }
+
+ @Override
+ public boolean containsAll(Collection<?> c) {
+ checkRead();
+ return wrapped.containsAll(c);
+ }
+
+ @Override
+ public ImmutableGraph getImmutableGraph() {
+ return new SimpleImmutableGraph(this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/9ae0a1bc/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/SecuredMGraph.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/SecuredMGraph.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/SecuredMGraph.java
index 6e68eda..77b6d6a 100644
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/SecuredMGraph.java
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/SecuredMGraph.java
@@ -20,20 +20,20 @@ package org.apache.clerezza.rdf.core.access;
import java.security.AccessControlException;
import java.util.concurrent.locks.ReadWriteLock;
-import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.ImmutableGraph;
import org.apache.commons.rdf.Iri;
import org.apache.clerezza.rdf.core.access.security.TcAccessController;
-import org.apache.clerezza.rdf.core.impl.SimpleGraph;
+import org.apache.clerezza.rdf.core.impl.SimpleImmutableGraph;
import org.apache.clerezza.rdf.core.impl.WriteBlockedMGraph;
/**
* A SecuredMGraph is a LockableMGraph that wraps a LockableMGraph checking each
- * access for the rights on a the graph for which the uri is passed to the
+ * access for the rights on a the ImmutableGraph for which the uri is passed to the
* constructor.
*
* @author mir
*/
-public class SecuredMGraph extends SecuredTripleCollection implements LockableMGraph {
+public class SecuredMGraph extends SecuredGraph implements LockableMGraph {
private LockableMGraph wrapped;
@@ -43,10 +43,6 @@ public class SecuredMGraph extends SecuredTripleCollection implements LockableMG
this.wrapped = wrapped;
}
- @Override
- public Graph getGraph() {
- return new SimpleGraph(this);
- }
@Override
public ReadWriteLock getLock() {
http://git-wip-us.apache.org/repos/asf/clerezza/blob/9ae0a1bc/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/SecuredTripleCollection.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/SecuredTripleCollection.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/SecuredTripleCollection.java
deleted file mode 100644
index affd22d..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/SecuredTripleCollection.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.clerezza.rdf.core.access;
-
-import java.util.Collection;
-import java.util.Iterator;
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.TripleCollection;
-import org.apache.commons.rdf.Iri;
-import org.apache.clerezza.rdf.core.access.security.TcAccessController;
-import org.apache.commons.rdf.event.FilterTriple;
-import org.apache.commons.rdf.event.GraphListener;
-
-/**
- * A Secured triple collection wraps a triple collection checking each access
- * for the rights on a the graph for which the uri is passed to the
- * constructor.
- *
- * @author mir, hasan
- */
-public class SecuredTripleCollection implements TripleCollection {
-
- private final TripleCollection wrapped;
- private final Iri name;
- private final TcAccessController tcAccessController;
-
- public SecuredTripleCollection(TripleCollection wrapped, Iri name,
- TcAccessController tcAccessController) {
- this.wrapped = wrapped;
- this.name = name;
- this.tcAccessController = tcAccessController;
- }
-
- @Override
- public Iterator<Triple> filter(final BlankNodeOrIri subject, final Iri predicate, final RdfTerm object) {
- final Iterator<Triple> baseIter = wrapped.filter(subject, predicate, object);
- return new Iterator<Triple>() {
-
- @Override
- public boolean hasNext() {
- checkRead();
- return baseIter.hasNext();
- }
-
- @Override
- public Triple next() {
- checkRead();
- return baseIter.next();
- }
-
- @Override
- public void remove() {
- checkWrite();
- baseIter.remove();
- }
- };
- }
-
- @Override
- public int size() {
- checkRead();
- return wrapped.size();
- }
-
- @Override
- public boolean isEmpty() {
- checkRead();
- return wrapped.isEmpty();
- }
-
- @Override
- public Object[] toArray() {
- checkRead();
- return wrapped.toArray();
- }
-
- @Override
- public <T> T[] toArray(T[] a) {
- checkRead();
- return wrapped.toArray(a);
- }
-
- @Override
- public boolean add(Triple e) {
- checkWrite();
- return wrapped.add(e);
- }
-
- @Override
- public boolean remove(Object o) {
- checkWrite();
- return wrapped.remove(o);
- }
-
- @Override
- public boolean addAll(Collection<? extends Triple> c) {
- checkWrite();
- return wrapped.addAll(c);
- }
-
- @Override
- public boolean removeAll(Collection<?> c) {
- checkWrite();
- return wrapped.removeAll(c);
- }
-
- @Override
- public boolean retainAll(Collection<?> c) {
- checkWrite();
- return wrapped.retainAll(c);
- }
-
- @Override
- public void clear() {
- checkWrite();
- wrapped.clear();
- }
-
- void checkRead() {
- tcAccessController.checkReadPermission(name);
- }
-
- void checkWrite() {
- tcAccessController.checkReadWritePermission(name);
- }
-
- @Override
- public boolean contains(Object o) {
- checkRead();
- return wrapped.contains((Triple) o);
- }
-
- @Override
- public void addGraphListener(GraphListener listener, FilterTriple filter, long delay) {
- checkRead();
- wrapped.addGraphListener(listener, filter, delay);
- }
-
- @Override
- public void addGraphListener(GraphListener listener, FilterTriple filter) {
- checkRead();
- wrapped.addGraphListener(listener, filter);
- }
-
- @Override
- public void removeGraphListener(GraphListener listener) {
- wrapped.removeGraphListener(listener);
- }
-
- @Override
- public Iterator<Triple> iterator() {
- return filter(null, null, null);
- }
-
- @Override
- public boolean containsAll(Collection<?> c) {
- checkRead();
- return wrapped.containsAll(c);
- }
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/9ae0a1bc/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcManager.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcManager.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcManager.java
index 048c5a4..4a977d8 100644
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcManager.java
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcManager.java
@@ -32,14 +32,14 @@ import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
+import org.apache.commons.rdf.ImmutableGraph;
+import org.apache.commons.rdf.Graph;
import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.MGraph;
-import org.apache.commons.rdf.TripleCollection;
import org.apache.commons.rdf.Iri;
import org.apache.clerezza.rdf.core.access.security.TcAccessController;
import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
import org.apache.clerezza.rdf.core.impl.WriteBlockedMGraph;
-import org.apache.clerezza.rdf.core.impl.WriteBlockedTripleCollection;
+import org.apache.clerezza.rdf.core.impl.WriteBlockedGraph;
import org.apache.clerezza.rdf.core.sparql.NoQueryEngineException;
import org.apache.clerezza.rdf.core.sparql.ParseException;
import org.apache.clerezza.rdf.core.sparql.QueryEngine;
@@ -85,34 +85,34 @@ import org.osgi.service.component.annotations.ReferencePolicy;
*
* This class returns
* <code>LockableMGraph</code>s a subtype of
- * <code>MGraph</code> that allows read/write locks.
+ * <code>Graph</code> that allows read/write locks.
*
- * This class also registers all TripleCollections as services with the property
+ * This class also registers all Graphs as services with the property
* 'name' indicating there name.
*
- * Security checks are done when a TripleCollection is retrieved. The returned
- * TripleCollection will do no further security checks. Because of this it
+ * Security checks are done when a Graph is retrieved. The returned
+ * Graph will do no further security checks. Because of this it
* should not be passed to a context where different access control applies. If
- * an MGraph is retrieved without having write permission the returned mGraph
+ * an Graph is retrieved without having write permission the returned graph
* will be read-only.
*
- * If a TripleCollections needs to passed around across different security
+ * If a Graphs needs to passed around across different security
* contexts the one retrieved from the OSGi service whiteboard should be used as
* this performs access control on every access.
*
* @author reto, mir, hasan
*
*/
-//immedia is set to true as this should register the graph services (even if manager service is not required)
+//immedia is set to true as this should register the ImmutableGraph services (even if manager service is not required)
@Component(service = TcManager.class, immediate = true)
@Properties({
@Property(name = TcManager.MGRAPH_CACHE_ENABLED, boolValue = true, description = "Enable caching mgraphs."),
- @Property(name = TcManager.TRIPLECOLLECTION_SERVICES_ENABLED, boolValue = true, description = "Register triple collections as services.") })
+ @Property(name = TcManager.Graph_SERVICES_ENABLED, boolValue = true, description = "Register triple collections as services.") })
public class TcManager extends TcProviderMultiplexer {
public final static String GENERAL_PURPOSE_TC = "general.purpose.tc";
- public final static String TRIPLECOLLECTION_SERVICES_ENABLED = "triplecollection.services.enabled";
- public final static String MGRAPH_CACHE_ENABLED = "mgraph.cache.enabled";
+ public final static String Graph_SERVICES_ENABLED = "Graph.services.enabled";
+ public final static String MGRAPH_CACHE_ENABLED = "graph.cache.enabled";
private static volatile TcManager instance;
private TcAccessController tcAccessController = new TcAccessController() {
@@ -185,7 +185,7 @@ public class TcManager extends TcProviderMultiplexer {
// Read configuration
isTcServicesEnabled = true;
- Object configTcServicesEnabled = componentContext.getProperties().get(TRIPLECOLLECTION_SERVICES_ENABLED);
+ Object configTcServicesEnabled = componentContext.getProperties().get(Graph_SERVICES_ENABLED);
if ( configTcServicesEnabled != null && configTcServicesEnabled instanceof String ) {
isTcServicesEnabled = Boolean.valueOf((String)configTcServicesEnabled);
}
@@ -211,7 +211,7 @@ public class TcManager extends TcProviderMultiplexer {
}
@Override
- public Graph getGraph(Iri name) throws NoSuchEntityException {
+ public ImmutableGraph getGraph(Iri name) throws NoSuchEntityException {
tcAccessController.checkReadPermission(name);
return super.getGraph(name);
}
@@ -228,12 +228,12 @@ public class TcManager extends TcProviderMultiplexer {
}
@Override
- public TripleCollection getTriples(Iri name) {
+ public Graph getTriples(Iri name) {
try {
tcAccessController.checkReadWritePermission(name);
} catch (AccessControlException e) {
tcAccessController.checkReadPermission(name);
- return new WriteBlockedTripleCollection(
+ return new WriteBlockedGraph(
super.getTriples(name));
}
return super.getTriples(name);
@@ -247,20 +247,20 @@ public class TcManager extends TcProviderMultiplexer {
}
@Override
- public Graph createGraph(Iri name, TripleCollection triples) {
+ public ImmutableGraph createGraph(Iri name, Graph triples) {
tcAccessController.checkReadWritePermission(name);
return super.createGraph(name, triples);
}
@Override
- public void deleteTripleCollection(Iri name) {
+ public void deleteGraph(Iri name) {
tcAccessController.checkReadWritePermission(name);
- super.deleteTripleCollection(name);
+ super.deleteGraph(name);
}
@Override
- public Set<Iri> getNames(Graph graph) {
- return super.getNames(graph);
+ public Set<Iri> getNames(ImmutableGraph ImmutableGraph) {
+ return super.getNames(ImmutableGraph);
}
@Override
@@ -276,8 +276,8 @@ public class TcManager extends TcProviderMultiplexer {
}
@Override
- public Set<Iri> listTripleCollections() {
- Set<Iri> result = super.listTripleCollections();
+ public Set<Iri> listImmutableGraphs() {
+ Set<Iri> result = super.listImmutableGraphs();
return excludeNonReadable(result);
}
@@ -304,11 +304,11 @@ public class TcManager extends TcProviderMultiplexer {
* in this TcManages executeSparqlQuery(String, UriRef) should be used instead.
*
* @param query the sparql query to execute
- * @param defaultGraph the default graph against which to execute the query
+ * @param defaultGraph the default ImmutableGraph against which to execute the query
* if no FROM clause is present
- * @return the resulting ResultSet, Graph or Boolean value
+ * @return the resulting ResultSet, ImmutableGraph or Boolean value
*/
- public Object executeSparqlQuery(String query, TripleCollection defaultGraph) throws ParseException {
+ public Object executeSparqlQuery(String query, Graph defaultGraph) throws ParseException {
TcProvider singleTargetTcProvider = null;
final Iri defaultGraphName = new Iri("urn:x-temp:/kjsfadfhfasdffds");
@@ -331,11 +331,11 @@ public class TcManager extends TcProviderMultiplexer {
/**
* Executes any sparql query. The type of the result object will vary
* depending on the type of the query. Note that this method only works for
- * queries that do not need a default graph.
+ * queries that do not need a default ImmutableGraph.
*
* @param query the sparql query to execute
* @param forceFastlane indicate whether to force fastlane usage.
- * @return the resulting ResultSet, Graph or Boolean value
+ * @return the resulting ResultSet, ImmutableGraph or Boolean value
*/
public Object executeSparqlQuery(String query, boolean forceFastlane) throws ParseException {
TcProvider singleTargetTcProvider = null;
@@ -367,8 +367,8 @@ public class TcManager extends TcProviderMultiplexer {
* in this TcManages executeSparqlQuery(String, UriRef) should be used instead.
*
* @param query the sparql query to execute
- * @param defaultGraphName the graph to be used as default graph in the Sparql Graph Store
- * @return the resulting ResultSet, Graph or Boolean value
+ * @param defaultGraphName the ImmutableGraph to be used as default ImmutableGraph in the Sparql ImmutableGraph Store
+ * @return the resulting ResultSet, ImmutableGraph or Boolean value
*/
public Object executeSparqlQuery(String query, Iri defaultGraphName) throws ParseException {
return executeSparqlQuery(query, defaultGraphName, false);
@@ -380,9 +380,9 @@ public class TcManager extends TcProviderMultiplexer {
* in this TcManages executeSparqlQuery(String, UriRef) should be used instead.
*
* @param query the sparql query to execute
- * @param defaultGraph the graph to be used as default graph in the Sparql Graph Store
+ * @param defaultGraph the ImmutableGraph to be used as default ImmutableGraph in the Sparql ImmutableGraph Store
* @param forceFastlane indicate whether to force fastlane usage.
- * @return the resulting ResultSet, Graph or Boolean value
+ * @return the resulting ResultSet, ImmutableGraph or Boolean value
*/
public Object executeSparqlQuery(String query, Iri defaultGraphName, boolean forceFastlane) throws ParseException {
TcProvider singleTargetTcProvider = null;
@@ -411,14 +411,14 @@ public class TcManager extends TcProviderMultiplexer {
* depending on the type of the query.
*
* @param query the sparql query to execute
- * @param defaultGraph the default graph against which to execute the query
+ * @param defaultGraph the default ImmutableGraph against which to execute the query
* if no FROM clause is present
- * @return the resulting ResultSet, Graph or Boolean value
+ * @return the resulting ResultSet, ImmutableGraph or Boolean value
*
* @deprecated Query is discontinued
*/
@Deprecated
- public Object executeSparqlQuery(Query query, TripleCollection defaultGraph) {
+ public Object executeSparqlQuery(Query query, Graph defaultGraph) {
final QueryEngine queryEngine = this.queryEngine;
if (queryEngine != null) {
return queryEngine.execute(this, defaultGraph, query);
@@ -431,14 +431,14 @@ public class TcManager extends TcProviderMultiplexer {
* Executes a sparql SELECT query.
*
* @param query the sparql SELECT query to execute
- * @param defaultGraph the default graph against which to execute the query
+ * @param defaultGraph the default ImmutableGraph against which to execute the query
* if not FROM clause is present
* @return the resulting ResultSet
* @deprecated Query is discontinued
*/
@Deprecated
public ResultSet executeSparqlQuery(SelectQuery query,
- TripleCollection defaultGraph) {
+ Graph defaultGraph) {
return (ResultSet) executeSparqlQuery((Query) query, defaultGraph);
}
@@ -446,14 +446,14 @@ public class TcManager extends TcProviderMultiplexer {
* Executes a sparql ASK query.
*
* @param query the sparql ASK query to execute
- * @param defaultGraph the default graph against which to execute the query
+ * @param defaultGraph the default ImmutableGraph against which to execute the query
* if not FROM clause is present
* @return the boolean value this query evaluates to
* @deprecated Query is discontinued
*/
@Deprecated
public boolean executeSparqlQuery(AskQuery query,
- TripleCollection defaultGraph) {
+ Graph defaultGraph) {
return (Boolean) executeSparqlQuery((Query) query, defaultGraph);
}
@@ -461,30 +461,30 @@ public class TcManager extends TcProviderMultiplexer {
* Executes a sparql DESCRIBE query.
*
* @param query the sparql DESCRIBE query to execute
- * @param defaultGraph the default graph against which to execute the query
+ * @param defaultGraph the default ImmutableGraph against which to execute the query
* if not FROM clause is present
- * @return the resulting Graph
+ * @return the resulting ImmutableGraph
* @deprecated Query is discontinued
*/
@Deprecated
- public Graph executeSparqlQuery(DescribeQuery query,
- TripleCollection defaultGraph) {
- return (Graph) executeSparqlQuery((Query) query, defaultGraph);
+ public ImmutableGraph executeSparqlQuery(DescribeQuery query,
+ Graph defaultGraph) {
+ return (ImmutableGraph) executeSparqlQuery((Query) query, defaultGraph);
}
/**
* Executes a sparql CONSTRUCT query.
*
* @param query the sparql CONSTRUCT query to execute
- * @param defaultGraph the default graph against which to execute the query
+ * @param defaultGraph the default ImmutableGraph against which to execute the query
* if not FROM clause is present
- * @return the resulting Graph
+ * @return the resulting ImmutableGraph
* @deprecated Query is discontinued
*/
@Deprecated
- public Graph executeSparqlQuery(ConstructQuery query,
- TripleCollection defaultGraph) {
- return (Graph) executeSparqlQuery((Query) query, defaultGraph);
+ public ImmutableGraph executeSparqlQuery(ConstructQuery query,
+ Graph defaultGraph) {
+ return (ImmutableGraph) executeSparqlQuery((Query) query, defaultGraph);
}
/**
@@ -562,7 +562,7 @@ public class TcManager extends TcProviderMultiplexer {
// Only create the service when activated. When not activated
// creating will be delayed till after activation.
if (componentContext != null) {
- registerTripleCollectionAsService(name, true);
+ registerGraphAsService(name, true);
}
}
}
@@ -573,25 +573,25 @@ public class TcManager extends TcProviderMultiplexer {
// Only create the service when activated. When not activated
// creating will be delayed till after activation.
if (componentContext != null) {
- registerTripleCollectionAsService(name, false);
+ registerGraphAsService(name, false);
}
}
}
- private void registerTripleCollectionAsService(Iri name, boolean isMGraph) {
+ private void registerGraphAsService(Iri name, boolean isMGraph) {
Dictionary<String,Object> props = new Hashtable<String, Object>();
props.put("name", name.getUnicodeString());
String[] interfaceNames;
Object service;
if (isMGraph) {
interfaceNames = new String[]{
- MGraph.class.getName(),
+ Graph.class.getName(),
LockableMGraph.class.getName()
};
service = new MGraphServiceFactory(this, name, tcAccessController);
} else {
- interfaceNames = new String[]{Graph.class.getName()};
- service = new GraphServiceFactory(this, name, tcAccessController);
+ interfaceNames = new String[]{ImmutableGraph.class.getName()};
+ service = new ImmutableGraphServiceFactory(this, name, tcAccessController);
}
final int bundleState = componentContext.getBundleContext().getBundle().getState();
if ((bundleState == Bundle.ACTIVE) || (bundleState == Bundle.STARTING)) {
@@ -613,13 +613,13 @@ public class TcManager extends TcProviderMultiplexer {
private TcProvider getSingleTargetTcProvider(final Set<Iri> referencedGraphs) {
TcProvider singleTargetTcProvider = null;
for (WeightedTcProvider provider : providerList) {
- final Set<Iri> providerTripleCollections = provider.listTripleCollections();
- if (providerTripleCollections.containsAll(referencedGraphs)) {
+ final Set<Iri> providerGraphs = provider.listGraphs();
+ if (providerGraphs.containsAll(referencedGraphs)) {
singleTargetTcProvider = provider;
break; //success
}
for (Iri graphName : referencedGraphs) {
- if (providerTripleCollections.contains(graphName)) {
+ if (providerGraphs.contains(graphName)) {
break; //failure
}
}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/9ae0a1bc/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcProvider.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcProvider.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcProvider.java
index 003d2fa..6a97ff7 100644
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcProvider.java
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcProvider.java
@@ -20,133 +20,133 @@ package org.apache.clerezza.rdf.core.access;
import java.util.Set;
+import org.apache.commons.rdf.ImmutableGraph;
+import org.apache.commons.rdf.Graph;
import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.MGraph;
-import org.apache.commons.rdf.TripleCollection;
import org.apache.commons.rdf.Iri;
/**
- * A TC (TripleCollection) Provider allows access to and optionally
- * creation of named {@link Graph}s and {@link MGraph}s (mutable graphs)
+ * A TC (Graph) Provider allows access to and optionally
+ * creation of named {@link ImmutableGraph}s and {@link Graph}s (mutable graphs)
*
* @author reto
*/
public interface TcProvider {
/**
- * Get a <code>Graph</code> by its name
+ * Get a <code>ImmutableGraph</code> by its name
*
- * @param name the name of the Graph
- * @return the <code>Graph</code> with the specified name
- * @throws NoSuchEntityException if there is no <code>Graph</code>
+ * @param name the name of the ImmutableGraph
+ * @return the <code>ImmutableGraph</code> with the specified name
+ * @throws NoSuchEntityException if there is no <code>ImmutableGraph</code>
* with the specified name
*/
- Graph getGraph(Iri name) throws NoSuchEntityException;
+ ImmutableGraph getGraph(Iri name) throws NoSuchEntityException;
/**
- * Get an <code>MGraph</code> by its name. The instances
+ * Get an <code>Graph</code> by its name. The instances
* returned in different invocations are <code>equals</code>.
*
- * @param the name of the <code>MGraph</code>
- * @return name the <code>MGraph</code> with the specified name
- * @throws NoSuchEntityException if there is no <code>MGraph</code>
+ * @param the name of the <code>Graph</code>
+ * @return name the <code>Graph</code> with the specified name
+ * @throws NoSuchEntityException if there is no <code>Graph</code>
* with the specified name
*/
- MGraph getMGraph(Iri name) throws NoSuchEntityException;
+ Graph getMGraph(Iri name) throws NoSuchEntityException;
/**
- * This method is used to get a <code>TripleCollection</code> indifferently
- * whether it's a Graph or an MGraph. If the <code>name</code> names an
- * <code>MGraph</code> the result is the same as when invoking
+ * This method is used to get a <code>Graph</code> indifferently
+ * whether it's a ImmutableGraph or an Graph. If the <code>name</code> names an
+ * <code>Graph</code> the result is the same as when invoking
* <code>getMGraph</code> with that argument, analogously for
- * <code>Graph</code>S the method returns an instance equals to what
+ * <code>ImmutableGraph</code>S the method returns an instance equals to what
* <code>getGraph</code> would return.
*
- * @param name the name of the <Code>Graph</code> or <code>MGraph</code>
- * @return the <Code>Graph</code> or <code>MGraph</code>
- * @throws NoSuchEntityException if there is no <code>Graph</code>
- * or <code>MGraph</code> with the specified name
+ * @param name the name of the <Code>ImmutableGraph</code> or <code>Graph</code>
+ * @return the <Code>ImmutableGraph</code> or <code>Graph</code>
+ * @throws NoSuchEntityException if there is no <code>ImmutableGraph</code>
+ * or <code>Graph</code> with the specified name
*/
- TripleCollection getTriples(Iri name) throws NoSuchEntityException;
+ Graph getTriples(Iri name) throws NoSuchEntityException;
/**
- * Lists the name of the <Code>Graph</code>s available through this
+ * Lists the name of the <Code>ImmutableGraph</code>s available through this
* <code>TcProvider</code>, implementations may take into account the
- * security context and omit <Code>Graph</code>s for which access is not
+ * security context and omit <Code>ImmutableGraph</code>s for which access is not
* allowed.
*
- * @return the list of <Code>Graph</code>s
+ * @return the list of <Code>ImmutableGraph</code>s
*/
- Set<Iri> listGraphs();
+ Set<Iri> listImmutableGraphs();
/**
- * Lists the name of the <Code>MGraph</code>s available through this
+ * Lists the name of the <Code>Graph</code>s available through this
* <code>TcProvider</code>, implementations may take into account the
- * security context and omit <Code>MGraph</code>s for which access is not
+ * security context and omit <Code>Graph</code>s for which access is not
* allowed.
*
- * @return the list of <Code>MGraph</code>s
+ * @return the list of <Code>Graph</code>s
*/
Set<Iri> listMGraphs();
/**
- * Lists the name of the <Code>TripleCollection</code>s available through this
+ * Lists the name of the <Code>Graph</code>s available through this
* <code>TcProvider</code> indifferently whether they are Graphs or an
* MGraphs, implementations may take into account the security context and
- * omit <Code>TripleCollection</code>s for which access is not allowed.
+ * omit <Code>Graph</code>s for which access is not allowed.
*
- * @return the list of <Code>TripleCollection</code>s
+ * @return the list of <Code>Graph</code>s
*/
- Set<Iri> listTripleCollections();
+ Set<Iri> listGraphs();
/**
- * Creates an initially empty <code>MGraph</code> with a specified name
+ * Creates an initially empty <code>Graph</code> with a specified name
*
- * @param name names the new <code>MGraph</code>
- * @return the newly created <code>MGraph</code>
+ * @param name names the new <code>Graph</code>
+ * @return the newly created <code>Graph</code>
* @throws UnsupportedOperationException if this provider doesn't support
- * creating <code>MGraph</code>S
- * @throws EntityAlreadyExistsException if an MGraph with the specified name
+ * creating <code>Graph</code>S
+ * @throws EntityAlreadyExistsException if an Graph with the specified name
* already exists
*/
- MGraph createMGraph(Iri name) throws UnsupportedOperationException,
+ Graph createMGraph(Iri name) throws UnsupportedOperationException,
EntityAlreadyExistsException;
/**
- * Creates a <code>Graph</code> with a specified name
+ * Creates a <code>ImmutableGraph</code> with a specified name
*
- * @param name the name of the <code>Graph</code> to be created
- * @param triples the triples of the new <code>Graph</code>
- * @return the newly created <code>Graph</code>
+ * @param name the name of the <code>ImmutableGraph</code> to be created
+ * @param triples the triples of the new <code>ImmutableGraph</code>
+ * @return the newly created <code>ImmutableGraph</code>
* @throws UnsupportedOperationException if this provider doesn't support
- * creating <code>Graph</code>S
- * @throws EntityAlreadyExistsException if a Graph with the specified name
+ * creating <code>ImmutableGraph</code>S
+ * @throws EntityAlreadyExistsException if a ImmutableGraph with the specified name
* already exists
*/
- Graph createGraph(Iri name, TripleCollection triples)
+ ImmutableGraph createGraph(Iri name, Graph triples)
throws UnsupportedOperationException, EntityAlreadyExistsException;
/**
- * Deletes the <code>Graph</code> or <code>MGraph</code> of a specified name.
- * If <code>name</code> references a Graph and the graph has other names, it
+ * Deletes the <code>ImmutableGraph</code> or <code>Graph</code> of a specified name.
+ * If <code>name</code> references a ImmutableGraph and the ImmutableGraph has other names, it
* will still be available with those other names.
*
* @param name the entity to be removed
* @throws UnsupportedOperationException if this provider doesn't support
* entities deletion.
* @throws NoSuchEntityException if <code>name</code> doesn't refer to a
- * <code>Graph</code> or an <code>MGraph</code>.
- * @throws EntityUndeletableException if the specified Graph is undeletable
+ * <code>ImmutableGraph</code> or an <code>Graph</code>.
+ * @throws EntityUndeletableException if the specified ImmutableGraph is undeletable
*/
- void deleteTripleCollection(Iri name) throws UnsupportedOperationException,
+ void deleteGraph(Iri name) throws UnsupportedOperationException,
NoSuchEntityException, EntityUndeletableException;
/**
- * get a set of the names of a <code>Graph</code>
+ * get a set of the names of a <code>ImmutableGraph</code>
*
- * @param graph
- * @return the set names of <code>Graph</code>, the set is empty if
- * <code>Graph</code> is unknown
+ * @param ImmutableGraph
+ * @return the set names of <code>ImmutableGraph</code>, the set is empty if
+ * <code>ImmutableGraph</code> is unknown
*/
- Set<Iri> getNames(Graph graph);
+ Set<Iri> getNames(ImmutableGraph ImmutableGraph);
}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/9ae0a1bc/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcProviderMultiplexer.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcProviderMultiplexer.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcProviderMultiplexer.java
index de15f2b..a8e4da6 100644
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcProviderMultiplexer.java
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcProviderMultiplexer.java
@@ -30,9 +30,9 @@ import java.util.SortedSet;
import java.util.TreeSet;
+import org.apache.commons.rdf.ImmutableGraph;
+import org.apache.commons.rdf.Graph;
import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.MGraph;
-import org.apache.commons.rdf.TripleCollection;
import org.apache.commons.rdf.Iri;
import org.apache.clerezza.rdf.core.sparql.QueryEngine;
@@ -85,7 +85,7 @@ public class TcProviderMultiplexer implements TcProvider {
/**
* subclasses overwrite this method to be notified when a new
- * Graph is available (either because it has been created or being
+ * ImmutableGraph is available (either because it has been created or being
* provided by a newly added WeightedTcProvider). The default implementation
* does nothing.
*
@@ -96,7 +96,7 @@ public class TcProviderMultiplexer implements TcProvider {
/**
* subclasses overwrite this method to be notified when a new
- * MGraph is available (either because it has been created or being
+ * Graph is available (either because it has been created or being
* provided by a newly added WeightedTcProvider). The default implementation
* does nothing.
*
@@ -106,11 +106,11 @@ public class TcProviderMultiplexer implements TcProvider {
}
/**
- * subclasses overwrite this method to be notified whenTripleCollection is
+ * subclasses overwrite this method to be notified whenGraph is
* no longer available (either because it has been deleted or bacause its
* WeightedTcProvider was removed). The default implementation does nothing.
*
- * for implementational reasons even for name of TripleCollection not
+ * for implementational reasons even for name of Graph not
* previously registered.
*
* @param name
@@ -135,7 +135,7 @@ public class TcProviderMultiplexer implements TcProvider {
*/
private void updateLockableMGraphCache(WeightedTcProvider provider,
boolean providerAdded) {
- Set<Iri> uriSet = provider.listTripleCollections();
+ Set<Iri> uriSet = provider.listGraphs();
if (!(uriSet == null || uriSet.isEmpty())) {
if (providerAdded) {
weightedProviderAdded(provider, uriSet);
@@ -159,9 +159,9 @@ public class TcProviderMultiplexer implements TcProvider {
continue;
}
}
- TripleCollection triples = newProvider.getTriples(name);
- if (triples instanceof MGraph) {
- mGraphCache.put(name, new MGraphHolder(newProvider, ensureLockable((MGraph)triples)));
+ Graph triples = newProvider.getTriples(name);
+ if (triples instanceof Graph) {
+ mGraphCache.put(name, new MGraphHolder(newProvider, ensureLockable((Graph)triples)));
mGraphAppears(name);
} else {
graphAppears(name);
@@ -196,13 +196,13 @@ public class TcProviderMultiplexer implements TcProvider {
mGraphCache.remove(name);
if (isCachingEnabled()) {
- // check if another WeightedTcProvider has the TripleCollection.
+ // check if another WeightedTcProvider has the Graph.
// And if so register as service.
for (WeightedTcProvider provider : providerList) {
try {
- TripleCollection triples = provider.getTriples(name);
- if (triples instanceof MGraph) {
- mGraphCache.put(name, new MGraphHolder(provider, ensureLockable((MGraph)triples)));
+ Graph triples = provider.getTriples(name);
+ if (triples instanceof Graph) {
+ mGraphCache.put(name, new MGraphHolder(provider, ensureLockable((Graph)triples)));
mGraphAppears(name);
} else {
graphAppears(name);
@@ -218,7 +218,7 @@ public class TcProviderMultiplexer implements TcProvider {
}
@Override
- public Graph getGraph(Iri name) throws NoSuchEntityException {
+ public ImmutableGraph getGraph(Iri name) throws NoSuchEntityException {
for (TcProvider provider : providerList) {
try {
return provider.getGraph(name);
@@ -258,7 +258,7 @@ public class TcProviderMultiplexer implements TcProvider {
throws NoSuchEntityException {
for (WeightedTcProvider provider : providerList) {
try {
- MGraph providedMGraph = provider.getMGraph(name);
+ Graph providedMGraph = provider.getMGraph(name);
LockableMGraph result = ensureLockable(providedMGraph);
if (isCachingEnabled()) {
@@ -276,16 +276,16 @@ public class TcProviderMultiplexer implements TcProvider {
}
@Override
- public TripleCollection getTriples(Iri name)
+ public Graph getTriples(Iri name)
throws NoSuchEntityException {
- TripleCollection result;
+ Graph result;
for (WeightedTcProvider provider : providerList) {
try {
result = provider.getTriples(name);
- if (!(result instanceof MGraph)) {
+ if (!(result instanceof Graph)) {
return result;
} else {
- // This is to ensure the MGraph gets added to the cache
+ // This is to ensure the Graph gets added to the cache
return getMGraph(name);
}
} catch (NoSuchEntityException e) {
@@ -303,7 +303,7 @@ public class TcProviderMultiplexer implements TcProvider {
for (WeightedTcProvider provider : providerList) {
try {
- MGraph providedMGraph = provider.createMGraph(name);
+ Graph providedMGraph = provider.createMGraph(name);
LockableMGraph result;
if (providedMGraph instanceof LockableMGraph) {
result = (LockableMGraph) providedMGraph;
@@ -311,7 +311,7 @@ public class TcProviderMultiplexer implements TcProvider {
result = new LockableMGraphWrapper(providedMGraph);
}
- // unregisters a possible Graph or MGraph service under this name
+ // unregisters a possible ImmutableGraph or Graph service under this name
// provided by a WeightedTcProvider with a lower weight.
tcDisappears(name);
if (isCachingEnabled()) {
@@ -326,16 +326,16 @@ public class TcProviderMultiplexer implements TcProvider {
}
}
throw new UnsupportedOperationException(
- "No provider could create MGraph.");
+ "No provider could create Graph.");
}
@Override
- public Graph createGraph(Iri name, TripleCollection triples) {
+ public ImmutableGraph createGraph(Iri name, Graph triples) {
for (WeightedTcProvider provider : providerList) {
try {
- Graph result = provider.createGraph(name, triples);
+ ImmutableGraph result = provider.createGraph(name, triples);
- // unregisters a possible Graph or MGraph service under this name
+ // unregisters a possible ImmutableGraph or Graph service under this name
// provided by a WeightedTcProvider with a lower weight.
tcDisappears(name);
if (isCachingEnabled()) {
@@ -350,14 +350,14 @@ public class TcProviderMultiplexer implements TcProvider {
}
}
throw new UnsupportedOperationException(
- "No provider could create Graph.");
+ "No provider could create ImmutableGraph.");
}
@Override
- public void deleteTripleCollection(Iri name) {
+ public void deleteGraph(Iri name) {
for (TcProvider provider : providerList) {
try {
- provider.deleteTripleCollection(name);
+ provider.deleteGraph(name);
final MGraphHolder holder = mGraphCache.get(name);
if ((holder != null)
&& (holder.getWeightedTcProvider() != null)
@@ -374,7 +374,7 @@ public class TcProviderMultiplexer implements TcProvider {
//we do nothing and try our luck with the next provider
}
}
- // this throws a NoSuchEntityException if the graph doesn't exist
+ // this throws a NoSuchEntityException if the ImmutableGraph doesn't exist
getTriples(name);
// the entity exists but cannot be deleted
throw new UnsupportedOperationException(
@@ -382,10 +382,10 @@ public class TcProviderMultiplexer implements TcProvider {
}
@Override
- public Set<Iri> getNames(Graph graph) {
+ public Set<Iri> getNames(ImmutableGraph ImmutableGraph) {
Set<Iri> result = new HashSet<Iri>();
for (TcProvider provider : providerList) {
- result.addAll(provider.getNames(graph));
+ result.addAll(provider.getNames(ImmutableGraph));
}
return result;
}
@@ -409,15 +409,15 @@ public class TcProviderMultiplexer implements TcProvider {
}
@Override
- public Set<Iri> listTripleCollections() {
+ public Set<Iri> listImmutableGraphs() {
Set<Iri> result = new HashSet<Iri>();
for (TcProvider provider : providerList) {
- result.addAll(provider.listTripleCollections());
+ result.addAll(provider.listImmutableGraphs());
}
return result;
}
- private LockableMGraph ensureLockable(MGraph providedMGraph) {
+ private LockableMGraph ensureLockable(Graph providedMGraph) {
LockableMGraph result;
if (providedMGraph instanceof LockableMGraph) {
result = (LockableMGraph) providedMGraph;
@@ -429,16 +429,16 @@ public class TcProviderMultiplexer implements TcProvider {
/**
* Contains an unsecured LockableMGraph, a ServiceRegistration and
- * the WeightedTcProvider that generated the graph
+ * the WeightedTcProvider that generated the ImmutableGraph
*/
private static class MGraphHolder {
private WeightedTcProvider tcProvider;
private WeakReference<LockableMGraph> mGraphReference;
- MGraphHolder(WeightedTcProvider tcProvider, LockableMGraph mGraph) {
+ MGraphHolder(WeightedTcProvider tcProvider, LockableMGraph graph) {
this.tcProvider = tcProvider;
- this.mGraphReference = new WeakReference<LockableMGraph>(mGraph);
+ this.mGraphReference = new WeakReference<LockableMGraph>(graph);
}
LockableMGraph getMGraph() {
http://git-wip-us.apache.org/repos/asf/clerezza/blob/9ae0a1bc/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/package.html
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/package.html b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/package.html
index e501483..8098e02 100644
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/package.html
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/package.html
@@ -27,8 +27,8 @@
</head>
<body>
<p>This package provides access to named {@link
- org.apache.clerezza.rdf.model.Graph}S and {@link
- org.apache.clerezza.rdf.model.MGraph}S that may originate from various
+ org.apache.clerezza.rdf.model.ImmutableGraph}S and {@link
+ org.apache.clerezza.rdf.model.Graph}S that may originate from various
implementations.</p>
<h3>Accessing</h3>
<p>
http://git-wip-us.apache.org/repos/asf/clerezza/blob/9ae0a1bc/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/security/TcAccessController.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/security/TcAccessController.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/security/TcAccessController.java
index 3e046a0..405cfbd 100644
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/security/TcAccessController.java
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/security/TcAccessController.java
@@ -49,8 +49,8 @@ import org.apache.commons.rdf.Literal;
* <code>TcManager</code>.
*
* Clients with a ConfigureTcAcessPermission can set the permissions required to
- * access a TripleCollection. These permissions are stored persistently in an
- * MGraph named urn:x-localinstance:/graph-access.graph
+ * access a Graph. These permissions are stored persistently in an
+ * Graph named urn:x-localinstance:/ImmutableGraph-access.ImmutableGraph
*
* Clients should get an instance from TcManager.getTcAccessController()
*
@@ -59,7 +59,7 @@ import org.apache.commons.rdf.Literal;
public abstract class TcAccessController {
private final TcManager tcManager;
- private final Iri permissionGraphName = new Iri("urn:x-localinstance:/graph-access.graph");
+ private final Iri permissionGraphName = new Iri("urn:x-localinstance:/ImmutableGraph-access.ImmutableGraph");
//we can't rely on ontology plugin in rdf core
private String ontologyNamespace = "http://clerezza.apache.org/2010/07/10/graphpermssions#";
private final Iri readPermissionListProperty = new Iri(ontologyNamespace + "readPermissionList");
@@ -80,14 +80,14 @@ public abstract class TcAccessController {
/**
*
- * @param tcManager the tcManager used to locate urn:x-localinstance:/graph-access.graph
+ * @param tcManager the tcManager used to locate urn:x-localinstance:/ImmutableGraph-access.ImmutableGraph
*/
public TcAccessController() {
this.tcManager = getTcManager();
}
- public void checkReadPermission(Iri tripleCollectionUri) {
- if (tripleCollectionUri.equals(permissionGraphName)) {
+ public void checkReadPermission(Iri GraphUri) {
+ if (GraphUri.equals(permissionGraphName)) {
//This is world readable, as this prevents as from doingf things as
//priviledged during verfification
return;
@@ -98,38 +98,38 @@ public abstract class TcAccessController {
try {
AccessController.checkPermission(new AllPermission());
} catch (AccessControlException e) {
- Collection<Permission> perms = getRequiredReadPermissions(tripleCollectionUri);
+ Collection<Permission> perms = getRequiredReadPermissions(GraphUri);
if (perms.size() > 0) {
for (Permission permission : perms) {
AccessController.checkPermission(permission);
}
} else {
AccessController.checkPermission(new TcPermission(
- tripleCollectionUri.getUnicodeString(), TcPermission.READ));
+ GraphUri.getUnicodeString(), TcPermission.READ));
}
}
}
}
- public void checkReadWritePermission(Iri tripleCollectionUri) {
+ public void checkReadWritePermission(Iri GraphUri) {
SecurityManager security = System.getSecurityManager();
if (security != null) {
//will AllPermissions the rest is obsolete
try {
AccessController.checkPermission(new AllPermission());
} catch (AccessControlException e) {
- if (tripleCollectionUri.equals(permissionGraphName)) {
+ if (GraphUri.equals(permissionGraphName)) {
AccessController.checkPermission(new TcPermission(
- tripleCollectionUri.getUnicodeString(), TcPermission.READWRITE));
+ GraphUri.getUnicodeString(), TcPermission.READWRITE));
} else {
- Collection<Permission> perms = getRequiredReadWritePermissions(tripleCollectionUri);
+ Collection<Permission> perms = getRequiredReadWritePermissions(GraphUri);
if (perms.size() > 0) {
for (Permission permission : perms) {
AccessController.checkPermission(permission);
}
} else {
AccessController.checkPermission(new TcPermission(
- tripleCollectionUri.getUnicodeString(), TcPermission.READWRITE));
+ GraphUri.getUnicodeString(), TcPermission.READWRITE));
}
}
}
@@ -140,19 +140,19 @@ public abstract class TcAccessController {
* Set the set of permissions required for read access to a triple-collection, if
* the set is non-empty the default TCPermisson is no longer required.
*
- * @param tripleCollectionUri
+ * @param GraphUri
* @param permissionDescriptions
*/
- public void setRequiredReadPermissionStrings(Iri tripleCollectionUri,
+ public void setRequiredReadPermissionStrings(Iri GraphUri,
Collection<String> permissionDescriptions) {
- readPermissionCache.remove(tripleCollectionUri);
+ readPermissionCache.remove(GraphUri);
final LockableMGraph permissionMGraph = getOrCreatePermisionGraph();
Lock l = permissionMGraph.getLock().writeLock();
l.lock();
try {
- removeExistingRequiredReadPermissions(tripleCollectionUri, permissionMGraph);
+ removeExistingRequiredReadPermissions(GraphUri, permissionMGraph);
final BlankNodeOrIri permissionList = createList(permissionDescriptions.iterator(), permissionMGraph);
- permissionMGraph.add(new TripleImpl(tripleCollectionUri,
+ permissionMGraph.add(new TripleImpl(GraphUri,
readPermissionListProperty, permissionList));
} finally {
l.unlock();
@@ -163,16 +163,16 @@ public abstract class TcAccessController {
* Set the set of permissions required for read access to a triple-collection, if
* the set is non-empty the default TCPermisson is no longer required.
*
- * @param tripleCollectionUri
+ * @param GraphUri
* @param permissionDescriptions
*/
- public void setRequiredReadPermissions(Iri tripleCollectionUri,
+ public void setRequiredReadPermissions(Iri GraphUri,
Collection<Permission> permissions) {
Collection<String> permissionStrings = new ArrayList<String>();
for (Permission permission : permissions) {
permissionStrings.add(permission.toString());
}
- setRequiredReadPermissionStrings(tripleCollectionUri, permissionStrings);
+ setRequiredReadPermissionStrings(GraphUri, permissionStrings);
}
/**
@@ -180,19 +180,19 @@ public abstract class TcAccessController {
* triple-collection, if
* the set is non-empty the default TCPermisson is no longer required.
*
- * @param tripleCollectionUri
+ * @param GraphUri
* @param permissionDescriptions
*/
- public void setRequiredReadWritePermissionStrings(Iri tripleCollectionUri,
+ public void setRequiredReadWritePermissionStrings(Iri GraphUri,
Collection<String> permissionDescriptions) {
- readWritePermissionCache.remove(tripleCollectionUri);
+ readWritePermissionCache.remove(GraphUri);
final LockableMGraph permissionMGraph = getOrCreatePermisionGraph();
Lock l = permissionMGraph.getLock().writeLock();
l.lock();
try {
- removeExistingRequiredReadPermissions(tripleCollectionUri, permissionMGraph);
+ removeExistingRequiredReadPermissions(GraphUri, permissionMGraph);
final BlankNodeOrIri permissionList = createList(permissionDescriptions.iterator(), permissionMGraph);
- permissionMGraph.add(new TripleImpl(tripleCollectionUri,
+ permissionMGraph.add(new TripleImpl(GraphUri,
readWritePermissionListProperty, permissionList));
} finally {
l.unlock();
@@ -204,16 +204,16 @@ public abstract class TcAccessController {
* triple-collection, if
* the set is non-empty the default TCPermisson is no longer required.
*
- * @param tripleCollectionUri
+ * @param GraphUri
* @param permissionDescriptions
*/
- public void setRequiredReadWritePermissions(Iri tripleCollectionUri,
+ public void setRequiredReadWritePermissions(Iri GraphUri,
Collection<Permission> permissions) {
Collection<String> permissionStrings = new ArrayList<String>();
for (Permission permission : permissions) {
permissionStrings.add(permission.toString());
}
- setRequiredReadWritePermissionStrings(tripleCollectionUri, permissionStrings);
+ setRequiredReadWritePermissionStrings(GraphUri, permissionStrings);
}
/**
@@ -221,18 +221,18 @@ public abstract class TcAccessController {
* triple-collection, the set may be empty meaning that the default
* TCPermission is required.
*
- * @param tripleCollectionUri
+ * @param GraphUri
* @return the collection of permissions
*/
- public Collection<Permission> getRequiredReadPermissions(Iri tripleCollectionUri) {
- Collection<Permission> result = readPermissionCache.get(tripleCollectionUri);
+ public Collection<Permission> getRequiredReadPermissions(Iri GraphUri) {
+ Collection<Permission> result = readPermissionCache.get(GraphUri);
if (result == null) {
result = new ArrayList<Permission>();
- Collection<String> permissionStrings = getRequiredReadPermissionStrings(tripleCollectionUri);
+ Collection<String> permissionStrings = getRequiredReadPermissionStrings(GraphUri);
for (String string : permissionStrings) {
result.add(PermissionParser.getPermission(string, getClass().getClassLoader()));
}
- readPermissionCache.put(tripleCollectionUri, result);
+ readPermissionCache.put(GraphUri, result);
}
return result;
}
@@ -242,18 +242,18 @@ public abstract class TcAccessController {
* triple-collection, the set may be empty meaning that the default
* TCPermission is required.
*
- * @param tripleCollectionUri
+ * @param GraphUri
* @return the collection of permissions
*/
- public Collection<Permission> getRequiredReadWritePermissions(Iri tripleCollectionUri) {
- Collection<Permission> result = readWritePermissionCache.get(tripleCollectionUri);
+ public Collection<Permission> getRequiredReadWritePermissions(Iri GraphUri) {
+ Collection<Permission> result = readWritePermissionCache.get(GraphUri);
if (result == null) {
result = new ArrayList<Permission>();
- Collection<String> permissionStrings = getRequiredReadWritePermissionStrings(tripleCollectionUri);
+ Collection<String> permissionStrings = getRequiredReadWritePermissionStrings(GraphUri);
for (String string : permissionStrings) {
result.add(PermissionParser.getPermission(string, getClass().getClassLoader()));
}
- readWritePermissionCache.put(tripleCollectionUri, result);
+ readWritePermissionCache.put(GraphUri, result);
}
return result;
}
@@ -272,10 +272,10 @@ public abstract class TcAccessController {
}
//called withiong write-lock
- private void removeExistingRequiredReadPermissions(Iri tripleCollectionUri,
+ private void removeExistingRequiredReadPermissions(Iri GraphUri,
LockableMGraph permissionMGraph) {
try {
- Triple t = permissionMGraph.filter(tripleCollectionUri, readPermissionListProperty, null).next();
+ Triple t = permissionMGraph.filter(GraphUri, readPermissionListProperty, null).next();
RdfTerm list = t.getObject();
removeList((BlankNodeOrIri) list, permissionMGraph);
permissionMGraph.remove(t);
@@ -298,19 +298,19 @@ public abstract class TcAccessController {
}
}
- private Collection<String> getRequiredReadWritePermissionStrings(final Iri tripleCollectionUri) {
- return getRequiredPermissionStrings(tripleCollectionUri, readWritePermissionListProperty);
+ private Collection<String> getRequiredReadWritePermissionStrings(final Iri GraphUri) {
+ return getRequiredPermissionStrings(GraphUri, readWritePermissionListProperty);
}
- private Collection<String> getRequiredReadPermissionStrings(final Iri tripleCollectionUri) {
- return getRequiredPermissionStrings(tripleCollectionUri, readPermissionListProperty);
+ private Collection<String> getRequiredReadPermissionStrings(final Iri GraphUri) {
+ return getRequiredPermissionStrings(GraphUri, readPermissionListProperty);
}
- private Collection<String> getRequiredPermissionStrings(final Iri tripleCollectionUri, Iri property) {
+ private Collection<String> getRequiredPermissionStrings(final Iri GraphUri, Iri property) {
try {
final LockableMGraph permissionMGraph = tcManager.getMGraph(permissionGraphName);
Lock l = permissionMGraph.getLock().readLock();
l.lock();
try {
- Triple t = permissionMGraph.filter(tripleCollectionUri, property, null).next();
+ Triple t = permissionMGraph.filter(GraphUri, property, null).next();
BlankNodeOrIri list = (BlankNodeOrIri) t.getObject();
LinkedList<String> result = new LinkedList<String>();
readList(list, permissionMGraph, result);
http://git-wip-us.apache.org/repos/asf/clerezza/blob/9ae0a1bc/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/security/TcPermission.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/security/TcPermission.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/security/TcPermission.java
index d93d1f0..1f16972 100644
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/security/TcPermission.java
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/security/TcPermission.java
@@ -25,10 +25,10 @@ import java.util.Set;
import java.util.regex.Pattern;
/**
- * A permission to access <code>TripleCollection<code>s matching a specified
+ * A permission to access <code>Graph<code>s matching a specified
* name pattern. A pattern is matched if and only if the pattern is equals
- * to name of the <code>TripleCollection<code> or the pattern ends with "/*" and
- * the name of the <code>TripleCollection<code> starts with the characters
+ * to name of the <code>Graph<code> or the pattern ends with "/*" and
+ * the name of the <code>Graph<code> starts with the characters
* preceding the '*' in the pattern.
*
* @author reto, tsuy