Retrieving namespace definition / store properties

2005-06-01 Thread Brusic, Ivan
I am trying to access the /slide/namespace/defintion/story/contentstore
properties defined in domain.xml via code.  NamespaceConfig obviously
doesn't have them, and there are no get methods defined in ContentStore.
I am basically trying to retrieve the value of path to the content root.
Is this at all possible?
 
Thanks in advance.
 
-- 
Ivan
 


Re: Retrieving namespace definition / store properties

2005-06-02 Thread Martin Kalén

Brusic, Ivan wrote:

I am trying to access the /slide/namespace/defintion/story/contentstore
properties defined in domain.xml via code.  NamespaceConfig obviously
doesn't have them, and there are no get methods defined in ContentStore.
I am basically trying to retrieve the value of path to the content root.
Is this at all possible?


I didn't find any easily accessible API methods to retrieve this.

However, if you are using an EmbeddedDomain and don't mind extremly
ugly code (major hack-warning!) the answer is:
 yes, it is _possible_
(bot not supported by the API, not nice or clean,
 and as far as I could see not possible under a strict JRE
 security model since the hacky solution includes looking
 up protected fields by reflection).

//EmbeddedDomain domain;
//...init domain...

String namespaceName = "yourNamespace";
String principal = "yourUser";
String uri = "/your/path/of/choice";

String key = "rootpath";

Namespace ns = domain.getNamespace(namespaceName);
CredentialsToken credentials = new CredentialsToken(principal);
SlideToken slideToken = new SlideTokenImpl(credentials);
Uri slideUri = ns.getUri(slideToken, uri);
slideStore = slideUri.getStore();
if (slideStore instanceof AbstractStore) {
  try {
Field contentStoreField = 
AbstractStore.class.getDeclaredField("contentStore");
contentStoreField.setAccessible(true);
ContentStore contentStore = (ContentStore) 
contentStoreField.get((AbstractStore) slideStore);
if (contentStore instanceof AbstractTxFileStoreService) {
  Field storeDirField = 
AbstractTxFileStoreService.class.getDeclaredField("storeDir");
  storeDirField.setAccessible(true);
  System.out.println("storeDir=" + 
storeDirField.get((AbstractTxFileStoreService) contentStore));
}
  } catch (Exception e) {
System.err.println("Could not retrieve storeDir");
e.printStackTrace(System.err);
  }
}


I wonder why it's only possible to retrieve Domain level config
params easily using the API? Any Slide developer care to comment
on the API thoughts behind this? (Maybe it's just considered
not to be a generic use-case.)

Regards,
 Martin


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]