Even if there are lots of tools out there in the links everyone
provide they are mostly toys, commercial, or not actively developed...
It's not very hard to create a method that given a session dumps an
excerpt of the repository, for example (code below taken from our
CalencoV2 system. The code below is part of Calenco's
PooledRepoManager class, released under the AGPL license):
static String NL = System.getProperty("line.separator");
public void dump(Appendable appendable) {
Session session = null;
try {
session = getSessionRO(); // Get a JCR Read-only session
dump(session.getRootNode(), appendable);
} catch (Exception e) {
String msg = String.format("Cannot dump repository content
into %s", appendable.getClass().getName());
log.severe(msg);
throw new RuntimeException(msg, e);
} finally {
releaseSessionRO(session); // Logout from the Read-only session
}
}
public void dump(Node node, Appendable appendable) throws
RepositoryException, IOException {
String nname = node.getName();
if (!nname.equals("jcr:system")) { // Skip the JCR system node // NOI18N
appendable.append("------------------------ Node
-----------------------").append(NL);
appendable.append(String.format("%s
[%s]", (nname.isEmpty() ? "Root Node" : nname),
node.getPath())).append(NL);
appendable.append("····················· Properties
····················").append(NL);
PropertyIterator pit = node.getProperties();
if (pit.hasNext()) {
while (pit.hasNext()) {
Property p = pit.nextProperty();
String pname = p.getName();
int ptype = p.getType();
if (!p.getDefinition().isMultiple()) {
if (ptype == PropertyType.BINARY) {
appendable.append(String.format("@%s=BINARY_VALUE",
pname)).append(NL); // NOI18N
} else {
appendable.append(String.format("@%s=\"%s\"", pname,
p.getString())).append(NL); // NOI18N
}
} else {
int i = 0;
for (Value value : p.getValues()) {
appendable.append(String.format("@%s[%d]=\"%s\"", pname, i, (ptype ==
PropertyType.BINARY ? "BINARY_VALUE" :
value.getString()))).append(NL); // NOI18N
i++;
}
}
}
} else {
appendable.append("NONE").append(NL);
}
appendable.append("-----------------------------------------------------").append(NL);
// NOI18N
NodeIterator nodes = node.getNodes();
while (nodes.hasNext()) {
dump(nodes.nextNode(), appendable);
}
}
}
The above method skips the system (jcr:system) node, feel free to
adapt it to your needs. Using a similar algorithm as the above one, it
was nearly trivial to build a JSON representation of the JCR
repository with a format suitable for dojo's tree widget, having a
web-based read-only view of a running JCR repository.
On Mon, Feb 8, 2010 at 2:54 PM, ChadDavis <[email protected]> wrote:
> Is there a repo browser that can show me the node structure, complete
> with properties, node types, property types, etc.?
>
--
Fabián Mandelbaum
IS Engineer