1 24 package org.ofbiz.content.data; 25 26 import java.io.File ; 27 import java.io.FileNotFoundException ; 28 import java.io.FileOutputStream ; 29 import java.io.FileWriter ; 30 import java.io.StringWriter ; 31 import java.io.IOException ; 32 import java.io.RandomAccessFile ; 33 import java.io.Writer ; 34 import java.sql.Timestamp ; 35 import java.util.HashMap ; 36 import java.util.Locale ; 37 import java.util.Map ; 38 39 import org.ofbiz.base.util.Debug; 40 import org.ofbiz.base.util.GeneralException; 41 import org.ofbiz.base.util.UtilDateTime; 42 import org.ofbiz.base.util.UtilMisc; 43 import org.ofbiz.base.util.UtilValidate; 44 import org.ofbiz.entity.GenericDelegator; 45 import org.ofbiz.entity.GenericEntityException; 46 import org.ofbiz.entity.GenericValue; 47 import org.ofbiz.entity.util.ByteWrapper; 48 import org.ofbiz.service.DispatchContext; 49 import org.ofbiz.service.GenericServiceException; 50 import org.ofbiz.service.LocalDispatcher; 51 import org.ofbiz.service.ModelService; 52 import org.ofbiz.service.ServiceUtil; 53 54 64 public class DataServices { 65 66 public static final String module = DataServices.class.getName(); 67 68 71 public static Map createDataResourceAndText(DispatchContext dctx, Map context) { 72 GenericDelegator delegator = dctx.getDelegator(); 73 LocalDispatcher dispatcher = dctx.getDispatcher(); 74 Map result = new HashMap (); 75 76 Map thisResult = createDataResourceMethod(dctx, context); 77 if (thisResult.get(ModelService.RESPONSE_MESSAGE) != null) { 78 return ServiceUtil.returnError((String ) thisResult.get(ModelService.ERROR_MESSAGE)); 79 } 80 81 result.put("dataResourceId", thisResult.get("dataResourceId")); 82 context.put("dataResourceId", thisResult.get("dataResourceId")); 83 84 String dataResourceTypeId = (String ) context.get("dataResourceTypeId"); 85 if (dataResourceTypeId != null && dataResourceTypeId.equals("ELECTRONIC_TEXT")) { 86 thisResult = createElectronicText(dctx, context); 87 if (thisResult.get(ModelService.RESPONSE_MESSAGE) != null) { 88 return ServiceUtil.returnError((String ) thisResult.get(ModelService.ERROR_MESSAGE)); 89 } 90 } 91 92 return result; 93 } 94 95 98 public static Map createDataResource(DispatchContext dctx, Map context) { 99 Map result = createDataResourceMethod(dctx, context); 100 return result; 101 } 102 103 public static Map createDataResourceMethod(DispatchContext dctx, Map context) { 104 Map result = new HashMap (); 105 GenericDelegator delegator = dctx.getDelegator(); 106 LocalDispatcher dispatcher = dctx.getDispatcher(); 107 GenericValue userLogin = (GenericValue) context.get("userLogin"); 108 String userLoginId = (String ) userLogin.get("userLoginId"); 109 String createdByUserLogin = userLoginId; 110 String lastModifiedByUserLogin = userLoginId; 111 Timestamp createdDate = UtilDateTime.nowTimestamp(); 112 Timestamp lastModifiedDate = UtilDateTime.nowTimestamp(); 113 String dataTemplateTypeId = (String ) context.get("dataTemplateTypeId"); 114 if (UtilValidate.isEmpty(dataTemplateTypeId)) { 115 dataTemplateTypeId = "NONE"; 116 context.put("dataTemplateTypeId", dataTemplateTypeId ); 117 } 118 119 String dataResourceId = (String ) context.get("dataResourceId"); 121 if (UtilValidate.isEmpty(dataResourceId)) 122 dataResourceId = delegator.getNextSeqId("DataResource").toString(); 123 if (Debug.infoOn()) Debug.logInfo("in createDataResourceMethod, dataResourceId:" + dataResourceId, module); 124 GenericValue dataResource = delegator.makeValue("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId)); 125 dataResource.setNonPKFields(context); 126 dataResource.put("createdByUserLogin", createdByUserLogin); 127 dataResource.put("lastModifiedByUserLogin", lastModifiedByUserLogin); 128 dataResource.put("createdDate", createdDate); 129 dataResource.put("lastModifiedDate", lastModifiedDate); 130 try { 131 dataResource.create(); 132 } catch (GenericEntityException e) { 133 return ServiceUtil.returnError(e.getMessage()); 134 } catch(Exception e2) { 135 return ServiceUtil.returnError(e2.getMessage()); 136 } 137 result.put("dataResourceId", dataResourceId); 138 result.put("dataResource", dataResource); 139 return result; 140 } 141 142 145 public static Map createElectronicText(DispatchContext dctx, Map context) { 146 Map result = createElectronicTextMethod(dctx, context); 147 return result; 148 } 149 150 public static Map createElectronicTextMethod(DispatchContext dctx, Map context) { 151 HashMap result = new HashMap (); 152 GenericDelegator delegator = dctx.getDelegator(); 153 LocalDispatcher dispatcher = dctx.getDispatcher(); 154 String dataResourceId = (String ) context.get("dataResourceId"); 155 String textData = (String ) context.get("textData"); 156 if (textData != null && textData.length() > 0) { 157 GenericValue electronicText = delegator.makeValue("ElectronicText", UtilMisc.toMap("dataResourceId", dataResourceId, "textData", textData)); 158 try { 159 electronicText.create(); 160 } catch (GenericEntityException e) { 161 return ServiceUtil.returnError(e.getMessage()); 162 } 163 } 164 165 166 return result; 167 } 168 169 172 public static Map createFile(DispatchContext dctx, Map context) { 173 174 return createFileMethod(dctx, context); 175 } 176 177 public static Map createFileNoPerm(DispatchContext dctx, Map context) { 178 context.put("skipPermissionCheck", "true"); 179 return createFileMethod(dctx, context); 180 } 181 182 public static Map createFileMethod(DispatchContext dctx, Map context) { 183 GenericDelegator delegator = dctx.getDelegator(); 184 LocalDispatcher dispatcher = dctx.getDispatcher(); 185 String dataResourceTypeId = (String ) context.get("dataResourceTypeId"); 187 String objectInfo = (String ) context.get("objectInfo"); 188 ByteWrapper binData = (ByteWrapper) context.get("binData"); 189 String textData = (String ) context.get("textData"); 190 191 String prefix = ""; 193 String sep = ""; 194 195 if (UtilValidate.isNotEmpty(textData) && binData != null) { 197 return ServiceUtil.returnError("Cannot process both character and binary data in the same file"); 198 } 199 200 File file = null; 202 if (UtilValidate.isEmpty(dataResourceTypeId) || dataResourceTypeId.equals("LOCAL_FILE")) { 203 file = new File (objectInfo); 204 if (!file.isAbsolute()) { 205 return ServiceUtil.returnError("DataResource LOCAL_FILE does not point to an absolute location"); 206 } 207 } else if (dataResourceTypeId.equals("OFBIZ_FILE")) { 208 prefix = System.getProperty("ofbiz.home"); 209 if (objectInfo.indexOf("/") != 0 && prefix.lastIndexOf("/") != (prefix.length() - 1)) { 210 sep = "/"; 211 } 212 file = new File (prefix + sep + objectInfo); 213 } else if (dataResourceTypeId.equals("CONTEXT_FILE")) { 214 prefix = (String ) context.get("rootDir"); 215 if (objectInfo.indexOf("/") != 0 && prefix.lastIndexOf("/") != (prefix.length() - 1)) { 216 sep = "/"; 217 } 218 file = new File (prefix + sep + objectInfo); 219 } 220 if (file == null) { 221 return ServiceUtil.returnError("Unable to obtain a reference to file - " + objectInfo); 222 } 223 224 if (UtilValidate.isNotEmpty(textData)) { 226 try { 227 FileWriter out = new FileWriter (file); 228 out.write(textData); 229 out.close(); 230 } catch (IOException e) { 231 Debug.logWarning(e, module); 232 return ServiceUtil.returnError("Unable to write character data to: " + file.getAbsolutePath()); 233 } 234 } else if (binData != null) { 235 try { 236 RandomAccessFile out = new RandomAccessFile (file, "rw"); 237 out.write(binData.getBytes()); 238 out.close(); 239 } catch (FileNotFoundException e) { 240 Debug.logError(e, module); 241 return ServiceUtil.returnError("Unable to open file for writing: " + file.getAbsolutePath()); 242 } catch (IOException e) { 243 Debug.logError(e, module); 244 return ServiceUtil.returnError("Unable to write binary data to: " + file.getAbsolutePath()); 245 } 246 } else { 247 return ServiceUtil.returnError("No file content passed for: " + file.getAbsolutePath()); 248 } 249 250 Map result = ServiceUtil.returnSuccess(); 251 return result; 252 } 253 254 257 public static Map updateDataResourceAndText(DispatchContext dctx, Map context) { 258 GenericDelegator delegator = dctx.getDelegator(); 259 LocalDispatcher dispatcher = dctx.getDispatcher(); 260 Map thisResult = updateDataResourceMethod(dctx, context); 261 if (thisResult.get(ModelService.RESPONSE_MESSAGE) != null) { 262 return ServiceUtil.returnError((String ) thisResult.get(ModelService.ERROR_MESSAGE)); 263 } 264 String dataResourceTypeId = (String ) context.get("dataResourceTypeId"); 265 if (dataResourceTypeId != null && dataResourceTypeId.equals("ELECTRONIC_TEXT")) { 266 thisResult = updateElectronicText(dctx, context); 267 if (thisResult.get(ModelService.RESPONSE_MESSAGE) != null) { 268 return ServiceUtil.returnError((String ) thisResult.get(ModelService.ERROR_MESSAGE)); 269 } 270 } 271 return ServiceUtil.returnSuccess(); 272 } 273 274 275 276 279 public static Map updateDataResource(DispatchContext dctx, Map context) { 280 Map result = updateDataResourceMethod(dctx, context); 282 return result; 283 } 284 285 public static Map updateDataResourceMethod(DispatchContext dctx, Map context) { 286 287 Map result = new HashMap (); 288 GenericDelegator delegator = dctx.getDelegator(); 289 LocalDispatcher dispatcher = dctx.getDispatcher(); 290 GenericValue dataResource = null; 291 GenericValue userLogin = (GenericValue) context.get("userLogin"); 293 String userLoginId = (String ) userLogin.get("userLoginId"); 294 String lastModifiedByUserLogin = userLoginId; 295 Timestamp lastModifiedDate = UtilDateTime.nowTimestamp(); 296 297 String dataResourceId = (String ) context.get("dataResourceId"); 299 try { 300 dataResource = delegator.findByPrimaryKey("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId)); 301 } catch (GenericEntityException e) { 302 Debug.logWarning(e, module); 303 return ServiceUtil.returnError("dataResource.update.read_failure" + e.getMessage()); 304 } 305 306 dataResource.setNonPKFields(context); 307 dataResource.put("lastModifiedByUserLogin", lastModifiedByUserLogin); 308 dataResource.put("lastModifiedDate", lastModifiedDate); 309 310 try { 311 dataResource.store(); 312 } catch (GenericEntityException e) { 313 Debug.logError(e, module); 314 return ServiceUtil.returnError(e.getMessage()); 315 } 316 317 result.put("dataResource", dataResource); 318 return result; 319 } 320 321 324 public static Map updateElectronicText(DispatchContext dctx, Map context) { 325 Map result = updateElectronicTextMethod(dctx, context); 326 return result; 327 } 328 329 336 public static Map updateElectronicTextMethod(DispatchContext dctx, Map context) { 337 HashMap result = new HashMap (); 338 GenericDelegator delegator = dctx.getDelegator(); 339 LocalDispatcher dispatcher = dctx.getDispatcher(); 340 GenericValue electronicText = null; 341 String dataResourceId = (String ) context.get("dataResourceId"); 343 result.put("dataResourceId",dataResourceId); 344 String contentId = (String ) context.get("contentId"); 345 result.put("contentId",contentId); 346 if (UtilValidate.isEmpty(dataResourceId)) { 347 String errMsg = "dataResourceId is null."; 348 Debug.logError(errMsg, module); 349 return ServiceUtil.returnError(errMsg); 350 351 } 352 String textData = (String ) context.get("textData"); 353 if (Debug.infoOn()) Debug.logInfo("in updateElectronicText, textData:" + textData, module); 354 try { 355 electronicText = delegator.findByPrimaryKey("ElectronicText", UtilMisc.toMap("dataResourceId", dataResourceId)); 356 if (electronicText != null) { 357 electronicText.put("textData", textData); 358 electronicText.store(); 359 } else { 360 electronicText = delegator.makeValue("ElectronicText", null); 361 electronicText.put("dataResourceId", dataResourceId); 362 electronicText.put("textData", textData); 363 electronicText.create(); 364 } 365 } catch (GenericEntityException e) { 366 Debug.logWarning(e, module); 367 return ServiceUtil.returnError("electronicText.update.read_failure" + e.getMessage()); 368 } 369 370 return result; 371 } 372 373 376 public static Map updateFile(DispatchContext dctx, Map context) { 377 Map result = null; 378 try { 379 result = updateFileMethod(dctx, context); 380 } catch (GenericServiceException e) { 381 return ServiceUtil.returnError(e.getMessage()); 382 } 383 return result; 384 } 385 386 public static Map updateFileMethod(DispatchContext dctx, Map context) throws GenericServiceException { 387 HashMap result = new HashMap (); 388 GenericDelegator delegator = dctx.getDelegator(); 389 LocalDispatcher dispatcher = dctx.getDispatcher(); 390 String dataResourceTypeId = (String ) context.get("dataResourceTypeId"); 394 String objectInfo = (String ) context.get("objectInfo"); 395 String textData = (String ) context.get("textData"); 396 ByteWrapper binData = (ByteWrapper) context.get("binData"); 397 String prefix = ""; 398 File file = null; 399 String fileName = ""; 400 String sep = ""; 401 try { 402 if (UtilValidate.isEmpty(dataResourceTypeId) || dataResourceTypeId.equals("LOCAL_FILE")) { 403 fileName = prefix + sep + objectInfo; 404 file = new File (fileName); 405 if (file == null) { 406 throw new GenericServiceException("File: " + fileName + " is null."); 407 } 408 if (!file.isAbsolute()) { 409 throw new GenericServiceException("File: " + fileName + " is not absolute."); 410 } 411 } else if (dataResourceTypeId.equals("OFBIZ_FILE")) { 412 prefix = System.getProperty("ofbiz.home"); 413 if (objectInfo.indexOf("/") != 0 && prefix.lastIndexOf("/") != (prefix.length() - 1)) { 414 sep = "/"; 415 } 416 file = new File (prefix + sep + objectInfo); 417 } else if (dataResourceTypeId.equals("CONTEXT_FILE")) { 418 prefix = (String ) context.get("rootDir"); 419 if (objectInfo.indexOf("/") != 0 && prefix.lastIndexOf("/") != (prefix.length() - 1)) { 420 sep = "/"; 421 } 422 file = new File (prefix + sep + objectInfo); 423 } 424 if (file == null) { 425 throw new IOException ("File: " + file + " is null"); 426 } 427 428 if (UtilValidate.isNotEmpty(textData)) { 430 try { 431 FileWriter out = new FileWriter (file); 432 out.write(textData); 433 out.close(); 434 } catch (IOException e) { 435 Debug.logWarning(e, module); 436 return ServiceUtil.returnError("Unable to write character data to: " + file.getAbsolutePath()); 437 } 438 } else if (binData != null) { 439 try { 440 RandomAccessFile out = new RandomAccessFile (file, "rw"); 441 out.write(binData.getBytes()); 442 out.close(); 443 } catch (FileNotFoundException e) { 444 Debug.logError(e, module); 445 return ServiceUtil.returnError("Unable to open file for writing: " + file.getAbsolutePath()); 446 } catch (IOException e) { 447 Debug.logError(e, module); 448 return ServiceUtil.returnError("Unable to write binary data to: " + file.getAbsolutePath()); 449 } 450 } else { 451 return ServiceUtil.returnError("No file content passed for: " + file.getAbsolutePath()); 452 } 453 454 } catch (IOException e) { 455 Debug.logWarning(e, module); 456 throw new GenericServiceException(e.getMessage()); 457 } 458 459 return result; 460 } 461 462 public static Map renderDataResourceAsText(DispatchContext dctx, Map context) throws GeneralException, IOException { 463 Map results = new HashMap (); 464 GenericDelegator delegator = dctx.getDelegator(); 465 Writer out = (Writer ) context.get("outWriter"); 467 Map templateContext = (Map ) context.get("templateContext"); 468 String dataResourceId = (String ) context.get("dataResourceId"); 470 if (templateContext != null && UtilValidate.isEmpty(dataResourceId)) { 471 dataResourceId = (String ) templateContext.get("dataResourceId"); 472 } 473 String mimeTypeId = (String ) context.get("mimeTypeId"); 474 if (templateContext != null && UtilValidate.isEmpty(mimeTypeId)) { 475 mimeTypeId = (String ) templateContext.get("mimeTypeId"); 476 } 477 478 Locale locale = (Locale ) context.get("locale"); 479 480 if (templateContext == null) { 481 templateContext = new HashMap (); 482 } 483 484 GenericValue view = (GenericValue) context.get("subContentDataResourceView"); 485 Writer outWriter = new StringWriter (); 486 DataResourceWorker.renderDataResourceAsTextCache(delegator, dataResourceId, outWriter, templateContext, view, locale, mimeTypeId); 487 try { 488 out.write(outWriter.toString()); 489 results.put("textData", outWriter.toString()); 490 } catch (IOException e) { 491 Debug.logError(e, "Error rendering sub-content text", module); 492 return ServiceUtil.returnError(e.toString()); 493 } 494 return results; 495 } 496 497 500 public static Map updateImage(DispatchContext dctx, Map context) { 501 Map result = updateImageMethod(dctx, context); 502 return result; 503 } 504 505 public static Map updateImageMethod(DispatchContext dctx, Map context) { 506 HashMap result = new HashMap (); 507 GenericDelegator delegator = dctx.getDelegator(); 508 LocalDispatcher dispatcher = dctx.getDispatcher(); 509 GenericValue image = null; 510 String dataResourceId = (String ) context.get("dataResourceId"); 512 ByteWrapper byteWrapper = (ByteWrapper)context.get("imageData"); 513 if (byteWrapper != null) { 514 byte[] imageBytes = byteWrapper.getBytes(); 515 try { 516 GenericValue imageDataResource = delegator.findByPrimaryKey("ImageDataResource", UtilMisc.toMap("dataResourceId", dataResourceId)); 517 if (Debug.infoOn()) Debug.logInfo("imageDataResource(U):" + imageDataResource, module); 518 if (Debug.infoOn()) Debug.logInfo("imageBytes(U):" + imageBytes, module); 519 if (imageDataResource == null) { 520 return createImageMethod(dctx, context); 521 } else { 522 imageDataResource.setBytes("imageData", imageBytes); 523 imageDataResource.store(); 524 } 525 } catch (GenericEntityException e) { 526 return ServiceUtil.returnError(e.getMessage()); 527 } 528 } 529 530 return result; 531 } 532 533 536 public static Map createImage(DispatchContext dctx, Map context) { 537 Map result = createImageMethod(dctx, context); 538 return result; 539 } 540 541 public static Map createImageMethod(DispatchContext dctx, Map context) { 542 HashMap result = new HashMap (); 543 GenericDelegator delegator = dctx.getDelegator(); 544 LocalDispatcher dispatcher = dctx.getDispatcher(); 545 String dataResourceId = (String ) context.get("dataResourceId"); 546 ByteWrapper byteWrapper = (ByteWrapper)context.get("imageData"); 547 if (byteWrapper != null) { 548 byte[] imageBytes = byteWrapper.getBytes(); 549 try { 550 GenericValue imageDataResource = delegator.makeValue("ImageDataResource", UtilMisc.toMap("dataResourceId", dataResourceId)); 551 imageDataResource.setBytes("imageData", imageBytes); 553 if (Debug.infoOn()) Debug.logInfo("imageDataResource(C):" + imageDataResource, module); 554 imageDataResource.create(); 555 } catch (GenericEntityException e) { 556 return ServiceUtil.returnError(e.getMessage()); 557 } 558 } 559 560 return result; 561 } 562 563 566 public static Map createBinaryFile(DispatchContext dctx, Map context) { 567 Map result = null; 568 try { 569 result = createBinaryFileMethod(dctx, context); 570 } catch (GenericServiceException e) { 571 return ServiceUtil.returnError(e.getMessage()); 572 } 573 return result; 574 } 575 576 public static Map createBinaryFileMethod(DispatchContext dctx, Map context) throws GenericServiceException { 577 HashMap result = new HashMap (); 578 GenericDelegator delegator = dctx.getDelegator(); 579 LocalDispatcher dispatcher = dctx.getDispatcher(); 580 GenericValue dataResource = (GenericValue) context.get("dataResource"); 581 String dataResourceTypeId = (String ) dataResource.get("dataResourceTypeId"); 583 String objectInfo = (String ) dataResource.get("objectInfo"); 584 byte [] imageData = (byte []) context.get("imageData"); 585 String rootDir = (String )context.get("rootDir"); 586 String prefix = ""; 587 File file = null; 588 if (Debug.infoOn()) Debug.logInfo("in createBinaryFileMethod, dataResourceTypeId:" + dataResourceTypeId, module); 589 if (Debug.infoOn()) Debug.logInfo("in createBinaryFileMethod, objectInfo:" + objectInfo, module); 590 if (Debug.infoOn()) Debug.logInfo("in createBinaryFileMethod, rootDir:" + rootDir, module); 591 try { 592 file = DataResourceWorker.getContentFile(dataResourceTypeId, objectInfo, rootDir); 593 } catch (FileNotFoundException e) { 594 Debug.logWarning(e, module); 595 throw new GenericServiceException(e.getMessage()); 596 } catch (GeneralException e2) { 597 Debug.logWarning(e2, module); 598 throw new GenericServiceException(e2.getMessage()); 599 } 600 if (Debug.infoOn()) Debug.logInfo("in createBinaryFileMethod, file:" + file, module); 601 if (Debug.infoOn()) Debug.logInfo("in createBinaryFileMethod, imageData:" + imageData.length, module); 602 if (imageData != null && imageData.length > 0) { 603 try { 604 FileOutputStream out = new FileOutputStream (file); 605 out.write(imageData); 606 if (Debug.infoOn()) Debug.logInfo("in createBinaryFileMethod, length:" + file.length(), module); 607 out.close(); 608 } catch (IOException e) { 609 Debug.logWarning(e, module); 610 throw new GenericServiceException(e.getMessage()); 611 } 612 } 613 614 return result; 615 } 616 617 618 621 public static Map updateBinaryFile(DispatchContext dctx, Map context) { 622 Map result = null; 623 try { 624 result = updateBinaryFileMethod(dctx, context); 625 } catch (GenericServiceException e) { 626 return ServiceUtil.returnError(e.getMessage()); 627 } 628 return result; 629 } 630 631 public static Map updateBinaryFileMethod(DispatchContext dctx, Map context) throws GenericServiceException { 632 HashMap result = new HashMap (); 633 GenericDelegator delegator = dctx.getDelegator(); 634 LocalDispatcher dispatcher = dctx.getDispatcher(); 635 GenericValue dataResource = (GenericValue) context.get("dataResource"); 636 String dataResourceTypeId = (String ) dataResource.get("dataResourceTypeId"); 638 String objectInfo = (String ) dataResource.get("objectInfo"); 639 byte [] imageData = (byte []) context.get("imageData"); 640 String rootDir = (String )context.get("rootDir"); 641 String prefix = ""; 642 File file = null; 643 if (Debug.infoOn()) Debug.logInfo("in updateBinaryFileMethod, dataResourceTypeId:" + dataResourceTypeId, module); 644 if (Debug.infoOn()) Debug.logInfo("in updateBinaryFileMethod, objectInfo:" + objectInfo, module); 645 if (Debug.infoOn()) Debug.logInfo("in updateBinaryFileMethod, rootDir:" + rootDir, module); 646 try { 647 file = DataResourceWorker.getContentFile(dataResourceTypeId, objectInfo, rootDir); 648 } catch (FileNotFoundException e) { 649 Debug.logWarning(e, module); 650 throw new GenericServiceException(e.getMessage()); 651 } catch (GeneralException e2) { 652 Debug.logWarning(e2, module); 653 throw new GenericServiceException(e2.getMessage()); 654 } 655 if (Debug.infoOn()) Debug.logInfo("in updateBinaryFileMethod, file:" + file, module); 656 if (Debug.infoOn()) Debug.logInfo("in updateBinaryFileMethod, imageData:" + imageData, module); 657 if (imageData != null && imageData.length > 0) { 658 try { 659 FileOutputStream out = new FileOutputStream (file); 660 out.write(imageData); 661 if (Debug.infoOn()) Debug.logInfo("in updateBinaryFileMethod, length:" + file.length(), module); 662 out.close(); 663 } catch (IOException e) { 664 Debug.logWarning(e, module); 665 throw new GenericServiceException(e.getMessage()); 666 } 667 } 668 669 return result; 670 } 671 } 672 | Popular Tags |