use of org.alfresco.traitextender.Extend in project alfresco-repository by Alfresco.
the class FileFolderServiceImpl method search.
/**
* Full search with all options
*/
@Override
@Extend(traitAPI = FileFolderServiceTrait.class, extensionAPI = FileFolderServiceExtension.class)
public List<FileInfo> search(NodeRef contextNodeRef, String namePattern, boolean fileSearch, boolean folderSearch, boolean includeSubFolders) {
// get the raw nodeRefs
List<NodeRef> nodeRefs = searchInternal(contextNodeRef, namePattern, fileSearch, folderSearch, includeSubFolders);
List<FileInfo> results = toFileInfo(nodeRefs);
// eliminate unwanted files/folders
Iterator<FileInfo> iterator = results.iterator();
while (iterator.hasNext()) {
FileInfo file = iterator.next();
if (file.isFolder() && !folderSearch) {
iterator.remove();
} else if (!file.isFolder() && !fileSearch) {
iterator.remove();
}
}
// done
if (logger.isTraceEnabled()) {
logger.trace("Deep search: \n" + " context: " + contextNodeRef + "\n" + " pattern: " + namePattern + "\n" + " files: " + fileSearch + "\n" + " folders: " + folderSearch + "\n" + " deep: " + includeSubFolders + "\n" + " results: " + results);
}
return results;
}
use of org.alfresco.traitextender.Extend in project alfresco-repository by Alfresco.
the class DbNodeServiceImpl method getStores.
/**
* {@inheritDoc}
*/
@Extend(traitAPI = NodeServiceTrait.class, extensionAPI = NodeServiceExtension.class)
public List<StoreRef> getStores() {
// Get the ADM stores
List<Pair<Long, StoreRef>> stores = nodeDAO.getStores();
List<StoreRef> storeRefs = new ArrayList<StoreRef>(50);
for (Pair<Long, StoreRef> pair : stores) {
StoreRef storeRef = pair.getSecond();
if (storeRef.getProtocol().equals(StoreRef.PROTOCOL_DELETED)) {
// Ignore
continue;
}
storeRefs.add(storeRef);
}
// Return them all.
return storeRefs;
}
use of org.alfresco.traitextender.Extend in project alfresco-repository by Alfresco.
the class DbNodeServiceImpl method getChildAssocs.
@Extend(traitAPI = NodeServiceTrait.class, extensionAPI = NodeServiceExtension.class)
public List<ChildAssociationRef> getChildAssocs(NodeRef nodeRef, Set<QName> childNodeTypeQNames) {
// Get the node
Pair<Long, NodeRef> nodePair = getNodePairNotNull(nodeRef);
Long nodeId = nodePair.getFirst();
final List<ChildAssociationRef> results = new ArrayList<ChildAssociationRef>(100);
NodeDAO.ChildAssocRefQueryCallback callback = new NodeDAO.ChildAssocRefQueryCallback() {
public boolean preLoadNodes() {
return true;
}
@Override
public boolean orderResults() {
return true;
}
public boolean handle(Pair<Long, ChildAssociationRef> childAssocPair, Pair<Long, NodeRef> parentNodePair, Pair<Long, NodeRef> childNodePair) {
results.add(childAssocPair.getSecond());
// More results
return true;
}
public void done() {
}
};
// Get all child associations with the specific qualified name
nodeDAO.getChildAssocsByChildTypes(nodeId, childNodeTypeQNames, callback);
// Done
return results;
}
use of org.alfresco.traitextender.Extend in project alfresco-repository by Alfresco.
the class DbNodeServiceImpl method setType.
/**
* @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);
}
}
use of org.alfresco.traitextender.Extend in project alfresco-repository by Alfresco.
the class DbNodeServiceImpl method getPrimaryParent.
@Extend(traitAPI = NodeServiceTrait.class, extensionAPI = NodeServiceExtension.class)
public ChildAssociationRef getPrimaryParent(NodeRef nodeRef) throws InvalidNodeRefException {
// Get the node
Pair<Long, NodeRef> nodePair = getNodePairNotNull(nodeRef);
Long nodeId = nodePair.getFirst();
// get the primary parent assoc
Pair<Long, ChildAssociationRef> assocPair = nodeDAO.getPrimaryParentAssoc(nodeId);
// done - the assoc may be null for a root node
ChildAssociationRef assocRef = null;
if (assocPair == null) {
assocRef = new ChildAssociationRef(null, null, null, nodeRef);
} else {
assocRef = assocPair.getSecond();
}
return assocRef;
}
Aggregations