Author: nzamosenchuk
Date: 2010-08-13 05:06:03 -0400 (Fri, 13 Aug 2010)
New Revision: 2912
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/PropertyImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RepositoryImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/WorkspaceImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/BaseValue.java
Log:
EXOJCR-776 : implemented toString() method of main classes (Repository, Workspace,
Session, Node, Property, Value)
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2010-08-11
13:20:05 UTC (rev 2911)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2010-08-13
09:06:03 UTC (rev 2912)
@@ -67,6 +67,7 @@
import java.io.InputStream;
import java.security.AccessControlException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
@@ -3356,4 +3357,69 @@
return (Property)nextItem();
}
}
+
+ @Override
+ public String toString()
+ {
+ // toString can be invoked on invalid node, so need to ensure no exceptions thrown
by skipping them
+ String primaryType;
+ String mixinTypes;
+ String acl;
+ boolean locked;
+ boolean checkedOut;
+ // get primary type name
+ try
+ {
+ primaryType = getPrimaryNodeType().getName();
+ }
+ catch (RepositoryException e)
+ {
+ primaryType = "Error requesting primary type";
+ }
+ // get mixins
+ try
+ {
+ mixinTypes = Arrays.toString(getMixinTypeNames());
+ }
+ catch (RepositoryException e)
+ {
+ mixinTypes = "Error requesting mixin types";
+ }
+ // get ACL
+ try
+ {
+ AccessControlList list = getACL();
+ acl = list == null ? "-;" : list.dump();
+ acl = acl.replaceAll("\\n", "; ");
+ }
+ catch (RepositoryException e)
+ {
+ acl = "Error requesting ACL";
+ }
+ // check if locked
+ try
+ {
+ locked = isLocked();
+ }
+ catch (RepositoryException e)
+ {
+ // not valid node
+ locked = false;
+ }
+ // check if checkedOut
+ try
+ {
+ checkedOut = isCheckedOut();
+ }
+ catch (RepositoryException e)
+ {
+ // not valid, or versioning not supported
+ checkedOut = false;
+ }
+ return String
+ .format(
+ "Node {\n id: %s;\n path: %s;\n primary-type: %s;\n mixin-types: %s;\n
acl: %s\n locked: %b;\n checked-out: %b \n}",
+ data == null ? "not valid node" : data.getIdentifier(), qpath ==
null ? "undefined" : qpath.getAsString(),
+ primaryType, mixinTypes, acl, locked, checkedOut);
+ }
}
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/PropertyImpl.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/PropertyImpl.java 2010-08-11
13:20:05 UTC (rev 2911)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/PropertyImpl.java 2010-08-13
09:06:03 UTC (rev 2912)
@@ -608,4 +608,22 @@
return false;
}
+ @Override
+ public String toString()
+ {
+ String typeName;
+ try
+ {
+ typeName = PropertyType.nameFromValue(type);
+ }
+ catch (IllegalArgumentException e)
+ {
+ // Value has abnormal type
+ typeName = String.valueOf(type);
+ }
+ return String.format("Property {\n id: %s;\n path: %s;\n type: %s;\n
multi-valued: %b\n}", data == null
+ ? "not valid property" : data.getIdentifier(), qpath == null ?
"undefined" : qpath.getAsString(), typeName,
+ data == null ? false : isMultiValued());
+ }
+
}
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RepositoryImpl.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RepositoryImpl.java 2010-08-11
13:20:05 UTC (rev 2911)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RepositoryImpl.java 2010-08-13
09:06:03 UTC (rev 2912)
@@ -707,4 +707,26 @@
}
}
+ @Override
+ public String toString()
+ {
+ String stateTitle;
+ switch (state)
+ {
+ case ONLINE :
+ stateTitle = "online";
+ break;
+ case OFFLINE :
+ stateTitle = "offline";
+ break;
+ case READONLY :
+ stateTitle = "readonly";
+ break;
+ default :
+ stateTitle = "undefined";
+ }
+ return String.format("Repository {\n name: %s;\n system workspace: %s;\n
state: %s \n}", name,
+ systemWorkspaceName, stateTitle);
+ }
+
}
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionImpl.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionImpl.java 2010-08-11
13:20:05 UTC (rev 2911)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionImpl.java 2010-08-13
09:06:03 UTC (rev 2912)
@@ -1050,4 +1050,11 @@
return lazyReadThreshold;
}
+ @Override
+ public String toString()
+ {
+ return String.format("Session {\n id: %s;\n userId: %s;\n workspace: %s/%s ;\n
alive: %b\n}", id, getUserID(),
+ repository.getName(), workspaceName, live);
+ }
+
}
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/WorkspaceImpl.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/WorkspaceImpl.java 2010-08-11
13:20:05 UTC (rev 2911)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/WorkspaceImpl.java 2010-08-13
09:06:03 UTC (rev 2912)
@@ -708,4 +708,11 @@
return nodeTypeManager;
}
+ @Override
+ public String toString()
+ {
+ return String.format("Workspace {\n name: %s/%s;\n session-id: %s \n}",
repository().getName(), name, session
+ .getId());
+ }
+
}
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/BaseValue.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/BaseValue.java 2010-08-11
13:20:05 UTC (rev 2911)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/BaseValue.java 2010-08-13
09:06:03 UTC (rev 2912)
@@ -421,4 +421,22 @@
return bytes != null;
}
}
+
+ @Override
+ public String toString()
+ {
+ String typeName;
+ try
+ {
+ typeName = PropertyType.nameFromValue(type);
+ }
+ catch (IllegalArgumentException e)
+ {
+ // Value has abnormal type
+ typeName = String.valueOf(type);
+ }
+ return String.format("Value {\n type: %s;\n data-class: %s;\n size: %s
bytes\n}", typeName, internalData == null
+ ? null : internalData.getClass().getName(), internalData == null ?
"undefined" : internalData.getLength());
+ }
+
}