本文整理汇总了Java中org.alfresco.service.cmr.repository.InvalidNodeRefException类的典型用法代码示例。如果您正苦于以下问题:Java InvalidNodeRefException类的具体用法?Java InvalidNodeRefException怎么用?Java InvalidNodeRefException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InvalidNodeRefException类属于org.alfresco.service.cmr.repository包,在下文中一共展示了InvalidNodeRefException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: executeImpl
import org.alfresco.service.cmr.repository.InvalidNodeRefException; //导入依赖的package包/类
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
if (! isEnabled())
{
throw new WebScriptException(HttpServletResponse.SC_FORBIDDEN, "QuickShare is disabled system-wide");
}
// create map of params (template vars)
Map<String, String> params = req.getServiceMatch().getTemplateVars();
final NodeRef nodeRef = WebScriptUtil.getNodeRef(params);
if (nodeRef == null)
{
String msg = "A valid NodeRef must be specified!";
throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, msg);
}
try
{
QuickShareDTO dto = quickShareService.shareContent(nodeRef);
Map<String, Object> model = new HashMap<String, Object>(1);
model.put("sharedDTO", dto);
return model;
}
catch (InvalidNodeRefException inre)
{
throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find node: " + nodeRef);
}
}
示例2: executeImpl
import org.alfresco.service.cmr.repository.InvalidNodeRefException; //导入依赖的package包/类
@Override
protected Map<String, Object> executeImpl(final WebScriptRequest req, Status status, Cache cache)
{
// create map of params (template vars)
Map<String, String> params = req.getServiceMatch().getTemplateVars();
final NodeRef nodeRef = WebScriptUtil.getNodeRef(params);
if (nodeRef == null)
{
String msg = "A valid NodeRef must be specified!";
throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, msg);
}
try
{
Map<String, Object> model = quickShareService.getMetaData(nodeRef);
if (logger.isDebugEnabled())
{
logger.debug("Retrieved limited metadata: "+nodeRef+" ["+model+"]");
}
return model;
}
catch (InvalidNodeRefException inre)
{
logger.error("Unable to find node: "+inre.getNodeRef());
throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find nodeRef: "+inre.getNodeRef());
}
}
示例3: doInRetryingTransaction
import org.alfresco.service.cmr.repository.InvalidNodeRefException; //导入依赖的package包/类
/**
* To allow for possible 'read committed' behaviour in some databases, where a node that previously existed during a
* transaction can disappear from existence, we treat InvalidNodeRefExceptions as concurrency conditions.
*/
protected <T2> T2 doInRetryingTransaction(final RetryingTransactionCallback<T2> callback, boolean isReadThrough)
{
return transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<T2>()
{
@Override
public T2 execute() throws Throwable
{
try
{
return callback.execute();
}
catch (InvalidNodeRefException e)
{
// Turn InvalidNodeRefExceptions into retryable exceptions.
throw new ConcurrencyFailureException("Possible cache integrity issue during reindexing", e);
}
}
}, true, isReadThrough);
}
示例4: setPermission
import org.alfresco.service.cmr.repository.InvalidNodeRefException; //导入依赖的package包/类
public void setPermission(NodeRef nodeRef, String authority, PermissionReference permission, boolean allow)
{
CreationReport report = null;
try
{
report = getMutableAccessControlList(nodeRef);
}
catch (InvalidNodeRefException e)
{
return;
}
if (report.getCreated() != null)
{
SimpleAccessControlEntry entry = new SimpleAccessControlEntry();
entry.setAuthority(authority);
entry.setPermission(permission);
entry.setAccessStatus(allow ? AccessStatus.ALLOWED : AccessStatus.DENIED);
entry.setAceType(ACEType.ALL);
entry.setPosition(Integer.valueOf(0));
List<AclChange> changes = aclDaoComponent.setAccessControlEntry(report.getCreated().getId(), entry);
List<AclChange> all = new ArrayList<AclChange>(changes.size() + report.getChanges().size());
all.addAll(report.getChanges());
all.addAll(changes);
getACLDAO(nodeRef).updateChangedAcls(nodeRef, all);
}
}
示例5: toFileInfo
import org.alfresco.service.cmr.repository.InvalidNodeRefException; //导入依赖的package包/类
/**
* Helper method to convert node reference instances to file info
*
* @param nodeRefs the node references
* @return Return a list of file info
* @throws InvalidTypeException if the node is not a valid type
*/
private List<FileInfo> toFileInfo(List<NodeRef> nodeRefs) throws InvalidTypeException
{
List<FileInfo> results = new ArrayList<FileInfo>(nodeRefs.size());
for (NodeRef nodeRef : nodeRefs)
{
try
{
FileInfo fileInfo = toFileInfo(nodeRef, true);
results.add(fileInfo);
}
catch (InvalidNodeRefException inre)
{
logger.warn("toFileInfo: "+inre);
// skip
}
}
return results;
}
示例6: getChildAssocs
import org.alfresco.service.cmr.repository.InvalidNodeRefException; //导入依赖的package包/类
@Override
public List<ChildAssociationRef> getChildAssocs(Reference parentReference, QNamePattern typeQNamePattern,
QNamePattern qnamePattern, int maxResults, boolean preload) throws InvalidNodeRefException
{
if (typeQNamePattern.isMatch(ContentModel.ASSOC_CONTAINS))
{
return parentReference.execute(new GetChildAssocsMethod(this,
environment,
preload,
maxResults,
qnamePattern,
typeQNamePattern));
}
else
{
return Collections.emptyList();
}
}
示例7: decorate
import org.alfresco.service.cmr.repository.InvalidNodeRefException; //导入依赖的package包/类
/**
* @see org.alfresco.repo.jscript.app.PropertyDecorator#decorate(org.alfresco.service.namespace.QName, org.alfresco.service.cmr.repository.NodeRef, java.io.Serializable)
*/
@SuppressWarnings("unchecked")
public JSONAware decorate(QName propertyName, NodeRef nodeRef, Serializable value)
{
Collection<NodeRef> collection = (Collection<NodeRef>)value;
JSONArray array = new JSONArray();
for (NodeRef obj : collection)
{
try
{
JSONObject jsonObj = new JSONObject();
jsonObj.put("name", this.nodeService.getProperty(obj, ContentModel.PROP_NAME));
jsonObj.put("path", this.getPath(obj));
jsonObj.put("nodeRef", obj.toString());
array.add(jsonObj);
}
catch (InvalidNodeRefException e)
{
logger.warn("Category with nodeRef " + obj.toString() + " does not exist.");
}
}
return array;
}
示例8: importNode
import org.alfresco.service.cmr.repository.InvalidNodeRefException; //导入依赖的package包/类
public NodeRef importNode(ImportNode node)
{
// if node to import has a UUID and an existing node of the same uuid already exists
// then throw an error
String uuid = node.getUUID();
if (uuid != null && uuid.length() > 0)
{
NodeRef existingNodeRef = new NodeRef(rootRef.getStoreRef(), uuid);
if (nodeService.exists(existingNodeRef))
{
throw new InvalidNodeRefException("Node " + existingNodeRef + " already exists", existingNodeRef);
}
}
// import as if a new node
return createNewStrategy.importNode(node);
}
示例9: testNonRetryingSilentRollback
import org.alfresco.service.cmr.repository.InvalidNodeRefException; //导入依赖的package包/类
/**
* Sometimes, exceptions or other states may cause the transaction to be marked for
* rollback without an exception being generated. This tests that the exception stays
* absorbed and that another isn't generated, but that the transaction was rolled back
* properly.
*/
public void testNonRetryingSilentRollback()
{
RetryingTransactionCallback<Long> callback = new RetryingTransactionCallback<Long>()
{
public Long execute() throws Throwable
{
incrementCheckValue();
try
{
return blowUp();
}
catch (InvalidNodeRefException e)
{
// Expected, but absorbed
}
return null;
}
};
txnHelper.doInTransaction(callback);
long checkValue = getCheckValue();
assertEquals("Check value should not have changed", 0, checkValue);
}
示例10: getTypeAndAspectQNames
import org.alfresco.service.cmr.repository.InvalidNodeRefException; //导入依赖的package包/类
/**
* Get all aspect and node type qualified names
*
* @param nodeRef
* the node we are interested in
* @return Returns a set of qualified names containing the node type and all
* the node aspects, or null if the node no longer exists
*/
protected Set<QName> getTypeAndAspectQNames(NodeRef nodeRef)
{
Set<QName> qnames = null;
try
{
Set<QName> aspectQNames = getAspects(nodeRef);
QName typeQName = getType(nodeRef);
qnames = new HashSet<QName>(aspectQNames.size() + 1);
qnames.addAll(aspectQNames);
qnames.add(typeQName);
}
catch (InvalidNodeRefException e)
{
qnames = Collections.emptySet();
}
// done
return qnames;
}
示例11: getFileNameImpl
import org.alfresco.service.cmr.repository.InvalidNodeRefException; //导入依赖的package包/类
/**
* Return the file name for a node
*
* @param node NodeRef
* @return String
*/
public String getFileNameImpl(NodeRef node)
{
String fname = null;
try
{
fname = (String) nodeService.getProperty( node, ContentModel.PROP_NAME);
}
catch (InvalidNodeRefException ex)
{
}
return fname;
}
示例12: importImportableItemMetadata
import org.alfresco.service.cmr.repository.InvalidNodeRefException; //导入依赖的package包/类
protected final void importImportableItemMetadata(NodeRef nodeRef, Path parentFile, MetadataLoader.Metadata metadata)
{
// Attach aspects
if (metadata.getAspects() != null)
{
for (final QName aspect : metadata.getAspects())
{
if (logger.isDebugEnabled()) logger.debug("Attaching aspect '" + aspect.toString() + "' to node '" + nodeRef.toString() + "'.");
nodeService.addAspect(nodeRef, aspect, null); // Note: we set the aspect's properties separately, hence null for the third parameter
}
}
// Set property values for both the type and any aspect(s)
if (metadata.getProperties() != null)
{
if (logger.isDebugEnabled()) logger.debug("Adding properties to node '" + nodeRef.toString() + "':\n" + mapToString(metadata.getProperties()));
try
{
nodeService.addProperties(nodeRef, metadata.getProperties());
}
catch (final InvalidNodeRefException inre)
{
if (!nodeRef.equals(inre.getNodeRef()))
{
// Caused by an invalid NodeRef in the metadata (e.g. in an association)
throw new IllegalStateException("Invalid nodeRef found in metadata for '" + getFileName(parentFile) + "'. " +
"Probable cause: an association is being populated via metadata, but the " +
"NodeRef for the target of that association ('" + inre.getNodeRef() + "') is invalid. " +
"Please double check your metadata file and try again.", inre);
}
else
{
// Logic bug in the BFSIT. :-(
throw inre;
}
}
}
}
示例13: setType
import org.alfresco.service.cmr.repository.InvalidNodeRefException; //导入依赖的package包/类
/**
* @see org.alfresco.service.cmr.repository.NodeService#setType(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
*/
@Extend(traitAPI=NodeServiceTrait.class,extensionAPI=NodeServiceExtension.class)
public void setType(NodeRef nodeRef, QName typeQName) throws InvalidNodeRefException
{
// The node(s) involved may not be pending deletion
checkPendingDelete(nodeRef);
// check the node type
TypeDefinition nodeTypeDef = dictionaryService.getType(typeQName);
if (nodeTypeDef == null)
{
throw new InvalidTypeException(typeQName);
}
Pair<Long, NodeRef> nodePair = getNodePairNotNull(nodeRef);
// Invoke policies
invokeBeforeUpdateNode(nodeRef);
QName oldType = nodeDAO.getNodeType(nodePair.getFirst());
invokeBeforeSetType(nodeRef, oldType, typeQName);
// Set the type
boolean updatedNode = nodeDAO.updateNode(nodePair.getFirst(), typeQName, null);
// Add the default aspects and properties required for the given type. Existing values will not be overridden.
boolean updatedProps = addAspectsAndProperties(nodePair, typeQName, null, null, null, null, false);
// Invoke policies
if (updatedNode || updatedProps)
{
// Invoke policies
invokeOnUpdateNode(nodeRef);
invokeOnSetType(nodeRef, oldType, typeQName);
// Index
nodeIndexer.indexUpdateNode(nodeRef);
}
}
示例14: getNodeId
import org.alfresco.service.cmr.repository.InvalidNodeRefException; //导入依赖的package包/类
protected Long getNodeId(NodeRef nodeRef)
{
Pair<Long, NodeRef> nodePair = nodeDAO.getNodePair(tenantService.getName(nodeRef));
if (nodePair == null)
{
throw new InvalidNodeRefException("Node ref does not exist: " + nodeRef, nodeRef);
}
return nodePair.getFirst();
}
示例15: getPermissions
import org.alfresco.service.cmr.repository.InvalidNodeRefException; //导入依赖的package包/类
public NodePermissionEntry getPermissions(StoreRef storeRef)
{
// Create the object if it is not found.
// Null objects are not cached in hibernate
// If the object does not exist it will repeatedly query to check its
// non existence.
NodePermissionEntry npe = null;
Acl acl = null;
try
{
acl = getAccessControlList(storeRef);
}
catch (InvalidNodeRefException e)
{
// Do nothing.
}
if (acl == null)
{
// there isn't an access control list for the node - spoof a null one
SimpleNodePermissionEntry snpe = new SimpleNodePermissionEntry(null, true, Collections.<SimplePermissionEntry> emptyList());
npe = snpe;
}
else
{
npe = createSimpleNodePermissionEntry(storeRef);
}
return npe;
}