use of org.apache.ofbiz.service.LocalDispatcher in project ofbiz-framework by apache.
the class ContentManagementServices method updateSiteRolesDyn.
public static Map<String, Object> updateSiteRolesDyn(DispatchContext dctx, Map<String, ? extends Object> context) {
LocalDispatcher dispatcher = dctx.getDispatcher();
Delegator delegator = dctx.getDelegator();
Map<String, Object> results = new HashMap<String, Object>();
Map<String, Object> thisResult = new HashMap<String, Object>();
Map<String, Object> serviceContext = new HashMap<String, Object>();
// siteContentId will equal "ADMIN_MASTER", "AGINC_MASTER", etc.
// Remember that this service is called in the "multi" mode,
// with a new siteContentId each time.
// siteContentId could also have been name deptContentId, since this same
// service is used for updating department roles, too.
String siteContentId = (String) context.get("contentId");
String partyId = (String) context.get("partyId");
serviceContext.put("partyId", partyId);
serviceContext.put("contentId", siteContentId);
List<GenericValue> siteRoles = null;
try {
siteRoles = EntityQuery.use(delegator).from("RoleType").where("parentTypeId", "BLOG").cache().queryList();
} catch (GenericEntityException e) {
return ServiceUtil.returnError(e.toString());
}
for (GenericValue roleType : siteRoles) {
// BLOG_EDITOR, BLOG_ADMIN, etc.
String siteRole = (String) roleType.get("roleTypeId");
String cappedSiteRole = ModelUtil.dbNameToVarName(siteRole);
String siteRoleVal = (String) context.get(cappedSiteRole);
Object fromDate = context.get(cappedSiteRole + "FromDate");
serviceContext.put("roleTypeId", siteRole);
if (siteRoleVal != null && "Y".equalsIgnoreCase(siteRoleVal)) {
// for now, will assume that any error is due to duplicates - ignore
if (fromDate == null) {
try {
serviceContext.put("fromDate", UtilDateTime.nowTimestamp());
if (Debug.infoOn()) {
Debug.logInfo("updateSiteRoles, serviceContext(1):" + serviceContext, module);
}
addRoleToUser(delegator, dispatcher, serviceContext);
thisResult = dispatcher.runSync("createContentRole", serviceContext);
if (ServiceUtil.isError(thisResult)) {
return ServiceUtil.returnError(ServiceUtil.getErrorMessage(thisResult));
}
} catch (GenericServiceException e) {
Debug.logError(e, e.toString(), module);
} catch (Exception e2) {
Debug.logError(e2, e2.toString(), module);
}
}
} else {
if (fromDate != null) {
// return ServiceUtil.returnError(e.toString());
try {
Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module);
Map<String, Object> newContext = new HashMap<String, Object>();
newContext.put("contentId", serviceContext.get("contentId"));
newContext.put("partyId", serviceContext.get("partyId"));
newContext.put("roleTypeId", serviceContext.get("roleTypeId"));
thisResult = dispatcher.runSync("deactivateAllContentRoles", newContext);
if (ServiceUtil.isError(thisResult)) {
return ServiceUtil.returnError(ServiceUtil.getErrorMessage(thisResult));
}
} catch (GenericServiceException e) {
Debug.logError(e, e.toString(), module);
} catch (Exception e2) {
Debug.logError(e2, e2.toString(), module);
}
}
}
}
return results;
}
use of org.apache.ofbiz.service.LocalDispatcher in project ofbiz-framework by apache.
the class ContentManagementServices method persistContentAndAssoc.
/**
* persistContentAndAssoc
* A combination method that will create or update all or one of the following:
* a Content entity, a ContentAssoc related to the Content, and
* the ElectronicText that may be associated with the Content.
* The keys for determining if each entity is created is the presence
* of the contentTypeId, contentAssocTypeId and dataResourceTypeId.
* This service tries to handle DataResource fields with and
* without "dr" prefixes.
* Assumes binary data is always in field, "imageData".
*
* This service does not accept straight ContentAssoc parameters. They must be prefaced with "ca" + cap first letter
*/
public static Map<String, Object> persistContentAndAssoc(DispatchContext dctx, Map<String, ? extends Object> rcontext) throws GenericServiceException {
Delegator delegator = dctx.getDelegator();
LocalDispatcher dispatcher = dctx.getDispatcher();
Map<String, Object> context = UtilMisc.makeMapWritable(rcontext);
Locale locale = (Locale) context.get("locale");
// Knowing why a request fails permission check is one of the more difficult
// aspects of content management. Setting "displayFailCond" to true will
// put an html table in result.errorMessage that will show what tests were performed
Boolean bDisplayFailCond = (Boolean) context.get("displayFailCond");
String mapKey = (String) context.get("mapKey");
// If "deactivateExisting" is set, other Contents that are tied to the same
// contentIdTo will be deactivated (thruDate set to now)
String deactivateString = (String) context.get("deactivateExisting");
boolean deactivateExisting = "true".equalsIgnoreCase(deactivateString);
if (Debug.infoOn())
Debug.logInfo("in persist... mapKey(0):" + mapKey, module);
// ContentPurposes can get passed in as a delimited string or a list. Combine.
List<String> contentPurposeList = UtilGenerics.checkList(context.get("contentPurposeList"));
if (contentPurposeList == null) {
contentPurposeList = new LinkedList<String>();
}
String contentPurposeString = (String) context.get("contentPurposeString");
if (UtilValidate.isNotEmpty(contentPurposeString)) {
List<String> tmpPurposes = StringUtil.split(contentPurposeString, "|");
contentPurposeList.addAll(tmpPurposes);
}
if (contentPurposeList != null) {
context.put("contentPurposeList", contentPurposeList);
context.put("contentPurposeString", null);
}
if (Debug.infoOn()) {
Debug.logInfo("in persist... contentPurposeList(0):" + contentPurposeList, module);
Debug.logInfo("in persist... textData(0):" + context.get("textData"), module);
}
GenericValue content = delegator.makeValue("Content");
content.setPKFields(context);
content.setNonPKFields(context);
String contentId = (String) content.get("contentId");
String contentTypeId = (String) content.get("contentTypeId");
String origContentId = (String) content.get("contentId");
String origDataResourceId = (String) content.get("dataResourceId");
if (Debug.infoOn()) {
Debug.logInfo("in persist... contentId(0):" + contentId, module);
}
GenericValue dataResource = delegator.makeValue("DataResource");
dataResource.setPKFields(context);
dataResource.setNonPKFields(context);
dataResource.setAllFields(context, false, "dr", null);
String isPublic = (String) context.get("isPublic");
if (UtilValidate.isEmpty(isPublic)) {
dataResource.set("isPublic", "N");
}
context.putAll(dataResource);
String dataResourceId = (String) dataResource.get("dataResourceId");
String dataResourceTypeId = (String) dataResource.get("dataResourceTypeId");
if (Debug.infoOn()) {
Debug.logInfo("in persist... dataResourceId(0):" + dataResourceId, module);
}
GenericValue contentAssoc = delegator.makeValue("ContentAssoc");
String contentAssocTypeId = (String) context.get("contentAssocTypeId");
if (UtilValidate.isNotEmpty(contentAssocTypeId)) {
context.put("caContentAssocTypeId", contentAssocTypeId);
}
contentAssocTypeId = (String) context.get("caContentAssocTypeId");
contentAssoc.setAllFields(context, false, "ca", null);
contentAssoc.put("contentId", context.get("caContentId"));
context.putAll(contentAssoc);
GenericValue electronicText = delegator.makeValue("ElectronicText");
electronicText.setPKFields(context);
electronicText.setNonPKFields(context);
// save expected primary keys on result now in case there is no operation that uses them
Map<String, Object> results = ServiceUtil.returnSuccess();
results.put("contentId", content.get("contentId"));
results.put("dataResourceId", dataResource.get("dataResourceId"));
results.put("drDataResourceId", dataResource.get("dataResourceId"));
results.put("drDataResourceId", dataResource.get("dataResourceId"));
results.put("caContentIdTo", contentAssoc.get("contentIdTo"));
results.put("caContentId", contentAssoc.get("contentId"));
results.put("caFromDate", contentAssoc.get("fromDate"));
results.put("caContentAssocTypeId", contentAssoc.get("contentAssocTypeId"));
// get user info for multiple use
GenericValue userLogin = (GenericValue) context.get("userLogin");
boolean dataResourceExists = true;
if (Debug.infoOn()) {
Debug.logInfo("in persist... dataResourceTypeId(0):" + dataResourceTypeId, module);
}
if (UtilValidate.isNotEmpty(dataResourceTypeId)) {
Map<String, Object> dataResourceResult;
try {
dataResourceResult = persistDataResourceAndDataMethod(dctx, context);
} catch (GenericServiceException e) {
Debug.logError(e, e.toString(), module);
return ServiceUtil.returnError(e.toString());
} catch (GenericEntityException e) {
Debug.logError(e, e.toString(), module);
return ServiceUtil.returnError(e.toString());
} catch (Exception e) {
Debug.logError(e, e.toString(), module);
return ServiceUtil.returnError(e.toString());
}
String errorMsg = ServiceUtil.getErrorMessage(dataResourceResult);
if (UtilValidate.isNotEmpty(errorMsg)) {
return ServiceUtil.returnError(errorMsg);
}
dataResourceId = (String) dataResourceResult.get("dataResourceId");
results.put("dataResourceId", dataResourceId);
results.put("drDataResourceId", dataResourceId);
context.put("dataResourceId", dataResourceId);
content.put("dataResourceId", dataResourceId);
context.put("drDataResourceId", dataResourceId);
}
// Do update and create permission checks on Content if warranted.
// Force check here
context.put("skipPermissionCheck", null);
boolean contentExists = true;
if (Debug.infoOn()) {
Debug.logInfo("in persist... contentTypeId:" + contentTypeId + " dataResourceTypeId:" + dataResourceTypeId + " contentId:" + contentId + " dataResourceId:" + dataResourceId, module);
}
if (UtilValidate.isNotEmpty(contentTypeId)) {
if (UtilValidate.isEmpty(contentId)) {
contentExists = false;
} else {
try {
GenericValue val = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne();
if (val == null)
contentExists = false;
} catch (GenericEntityException e) {
return ServiceUtil.returnError(e.toString());
}
}
context.putAll(content);
if (contentExists) {
Map<String, Object> contentContext = new HashMap<String, Object>();
ModelService contentModel = dispatcher.getDispatchContext().getModelService("updateContent");
contentContext.putAll(contentModel.makeValid(content, ModelService.IN_PARAM));
contentContext.put("userLogin", userLogin);
contentContext.put("displayFailCond", bDisplayFailCond);
contentContext.put("skipPermissionCheck", context.get("skipPermissionCheck"));
Debug.logInfo("In persistContentAndAssoc calling updateContent with content: " + contentContext, module);
Map<String, Object> thisResult = dispatcher.runSync("updateContent", contentContext);
if (ServiceUtil.isError(thisResult) || ServiceUtil.isFailure(thisResult)) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ContentContentUpdatingError", UtilMisc.toMap("serviceName", "persistContentAndAssoc"), locale), null, null, thisResult);
}
} else {
Map<String, Object> contentContext = new HashMap<String, Object>();
ModelService contentModel = dispatcher.getDispatchContext().getModelService("createContent");
contentContext.putAll(contentModel.makeValid(content, ModelService.IN_PARAM));
contentContext.put("userLogin", userLogin);
contentContext.put("displayFailCond", bDisplayFailCond);
contentContext.put("skipPermissionCheck", context.get("skipPermissionCheck"));
Debug.logInfo("In persistContentAndAssoc calling createContent with content: " + contentContext, module);
Map<String, Object> thisResult = dispatcher.runSync("createContent", contentContext);
if (ServiceUtil.isError(thisResult) || ServiceUtil.isFailure(thisResult)) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ContentContentCreatingError", UtilMisc.toMap("serviceName", "persistContentAndAssoc"), locale), null, null, thisResult);
}
contentId = (String) thisResult.get("contentId");
}
results.put("contentId", contentId);
context.put("contentId", contentId);
context.put("caContentIdTo", contentId);
// Add ContentPurposes if this is a create operation
if (contentId != null && !contentExists) {
try {
Set<String> contentPurposeSet = UtilMisc.makeSetWritable(contentPurposeList);
for (String contentPurposeTypeId : contentPurposeSet) {
GenericValue contentPurpose = delegator.makeValue("ContentPurpose", UtilMisc.toMap("contentId", contentId, "contentPurposeTypeId", contentPurposeTypeId));
contentPurpose.create();
}
} catch (GenericEntityException e) {
return ServiceUtil.returnError(e.toString());
}
}
} else if (UtilValidate.isNotEmpty(dataResourceTypeId) && UtilValidate.isNotEmpty(contentId)) {
// If dataResource was not previously existing, then update the associated content with its id
if (UtilValidate.isNotEmpty(dataResourceId) && !dataResourceExists) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("userLogin", userLogin);
map.put("dataResourceId", dataResourceId);
map.put("contentId", contentId);
if (Debug.infoOn())
Debug.logInfo("in persist... context:" + context, module);
Map<String, Object> r = ContentServices.updateContentMethod(dctx, map);
boolean isError = ModelService.RESPOND_ERROR.equals(r.get(ModelService.RESPONSE_MESSAGE));
if (isError)
return ServiceUtil.returnError((String) r.get(ModelService.ERROR_MESSAGE));
}
}
// Put contentId
if (UtilValidate.isNotEmpty(contentId)) {
contentAssoc.put("contentIdTo", contentId);
}
// If parentContentIdTo or parentContentIdFrom exists, create association with newly created content
if (Debug.infoOn()) {
Debug.logInfo("CREATING contentASSOC contentAssocTypeId:" + contentAssocTypeId, module);
}
// create content assoc if the key values are present....
if (Debug.infoOn())
Debug.logInfo("contentAssoc: " + contentAssoc.toString(), module);
if (UtilValidate.isNotEmpty(contentAssocTypeId) && contentAssoc.get("contentId") != null && contentAssoc.get("contentIdTo") != null) {
if (Debug.infoOn())
Debug.logInfo("in persistContentAndAssoc, deactivateExisting:" + deactivateExisting, module);
Map<String, Object> contentAssocContext = new HashMap<String, Object>();
contentAssocContext.put("userLogin", userLogin);
contentAssocContext.put("displayFailCond", bDisplayFailCond);
contentAssocContext.put("skipPermissionCheck", context.get("skipPermissionCheck"));
Map<String, Object> thisResult = null;
try {
GenericValue contentAssocExisting = EntityQuery.use(delegator).from("ContentAssoc").where(contentAssoc.getPrimaryKey()).queryOne();
if (contentAssocExisting == null) {
ModelService contentAssocModel = dispatcher.getDispatchContext().getModelService("createContentAssoc");
Map<String, Object> ctx = contentAssocModel.makeValid(contentAssoc, ModelService.IN_PARAM);
contentAssocContext.putAll(ctx);
thisResult = dispatcher.runSync("createContentAssoc", contentAssocContext);
if (ServiceUtil.isError(thisResult) || ServiceUtil.isFailure(thisResult)) {
return ServiceUtil.returnError(ServiceUtil.getErrorMessage(thisResult));
}
results.put("caContentIdTo", thisResult.get("contentIdTo"));
results.put("caContentId", thisResult.get("contentIdFrom"));
results.put("caContentAssocTypeId", thisResult.get("contentAssocTypeId"));
results.put("caFromDate", thisResult.get("fromDate"));
results.put("caSequenceNum", thisResult.get("sequenceNum"));
} else {
if (deactivateExisting) {
contentAssocExisting.put("thruDate", UtilDateTime.nowTimestamp());
} else if (UtilValidate.isNotEmpty(context.get("thruDate"))) {
contentAssocExisting.put("thruDate", (Timestamp) context.get("thruDate"));
}
ModelService contentAssocModel = dispatcher.getDispatchContext().getModelService("updateContentAssoc");
Map<String, Object> ctx = contentAssocModel.makeValid(contentAssocExisting, ModelService.IN_PARAM);
contentAssocContext.putAll(ctx);
thisResult = dispatcher.runSync("updateContentAssoc", contentAssocContext);
if (ServiceUtil.isError(thisResult) || ServiceUtil.isFailure(thisResult)) {
return ServiceUtil.returnError(ServiceUtil.getErrorMessage(thisResult));
}
}
} catch (GenericEntityException e) {
throw new GenericServiceException(e.toString());
} catch (Exception e2) {
throw new GenericServiceException(e2.toString());
}
String errMsg = ServiceUtil.getErrorMessage(thisResult);
if (UtilValidate.isNotEmpty(errMsg)) {
return ServiceUtil.returnError(errMsg);
}
}
context.remove("skipPermissionCheck");
context.put("contentId", origContentId);
context.put("dataResourceId", origDataResourceId);
context.remove("dataResource");
Debug.logInfo("results:" + results, module);
return results;
}
use of org.apache.ofbiz.service.LocalDispatcher in project ofbiz-framework by apache.
the class ContentManagementServices method changeLeafToNode.
public static Map<String, Object> changeLeafToNode(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException {
Map<String, Object> result = new HashMap<String, Object>();
Delegator delegator = dctx.getDelegator();
LocalDispatcher dispatcher = dctx.getDispatcher();
Map<String, Object> thisResult = new HashMap<String, Object>();
String contentId = (String) context.get("contentId");
GenericValue userLogin = (GenericValue) context.get("userLogin");
String userLoginId = userLogin.getString("userLoginId");
Locale locale = (Locale) context.get("locale");
try {
GenericValue content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne();
if (content == null) {
Debug.logError("content was null", module);
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ContentNoContentFound", UtilMisc.toMap("contentId", ""), locale));
}
String dataResourceId = content.getString("dataResourceId");
content.set("dataResourceId", null);
content.set("lastModifiedDate", UtilDateTime.nowTimestamp());
content.set("lastModifiedByUserLogin", userLoginId);
content.store();
if (UtilValidate.isNotEmpty(dataResourceId)) {
// add previous DataResource as part of new subcontent
GenericValue contentClone = (GenericValue) content.clone();
contentClone.set("dataResourceId", dataResourceId);
content.set("lastModifiedDate", UtilDateTime.nowTimestamp());
content.set("lastModifiedByUserLogin", userLoginId);
content.set("createdDate", UtilDateTime.nowTimestamp());
content.set("createdByUserLogin", userLoginId);
contentClone.set("contentId", null);
ModelService modelService = dctx.getModelService("persistContentAndAssoc");
Map<String, Object> serviceIn = modelService.makeValid(contentClone, ModelService.IN_PARAM);
serviceIn.put("userLogin", userLogin);
serviceIn.put("contentIdTo", contentId);
serviceIn.put("contentAssocTypeId", "SUB_CONTENT");
serviceIn.put("sequenceNum", Long.valueOf(50));
try {
thisResult = dispatcher.runSync("persistContentAndAssoc", serviceIn);
if (ServiceUtil.isError(thisResult)) {
return ServiceUtil.returnError(ServiceUtil.getErrorMessage(thisResult));
}
} catch (ServiceAuthException e) {
return ServiceUtil.returnError(e.toString());
}
List<String> typeList = UtilMisc.toList("SUB_CONTENT");
ContentManagementWorker.updateStatsTopDown(delegator, contentId, typeList);
}
} catch (GenericEntityException e) {
Debug.logError(e, module);
return ServiceUtil.returnError(e.toString());
}
return result;
}
use of org.apache.ofbiz.service.LocalDispatcher in project ofbiz-framework by apache.
the class ContentManagementServices method updateSiteRoles.
/**
* Service for update publish sites with a ContentRole that will tie them to the passed
* in party.
*/
public static Map<String, Object> updateSiteRoles(DispatchContext dctx, Map<String, ? extends Object> context) {
LocalDispatcher dispatcher = dctx.getDispatcher();
Delegator delegator = dctx.getDelegator();
GenericValue userLogin = (GenericValue) context.get("userLogin");
Map<String, Object> results = new HashMap<String, Object>();
String siteContentId = (String) context.get("contentId");
String partyId = (String) context.get("partyId");
if (UtilValidate.isEmpty(siteContentId) || UtilValidate.isEmpty(partyId))
return results;
List<GenericValue> siteRoles = null;
try {
siteRoles = EntityQuery.use(delegator).from("RoleType").where("parentTypeId", "BLOG").cache().queryList();
} catch (GenericEntityException e) {
return ServiceUtil.returnError(e.toString());
}
for (GenericValue roleType : siteRoles) {
Map<String, Object> serviceContext = new HashMap<String, Object>();
serviceContext.put("partyId", partyId);
serviceContext.put("contentId", siteContentId);
serviceContext.put("userLogin", userLogin);
Debug.logInfo("updateSiteRoles, serviceContext(0):" + serviceContext, module);
// BLOG_EDITOR, BLOG_ADMIN, etc.
String siteRole = (String) roleType.get("roleTypeId");
String cappedSiteRole = ModelUtil.dbNameToVarName(siteRole);
if (Debug.infoOn()) {
Debug.logInfo("updateSiteRoles, cappediteRole(1):" + cappedSiteRole, module);
}
String siteRoleVal = (String) context.get(cappedSiteRole);
if (Debug.infoOn()) {
Debug.logInfo("updateSiteRoles, siteRoleVal(1):" + siteRoleVal, module);
Debug.logInfo("updateSiteRoles, context(1):" + context, module);
}
Object fromDate = context.get(cappedSiteRole + "FromDate");
if (Debug.infoOn()) {
Debug.logInfo("updateSiteRoles, fromDate(1):" + fromDate, module);
}
serviceContext.put("roleTypeId", siteRole);
if (siteRoleVal != null && "Y".equalsIgnoreCase(siteRoleVal)) {
// for now, will assume that any error is due to duplicates - ignore
if (fromDate == null) {
try {
Map<String, Object> newContext = new HashMap<String, Object>();
newContext.put("contentId", serviceContext.get("contentId"));
newContext.put("partyId", serviceContext.get("partyId"));
newContext.put("roleTypeId", serviceContext.get("roleTypeId"));
newContext.put("userLogin", userLogin);
Map<String, Object> permResults = dispatcher.runSync("deactivateAllContentRoles", newContext);
if (ServiceUtil.isError(permResults)) {
return ServiceUtil.returnError(ServiceUtil.getErrorMessage(permResults));
}
serviceContext.put("fromDate", UtilDateTime.nowTimestamp());
if (Debug.infoOn())
Debug.logInfo("updateSiteRoles, serviceContext(1):" + serviceContext, module);
permResults = dispatcher.runSync("createContentRole", serviceContext);
if (ServiceUtil.isError(permResults)) {
return ServiceUtil.returnError(ServiceUtil.getErrorMessage(permResults));
}
} catch (GenericServiceException e) {
Debug.logError(e, e.toString(), module);
return ServiceUtil.returnError(e.toString());
} catch (Exception e2) {
Debug.logError(e2, e2.toString(), module);
return ServiceUtil.returnError(e2.toString());
}
}
} else {
if (fromDate != null) {
// for now, will assume that any error is due to non-existence - ignore
try {
Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module);
Map<String, Object> newContext = new HashMap<String, Object>();
newContext.put("contentId", serviceContext.get("contentId"));
newContext.put("partyId", serviceContext.get("partyId"));
newContext.put("roleTypeId", serviceContext.get("roleTypeId"));
newContext.put("userLogin", userLogin);
Map<String, Object> permResults = dispatcher.runSync("deactivateAllContentRoles", newContext);
if (ServiceUtil.isError(permResults)) {
return ServiceUtil.returnError(ServiceUtil.getErrorMessage(permResults));
}
} catch (GenericServiceException e) {
Debug.logError(e, e.toString(), module);
return ServiceUtil.returnError(e.toString());
} catch (Exception e2) {
Debug.logError(e2, e2.toString(), module);
return ServiceUtil.returnError(e2.toString());
}
}
}
}
return results;
}
use of org.apache.ofbiz.service.LocalDispatcher in project ofbiz-framework by apache.
the class ContentManagementServices method followNodeChildren.
public static Map<String, Object> followNodeChildren(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException {
Map<String, Object> result = null;
Delegator delegator = dctx.getDelegator();
LocalDispatcher dispatcher = dctx.getDispatcher();
Security security = dctx.getSecurity();
GenericValue userLogin = (GenericValue) context.get("userLogin");
Locale locale = (Locale) context.get("locale");
if (!security.hasEntityPermission("CONTENTMGR", "_ADMIN", userLogin)) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ContentPermissionNotGranted", locale));
}
String contentId = (String) context.get("contentId");
String serviceName = (String) context.get("serviceName");
String contentAssocTypeId = (String) context.get("contentAssocTypeId");
List<String> contentAssocTypeIdList = new LinkedList<String>();
if (UtilValidate.isNotEmpty(contentAssocTypeId)) {
contentAssocTypeIdList = StringUtil.split(contentAssocTypeId, "|");
}
if (contentAssocTypeIdList.size() == 0) {
contentAssocTypeIdList.add("SUB_CONTENT");
}
Map<String, Object> ctx = new HashMap<String, Object>();
ctx.put("userLogin", userLogin);
ctx.put("contentAssocTypeIdList", contentAssocTypeIdList);
try {
GenericValue content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne();
result = followNodeChildrenMethod(content, dispatcher, serviceName, ctx);
} catch (GenericEntityException e) {
Debug.logError(e.toString(), module);
return ServiceUtil.returnError(e.toString());
}
return result;
}
Aggregations