[exo-jcr-commits] exo-jcr SVN: r2171 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core.
do-not-reply at jboss.org
do-not-reply at jboss.org
Fri Mar 26 10:47:07 EDT 2010
Author: pnedonosko
Date: 2010-03-26 10:47:07 -0400 (Fri, 26 Mar 2010)
New Revision: 2171
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
Log:
EXOJCR-615 checkValid in NodeImpl.isNodeType(String); formatting
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java 2010-03-26 14:40:50 UTC (rev 2170)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java 2010-03-26 14:47:07 UTC (rev 2171)
@@ -187,7 +187,9 @@
// 6.2.8 If depth > n is specified then an ItemNotFoundException is
// thrown.
if (degree < 0)
+ {
throw new ItemNotFoundException("Can't get ancestor with ancestor's degree < 0.");
+ }
final QPath myPath = getData().getQPath();
int n = myPath.getDepth() - degree;
@@ -277,7 +279,9 @@
public boolean isNew()
{
if (isValid())
+ {
return dataManager.isNew(getInternalIdentifier());
+ }
// if was removed (is invalid by check), isn't new
return false;
@@ -289,7 +293,9 @@
public boolean isModified()
{
if (isValid())
+ {
return dataManager.isModified(getData());
+ }
// if was removed (is invalid by check), was modified
return true;
@@ -304,25 +310,38 @@
checkValid();
if (isRoot())
+ {
throw new RepositoryException("Can't remove ROOT node.");
+ }
// Check constraints
ItemDefinition def;
if (isNode())
+ {
def = ((NodeImpl)this).getDefinition();
+ }
else
+ {
def = ((PropertyImpl)this).getDefinition();
+ }
if (def.isMandatory() || def.isProtected())
+ {
throw new ConstraintViolationException("Can't remove mandatory or protected item " + getPath());
+ }
+
NodeImpl parentNode = parent();
// Check if versionable ancestor is not checked-in
if (!parentNode.checkedOut())
+ {
throw new VersionException("Node " + parent().getPath() + " or its nearest ancestor is checked-in");
+ }
// Check locking
if (!parentNode.checkLocking())
+ {
throw new LockException("Node " + parent().getPath() + " is locked ");
+ }
// launch event
session.getActionHandler().preRemoveItem(this);
@@ -444,8 +463,10 @@
PropertyDefinitionData def = defs.getDefinition(isMultiValue);
if (def != null && def.isProtected())
+ {
throw new ConstraintViolationException("Can not set protected property "
+ locationFactory.createJCRPath(qpath).getAsString(false));
+ }
if (multiValue && (def == null || (prevProp != null && !prevProp.isMultiValued())))
{
@@ -461,11 +482,15 @@
// Check if checked-in (versionable)
if (!parentNode.checkedOut())
+ {
throw new VersionException("Node " + parentNode.getPath() + " or its nearest ancestor is checked-in");
+ }
// Check is locked
if (!parentNode.checkLocking())
+ {
throw new LockException("Node " + parentNode.getPath() + " is locked ");
+ }
List<ValueData> valueDataList = new ArrayList<ValueData>();
@@ -583,7 +608,9 @@
checkValid();
if (isNew())
+ {
throw new RepositoryException("It is impossible to call save() on the newly added item " + getPath());
+ }
NodeTypeDataManager ntManager = session.getWorkspace().getNodeTypesHolder();
@@ -658,9 +685,13 @@
checkValid();
if (keepChanges)
+ {
dataManager.refresh(this.getData());
+ }
else
+ {
dataManager.rollback(this.getData());
+ }
}
// -------------------- Implementation ----------------------
@@ -750,11 +781,6 @@
return nodeTypes;
}
- // @Deprecated
- // public ExtendedNodeType[] getParentNodeTypes() throws RepositoryException {
- // return nodeTypes(parentData());
- // }
-
public String getInternalIdentifier()
{
return data.getIdentifier();
@@ -856,7 +882,9 @@
{
if (value == null)
+ {
return null;
+ }
switch (type)
{
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-03-26 14:40:50 UTC (rev 2170)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2010-03-26 14:47:07 UTC (rev 2171)
@@ -1064,8 +1064,8 @@
*/
public NodeType getPrimaryNodeType() throws RepositoryException
{
+ checkValid();
- checkValid();
ExtendedNodeTypeManager nodeTypeManager = (ExtendedNodeTypeManager)session.getWorkspace().getNodeTypeManager();
return nodeTypeManager.findNodeType(nodeData().getPrimaryTypeName());
}
@@ -1334,6 +1334,7 @@
{
checkValid();
+
return session.getLockManager().holdsLock((NodeData)getData());
}
@@ -1379,6 +1380,7 @@
*/
public boolean isNodeType(InternalQName qName) throws RepositoryException
{
+ checkValid();
return session.getWorkspace().getNodeTypesHolder().isNodeType(qName, nodeData().getPrimaryTypeName(),
nodeData().getMixinTypeNames());
@@ -1733,8 +1735,13 @@
*/
public void removePermission(String identity) throws RepositoryException, AccessControlException
{
+
+ checkValid();
+
if (!isNodeType(Constants.EXO_PRIVILEGEABLE))
+ {
throw new AccessControlException("Node is not exo:privilegeable " + getPath());
+ }
checkPermission(PermissionType.CHANGE_PERMISSION);
@@ -1750,6 +1757,8 @@
public void removePermission(String identity, String permission) throws RepositoryException, AccessControlException
{
+ checkValid();
+
if (!isNodeType(Constants.EXO_PRIVILEGEABLE))
throw new AccessControlException("Node is not exo:privilegeable " + getPath());
@@ -1890,14 +1899,22 @@
public void setPermission(String identity, String[] permission) throws RepositoryException, AccessControlException
{
+ checkValid();
+
if (!isNodeType(Constants.EXO_PRIVILEGEABLE))
+ {
throw new AccessControlException("Node is not exo:privilegeable " + getPath());
+ }
if (identity == null)
+ {
throw new RepositoryException("Identity cannot be null");
+ }
if (permission == null)
+ {
throw new RepositoryException("Permission cannot be null");
+ }
// check if changing permission allowed
checkPermission(PermissionType.CHANGE_PERMISSION);
@@ -1918,12 +1935,18 @@
public void setPermissions(Map permissions) throws RepositoryException, AccessDeniedException,
AccessControlException
{
-
+
+ checkValid();
+
if (!isNodeType(Constants.EXO_PRIVILEGEABLE))
+ {
throw new AccessControlException("Node is not exo:privilegeable " + getPath());
+ }
if (permissions.size() == 0)
+ {
throw new RepositoryException("Permission map size cannot be 0");
+ }
checkPermission(PermissionType.CHANGE_PERMISSION);
@@ -1944,6 +1967,7 @@
aces.add(ace);
}
}
+
AccessControlList acl = new AccessControlList(getACL().getOwner(), aces);
setACL(acl);
updatePermissions(acl);
@@ -2289,7 +2313,9 @@
{
if (!this.isNodeType(Constants.MIX_VERSIONABLE))
+ {
throw new UnsupportedRepositoryOperationException("Node is not mix:versionable " + getPath());
+ }
PropertyData vhProp =
(PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_VERSIONHISTORY, 1));
More information about the exo-jcr-commits
mailing list