ContentImpl.java

Index Score
org.apache.slide.content
Jakarta Slide

View: Reasons, Metrics, Source Code

These are the metrics that contribute to the Enerjy Score for this file, ranked by impact. So the metrics listed at the top influence the score to a greater extent that the metrics listed at the bottom.

MetricDescription
RETURNSNumber of return points from functions
EXEC_COMMENTSComments in executable code
INTERFACE_COMPLEXITYInterface complexity
LINE_COMMENTNumber of line comments
JAVA0115JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
SIZESize of the file in bytes
ELOCEffective lines of code
OPERANDSNumber of operands
LINESNumber of lines in the source file
PROGRAM_LENGTHHalstead program length
LOCLines of code
PARAMSNumber of formal parameter declarations
OPERATORSNumber of operators
JAVA0034JAVA0034 Missing braces in if statement
EXITSProcedure exits
COMMENTSComment lines
LOGICAL_LINESNumber of statements
JAVA0144JAVA0144 Line exceeds maximum M characters
WHITESPACENumber of whitespace lines
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
DECL_COMMENTSComments in declarations
UNIQUE_OPERANDSNumber of unique operands
PROGRAM_VOCABHalstead program vocabulary
CYCLOMATICCyclomatic complexity
BLOCKSNumber of blocks
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
DOC_COMMENTNumber of javadoc comment lines
JAVA0265JAVA0265 Use of Throwable.printStackTrace()
COMPARISONSNumber of comparison operators
JAVA0049JAVA0049 Nested block at depth N (maximum: M)
JAVA0166JAVA0166 Generic exception caught
JAVA0160JAVA0160 Method does not throw specified exception
JAVA0117JAVA0117 Missing javadoc: method 'method'
JAVA0177JAVA0177 Variable declaration missing initializer
NEST_DEPTHMaximum nesting depth
PROGRAM_VOLUMEHalstead program volume
UNIQUE_OPERATORSNumber of unique operators
JAVA0136JAVA0136 N methods defined in class (maximum: M)
JAVA0032JAVA0032 Switch statement missing default
JAVA0138JAVA0138 N parameters defined for method (maximum: M)
JAVA0126JAVA0126 Method declares unchecked exception in throws
FUNCTIONSNumber of function declarations
JAVA0130JAVA0130 Non-static method does not use instance fields
JAVA0270JAVA0270 Use Java 5.0 enhanced for loop construct to iterate over all elements in an array
JAVA0145JAVA0145 Tab character used in source file
/* * $Header$ * $Revision: 356411 $ * $Date: 2005-12-12 18:19:32 -0500 (Mon, 12 Dec 2005) $ * * ==================================================================== * * Copyright 1999-2002 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package org.apache.slide.content; import java.lang.reflect.Method; import java.util.Date; import java.util.Enumeration; import java.util.Vector; import org.apache.slide.common.Domain; import org.apache.slide.common.Namespace; import org.apache.slide.common.NamespaceConfig; import org.apache.slide.common.ServiceAccessException; import org.apache.slide.common.SlideToken; import org.apache.slide.common.Uri; import org.apache.slide.common.UriPath; import org.apache.slide.lock.Lock; import org.apache.slide.lock.ObjectLockedException; import org.apache.slide.security.AccessDeniedException; import org.apache.slide.security.Security; import org.apache.slide.structure.ActionNode; import org.apache.slide.structure.LinkedObjectNotFoundException; import org.apache.slide.structure.ObjectNode; import org.apache.slide.structure.ObjectNotFoundException; import org.apache.slide.structure.Structure; import org.apache.slide.structure.SubjectNode; import org.apache.slide.util.Configuration; import org.apache.slide.event.EventDispatcher; import org.apache.slide.event.ContentEvent; import org.apache.slide.event.VetoException; /** * Implementation of the content interface. * * @version $Revision: 356411 $ */ public class ContentImpl implements Content { // -------------------------------------------------------------- Constants protected static final String I_URIREDIRECTORCLASS = "uriRedirectorClass"; protected static final String I_URIREDIRECTORCLASS_DEFAULT = "org.apache.slide.webdav.util.DeltavUriRedirector"; protected static final int PRE_STORE = 0; protected static final int POST_STORE = 1; protected static final int POST_RETRIEVE = 2; protected static final int PRE_REMOVE = 3; protected static final int POST_REMOVE = 4; protected static Class uriRedirectorClass; static { try { String uriRedirectorClassName = Domain.getParameter(I_URIREDIRECTORCLASS, I_URIREDIRECTORCLASS_DEFAULT); uriRedirectorClass = Class.forName( uriRedirectorClassName ); } catch( Exception x ) { Domain.warn( "Loading of redirector class failed: "+x.getMessage() ); } } // ----------------------------------------------------------- Constructors /** * Constructor. * * @param namespace Namespace * @param namespaceConfig Namespace configuration * @param securityHelper Security helper * @param structureHelper Structure helper * @param lockHelper lockHelper */ public ContentImpl(Namespace namespace, NamespaceConfig namespaceConfig, Security securityHelper, Structure structureHelper, Lock lockHelper) { this.namespace = namespace; this.namespaceConfig = namespaceConfig; this.securityHelper = securityHelper; this.structureHelper = structureHelper; this.lockHelper = lockHelper; } // ----------------------------------------------------- Instance Variables /** * Namespace. */ private Namespace namespace; /** * Namespace configuration. */ private NamespaceConfig namespaceConfig; /** * Security helper. */ private Security securityHelper; /** * Structure helper. */ private Structure structureHelper; /** * Lock helper. */ private Lock lockHelper; // -------------------------------------------------------- Content Methods /** * Retrieve revision descriptors. * * @param strUri Uri * @return NodeRevisionDescriptors */ public NodeRevisionDescriptors retrieve(SlideToken token, String strUri) throws ObjectNotFoundException, AccessDeniedException, LinkedObjectNotFoundException, ServiceAccessException, ObjectLockedException, VetoException { String originalUri = strUri; strUri = redirectUri( originalUri ); // security token null - is ignored anyway ObjectNode associatedObject = structureHelper.retrieve(token, strUri, false); // Checking security and locking securityHelper.checkCredentials (token, associatedObject, namespaceConfig.getReadRevisionMetadataAction()); lockHelper.checkLock(token, associatedObject, namespaceConfig.getReadRevisionMetadataAction()); Uri objectUri = namespace.getUri(token, associatedObject.getUri()); NodeRevisionDescriptors revisionDescriptors = null; try { revisionDescriptors = objectUri.getStore() .retrieveRevisionDescriptors(objectUri); } catch (RevisionDescriptorNotFoundException e) { // No revision descriptors. We have to create some. revisionDescriptors = new NodeRevisionDescriptors(); revisionDescriptors.setUri(objectUri.toString()); // FIXME: createRevisionDescriptors shouldn't be done in this read-only method objectUri.getStore() .createRevisionDescriptors(objectUri, revisionDescriptors); } revisionDescriptors.setOriginalUri( originalUri ); return revisionDescriptors; } /** * Retrieve revision descriptor of the latest revision * from a branch. * * @param revisionDescriptors Node revision descriptors * @param branch String branch */ public NodeRevisionDescriptor retrieve (SlideToken token, NodeRevisionDescriptors revisionDescriptors, String branch) throws ObjectNotFoundException, AccessDeniedException, LinkedObjectNotFoundException, ServiceAccessException, RevisionDescriptorNotFoundException, ObjectLockedException, BranchNotFoundException, NodeNotVersionedException, VetoException { NodeRevisionDescriptor result; Uri objectUri = namespace.getUri(token, revisionDescriptors.getUri()); NodeRevisionNumber latestNrn = redirectLatestRevisionNumber( revisionDescriptors.getOriginalUri() ); NodeRevisionDescriptors realRevisionDescriptors = objectUri.getStore() .retrieveRevisionDescriptors(objectUri); if (!realRevisionDescriptors.isVersioned()) { // Invalid function call : we try to create a revision, but the // descriptors won't allow it throw new NodeNotVersionedException(realRevisionDescriptors.getUri()); } if( latestNrn == null ) { // Retrieving latest revision numbers NodeRevisionNumber branchLatestRevisionNumber = realRevisionDescriptors.getLatestRevision(branch); if (branchLatestRevisionNumber == null) { throw new BranchNotFoundException (realRevisionDescriptors.getUri().toString(), branch); } result = retrieve(token, realRevisionDescriptors, branchLatestRevisionNumber); } else { result = retrieve( token, revisionDescriptors, latestNrn ); } return result; } /** * Retrieve revision descriptor. * * @param revisionDescriptors Node revision descriptors * @param revisionNumber Node revision number */ public NodeRevisionDescriptor retrieve (SlideToken token, NodeRevisionDescriptors revisionDescriptors, NodeRevisionNumber revisionNumber) throws ObjectNotFoundException, AccessDeniedException, LinkedObjectNotFoundException, ServiceAccessException, RevisionDescriptorNotFoundException, ObjectLockedException, VetoException { ObjectNode associatedObject = structureHelper.retrieve (token, revisionDescriptors.getUri(), false); // Checking security and locking securityHelper.checkCredentials (token, associatedObject, namespaceConfig.getReadRevisionMetadataAction()); lockHelper.checkLock(token, associatedObject, namespaceConfig.getReadRevisionMetadataAction()); Uri objectUri = namespace.getUri(token, revisionDescriptors.getUri()); NodeRevisionDescriptor revisionDescriptor = objectUri.getStore().retrieveRevisionDescriptor (objectUri, revisionNumber); // Invoke interceptors invokeInterceptors(token, revisionDescriptors, revisionDescriptor, null, POST_RETRIEVE); // Fire event if ( ContentEvent.RETRIEVE.isEnabled() ) EventDispatcher.getInstance().fireVetoableEvent(ContentEvent.RETRIEVE, new ContentEvent(this, token, namespace, objectUri.toString(), revisionDescriptors, revisionDescriptor)); return revisionDescriptor; } /** * Retrieve revision descriptor from the latest revision * in the main branch. * * @param revisionDescriptors Node revision descriptors */ public NodeRevisionDescriptor retrieve (SlideToken token, NodeRevisionDescriptors revisionDescriptors) throws ObjectNotFoundException, AccessDeniedException, LinkedObjectNotFoundException, ServiceAccessException, RevisionDescriptorNotFoundException, ObjectLockedException, VetoException { NodeRevisionDescriptor result; Uri objectUri = namespace.getUri(token, revisionDescriptors.getUri()); NodeRevisionNumber latestNrn = redirectLatestRevisionNumber( revisionDescriptors.getOriginalUri() ); NodeRevisionDescriptors realRevisionDescriptors = objectUri.getStore() .retrieveRevisionDescriptors(objectUri); if( latestNrn == null ) { result = retrieve( token, revisionDescriptors, realRevisionDescriptors.getLatestRevision()); } else { result = retrieve( token, revisionDescriptors, latestNrn ); } return result; } /** * Retrieve revision content. * * @param revisionDescriptors Node revision descriptors * @param revisionDescriptor Node revision descriptor */ public NodeRevisionContent retrieve (SlideToken token, NodeRevisionDescriptors revisionDescriptors, NodeRevisionDescriptor revisionDescriptor) throws ObjectNotFoundException, AccessDeniedException, LinkedObjectNotFoundException, ServiceAccessException, RevisionNotFoundException, RevisionContentNotFoundException, ObjectLockedException, VetoException { return retrieve(token, revisionDescriptors.getUri(), revisionDescriptor); } /** * Retrieve revision content. * * @param strUri Uri * @param revisionDescriptor Node revision descriptor */ public NodeRevisionContent retrieve (SlideToken token, String strUri, NodeRevisionDescriptor revisionDescriptor) throws ObjectNotFoundException, AccessDeniedException, LinkedObjectNotFoundException, ServiceAccessException, RevisionNotFoundException, RevisionContentNotFoundException, ObjectLockedException, VetoException { ObjectNode associatedObject = structureHelper.retrieve(token, strUri, false); // Checking security and locking securityHelper.checkCredentials (token, associatedObject, namespaceConfig.getReadRevisionContentAction()); lockHelper.checkLock(token, associatedObject, namespaceConfig.getReadRevisionContentAction()); Uri objectUri = namespace.getUri(token, strUri); NodeRevisionContent revisionContent = objectUri.getStore().retrieveRevisionContent(objectUri, revisionDescriptor); // Invoke interceptors invokeInterceptors(token, null, revisionDescriptor, revisionContent, POST_RETRIEVE); // Fire event if ( ContentEvent.RETRIEVE.isEnabled() ) EventDispatcher.getInstance().fireVetoableEvent(ContentEvent.RETRIEVE, new ContentEvent(this, token, namespace, objectUri.toString(), revisionDescriptor, revisionContent)); return revisionContent; } /** * Create new revision descriptors. * * @param strUri Uri * @param isVersioned true is the resource is versioned */ public void create(SlideToken token, String strUri, boolean isVersioned) throws ObjectNotFoundException, AccessDeniedException, LinkedObjectNotFoundException, ServiceAccessException, ObjectLockedException, VetoException { // Check parent exists and is not lock-null checkParentExists(strUri, token); // Retrieve the associated object ObjectNode associatedObject = structureHelper.retrieve(token, strUri, false); // Next we do a security check and a locking check for modifyRevisions securityHelper.checkCredentials (token, associatedObject, namespaceConfig.getCreateRevisionMetadataAction()); lockHelper.checkLock (token, associatedObject, namespaceConfig.getCreateRevisionMetadataAction()); if (namespaceConfig.getCreateRevisionMetadataAction() != namespaceConfig.getCreateRevisionContentAction()) { securityHelper.checkCredentials (token, associatedObject, namespaceConfig.getCreateRevisionContentAction()); lockHelper.checkLock (token, associatedObject, namespaceConfig.getCreateRevisionContentAction()); } Uri objectUri = namespace.getUri(token, strUri); NodeRevisionDescriptors revisionDescriptors = new NodeRevisionDescriptors(isVersioned); revisionDescriptors.setUri(strUri); objectUri.getStore() .createRevisionDescriptors(objectUri, revisionDescriptors); } /** * Create new revision in main branch. * * @param strUri Uri * @param revisionDescriptor New Node revision descriptor * @param revisionContent New Node revision content */ public void create(SlideToken token, String strUri, NodeRevisionDescriptor revisionDescriptor, NodeRevisionContent revisionContent) throws ObjectNotFoundException, AccessDeniedException, RevisionAlreadyExistException, LinkedObjectNotFoundException, ServiceAccessException, ObjectLockedException, VetoException { // Check parent exists and is not lock-null checkParentExists(strUri, token); // Retrieve the associated object ObjectNode associatedObject = structureHelper.retrieve(token, strUri, false); // Next we do a security check and a locking check for modifyRevisions securityHelper.checkCredentials (token, associatedObject, namespaceConfig.getCreateRevisionMetadataAction()); lockHelper.checkLock (token, associatedObject, namespaceConfig.getCreateRevisionMetadataAction()); if (namespaceConfig.getCreateRevisionMetadataAction() != namespaceConfig.getCreateRevisionContentAction()) { securityHelper.checkCredentials (token, associatedObject, namespaceConfig.getCreateRevisionContentAction()); lockHelper.checkLock (token, associatedObject, namespaceConfig.getCreateRevisionContentAction()); } setDefaultProperties(associatedObject, revisionDescriptor); // set the creation date if not already set if (revisionDescriptor.getCreationDate() == null) { revisionDescriptor.setCreationDate(new Date()); // Set the creation user setCreationUser(token, revisionDescriptor); } // set the display name (in case of copy) if (!Configuration.useBinding(namespace.getUri(token, strUri).getStore())) { if (revisionDescriptor.getName() == null || revisionDescriptor.getName().length() == 0) { revisionDescriptor.setName(UriPath.getLastSegment(strUri)); } } Uri objectUri = namespace.getUri(token, strUri); NodeRevisionDescriptors revisionDescriptors = null; try { revisionDescriptors = objectUri.getStore() .retrieveRevisionDescriptors(objectUri); } catch (RevisionDescriptorNotFoundException e) { // No revision descriptors. We have to create some. revisionDescriptors = new NodeRevisionDescriptors(); revisionDescriptors.setUri(objectUri.toString()); objectUri.getStore() .createRevisionDescriptors(objectUri, revisionDescriptors); } // Retrieve the latest revision from the descriptor, // unless there is no revisions. We generate a new revision number, // basing on an existing revision, if any. NodeRevisionNumber newRevisionNumber = null; if (revisionDescriptors.isVersioned()) { if (revisionDescriptors.hasRevisions()) { newRevisionNumber = new NodeRevisionNumber (revisionDescriptors.getLatestRevision()); revisionDescriptors .addSuccessor(revisionDescriptors.getLatestRevision(), newRevisionNumber); revisionDescriptors .setSuccessors(newRevisionNumber, new Vector()); } else { newRevisionNumber = new NodeRevisionNumber(); revisionDescriptors .setSuccessors(newRevisionNumber, new Vector()); } // We now set the newly created revision as the latest revison revisionDescriptors.setLatestRevision(newRevisionNumber); // We update the descriptor revisionDescriptor.setRevisionNumber(newRevisionNumber); // Fire event if ( ContentEvent.CREATE.isEnabled() ) EventDispatcher.getInstance().fireVetoableEvent(ContentEvent.CREATE, new ContentEvent(this, token, namespace, objectUri.toString(), revisionDescriptors, revisionDescriptor, revisionContent)); // Invoke interceptors invokeInterceptors(token, revisionDescriptors, revisionDescriptor, revisionContent, PRE_STORE); if (revisionContent != null) { // Storing the new revision contents objectUri.getStore() .createRevisionContent(objectUri, revisionDescriptor, revisionContent); } // Now creating the revision desriptor in the store revisionDescriptor.setModificationDate(revisionDescriptor.getCreationDate()); revisionDescriptor.setModificationUser( securityHelper.getPrincipal(token).getPath().lastSegment()); objectUri.getStore() .createRevisionDescriptor(objectUri, revisionDescriptor); } else { // We don't use versioning for this object. // Two options : // - The object already has one (and only one) revision, // so we update it // - The object dooesn't have any revisions right now, so we create // the initial revision newRevisionNumber = new NodeRevisionNumber(); revisionDescriptor.setRevisionNumber(newRevisionNumber); if (!revisionDescriptors.hasRevisions()) { // Fire event if ( ContentEvent.CREATE.isEnabled() ) EventDispatcher.getInstance().fireVetoableEvent(ContentEvent.CREATE, new ContentEvent(this, token, namespace, objectUri.toString(), revisionDescriptors, revisionDescriptor, revisionContent)); // Invoke interceptors invokeInterceptors(token, revisionDescriptors, revisionDescriptor, revisionContent, PRE_STORE); if (revisionContent != null) { // Storing the new revision contents objectUri.getStore() .createRevisionContent(objectUri, revisionDescriptor, revisionContent); } // Now creating the revision desriptor in the store revisionDescriptor.setModificationDate(revisionDescriptor.getCreationDate()); revisionDescriptor.setModificationUser( securityHelper.getPrincipal(token).getPath().lastSegment()); objectUri.getStore() .createRevisionDescriptor(objectUri, revisionDescriptor); } else { try { { // merge the new received properties into the // revisionDescriptor // We update the descriptor's properties NodeRevisionDescriptor oldRevisionDescriptor = objectUri.getStore() .retrieveRevisionDescriptor (objectUri, newRevisionNumber); Enumeration newPropertiesList = revisionDescriptor.enumerateProperties(); while (newPropertiesList.hasMoreElements()) { oldRevisionDescriptor .setProperty((NodeProperty) newPropertiesList .nextElement() ); } // now use the merged revision descriptor revisionDescriptor = oldRevisionDescriptor; } // end of merge // Fire event if ( ContentEvent.CREATE.isEnabled() ) EventDispatcher.getInstance().fireVetoableEvent(ContentEvent.CREATE, new ContentEvent(this, token, namespace, objectUri.toString(), revisionDescriptors, revisionDescriptor, revisionContent)); // Invoke interceptors invokeInterceptors(token, revisionDescriptors, revisionDescriptor, revisionContent, PRE_STORE); if (revisionContent != null) { // Storing the new revision contents try { objectUri.getStore() .storeRevisionContent(objectUri, revisionDescriptor, revisionContent); } catch (RevisionNotFoundException e) { objectUri.getStore() .createRevisionContent(objectUri, revisionDescriptor, revisionContent); } } revisionDescriptor.setModificationDate(revisionDescriptor.getCreationDate()); revisionDescriptor.setModificationUser( securityHelper.getPrincipal(token).getPath().lastSegment()); objectUri.getStore() .storeRevisionDescriptor (objectUri, revisionDescriptor); } catch (RevisionDescriptorNotFoundException e) { // Should NEVER happen. // Basically, it would mean that there is no initial // revision, which is incorrect since the object // HAS revisions. // Fire event if ( ContentEvent.CREATE.isEnabled() ) EventDispatcher.getInstance().fireVetoableEvent(ContentEvent.CREATE, new ContentEvent(this, token, namespace, objectUri.toString(), revisionDescriptors, revisionDescriptor, revisionContent)); // Invoke interceptors invokeInterceptors(token, revisionDescriptors, revisionDescriptor, revisionContent, PRE_STORE); revisionDescriptor.setModificationDate(revisionDescriptor.getCreationDate()); revisionDescriptor.setModificationUser( securityHelper.getPrincipal(token).getPath().lastSegment()); objectUri.getStore() .createRevisionDescriptor(objectUri, revisionDescriptor); } } // Updating the descriptors object revisionDescriptors .setSuccessors(newRevisionNumber, new Vector()); revisionDescriptors.setLatestRevision(newRevisionNumber); } // We now store the updated revision descriptors try { objectUri.getStore() .storeRevisionDescriptors(objectUri, revisionDescriptors); } catch (RevisionDescriptorNotFoundException e) { // Problem ... e.printStackTrace(); } // Invoke interceptors invokeInterceptors(token, revisionDescriptors, revisionDescriptor, revisionContent, POST_STORE); } /** * Create new revision based on a previous revision. * * @param strUri Uri * @param branch Branch in which to create the revision * @param newRevisionDescriptor New revision descriptor * @param revisionContent Node revision content */ public void create(SlideToken token, String strUri, String branch, NodeRevisionDescriptor newRevisionDescriptor, NodeRevisionContent revisionContent) throws ObjectNotFoundException, AccessDeniedException, RevisionAlreadyExistException, LinkedObjectNotFoundException, ServiceAccessException, RevisionDescriptorNotFoundException, ObjectLockedException, NodeNotVersionedException, BranchNotFoundException, VetoException { // Check parent exists and is not lock-null checkParentExists(strUri, token); Uri objectUri = namespace.getUri(token, strUri); NodeRevisionDescriptors revisionDescriptors = objectUri.getStore() .retrieveRevisionDescriptors(objectUri); if( branch != null ) { // Retrieving latest revision numbers NodeRevisionNumber branchLatestRevisionNumber = revisionDescriptors.getLatestRevision(branch); if (branchLatestRevisionNumber == null) { throw new BranchNotFoundException(strUri, branch); } create(token, strUri, branchLatestRevisionNumber, newRevisionDescriptor, revisionContent); } else { // special handling for DeltaV used for the creation of the // branch-less VHR descriptor at version 0.0 create( token, strUri, newRevisionDescriptor ); } } /** * Create a branch based on specified revision. * * @param strUri Uri * @param branchName Name of the new branch * @param basedOnRevisionDescriptor Node revision descriptor of * the revision on which the new branch * is based on. * * @return the NodeRevisionNumber of the created revision. */ public NodeRevisionNumber fork(SlideToken token, String strUri, String branchName, NodeRevisionDescriptor basedOnRevisionDescriptor) throws ObjectNotFoundException, AccessDeniedException, LinkedObjectNotFoundException, ServiceAccessException, RevisionDescriptorNotFoundException, ObjectLockedException, NodeNotVersionedException, RevisionAlreadyExistException, VetoException { return fork(token, strUri, branchName, basedOnRevisionDescriptor.getRevisionNumber()); } /** * Create a branch based on specified revision. * * @param strUri Uri * @param branchName Name of the new branch * @param basedOnRevisionNumber NodeRevisionNumber revision descriptor of * the revision on which the new branch * is based on. * * @return the NodeRevisionNumber of the created revision. */ public NodeRevisionNumber fork(SlideToken token, String strUri, String branchName, NodeRevisionNumber basedOnRevisionNumber) throws ObjectNotFoundException, AccessDeniedException, LinkedObjectNotFoundException, ServiceAccessException, RevisionDescriptorNotFoundException, ObjectLockedException, NodeNotVersionedException, RevisionAlreadyExistException, VetoException { if (branchName.equals(NodeRevisionDescriptors.MAIN_BRANCH)) return null; // Retrieve the associated object ObjectNode associatedObject = structureHelper.retrieve(token, strUri, false); // Next we do a security check and a locking check for modifyRevisions securityHelper.checkCredentials (token, associatedObject, namespaceConfig.getCreateRevisionMetadataAction()); lockHelper.checkLock (token, associatedObject, namespaceConfig.getCreateRevisionMetadataAction()); securityHelper.checkCredentials (token, associatedObject, namespaceConfig.getCreateRevisionContentAction()); lockHelper.checkLock(token, associatedObject, namespaceConfig.getCreateRevisionContentAction()); Uri objectUri = namespace.getUri(token, strUri); // Retrieve the revision table NodeRevisionDescriptors revisionDescriptors = objectUri.getStore() .retrieveRevisionDescriptors(objectUri); if (!revisionDescriptors.isVersioned()) { // Invalid function call : we try to create a revision, but the // descriptors won't allow it throw new NodeNotVersionedException(strUri); } // Retrieving the revision on which the new branch is based. NodeRevisionDescriptor basedOnRevisionDescriptor = objectUri.getStore().retrieveRevisionDescriptor (objectUri, basedOnRevisionNumber); NodeRevisionContent basedOnRevisionContent = null; try { basedOnRevisionContent = objectUri.getStore().retrieveRevisionContent (objectUri, basedOnRevisionDescriptor); } catch (RevisionNotFoundException e) { } // Create a revision number suited for the new branch NodeRevisionNumber branchedRevisionNumber = new NodeRevisionNumber(basedOnRevisionNumber, true); basedOnRevisionDescriptor.setRevisionNumber(branchedRevisionNumber); basedOnRevisionDescriptor.setBranchName(branchName); revisionDescriptors.setUri(strUri); revisionDescriptors.setLatestRevision (branchName, branchedRevisionNumber); revisionDescriptors.addSuccessor (basedOnRevisionNumber, branchedRevisionNumber); // Fire event if ( ContentEvent.FORK.isEnabled() ) EventDispatcher.getInstance().fireVetoableEvent(ContentEvent.FORK, new ContentEvent(this, token, namespace, strUri, revisionDescriptors)); // Invoke interceptors invokeInterceptors(token, revisionDescriptors, basedOnRevisionDescriptor, basedOnRevisionContent, PRE_STORE); // Storing back everything // TODO: setModificationDate // clone of NRD required?? if (basedOnRevisionContent != null) { objectUri.getStore().createRevisionContent (objectUri, basedOnRevisionDescriptor, basedOnRevisionContent); } objectUri.getStore().createRevisionDescriptor (objectUri, basedOnRevisionDescriptor); objectUri.getStore().storeRevisionDescriptors (objectUri, revisionDescriptors); // Invoke interceptors invokeInterceptors(token, revisionDescriptors, basedOnRevisionDescriptor, basedOnRevisionContent, POST_STORE); return branchedRevisionNumber; } /** * Merge specified branches into a single branch. * * @param strUri Uri * @param mainBranch Branch into which the other branch will be merged * @param branch Branch to merge into main branch * @param newRevisionDescriptor New revision descriptor * @param revisionContent Node revision content */ public void merge(SlideToken token, String strUri, NodeRevisionDescriptor mainBranch, NodeRevisionDescriptor branch, NodeRevisionDescriptor newRevisionDescriptor, NodeRevisionContent revisionContent) throws ObjectNotFoundException, AccessDeniedException, LinkedObjectNotFoundException, ServiceAccessException, RevisionDescriptorNotFoundException, ObjectLockedException, NodeNotVersionedException, BranchNotFoundException, RevisionAlreadyExistException, VetoException { merge(token, strUri, mainBranch.getBranchName(), branch.getBranchName(), newRevisionDescriptor, revisionContent); } /** * Merge specified branches into a single branch. * * @param strUri Uri * @param mainBranch Branch into which the other branch will be merged * @param branch Branch to merge into main branch * @param newRevisionDescriptor New revision descriptor * @param revisionContent Node revision content */ public void merge(SlideToken token, String strUri, String mainBranch, String branch, NodeRevisionDescriptor newRevisionDescriptor, NodeRevisionContent revisionContent) throws ObjectNotFoundException, AccessDeniedException, LinkedObjectNotFoundException, ServiceAccessException, RevisionDescriptorNotFoundException, ObjectLockedException, NodeNotVersionedException, BranchNotFoundException, RevisionAlreadyExistException, VetoException { // Retrieve the associated object ObjectNode associatedObject = structureHelper.retrieve(token, strUri, false); // Next we do a security check and a locking check for modifyRevisions securityHelper.checkCredentials (token, associatedObject, namespaceConfig.getCreateRevisionMetadataAction()); lockHelper.checkLock (token, associatedObject, namespaceConfig.getCreateRevisionMetadataAction()); securityHelper.checkCredentials (token, associatedObject, namespaceConfig.getCreateRevisionContentAction()); lockHelper.checkLock(token, associatedObject, namespaceConfig.getCreateRevisionContentAction()); setDefaultProperties(associatedObject, newRevisionDescriptor); Uri objectUri = namespace.getUri(token, strUri); // Retrieve the revision table NodeRevisionDescriptors revisionDescriptors = objectUri.getStore().retrieveRevisionDescriptors(objectUri); if (!revisionDescriptors.isVersioned()) { // Invalid function call : we try to create a revision, but the // descriptors won't allow it throw new NodeNotVersionedException(strUri); } // Retrieving latest revision numbers NodeRevisionNumber mainBranchLatestRevisionNumber = revisionDescriptors.getLatestRevision(mainBranch); NodeRevisionNumber branchLatestRevisionNumber = revisionDescriptors.getLatestRevision(branch); if (mainBranchLatestRevisionNumber == null) { throw new BranchNotFoundException(strUri, mainBranch); } if (branchLatestRevisionNumber == null) { throw new BranchNotFoundException(strUri, branch); } NodeRevisionNumber newRevisionNumber = new NodeRevisionNumber(mainBranchLatestRevisionNumber); newRevisionDescriptor.setRevisionNumber(newRevisionNumber); newRevisionDescriptor.setBranchName(branch); revisionDescriptors.addSuccessor (mainBranchLatestRevisionNumber, newRevisionNumber); revisionDescriptors.addSuccessor (branchLatestRevisionNumber, newRevisionNumber); revisionDescriptors.setLatestRevision(mainBranch, newRevisionNumber); // Fire event if ( ContentEvent.MERGE.isEnabled() ) EventDispatcher.getInstance().fireVetoableEvent(ContentEvent.MERGE, new ContentEvent(this, token, namespace, objectUri.toString(), revisionDescriptors, newRevisionDescriptor, revisionContent)); // Invoke interceptors invokeInterceptors(token, revisionDescriptors, newRevisionDescriptor, revisionContent, PRE_STORE); // Storing back everything if (revisionContent != null) { objectUri.getStore().createRevisionContent (objectUri, newRevisionDescriptor, revisionContent); } newRevisionDescriptor.setModificationDate(newRevisionDescriptor.getCreationDate()); newRevisionDescriptor.setModificationUser( securityHelper.getPrincipal(token).getPath().lastSegment()); objectUri.getStore().createRevisionDescriptor (objectUri, newRevisionDescriptor); objectUri.getStore().storeRevisionDescriptors (objectUri, revisionDescriptors); // Invoke interceptors invokeInterceptors(token, revisionDescriptors, newRevisionDescriptor, revisionContent, POST_STORE); } /** * Update contents of an existing revision. * * @param strUri Uri * @param revisionDescriptor Revision descriptor * @param revisionContent Revision content */ public void store(SlideToken token, String strUri, NodeRevisionDescriptor revisionDescriptor, NodeRevisionContent revisionContent) throws ObjectNotFoundException, AccessDeniedException, LinkedObjectNotFoundException, ServiceAccessException, RevisionDescriptorNotFoundException, ObjectLockedException, RevisionNotFoundException, VetoException { // Retrieve the associated object ObjectNode associatedObject = structureHelper.retrieve(token, strUri, false); // Next we do a security check and a locking check for modifyRevisions securityHelper.checkCredentials (token, associatedObject, namespaceConfig.getModifyRevisionMetadataAction()); lockHelper.checkLock (token, associatedObject, namespaceConfig.getModifyRevisionMetadataAction()); securityHelper.checkCredentials (token, associatedObject, namespaceConfig.getModifyRevisionContentAction()); lockHelper.checkLock(token, associatedObject, namespaceConfig.getModifyRevisionContentAction()); setDefaultProperties(associatedObject, revisionDescriptor); Uri objectUri = namespace.getUri(token, strUri); // Retrieve the revision table NodeRevisionDescriptors revisionDescriptors = objectUri.getStore().retrieveRevisionDescriptors(objectUri); // Fire event if ( revisionDescriptor.getRevisionNumber() != NodeRevisionNumber.HIDDEN_0_0 && ContentEvent.STORE.isEnabled() ) EventDispatcher.getInstance().fireVetoableEvent(ContentEvent.STORE, new ContentEvent(this, token, namespace, objectUri.toString(), revisionDescriptors, revisionDescriptor, revisionContent)); // Invoke interceptors invokeInterceptors(token, revisionDescriptors, revisionDescriptor, revisionContent, PRE_STORE); if (revisionContent != null) { try { // Removed retrieveContent call [pnever, 25-APR-2003]. // Reasons: // - it is not necessary to check existence because storeRevisionContent also throws RevisionNotFoundException // - it is harmful for filesystem-based stores, as the input streams created by retrieveRevisionContent never are closed // Simple scenario: // Use the FileContentStore, create a file, update it and then try to delete it. // It will not be deleted from the filesystem. // // objectUri.getStore().retrieveRevisionContent // (objectUri, revisionDescriptor); objectUri.getStore().storeRevisionContent (objectUri, revisionDescriptor, revisionContent); } catch (RevisionNotFoundException e) { try { objectUri.getStore().createRevisionContent (objectUri, revisionDescriptor, revisionContent); } catch (RevisionAlreadyExistException ex) { // Should never happen ex.printStackTrace(); } } } revisionDescriptor.setModificationDate(new Date()); revisionDescriptor.setModificationUser( securityHelper.getPrincipal(token).getPath().lastSegment()); objectUri.getStore().storeRevisionDescriptor (objectUri, revisionDescriptor); // Invoke interceptors invokeInterceptors(token, revisionDescriptors, revisionDescriptor, revisionContent, POST_STORE); } /** * Remove all revisions at this Uri. * * @param revisionDescriptors Node revision descriptors */ public void remove(SlideToken token, NodeRevisionDescriptors revisionDescriptors) throws ObjectNotFoundException, AccessDeniedException, LinkedObjectNotFoundException, ServiceAccessException, RevisionDescriptorNotFoundException, ObjectLockedException, VetoException { // Invoke interceptors invokeInterceptors(token, revisionDescriptors, null, null, PRE_REMOVE); // Retrieve the associated object ObjectNode associatedObject = structureHelper.retrieve (token, revisionDescriptors.getUri(), false); // Next we do a security check and a locking check for modifyRevisions securityHelper.checkCredentials (token, associatedObject, namespaceConfig.getRemoveRevisionMetadataAction()); lockHelper.checkLock (token, associatedObject, namespaceConfig.getRemoveRevisionMetadataAction()); securityHelper.checkCredentials (token, associatedObject, namespaceConfig.getRemoveRevisionContentAction()); lockHelper.checkLock(token, associatedObject, namespaceConfig.getRemoveRevisionContentAction()); Uri objectUri = namespace.getUri(token, revisionDescriptors.getUri()); // Fire event if ( ContentEvent.REMOVE.isEnabled() ) EventDispatcher.getInstance().fireVetoableEvent(ContentEvent.REMOVE, new ContentEvent(this, token, namespace, objectUri.toString(), revisionDescriptors)); objectUri.getStore().removeRevisionDescriptors(objectUri); // Invoke interceptors invokeInterceptors(token, revisionDescriptors, null, null, POST_REMOVE); } /** * Remove specified revision. * * @param strUri Uri * @param revisionDescriptor Node revision descriptor */ public void remove(SlideToken token, String strUri, NodeRevisionDescriptor revisionDescriptor) throws ObjectNotFoundException, AccessDeniedException, LinkedObjectNotFoundException, ServiceAccessException, RevisionDescriptorNotFoundException, ObjectLockedException, VetoException { remove(token, strUri, revisionDescriptor.getRevisionNumber()); } /** * Remove specified revision. * * @param strUri Uri * @param revisionNumber Revision number */ public void remove(SlideToken token, String strUri, NodeRevisionNumber revisionNumber) throws ObjectNotFoundException, AccessDeniedException, LinkedObjectNotFoundException, ServiceAccessException, RevisionDescriptorNotFoundException, ObjectLockedException, VetoException { // Retrieve the associated object ObjectNode associatedObject = structureHelper.retrieve(token, strUri, false); // Next we do a security check and a locking check for modifyRevisions securityHelper.checkCredentials (token, associatedObject, namespaceConfig.getRemoveRevisionMetadataAction()); lockHelper.checkLock (token, associatedObject, namespaceConfig.getRemoveRevisionMetadataAction()); securityHelper.checkCredentials (token, associatedObject, namespaceConfig.getRemoveRevisionContentAction()); lockHelper.checkLock(token, associatedObject, namespaceConfig.getRemoveRevisionContentAction()); Uri objectUri = namespace.getUri(token, strUri); NodeRevisionDescriptor revisionDescriptor = objectUri.getStore().retrieveRevisionDescriptor (objectUri, revisionNumber); // Fire event if ( revisionNumber != NodeRevisionNumber.HIDDEN_0_0 && ContentEvent.REMOVE.isEnabled() ) EventDispatcher.getInstance().fireVetoableEvent(ContentEvent.REMOVE, new ContentEvent(this, token, namespace, objectUri.toString(), revisionDescriptor)); // Invoke interceptors NodeRevisionDescriptors revisionDescriptors = new NodeRevisionDescriptors(); revisionDescriptors.setUri(strUri); invokeInterceptors(token, revisionDescriptors, revisionDescriptor, null, PRE_REMOVE); objectUri.getStore().removeRevisionContent (objectUri, revisionDescriptor); objectUri.getStore() .removeRevisionDescriptor(objectUri, revisionNumber); // Invoke interceptors invokeInterceptors(token, null, revisionDescriptor, null, POST_REMOVE); } // ------------------------------------------------------ Protected Methods /** * Create new revision based on a previous revision. * * @param strUri Uri * @param basedOnRevisionNumber Number of revision on which the * new revision is based * @param newRevisionDescriptor New revision descriptor * @param revisionContent Node revision content */ protected void create(SlideToken token, String strUri, NodeRevisionNumber basedOnRevisionNumber, NodeRevisionDescriptor newRevisionDescriptor, NodeRevisionContent revisionContent) throws ObjectNotFoundException, AccessDeniedException, RevisionAlreadyExistException, LinkedObjectNotFoundException, ServiceAccessException, RevisionDescriptorNotFoundException, ObjectLockedException, NodeNotVersionedException, VetoException { // Retrieve the associated object ObjectNode associatedObject = structureHelper.retrieve(token, strUri, false); // Next we do a security check and a locking check for modifyRevisions securityHelper.checkCredentials (token, associatedObject, namespaceConfig.getCreateRevisionMetadataAction()); lockHelper.checkLock (token, associatedObject, namespaceConfig.getCreateRevisionMetadataAction()); securityHelper.checkCredentials (token, associatedObject, namespaceConfig.getCreateRevisionContentAction()); lockHelper.checkLock(token, associatedObject, namespaceConfig.getCreateRevisionContentAction()); setDefaultProperties(associatedObject, newRevisionDescriptor); Uri objectUri = namespace.getUri(token, strUri); // Retrieve the revision table NodeRevisionDescriptors revisionDescriptors = objectUri.getStore() .retrieveRevisionDescriptors(objectUri); if (!revisionDescriptors.isVersioned()) { // Invalid function call : we try to create a revision, but the // descriptors won't allow it throw new NodeNotVersionedException(strUri); } // Retrieve the old revision descriptor, just to make sure that the old // revision we base the new one upon really exists NodeRevisionDescriptor realOldRevisionDescriptor = objectUri.getStore().retrieveRevisionDescriptor (objectUri, basedOnRevisionNumber); // We check that the old revision doesn't have successors, that is we : // - check to see if it's the latest revision in a branch // - store that information for later use NodeRevisionNumber latestNumberInBranch = revisionDescriptors.getLatestRevision (realOldRevisionDescriptor.getBranchName()); if (!realOldRevisionDescriptor.getRevisionNumber() .equals(latestNumberInBranch)) { throw new RevisionAlreadyExistException (objectUri.toString(), new NodeRevisionNumber (basedOnRevisionNumber)); } // Next, generate the new revision's number newRevisionDescriptor.setRevisionNumber (new NodeRevisionNumber(basedOnRevisionNumber)); // Set the creation date newRevisionDescriptor.setCreationDate(new Date()); // Set the creation user setCreationUser(token, newRevisionDescriptor); // Initialize the branch name in the new descriptor newRevisionDescriptor.setBranchName (realOldRevisionDescriptor.getBranchName()); // Fire event if ( ContentEvent.CREATE.isEnabled() ) EventDispatcher.getInstance().fireVetoableEvent(ContentEvent.CREATE, new ContentEvent(this, token, namespace, objectUri.toString(), revisionDescriptors, newRevisionDescriptor, revisionContent)); // Invoke interceptors invokeInterceptors(token, revisionDescriptors, newRevisionDescriptor, revisionContent, PRE_STORE); // Update the revision graph in the revision descriptors revisionDescriptors .addSuccessor(revisionDescriptors.getLatestRevision(newRevisionDescriptor.getBranchName()), newRevisionDescriptor.getRevisionNumber()); revisionDescriptors .setSuccessors(newRevisionDescriptor.getRevisionNumber(), new Vector()); revisionDescriptors .setLatestRevision(newRevisionDescriptor.getBranchName(), newRevisionDescriptor.getRevisionNumber()); if (revisionContent != null) { // Storing the new revision contents objectUri.getStore() .createRevisionContent(objectUri, newRevisionDescriptor, revisionContent); } // Now creating the revision desriptor in the store newRevisionDescriptor.setModificationDate(newRevisionDescriptor.getCreationDate()); newRevisionDescriptor.setModificationUser( securityHelper.getPrincipal(token).getPath().lastSegment()); objectUri.getStore() .createRevisionDescriptor(objectUri, newRevisionDescriptor); // We now store the updated revision descriptors try { objectUri.getStore() .storeRevisionDescriptors(objectUri, revisionDescriptors); } catch (RevisionDescriptorNotFoundException e) { // Problem ... e.printStackTrace(); } // Invoke interceptors invokeInterceptors(token, revisionDescriptors, newRevisionDescriptor, revisionContent, POST_STORE); } /** * Create new branch-less revision descriptor. * This is used only by DeltaV to store the VHR-specific descriptor at * revision 0.0, or to backup the properties of a VCR for checkout/uncheckout * at revision 0.0. */ protected void create( SlideToken token, String strUri, NodeRevisionDescriptor revisionDescriptor ) throws ObjectNotFoundException, AccessDeniedException, RevisionAlreadyExistException, LinkedObjectNotFoundException, ServiceAccessException, RevisionDescriptorNotFoundException, ObjectLockedException, NodeNotVersionedException, VetoException { // Retrieve the associated object ObjectNode associatedObject = structureHelper.retrieve(token, strUri, false); // Next we do a security check and a locking check for modifyRevisions securityHelper.checkCredentials (token, associatedObject, namespaceConfig.getCreateRevisionMetadataAction()); lockHelper.checkLock (token, associatedObject, namespaceConfig.getCreateRevisionMetadataAction()); securityHelper.checkCredentials (token, associatedObject, namespaceConfig.getCreateRevisionContentAction()); lockHelper.checkLock(token, associatedObject, namespaceConfig.getCreateRevisionContentAction()); setDefaultProperties(associatedObject, revisionDescriptor); Uri objectUri = namespace.getUri(token, strUri); // Retrieve the revision table NodeRevisionDescriptors revisionDescriptors = objectUri.getStore() .retrieveRevisionDescriptors(objectUri); // Set the creation date revisionDescriptor.setCreationDate(new Date()); // Set the creation user setCreationUser(token, revisionDescriptor); // Initialize the branch name in the new descriptor String branchName = "backup"; NodeProperty rootVersionProperty = revisionDescriptor.getProperty( "version-set"); if (rootVersionProperty != null) { branchName = "version-history"; } revisionDescriptor.setBranchName(branchName); // Fire event if ( revisionDescriptor.getRevisionNumber() != NodeRevisionNumber.HIDDEN_0_0 && ContentEvent.CREATE.isEnabled() ) EventDispatcher.getInstance().fireVetoableEvent(ContentEvent.CREATE, new ContentEvent(this, token, namespace, objectUri.toString(), revisionDescriptors, revisionDescriptor)); // Invoke interceptors invokeInterceptors(token, revisionDescriptors, revisionDescriptor, null, PRE_STORE); // Now creating the revision desriptor in the store revisionDescriptor.setModificationDate(revisionDescriptor.getCreationDate()); revisionDescriptor.setModificationUser( securityHelper.getPrincipal(token).getPath().lastSegment()); objectUri.getStore() .createRevisionDescriptor(objectUri, revisionDescriptor); // We now store the updated revision descriptors try { objectUri.getStore() .storeRevisionDescriptors(objectUri, revisionDescriptors); } catch (RevisionDescriptorNotFoundException e) { // Problem ... e.printStackTrace(); } // Invoke interceptors invokeInterceptors(token, revisionDescriptors, revisionDescriptor, null, POST_STORE); } private void setCreationUser(SlideToken token, NodeRevisionDescriptor revisionDescriptor) throws ServiceAccessException, ObjectNotFoundException { String creationUser = ((SubjectNode)securityHelper.getPrincipal(token)).getPath().lastSegment(); revisionDescriptor.setCreationUser(creationUser); revisionDescriptor.setOwner(creationUser); } /** * Set default properties for a revision descriptors. */ protected void setDefaultProperties (ObjectNode associatedObject, NodeRevisionDescriptor revisionDescriptor) { // Retrieving the roles of the associated object Enumeration roles = securityHelper.getRoles(associatedObject); while (roles.hasMoreElements()) { String role = (String) roles.nextElement(); Enumeration defaultProperties = namespaceConfig.getDefaultProperties(role); revisionDescriptor.setDefaultProperties(defaultProperties); } if (namespaceConfig.isPrincipal(associatedObject.getUri())) { // principals must have DAV:displayname if (revisionDescriptor.getName() == null || revisionDescriptor.getName().length() == 0) { revisionDescriptor.setName( UriPath.getLastSegment(associatedObject.getUri())); } // principals must have DAV:principal in resourcetype String rt = revisionDescriptor.getResourceType(); if (rt.indexOf("principal") < 0) { revisionDescriptor.setResourceType(rt+"<principal/>"); } } } /** * Invoke content interceptors. */ protected void invokeInterceptors (SlideToken token, NodeRevisionDescriptors revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, NodeRevisionContent revisionContent, int type) throws AccessDeniedException, ObjectNotFoundException, LinkedObjectNotFoundException, ObjectLockedException, ServiceAccessException { ContentInterceptor[] contentInterceptors = namespace.getContentInterceptors(); for (int i = 0; i < contentInterceptors.length; i++) { switch (type) { case PRE_STORE: contentInterceptors[i].preStoreContent (token, revisionDescriptors, revisionDescriptor, revisionContent); break; case POST_STORE: contentInterceptors[i].postStoreContent (token, revisionDescriptors, revisionDescriptor, revisionContent); break; case POST_RETRIEVE: contentInterceptors[i].postRetrieveContent (token, revisionDescriptors, revisionDescriptor, revisionContent); break; case PRE_REMOVE: contentInterceptors[i].preRemoveContent (token, revisionDescriptors, revisionDescriptor); break; case POST_REMOVE: contentInterceptors[i].postRemoveContent (token, revisionDescriptors, revisionDescriptor); break; } } } /** * */ protected String redirectUri( String uri ) { String result = uri; if( uriRedirectorClass != null ) { try { Method ru = uriRedirectorClass.getMethod( "redirectUri", new Class[]{String.class} ); result = (String)ru.invoke( null, new Object[]{uri} ); // obj=null since method is static } catch( Exception x ) { Domain.warn( "Redirecting of URI "+uri+" failed: "+x.getMessage() ); } } return result; } /** * */ protected NodeRevisionNumber redirectLatestRevisionNumber( String uri ) { NodeRevisionNumber result = null; if( uriRedirectorClass != null ) { try { Method ru = uriRedirectorClass.getMethod( "redirectLatestRevisionNumber", new Class[]{String.class} ); result = (NodeRevisionNumber)ru.invoke( null, new Object[]{uri} ); // obj=null since method is static } catch( Exception x ) { Domain.warn( "Redirecting of latest revision number for "+uri+" failed: "+x.getMessage() ); } } return result; } private boolean isLockNull( NodeRevisionDescriptor nrd ) { return nrd.propertyValueContains("resourcetype", "lock-null"); } private void checkParentExists(String strUri, SlideToken token) throws ServiceAccessException, ObjectLockedException, AccessDeniedException, LinkedObjectNotFoundException, ObjectNotFoundException, VetoException { if (namespaceConfig.getCreateObjectAction().equals(ActionNode.DEFAULT)) { // do not check during start-up return; } String parentUri = UriPath.getParentUri(strUri); try { NodeRevisionDescriptor parentNrd = retrieve(token, retrieve(token, parentUri)); if (isLockNull(parentNrd)) { throw new ObjectNotFoundException(parentUri); } } catch (RevisionDescriptorNotFoundException e) { throw new ObjectNotFoundException(parentUri); } } }

The table below shows all metrics for ContentImpl.java.

MetricValueDescription
BLOCKS101.00Number of blocks
BLOCK_COMMENT22.00Number of block comment lines
COMMENTS355.00Comment lines
COMMENT_DENSITY 0.43Comment density
COMPARISONS60.00Number of comparison operators
CYCLOMATIC103.00Cyclomatic complexity
DECL_COMMENTS36.00Comments in declarations
DOC_COMMENT178.00Number of javadoc comment lines
ELOC819.00Effective lines of code
EXEC_COMMENTS120.00Comments in executable code
EXITS109.00Procedure exits
FUNCTIONS27.00Number of function declarations
HALSTEAD_DIFFICULTY137.02Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY637.00Interface complexity
JAVA0001 0.00JAVA0001 Package name does not contain only lower case letters
JAVA0002 0.00JAVA0002 Package name does not begin with a top level domain name or country code
JAVA0003 0.00JAVA0003 Minimize use of on-demand (.*) imports
JAVA0004 0.00JAVA0004 Unnecessary import from java.lang
JAVA0005 1.00JAVA0005 Imports not in specified order
JAVA0006 0.00JAVA0006 Empty finally block
JAVA0007 0.00JAVA0007 Should not declare public field
JAVA0008 0.00JAVA0008 Empty catch block
JAVA0009 0.00JAVA0009 Protected member in final class
JAVA0010 0.00JAVA0010 Non-instantiable class does not contain a non-private static member
JAVA0011 0.00JAVA0011 Abstract class does not contain an abstract method
JAVA0012 0.00JAVA0012 Non-constructor method with same name as declaring class
JAVA0013 0.00JAVA0013 Non-blank final field is not static
JAVA0014 0.00JAVA0014 Class with only static members has non-private constructor
JAVA0015 0.00JAVA0015 Package class contains public nested type
JAVA0016 0.00JAVA0016 Abstract class contains public constructor
JAVA0017 0.00JAVA0017 Class name does not have required form
JAVA0018 0.00JAVA0018 Method name does not have required form
JAVA0019 0.00JAVA0019 Interface name does not have required form
JAVA0020 0.00JAVA0020 Field name does not have required form
JAVA0021 0.00JAVA0021 Interface method name does not have required form
JAVA0022 0.00JAVA0022 Static final field name does not have required form
JAVA0023 0.00JAVA0023 Empty finalize method
JAVA0024 0.00JAVA0024 Empty class
JAVA0025 0.00JAVA0025 Method override is empty
JAVA0026 0.00JAVA0026 Finalize method with parameters
JAVA0029 0.00JAVA0029 Private method not used
JAVA0030 0.00JAVA0030 Private field not used
JAVA0031 0.00JAVA0031 Case statement not properly closed
JAVA0032 1.00JAVA0032 Switch statement missing default
JAVA0033 0.00JAVA0033 default: not last case in switch statement
JAVA003414.00JAVA0034 Missing braces in if statement
JAVA0035 0.00JAVA0035 Missing braces in for statement
JAVA0036 0.00JAVA0036 Missing braces in while statement
JAVA0038 0.00JAVA0038 Non-case label in switch statement
JAVA0039 0.00JAVA0039 Break statement with label
JAVA0040 0.00JAVA0040 Switch statement contains N cases (maximum: M)
JAVA0041 0.00JAVA0041 Nested synchronized block
JAVA0042 0.00JAVA0042 Empty synchronized statement
JAVA0043 0.00JAVA0043 Inner class does not use outer class
JAVA0044 0.00JAVA0044 Serializable class with no instance variables
JAVA0045 0.00JAVA0045 Serializable class with only transient fields
JAVA0046 0.00JAVA0046 Name of class not derived from Exception ends with 'Exception'
JAVA0047 0.00JAVA0047 Serializable class derives from invalid base class
JAVA0048 0.00JAVA0048 Name of class derived from Exception does not end with 'Exception'
JAVA0049 3.00JAVA0049 Nested block at depth N (maximum: M)
JAVA0050 0.00JAVA0050 Class derives from java.lang.Error
JAVA0051 0.00JAVA0051 Class derives from java.lang.RuntimeException
JAVA0052 0.00JAVA0052 Class derives from java.lang.Throwable
JAVA0053 0.00JAVA0053 Unused label
JAVA0054 0.00JAVA0054 Inheritance depth N exceeds maximum M
JAVA0055 0.00JAVA0055 Class should be interface
JAVA0056 0.00JAVA0056 Unnecessary abstract modifier for interface or annotation
JAVA0057 0.00JAVA0057 Unnecessary default constructor
JAVA0058 0.00JAVA0058 Constructor calls super()
JAVA0059 0.00JAVA0059 Method override only calls super()
JAVA0061 0.00JAVA0061 Inaccessible member in anonymous class
JAVA0062 0.00JAVA0062 Public class missing public member or protected constructor
JAVA0063 0.00JAVA0063 Identifier name should not contain '$'
JAVA0064 0.00JAVA0064 N variations of identifier name (maximum: M)
JAVA0065 0.00JAVA0065 Unnecessary final modifier for method in final class
JAVA0066 0.00JAVA0066 Unnecessary modifier for interface nested type
JAVA0067 0.00JAVA0067 Array descriptor on identifier name
JAVA0068 0.00JAVA0068 Modifiers not declared in recommended order
JAVA0071 0.00JAVA0071 Strings compared with ==
JAVA0073 0.00JAVA0073 Integer division in floating-point context
JAVA0074 0.00JAVA0074 Use of Object.notify()
JAVA0075 0.00JAVA0075 Method parameter hides field
JAVA0076 0.00JAVA0076 Use of magic number
JAVA0077 0.00JAVA0077 Private field not used in declaring class
JAVA0078 0.00JAVA0078 Floating point values compared with ==
JAVA0079 0.00JAVA0079 Use of instance to reference static member
JAVA0080 0.00JAVA0080 Import declaration not used
JAVA0081 0.00JAVA0081 Boolean literal in comparison
JAVA0082 0.00JAVA0082 Unnecessary widening cast
JAVA0083 0.00JAVA0083 Unnecessary instanceof test
JAVA0084 0.00JAVA0084 Should use compound assignment operator
JAVA0085 0.00JAVA0085 Use of sun.* class
JAVA0087 0.00JAVA0087 Use of Thread.sleep()
JAVA0089 0.00JAVA0089 Use of restricted package
JAVA0092 0.00JAVA0092 Use of restricted type
JAVA0093 0.00JAVA0093 Redundant assignment
JAVA0094 0.00JAVA0094 Field hides a superclass field
JAVA0095 0.00JAVA0095 Uninitialized private field
JAVA0096 0.00JAVA0096 Field in nested class hides outer field
JAVA0098 0.00JAVA0098 Minimize use of implicit field initializers
JAVA0100 0.00JAVA0100 Class contains N non-final fields (maximum: M)
JAVA0101 0.00JAVA0101 Unnecessary modifier for field in interface
JAVA0102 0.00JAVA0102 Last statement in finalize() not super.finalize()
JAVA0103 0.00JAVA0103 Explicit call to finalize()
JAVA0104 0.00JAVA0104 finalize() only calls super.finalize()
JAVA0105 0.00JAVA0105 Duplicate import declaration
JAVA0106 0.00JAVA0106 Unnecessary import from current package
JAVA010813.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 0.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA0110 7.00JAVA0110 Incorrect javadoc: no @return tag
JAVA0111 0.00JAVA0111 Incorrect javadoc: @return tag for void method
JAVA0112 0.00JAVA0112 Incorrect javadoc: no exception 'exception' in throws
JAVA0113 1.00JAVA0113 Incorrect javadoc: no @author tag
JAVA0114 0.00JAVA0114 Incorrect javadoc: no @version tag
JAVA0115158.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0116 0.00JAVA0116 Missing javadoc: field 'field'
JAVA0117 0.00JAVA0117 Missing javadoc: method 'method'
JAVA0118 0.00JAVA0118 Missing javadoc: type 'type'
JAVA0119 0.00JAVA0119 Control variable changed within body of for loop
JAVA0123 0.00JAVA0123 Use all three components of for loop
JAVA0125 0.00JAVA0125 Continue statement with label
JAVA0126 0.00JAVA0126 Method declares unchecked exception in throws
JAVA0128 0.00JAVA0128 Public constructor in non-public class
JAVA0130 1.00JAVA0130 Non-static method does not use instance fields
JAVA0131 0.00JAVA0131 Compatible method does not override base
JAVA0132 0.00JAVA0132 Method overload with compatible signature
JAVA0133 0.00JAVA0133 Non-synchronized method overrides synchronized method
JAVA0135 0.00JAVA0135 Only one of Object.equals and Object.hashCode defined: missing 'method'
JAVA0136 1.00JAVA0136 N methods defined in class (maximum: M)
JAVA0137 0.00JAVA0137 Non-abstract class missing constructor
JAVA0138 2.00JAVA0138 N parameters defined for method (maximum: M)
JAVA0139 0.00JAVA0139 Definition of main other than public static void main(java.lang.String[])
JAVA0141 0.00JAVA0141 Unnecessary modifier for method in interface
JAVA0143 0.00JAVA0143 Synchronized method
JAVA014415.00JAVA0144 Line exceeds maximum M characters
JAVA0145 0.00JAVA0145 Tab character used in source file
JAVA0150 0.00JAVA0150 java.lang.Error (or subclass) thrown
JAVA0153 0.00JAVA0153 Inefficient conversion of integer to string
JAVA0159 0.00JAVA0159 Inefficient conversion of string to integer
JAVA0160 2.00JAVA0160 Method does not throw specified exception
JAVA0161 0.00JAVA0161 Conditional wait() not in loop
JAVA0163 0.00JAVA0163 Empty statement
JAVA0165 0.00JAVA0165 Conflicting return statement in finally block
JAVA0166 3.00JAVA0166 Generic exception caught
JAVA0167 0.00JAVA0167 ThreadDeath not rethrown
JAVA0169 0.00JAVA0169 Unnecessary catch block: exception 'exception'
JAVA0170 0.00JAVA0170 Caught exception not derived from java.lang.Exception
JAVA0171 0.00JAVA0171 Unused local variable
JAVA0173 0.00JAVA0173 Unused method parameter
JAVA0174 0.00JAVA0174 Assigned local variable never used
JAVA0175 0.00JAVA0175 Successive assignment to variable
JAVA0176 0.00JAVA0176 Local variable name does not have required form
JAVA0177 2.00JAVA0177 Variable declaration missing initializer
JAVA0179 0.00JAVA0179 Local variable hides visible field
JAVA0233 0.00JAVA0233 Definition of serialVersionUID other than 'private static final long serialVersionUID'
JAVA0234 0.00JAVA0234 Class is Serializable but does not define serialVersionUID
JAVA0235 0.00JAVA0235 Class defines serialVersionUID but does not implement Serializable
JAVA0236 0.00JAVA0236 Attempt to clone an object which does not implement Cloneable
JAVA0237 0.00JAVA0237 Class implements Cloneable but does not have public clone method
JAVA0238 0.00JAVA0238 Clone method does not call super.clone()
JAVA0239 0.00JAVA0239 Class declares 'readObject' or 'writeObject' but does not implement Serializable
JAVA0240 0.00JAVA0240 Serializable class which declares readObject or writeObject but not both
JAVA0241 0.00JAVA0241 'readObject' or 'writeObject' should be declared private in Serializable class
JAVA0242 0.00JAVA0242 Transient field in non-Serializable class
JAVA0243 0.00JAVA0243 'readResolve' or 'writeReplace' should be declared private or protected
JAVA0244 0.00JAVA0244 Field or method name in subclass differs only by case from inherited field or method
JAVA0245 0.00JAVA0245 JUnit TestCase with non-trivial constructor
JAVA0246 0.00JAVA0246 JUnit assertXXX statement missing message parameter
JAVA0247 0.00JAVA0247 JUnit 'setUp()' and 'tearDown()' should call super method
JAVA0248 0.00JAVA0248 JUnit method 'setUp' or 'tearDown' with incorrect signature
JAVA0249 0.00JAVA0249 JUnit TestCase 'suite()' should be declared static
JAVA0250 0.00JAVA0250 JUnit TestCase declares testXXX method with incorrect signature
JAVA0251 0.00JAVA0251 Use '%n' for line breaks in printf/format for platform independence
JAVA0252 0.00JAVA0252 'enum' is a Java 1.5 reserved word
JAVA0253 0.00JAVA0253 Not all enum constants consumed in switch statement
JAVA0254 0.00JAVA0254 Use enhanced for loop construct instead of Iterator
JAVA0255 0.00JAVA0255 Result of method invocation not used
JAVA0256 0.00JAVA0256 Assignment of external collection/array to field
JAVA0257 0.00JAVA0257 Use of 'Constant Interface' anti-pattern
JAVA0258 0.00JAVA0258 Implement Iterable for foreach compatibility
JAVA0259 0.00JAVA0259 Return of collection/array field
JAVA0260 0.00JAVA0260 Use 'enum' instead of Enumerated Type pattern
JAVA0261 0.00JAVA0261 Use specialized Enum collection types
JAVA0262 0.00JAVA0262 Use of char in integer context
JAVA0263 0.00JAVA0263 Long literal ends with 'l' instead of 'L'
JAVA0264 0.00JAVA0264 Integer math in long context - check for overflow
JAVA0265 4.00JAVA0265 Use of Throwable.printStackTrace()
JAVA0266 0.00JAVA0266 Use of System.out
JAVA0267 0.00JAVA0267 Use of System.err
JAVA0269 0.00JAVA0269 Contents of StringBuffer never used
JAVA0270 1.00JAVA0270 Use Java 5.0 enhanced for loop construct to iterate over all elements in an array
JAVA0271 0.00JAVA0271 Minimize use of on-demand (.*) static imports
JAVA0272 0.00JAVA0272 Thread.run() called
JAVA0273 0.00JAVA0273 Non-final derivative of Thread calls start() in constructor
JAVA0274 0.00JAVA0274 Serializable class has a synchronized readObject()
JAVA0275 0.00JAVA0275 Serializable class has a synchronized writeObject() and no other synchronized methods
JAVA0276 0.00JAVA0276 Unnecessary use of String constructor
JAVA0277 0.00JAVA0277 Iterator.next() implementation does not throw NoSuchElementException
JAVA0278 0.00JAVA0278 Unnecessary use of Boolean constructor
JAVA0279