pnever 2004/01/09 10:44:30
Modified: src/share/org/apache/slide/store ResourceId.java
Log:
Added parseUuri() to determine the actual store
Revision Changes Path
1.2 +54 -5 jakarta-slide/src/share/org/apache/slide/store/ResourceId.java
Index: ResourceId.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/store/ResourceId.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ResourceId.java 27 Dec 2003 14:54:37 -0000 1.1
+++ ResourceId.java 9 Jan 2004 18:44:30 -0000 1.2
@@ -66,6 +66,10 @@
import java.util.Enumeration;
import org.apache.slide.common.Namespace;
import org.apache.slide.common.Scope;
+import org.apache.slide.common.ScopeTokenizer;
+import org.apache.slide.common.ServiceAccessException;
+import org.apache.slide.common.ServiceConnectionFailedException;
+import org.apache.slide.common.ServiceMissingOnRootNodeException;
import org.apache.slide.common.SlideToken;
import org.apache.slide.common.Uri;
import org.apache.slide.common.UriPath;
@@ -151,6 +155,7 @@
private ResourceId(Uri uri, String uuri) {
super(uri.getToken(), uri.getNamespace(), uri.toString());
this.uuri = uuri;
+ parseUuri(uuri);
}
/**
@@ -208,7 +213,7 @@
public Namespace getNamespace() {
return super.getNamespace();
}
-
+
public boolean isStoreRoot() {
UriPath thisPath = new UriPath(uuri);
UriPath scopePath = new UriPath(scope.toString());
@@ -263,6 +268,50 @@
hrefElm.setText(resourceIdSchema(getStore())+getUuri());
r.add(hrefElm);
return r.toString();
+ }
+
+ /**
+ * This function is called by the constructor and when uri is changed.
+ *
+ * @param uri Uri to parse
+ */
+ private void parseUuri(String uuri) {
+ // We first try to tokenize the uri string.
+ scopes = new ScopeTokenizer(token, namespace, uuri);
+
+ // Find the qualifiying stuff from the registry.
+ // Then we contentStore the scope of the found Data Source
+ // within scope.
+ store = null;
+ while ((store == null) && (scopes.hasMoreElements())) {
+ Scope courScope = scopes.nextScope();
+ try {
+ if (token == null) {
+ store = namespace.retrieveStore(courScope, null);
+ } else {
+ store = namespace.retrieveStore(courScope,
token.getCredentialsToken());
+ }
+
+ if (store != null) {
+ scope = courScope;
+ }
+ }
+ catch (ServiceConnectionFailedException e) {
+ // Problem ...
+ // FIXME : Throw a RuntimeException ??
+ }
+ catch (ServiceAccessException e) {
+ // Problem ...
+ // FIXME : Throw a RuntimeException ??
+ }
+ }
+
+ // If descriptorsStore or contentStore is still null, then no valid
+ // scope is defined in the namespace ...
+ if (store == null) {
+ throw new ServiceMissingOnRootNodeException();
+ }
+
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]