1 package org.ofbiz.content.content; 2 3 import java.util.ArrayList ; 4 import java.util.HashMap ; 5 import java.util.Iterator ; 6 import java.util.List ; 7 import java.util.Locale ; 8 import java.util.Map ; 9 import javax.servlet.http.HttpServletRequest ; 10 import javax.servlet.http.HttpServletResponse ; 11 import javax.servlet.http.HttpSession ; 12 13 import org.ofbiz.base.util.Debug; 14 import org.ofbiz.base.util.StringUtil; 15 import org.ofbiz.base.util.UtilDateTime; 16 import org.ofbiz.base.util.UtilHttp; 17 import org.ofbiz.base.util.UtilMisc; 18 import org.ofbiz.base.util.UtilProperties; 19 import org.ofbiz.base.util.UtilValidate; 20 import org.ofbiz.entity.GenericDelegator; 21 import org.ofbiz.entity.GenericValue; 22 import org.ofbiz.entity.model.ModelEntity; 23 import org.ofbiz.entity.transaction.GenericTransactionException; 24 import org.ofbiz.entity.transaction.TransactionUtil; 25 import org.ofbiz.entity.util.ByteWrapper; 26 import org.ofbiz.entity.util.EntityUtil; 27 import org.ofbiz.minilang.MiniLangException; 28 import org.ofbiz.minilang.SimpleMapProcessor; 29 import org.ofbiz.service.GenericServiceException; 30 import org.ofbiz.service.LocalDispatcher; 31 import org.ofbiz.service.ModelService; 32 import org.ofbiz.service.ServiceAuthException; 33 import org.ofbiz.service.ServiceUtil; 34 35 import org.apache.commons.fileupload.DiskFileUpload; 36 import org.apache.commons.fileupload.FileItem; 37 import org.apache.commons.fileupload.FileUploadException; 38 39 40 49 public class UploadContentAndImage { 50 51 public static final String module = UploadContentAndImage.class.getName(); 52 public static final String err_resource = "ContentErrorUiLabel"; 53 54 public UploadContentAndImage() {} 55 56 57 public static String uploadContentAndImage(HttpServletRequest request, HttpServletResponse response) { 58 59 60 try { 61 Locale locale = UtilHttp.getLocale(request); 62 LocalDispatcher dispatcher = (LocalDispatcher)request.getAttribute("dispatcher"); 63 GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator"); 64 HttpSession session = request.getSession(); 65 GenericValue userLogin = (GenericValue)session.getAttribute("userLogin"); 66 67 DiskFileUpload dfu = new DiskFileUpload(); 68 java.util.List lst = null; 70 try { 71 lst = dfu.parseRequest(request); 72 } catch (FileUploadException e4) { 73 request.setAttribute("_ERROR_MESSAGE_", e4.getMessage()); 74 Debug.logError("[UploadContentAndImage.uploadContentAndImage] " + e4.getMessage(), module); 75 return "error"; 76 } 77 79 if (lst.size() == 0) { 80 String errMsg = UtilProperties.getMessage(UploadContentAndImage.err_resource, "uploadContentAndImage.no_files_uploaded", locale); 81 request.setAttribute("_ERROR_MESSAGE_", errMsg); 82 Debug.logWarning("[DataEvents.uploadImage] No files uploaded", module); 83 return "error"; 84 } 85 86 Map passedParams = new HashMap (); 87 FileItem fi = null; 88 FileItem imageFi = null; 89 byte[] imageBytes = {}; 90 for (int i = 0; i < lst.size(); i++) { 91 fi = (FileItem) lst.get(i); 92 String fieldName = fi.getFieldName(); 94 if (fi.isFormField()) { 95 String fieldStr = fi.getString(); 96 passedParams.put(fieldName, fieldStr); 97 } else if (fieldName.equals("imageData")) { 98 imageFi = fi; 99 imageBytes = imageFi.get(); 100 } 101 } 102 if (Debug.infoOn()) Debug.logInfo("[UploadContentAndImage]passedParams: " + passedParams, module); 103 104 TransactionUtil.begin(); 105 List contentPurposeList = ContentWorker.prepContentPurposeList(passedParams); 106 passedParams.put("contentPurposeList", contentPurposeList ); 107 String entityOperation = (String )passedParams.get("entityOperation"); 108 String passedContentId = (String )passedParams.get("ftlContentId"); 109 List targetOperationList = ContentWorker.prepTargetOperationList(passedParams, entityOperation); 110 passedParams.put("targetOperationList", targetOperationList ); 111 Map ftlContext = new HashMap (); 113 ftlContext.put("userLogin", userLogin); 114 ftlContext.put("contentId", passedParams.get("ftlContentId")); 115 ftlContext.put("ownerContentId", passedParams.get("ownerContentId")); 116 String contentTypeId = (String )passedParams.get("contentTypeId"); 117 ftlContext.put("contentTypeId", contentTypeId); 118 ftlContext.put("statusId", passedParams.get("statusId")); 119 ftlContext.put("contentPurposeList", UtilMisc.toList(passedParams.get("contentPurposeList"))); 120 ftlContext.put("contentPurposeList", contentPurposeList); 121 ftlContext.put("targetOperationList",targetOperationList); 122 ftlContext.put("contentName", passedParams.get("contentName")); 123 ftlContext.put("dataTemplateTypeId", passedParams.get("dataTemplateTypeId")); 124 ftlContext.put("description", passedParams.get("description")); 125 ftlContext.put("privilegeEnumId", passedParams.get("privilegeEnumId")); 126 String drid = (String )passedParams.get("dataResourceId"); 127 ftlContext.put("dataResourceId", drid); 129 ftlContext.put("dataResourceTypeId", null); String contentIdTo = (String )passedParams.get("contentIdTo"); 131 ftlContext.put("contentIdTo", contentIdTo); 132 String contentAssocTypeId = (String )passedParams.get("contentAssocTypeId"); 133 ftlContext.put("contentAssocTypeId", null); Map ftlResults = dispatcher.runSync("persistContentAndAssoc", ftlContext); 135 boolean isError = ModelService.RESPOND_ERROR.equals(ftlResults.get(ModelService.RESPONSE_MESSAGE)); 136 if (isError) { 137 request.setAttribute("_ERROR_MESSAGE_", ftlResults.get(ModelService.ERROR_MESSAGE)); 138 TransactionUtil.rollback(); 139 return "error"; 140 } 141 String ftlContentId = (String )ftlResults.get("contentId"); 142 if (UtilValidate.isNotEmpty(contentIdTo) ) { 143 Map map = new HashMap (); 144 map.put("fromDate", UtilDateTime.nowTimestamp()); 145 map.put("contentId", ftlContentId); 146 map.put("contentIdTo", contentIdTo); 147 map.put("userLogin", userLogin); 148 if (UtilValidate.isEmpty(contentAssocTypeId) && UtilValidate.isEmpty(passedContentId) && UtilValidate.isNotEmpty(contentIdTo) ) { 149 map.put("contentIdTo", ftlContentId); 152 map.put("contentId", contentIdTo); 153 map.put("contentAssocTypeId", "PUBLISH_RELEASE"); 154 } else if (contentAssocTypeId.equals("PUBLISH_LINK")) { 155 map.put("contentAssocTypeId", "PUBLISH_LINK"); 156 String publishOperation = (String )passedParams.get("publishOperation"); 157 if (UtilValidate.isEmpty(publishOperation) ) { 158 publishOperation = "CONTENT_PUBLISH"; 159 } 160 map.put("targetOperationList", StringUtil.split(publishOperation, "|")); 161 map.put("targetOperationString", null); 162 } else { 163 map.put("contentAssocTypeId", contentAssocTypeId); 164 } 165 if (UtilValidate.isNotEmpty((String )map.get("contentAssocTypeId"))) { 166 ftlResults = dispatcher.runSync("createContentAssoc", map); 167 isError = ModelService.RESPOND_ERROR.equals(ftlResults.get(ModelService.RESPONSE_MESSAGE)); 168 if (isError) { 169 request.setAttribute("_ERROR_MESSAGE_", ftlResults.get(ModelService.ERROR_MESSAGE)); 170 TransactionUtil.rollback(); 171 return "error"; 172 } 173 } 174 } 175 176 if (UtilValidate.isEmpty(ftlContentId)) 177 ftlContentId = passedContentId; 178 179 String ftlDataResourceId = drid; 180 181 if (Debug.infoOn()) Debug.logInfo("[UploadContentAndImage]ftlContentId:" + ftlContentId, module); 182 if ( passedParams.containsKey("summaryData") ) { 185 Map sumContext = new HashMap (); 186 sumContext.put("userLogin", userLogin); 187 sumContext.put("contentId", passedParams.get("sumContentId")); 188 sumContext.put("ownerContentId", ftlContentId); 189 sumContext.put("contentTypeId", "DOCUMENT"); 190 sumContext.put("statusId", passedParams.get("statusId")); 191 sumContext.put("contentPurposeList", UtilMisc.toList("SUMMARY")); 192 sumContext.put("targetOperationList",targetOperationList); 194 sumContext.put("contentName", passedParams.get("contentName")); 195 sumContext.put("description", passedParams.get("description")); 196 sumContext.put("privilegeEnumId", passedParams.get("privilegeEnumId")); 197 sumContext.put("dataResourceId", passedParams.get("sumDataResourceId")); 198 sumContext.put("dataResourceTypeId", "ELECTRONIC_TEXT"); 199 sumContext.put("contentIdTo", ftlContentId); 200 sumContext.put("contentAssocTypeId", "SUB_CONTENT"); 201 sumContext.put("textData", passedParams.get("summaryData")); 202 sumContext.put("mapKey", "SUMMARY"); 203 sumContext.put("dataTemplateTypeId", "NONE"); 204 Map sumResults = dispatcher.runSync("persistContentAndAssoc", sumContext); 205 isError = ModelService.RESPOND_ERROR.equals(sumResults.get(ModelService.RESPONSE_MESSAGE)); 206 if (isError) { 207 request.setAttribute("_ERROR_MESSAGE_", sumResults.get(ModelService.ERROR_MESSAGE)); 208 TransactionUtil.rollback(); 209 return "error"; 210 } 211 } 212 213 if ( passedParams.containsKey("textData") ) { 215 Map txtContext = new HashMap (); 216 txtContext.put("userLogin", userLogin); 217 txtContext.put("contentId", passedParams.get("txtContentId")); 218 txtContext.put("ownerContentId", ftlContentId); 219 txtContext.put("contentTypeId", "DOCUMENT"); 220 txtContext.put("statusId", passedParams.get("statusId")); 221 txtContext.put("contentPurposeList", UtilMisc.toList("MAIN_ARTICLE")); 223 txtContext.put("targetOperationList",targetOperationList); 224 txtContext.put("contentName", passedParams.get("contentName")); 225 txtContext.put("description", passedParams.get("description")); 226 txtContext.put("privilegeEnumId", passedParams.get("privilegeEnumId")); 227 txtContext.put("dataResourceId", passedParams.get("txtDataResourceId")); 228 txtContext.put("dataResourceTypeId", "ELECTRONIC_TEXT"); 229 txtContext.put("contentIdTo", ftlContentId); 230 txtContext.put("contentAssocTypeId", "SUB_CONTENT"); 231 txtContext.put("textData", passedParams.get("textData")); 232 txtContext.put("mapKey", "ARTICLE"); 233 txtContext.put("dataTemplateTypeId", "NONE"); 234 Map txtResults = dispatcher.runSync("persistContentAndAssoc", txtContext); 235 isError = ModelService.RESPOND_ERROR.equals(txtResults.get(ModelService.RESPONSE_MESSAGE)); 236 if (isError) { 237 request.setAttribute("_ERROR_MESSAGE_", txtResults.get(ModelService.ERROR_MESSAGE)); 238 TransactionUtil.rollback(); 239 return "error"; 240 } 241 } 242 243 Map imgContext = new HashMap (); 245 if (imageBytes.length > 0) { 246 imgContext.put("userLogin", userLogin); 247 imgContext.put("contentId", passedParams.get("imgContentId")); 248 imgContext.put("ownerContentId", ftlContentId); 249 imgContext.put("contentTypeId", "DOCUMENT"); 250 imgContext.put("statusId", passedParams.get("statusId")); 251 imgContext.put("contentName", passedParams.get("contentName")); 252 imgContext.put("description", passedParams.get("description")); 253 imgContext.put("contentPurposeList", contentPurposeList); 254 imgContext.put("privilegeEnumId", passedParams.get("privilegeEnumId")); 255 imgContext.put("targetOperationList",targetOperationList); 256 imgContext.put("dataResourceId", passedParams.get("imgDataResourceId")); 257 String dataResourceTypeId = "IMAGE_OBJECT"; 261 imgContext.put("dataResourceTypeId", dataResourceTypeId); 262 imgContext.put("contentIdTo", ftlContentId); 263 imgContext.put("contentAssocTypeId", "SUB_CONTENT"); 264 imgContext.put("imageData", new ByteWrapper(imageBytes)); 265 imgContext.put("mapKey", "IMAGE"); 266 imgContext.put("dataTemplateTypeId", "NONE"); 267 String rootDir = request.getSession().getServletContext().getRealPath("/"); 268 imgContext.put("rootDir", "rootDir"); 269 if (Debug.infoOn()) Debug.logInfo("[UploadContentAndImage]imgContext " + imgContext, module); 270 Map imgResults = dispatcher.runSync("persistContentAndAssoc", imgContext); 271 isError = ModelService.RESPOND_ERROR.equals(imgResults.get(ModelService.RESPONSE_MESSAGE)); 272 if (isError) { 273 request.setAttribute("_ERROR_MESSAGE_", imgResults.get(ModelService.ERROR_MESSAGE)); 274 TransactionUtil.rollback(); 275 return "error"; 276 } 277 } 278 279 String userLoginId = userLogin.getString("userLoginId"); 281 GenericValue authorContent = delegator.findByPrimaryKeyCache("Content", UtilMisc.toMap("contentId", userLoginId)); 282 if (authorContent != null) { 283 List authorAssocList = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId", ftlContentId, "contentIdTo", userLoginId, "contentAssocTypeId", "AUTHOR")); 284 List currentAuthorAssocList = EntityUtil.filterByDate(authorAssocList); 285 if (currentAuthorAssocList.size() == 0) { 287 GenericValue authorAssoc = delegator.makeValue("ContentAssoc", null); 289 authorAssoc.set("contentId", ftlContentId); 290 authorAssoc.set("contentIdTo", userLoginId); 291 authorAssoc.set("contentAssocTypeId", "AUTHOR"); 292 authorAssoc.set("fromDate", UtilDateTime.nowTimestamp()); 293 authorAssoc.set("createdByUserLogin", userLoginId); 294 authorAssoc.set("lastModifiedByUserLogin", userLoginId); 295 authorAssoc.set("createdDate", UtilDateTime.nowTimestamp()); 296 authorAssoc.set("lastModifiedDate", UtilDateTime.nowTimestamp()); 297 authorAssoc.create(); 298 } 299 } 300 301 request.setAttribute("dataResourceId", ftlDataResourceId); 302 request.setAttribute("drDataResourceId", ftlDataResourceId); 303 request.setAttribute("contentId", ftlContentId); 304 request.setAttribute("masterContentId", ftlContentId); 305 request.setAttribute("contentIdTo", contentIdTo); 306 String newTrail = passedParams.get("nodeTrailCsv") + "," + ftlContentId; 307 request.setAttribute("nodeTrailCsv", newTrail); 308 request.setAttribute("passedParams", passedParams); 309 TransactionUtil.commit(); 311 } catch( Exception e) { 312 Debug.logError(e, "[UploadContentAndImage] " , module); 313 request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); 314 try { 315 TransactionUtil.rollback(); 316 } catch(GenericTransactionException e2) { 317 request.setAttribute("_ERROR_MESSAGE_", e2.getMessage()); 318 return "error"; 319 } 320 return "error"; 321 } 322 return "success"; 323 } 324 325 public static String uploadContentStuff(HttpServletRequest request, HttpServletResponse response) { 326 327 328 try { 329 LocalDispatcher dispatcher = (LocalDispatcher)request.getAttribute("dispatcher"); 330 GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator"); 331 HttpSession session = request.getSession(); 332 GenericValue userLogin = (GenericValue)session.getAttribute("userLogin"); 333 334 DiskFileUpload dfu = new DiskFileUpload(); 335 java.util.List lst = null; 337 try { 338 lst = dfu.parseRequest(request); 339 } catch (FileUploadException e4) { 340 request.setAttribute("_ERROR_MESSAGE_", e4.getMessage()); 341 Debug.logError("[UploadContentAndImage.uploadContentAndImage] " + e4.getMessage(), module); 342 return "error"; 343 } 344 346 if (lst.size() == 0) { 347 request.setAttribute("_ERROR_MESSAGE_", "No files uploaded"); 348 Debug.logWarning("[DataEvents.uploadImage] No files uploaded", module); 349 return "error"; 350 } 351 352 Map passedParams = new HashMap (); 353 FileItem fi = null; 354 FileItem imageFi = null; 355 byte[] imageBytes = {}; 356 passedParams.put("userLogin", userLogin); 357 for (int i = 0; i < lst.size(); i++) { 358 fi = (FileItem) lst.get(i); 359 String fieldName = fi.getFieldName(); 361 if (fi.isFormField()) { 362 String fieldStr = fi.getString(); 363 passedParams.put(fieldName, fieldStr); 364 } else if (fieldName.startsWith("imageData")) { 365 imageFi = fi; 366 String fileName = fi.getName(); 367 passedParams.put("drObjectInfo", fileName); 368 String contentType = fi.getContentType(); 369 passedParams.put("drMimeTypeId", contentType); 370 imageBytes = imageFi.get(); 371 passedParams.put(fieldName, imageBytes); 372 if (Debug.infoOn()) Debug.logInfo("[UploadContentAndImage]imageData: " + imageBytes.length, module); 373 } 374 } 375 if (Debug.infoOn()) Debug.logInfo("[UploadContentAndImage]passedParams: " + passedParams, module); 376 377 String strRowCount = (String )passedParams.get("_rowCount"); 378 if (UtilValidate.isEmpty(strRowCount)) { 379 strRowCount = "1"; 380 } 381 int rowCount = Integer.parseInt(strRowCount); 382 TransactionUtil.begin(); 383 for (int i=0; i < rowCount; i++) { 384 String suffix = "_o_" + i; 385 if (i==0) 386 suffix = ""; 387 String returnMsg = processContentUpload(passedParams, suffix, request); 388 if (returnMsg.equals("error")) { 389 try { 390 TransactionUtil.rollback(); 391 } catch(GenericTransactionException e2) { 392 ServiceUtil.setMessages(request, e2.getMessage(), null, null); 393 return "error"; 394 } 395 return "error"; 396 } 397 } 398 TransactionUtil.commit(); 399 } catch( Exception e) { 400 Debug.logError(e, "[UploadContentAndImage] " , module); 401 request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); 402 try { 403 TransactionUtil.rollback(); 404 } catch(GenericTransactionException e2) { 405 request.setAttribute("_ERROR_MESSAGE_", e2.getMessage()); 406 return "error"; 407 } 408 return "error"; 409 } 410 return "success"; 411 } 412 413 public static String processContentUpload(Map passedParams, String suffix, HttpServletRequest request) throws GenericServiceException { 414 415 LocalDispatcher dispatcher = (LocalDispatcher)request.getAttribute("dispatcher"); 416 GenericDelegator delegator = (GenericDelegator)request.getAttribute("delegator"); 417 HttpSession session = request.getSession(); 418 GenericValue userLogin = (GenericValue)session.getAttribute("userLogin"); 419 Map ftlContext = new HashMap (); 420 421 String contentPurposeString = (String )passedParams.get("contentPurposeString" + suffix); 422 if (UtilValidate.isEmpty(contentPurposeString)) { 423 contentPurposeString = (String )passedParams.get("contentPurposeString"); 424 } 425 List contentPurposeList = StringUtil.split(contentPurposeString,"|"); 426 ftlContext.put("contentPurposeList", contentPurposeList); 427 428 String targetOperationString = (String )passedParams.get("targetOperationString" + suffix); 429 if (UtilValidate.isEmpty(targetOperationString)) { 430 targetOperationString = (String )passedParams.get("targetOperationString"); 431 } 432 List targetOperationList = StringUtil.split(targetOperationString,"|"); 433 ftlContext.put("targetOperationList",targetOperationList); 434 435 ftlContext.put("userLogin", userLogin); 436 Object objSequenceNum = passedParams.get("caSequenceNum"); 437 if (objSequenceNum != null ) { 438 if (objSequenceNum instanceof String ) { 439 Long sequenceNum = null; 440 try { 441 sequenceNum = new Long ((String )objSequenceNum); 442 } catch(NumberFormatException e) { 443 } 444 passedParams.put("caSequenceNum", sequenceNum); 445 } 446 } 447 448 GenericValue contentAssocDataResourceViewFrom = delegator.makeValue("ContentAssocDataResourceViewFrom",null); 449 ModelEntity modelEntity = delegator.getModelEntity("ContentAssocDataResourceViewFrom"); 450 List fieldNames = modelEntity.getAllFieldNames(); 451 Iterator iter = fieldNames.iterator(); 452 Map ftlContext2 = new HashMap (); 453 Map ftlContext3 = new HashMap (); 454 while (iter.hasNext()) { 455 String keyName = (String )iter.next(); 456 Object obj = passedParams.get(keyName + suffix); 457 ftlContext2.put(keyName, obj); 458 } 459 if (Debug.infoOn()) Debug.logInfo("[UploadContentStuff]ftlContext2:" + ftlContext2, module); 460 List errorMessages = new ArrayList (); 461 Locale loc = Locale.getDefault(); 462 try { 463 SimpleMapProcessor.runSimpleMapProcessor( "org/ofbiz/content/ContentManagementMapProcessors.xml", "contentIn", ftlContext2, ftlContext3, errorMessages, loc); 464 SimpleMapProcessor.runSimpleMapProcessor( "org/ofbiz/content/ContentManagementMapProcessors.xml", "contentOut", ftlContext3, ftlContext, errorMessages, loc); 465 466 ftlContext3 = new HashMap (); 467 SimpleMapProcessor.runSimpleMapProcessor( "org/ofbiz/content/ContentManagementMapProcessors.xml", "dataResourceIn", ftlContext2, ftlContext3, errorMessages, loc); 468 SimpleMapProcessor.runSimpleMapProcessor( "org/ofbiz/content/ContentManagementMapProcessors.xml", "dataResourceOut", ftlContext3, ftlContext, errorMessages, loc); 469 470 ftlContext3 = new HashMap (); 471 SimpleMapProcessor.runSimpleMapProcessor( "org/ofbiz/content/ContentManagementMapProcessors.xml", "contentAssocIn", ftlContext2, ftlContext3, errorMessages, loc); 472 SimpleMapProcessor.runSimpleMapProcessor( "org/ofbiz/content/ContentManagementMapProcessors.xml", "contentAssocOut", ftlContext3, ftlContext, errorMessages, loc); 473 } catch(MiniLangException e) { 474 throw new GenericServiceException(e.getMessage()); 475 } 476 477 478 ftlContext.put("textData", passedParams.get("textData" + suffix)); 479 byte[] bytes = (byte[])passedParams.get("imageData" + suffix); 480 ByteWrapper byteWrapper = new ByteWrapper(bytes); 481 ftlContext.put("imageData", byteWrapper); 482 if (Debug.infoOn()) Debug.logInfo("[UploadContentStuff]byteWrapper:" + byteWrapper, module); 483 if (Debug.infoOn()) Debug.logInfo("[UploadContentStuff]ftlContext:" + ftlContext, module); 486 Map ftlResults = null; 487 try { 488 ftlResults = dispatcher.runSync("persistContentAndAssoc", ftlContext); 489 } catch(ServiceAuthException e) { 490 String msg = e.getMessage(); 491 request.setAttribute("_ERROR_MESSAGE_", msg); 492 List errorMsgList = (List )request.getAttribute("_EVENT_MESSAGE_LIST_"); 493 if (Debug.infoOn()) Debug.logInfo("[UploadContentStuff]errorMsgList:" + errorMsgList, module); 494 if (Debug.infoOn()) Debug.logInfo("[UploadContentStuff]msg:" + msg, module); 495 if (errorMsgList == null) { 496 errorMsgList = new ArrayList (); 497 request.setAttribute("errorMessageList", errorMsgList); 498 } 499 errorMsgList.add(msg); 500 return "error"; 501 } 502 String msg = ServiceUtil.getErrorMessage(ftlResults); 503 if (UtilValidate.isNotEmpty(msg)) { 504 request.setAttribute("_ERROR_MESSAGE_", msg); 505 List errorMsgList = (List )request.getAttribute("_EVENT_MESSAGE_LIST_"); 506 if (errorMsgList == null) { 507 errorMsgList = new ArrayList (); 508 request.setAttribute("errorMessageList", errorMsgList); 509 } 510 errorMsgList.add(msg); 511 return "error"; 512 } 513 String returnedContentId = (String )ftlResults.get("contentId"); 514 if (Debug.infoOn()) Debug.logInfo("returnedContentId:" + returnedContentId, module); 515 request.setAttribute("contentId" + suffix, ftlResults.get("contentId")); 516 request.setAttribute("caContentIdTo" + suffix, ftlResults.get("contentIdTo")); 517 request.setAttribute("caContentIdStart" + suffix, ftlResults.get("contentIdTo")); 518 request.setAttribute("caContentAssocTypeId" + suffix, ftlResults.get("contentAssocTypeId")); 519 request.setAttribute("caFromDate" + suffix, ftlResults.get("fromDate")); 520 request.setAttribute("drDataResourceId" + suffix, ftlResults.get("dataResourceId")); 521 request.setAttribute("caContentId" + suffix, ftlResults.get("contentId")); 522 523 String caContentIdTo = (String )passedParams.get("caContentIdTo"); 524 if (UtilValidate.isNotEmpty(caContentIdTo)) { 525 Map resequenceContext = new HashMap (); 526 resequenceContext.put("contentIdTo", caContentIdTo); 527 resequenceContext.put("userLogin", userLogin); 528 try { 529 ftlResults = dispatcher.runSync("resequence", resequenceContext); 530 } catch(ServiceAuthException e) { 531 msg = e.getMessage(); 532 request.setAttribute("_ERROR_MESSAGE_", msg); 533 List errorMsgList = (List )request.getAttribute("_EVENT_MESSAGE_LIST_"); 534 if (Debug.infoOn()) Debug.logInfo("[UploadContentStuff]errorMsgList:" + errorMsgList, module); 535 if (Debug.infoOn()) Debug.logInfo("[UploadContentStuff]msg:" + msg, module); 536 if (errorMsgList == null) { 537 errorMsgList = new ArrayList (); 538 request.setAttribute("errorMessageList", errorMsgList); 539 } 540 errorMsgList.add(msg); 541 return "error"; 542 } 543 } 544 return "success"; 545 } 546 547 } | Popular Tags |