use of org.alfresco.service.cmr.repository.StoreRef in project records-management by Alfresco.
the class RmSubstitutionSuggestionsGet method getFilePlan.
/**
* Utility method to get the file plan from the passed parameters.
*
* @param req
* @return
*/
protected NodeRef getFilePlan(WebScriptRequest req, boolean unfiled) {
NodeRef filePlan = null;
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
String siteId = templateVars.get("siteid");
if (siteId != null) {
filePlan = filePlanService.getFilePlanBySiteId(siteId);
}
if (filePlan == null) {
String storeType = templateVars.get("store_type");
String storeId = templateVars.get("store_id");
String id = templateVars.get("id");
if (!StringUtils.isEmpty(storeType) && !StringUtils.isEmpty(storeId) && !StringUtils.isEmpty(id)) {
StoreRef storeRef = new StoreRef(storeType, storeId);
NodeRef nodeRef = new NodeRef(storeRef, id);
if (filePlanService.isFilePlan(nodeRef)) {
filePlan = nodeRef;
}
}
}
if (filePlan == null) {
// Assume we are in a legacy repository and we will grab the default file plan
filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
}
return unfiled ? filePlanService.getUnfiledContainer(filePlan) : filePlan;
}
use of org.alfresco.service.cmr.repository.StoreRef in project records-management by Alfresco.
the class RMAfterInvocationProvider method decide.
private Object[] decide(Authentication authentication, Object object, ConfigAttributeDefinition config, Object[] returnedObject) {
// Assumption: value is not null
BitSet incudedSet = new BitSet(returnedObject.length);
List<ConfigAttributeDefintion> supportedDefinitions = extractSupportedDefinitions(config);
if (supportedDefinitions.size() == 0) {
return returnedObject;
}
for (int i = 0, l = returnedObject.length; i < l; i++) {
Object current = returnedObject[i];
int parentReadCheck = checkRead(getParentReadCheckNode(current));
int childReadChek = checkRead(getChildReadCheckNode(current));
for (ConfigAttributeDefintion cad : supportedDefinitions) {
incudedSet.set(i, true);
NodeRef testNodeRef = null;
if (cad.parent) {
if (StoreRef.class.isAssignableFrom(current.getClass())) {
testNodeRef = null;
} else if (NodeRef.class.isAssignableFrom(current.getClass())) {
testNodeRef = nodeService.getPrimaryParent((NodeRef) current).getParentRef();
} else if (ChildAssociationRef.class.isAssignableFrom(current.getClass())) {
testNodeRef = ((ChildAssociationRef) current).getParentRef();
} else if (PermissionCheckValue.class.isAssignableFrom(current.getClass())) {
NodeRef nodeRef = ((PermissionCheckValue) current).getNodeRef();
testNodeRef = nodeService.getPrimaryParent(nodeRef).getParentRef();
} else {
throw new ACLEntryVoterException("The specified parameter is recognized: " + current.getClass());
}
} else {
if (StoreRef.class.isAssignableFrom(current.getClass())) {
testNodeRef = nodeService.getRootNode((StoreRef) current);
} else if (NodeRef.class.isAssignableFrom(current.getClass())) {
testNodeRef = (NodeRef) current;
} else if (ChildAssociationRef.class.isAssignableFrom(current.getClass())) {
testNodeRef = ((ChildAssociationRef) current).getChildRef();
} else if (PermissionCheckValue.class.isAssignableFrom(current.getClass())) {
testNodeRef = ((PermissionCheckValue) current).getNodeRef();
} else {
throw new ACLEntryVoterException("The specified parameter is recognized: " + current.getClass());
}
}
if (logger.isDebugEnabled()) {
logger.debug("\t" + cad.typeString + " test on " + testNodeRef + " from " + current.getClass().getName());
}
if (isUnfiltered(testNodeRef)) {
continue;
}
int readCheck = childReadChek;
if (cad.parent) {
readCheck = parentReadCheck;
}
if (incudedSet.get(i) && (testNodeRef != null) && (readCheck != AccessDecisionVoter.ACCESS_GRANTED)) {
incudedSet.set(i, false);
}
}
}
if (incudedSet.cardinality() == returnedObject.length) {
return returnedObject;
} else {
Object[] answer = new Object[incudedSet.cardinality()];
for (int i = incudedSet.nextSetBit(0), p = 0; i >= 0; i = incudedSet.nextSetBit(++i), p++) {
answer[p] = returnedObject[i];
}
return answer;
}
}
use of org.alfresco.service.cmr.repository.StoreRef in project SearchServices by Alfresco.
the class AlfrescoCoreAdminHandler method newDefaultCore.
private boolean newDefaultCore(SolrQueryRequest req, SolrQueryResponse rsp) {
SolrParams params = req.getParams();
String coreName = params.get("coreName") != null ? params.get("coreName") : "alfresco";
StoreRef storeRef = StoreRef.STORE_REF_WORKSPACE_SPACESSTORE;
String templateName = params.get("template") != null ? params.get("template") : DEFAULT_TEMPLATE;
Properties extraProperties = extractCustomProperties(params);
if (params.get("storeRef") != null) {
String store = params.get("storeRef");
storeRef = new StoreRef(store);
}
return newDefaultCore(coreName, storeRef, templateName, extraProperties, rsp);
}
use of org.alfresco.service.cmr.repository.StoreRef in project SearchServices by Alfresco.
the class AlfrescoCoreAdminHandler method setupNewDefaultCores.
/**
* Creates new default cores based on the "createDefaultCores" String passed in
* @param createDefaultCores comma delimited list of corenames.
*/
protected void setupNewDefaultCores(String createDefaultCores) {
final String VERSION_STORE_PROTOCOL = "workspace";
final String VERSION_STORE_ID = "version2Store";
SolrQueryResponse response = new SolrQueryResponse();
try {
String[] coreNames = createDefaultCores.toLowerCase().split(",");
for (String coreName : coreNames) {
log.info("Attempting to create default alfresco core: " + coreName);
switch(coreName) {
case "process":
StoreRef processStoreRef = new StoreRef("process", "services");
newDefaultCore("process", processStoreRef, "aps/process", null, response);
newDefaultCore("processDefinition", processStoreRef, "aps/processDefinition", null, response);
newDefaultCore("task", processStoreRef, "aps/task", null, response);
newDefaultCore("taskDefinition", processStoreRef, "aps/taskDefinition", null, response);
break;
case "archive":
newDefaultCore("archive", StoreRef.STORE_REF_ARCHIVE_SPACESSTORE, DEFAULT_TEMPLATE, null, response);
break;
case "alfresco":
newDefaultCore("alfresco", StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, DEFAULT_TEMPLATE, null, response);
break;
case "version":
newDefaultCore("version", new StoreRef(VERSION_STORE_PROTOCOL, VERSION_STORE_ID), DEFAULT_TEMPLATE, null, response);
break;
default:
log.error("Invalid '" + ALFRESCO_DEFAULTS + "' permitted values are alfresco,archive,version");
}
}
} catch (Exception e) {
log.error("Failed to create default alfresco cores (workspace/archive stores)", e);
}
}
use of org.alfresco.service.cmr.repository.StoreRef in project SearchServices by Alfresco.
the class AlfrescoCoreAdminHandler method newCore.
private boolean newCore(SolrQueryRequest req, SolrQueryResponse rsp) {
SolrParams params = req.getParams();
req.getContext();
// If numCore > 1 we are createing a collection of cores for a sole node in a cluster
int numShards = params.getInt("numShards", 1);
String store = "";
if (params.get("storeRef") != null) {
store = params.get("storeRef");
}
if ((store == null) || (store.length() == 0)) {
return false;
}
StoreRef storeRef = new StoreRef(store);
String templateName = "vanilla";
if (params.get("template") != null) {
templateName = params.get("template");
}
int replicationFactor = params.getInt("replicationFactor", 1);
int nodeInstance = params.getInt("nodeInstance", -1);
int numNodes = params.getInt("numNodes", 1);
String coreName = params.get("coreName");
String shardIds = params.get("shardIds");
Properties properties = extractCustomProperties(params);
return newCore(coreName, numShards, storeRef, templateName, replicationFactor, nodeInstance, numNodes, shardIds, properties, rsp);
}
Aggregations