* reflection performance penalty.
*/
public static Map<String, Object> updateContentAssocMethod(DispatchContext dctx, Map<String, ? extends Object> rcontext) {
Map<String, Object> context = UtilMisc.makeMapWritable(rcontext);
Delegator delegator = dctx.getDelegator();
LocalDispatcher dispatcher = dctx.getDispatcher();
Locale locale = (Locale) context.get("locale");
Map<String, Object> result = FastMap.newInstance();
context.put("entityOperation", "_UPDATE");
List<String> targetOperationList = ContentWorker.prepTargetOperationList(context, "_UPDATE");
List<String> contentPurposeList = ContentWorker.prepContentPurposeList(context);
context.put("targetOperationList", targetOperationList);
context.put("contentPurposeList", contentPurposeList);
// This section guesses how contentId should be used (From or To) if
// only a contentIdFrom o contentIdTo is passed in
String contentIdFrom = (String) context.get("contentId");
String contentIdTo = (String) context.get("contentIdTo");
String contentId = (String) context.get("contentId");
String contentAssocTypeId = (String) context.get("contentAssocTypeId");
Timestamp fromDate = (Timestamp) context.get("fromDate");
GenericValue contentAssoc = null;
try {
contentAssoc = delegator.findByPrimaryKey("ContentAssoc", UtilMisc.toMap("contentId", contentId, "contentIdTo", contentIdTo, "contentAssocTypeId", contentAssocTypeId, "fromDate", fromDate));
} catch (GenericEntityException e) {
Debug.logError(e, "Entity Error:" + e.getMessage(), module);
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ContentAssocRetrievingError", UtilMisc.toMap("errorString", e.getMessage()), locale));
}
if (contentAssoc == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ContentAssocUpdateError", locale));
}
contentAssoc.put("contentAssocPredicateId", context.get("contentAssocPredicateId"));
contentAssoc.put("dataSourceId", context.get("dataSourceId"));
contentAssoc.set("thruDate", context.get("thruDate"));
contentAssoc.set("sequenceNum", context.get("sequenceNum"));
contentAssoc.put("mapKey", context.get("mapKey"));
String upperCoordinateStr = (String) context.get("upperCoordinate");
if (UtilValidate.isEmpty(upperCoordinateStr)) {
contentAssoc.put("upperCoordinate", null);
} else {
contentAssoc.setString("upperCoordinate", upperCoordinateStr);
}
String leftCoordinateStr = (String) context.get("leftCoordinate");
if (UtilValidate.isEmpty(leftCoordinateStr)) {
contentAssoc.put("leftCoordinate", null);
} else {
contentAssoc.setString("leftCoordinate", leftCoordinateStr);
}
GenericValue userLogin = (GenericValue) context.get("userLogin");
String userLoginId = (String) userLogin.get("userLoginId");
String lastModifiedByUserLogin = userLoginId;
Timestamp lastModifiedDate = UtilDateTime.nowTimestamp();
contentAssoc.put("lastModifiedByUserLogin", lastModifiedByUserLogin);
contentAssoc.put("lastModifiedDate", lastModifiedDate);
String permissionStatus = null;
Map<String, Object> serviceInMap = FastMap.newInstance();
serviceInMap.put("userLogin", context.get("userLogin"));
serviceInMap.put("targetOperationList", targetOperationList);
serviceInMap.put("contentPurposeList", contentPurposeList);
serviceInMap.put("entityOperation", context.get("entityOperation"));
serviceInMap.put("contentIdTo", contentIdTo);
serviceInMap.put("contentIdFrom", contentIdFrom);
Map<String, Object> permResults = null;
try {
permResults = dispatcher.runSync("checkAssocPermission", serviceInMap);
} catch (GenericServiceException e) {
Debug.logError(e, "Problem checking permissions", "ContentServices");
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ContentPermissionNotGranted", locale));
}
permissionStatus = (String) permResults.get("permissionStatus");