List of usage examples for java.io IOException fillInStackTrace
public synchronized Throwable fillInStackTrace()
From source file:io.personium.core.bar.BarFileReadRunner.java
/** * bar???./*from ww w . j a va 2 s.c o m*/ */ public void run() { boolean isSuccess = true; String path = "/" + this.cell.getName() + "/" + boxName + "/"; log.debug("install target: " + path); try { List<String> doneKeys = new ArrayList<String>(); try { this.zipArchiveInputStream = new ZipArchiveInputStream(new FileInputStream(barFile)); } catch (IOException e) { throw PersoniumCoreException.Server.FILE_SYSTEM_ERROR.params(e.getMessage()); } // ("bar/")?? if (!isRootDir()) { String message = PersoniumCoreMessageUtils.getMessage("PL-BI-2001"); writeOutputStream(true, "PL-BI-1004", ROOT_DIR, message); isSuccess = false; return; } // 00_meta?? if (!isMetadataDir()) { String message = PersoniumCoreMessageUtils.getMessage("PL-BI-2001"); writeOutputStream(true, "PL-BI-1004", META_DIR, message); isSuccess = false; return; } // 00_meta??? ZipArchiveEntry zae = null; try { long maxBarEntryFileSize = getMaxBarEntryFileSize(); Set<String> keyList = barFileOrder.keySet(); while ((zae = this.zipArchiveInputStream.getNextZipEntry()) != null) { String entryName = zae.getName(); log.debug("Entry Name: " + entryName); log.debug("Entry Size: " + zae.getSize()); log.debug("Entry Compressed Size: " + zae.getCompressedSize()); if (!zae.isDirectory()) { this.progressInfo.addDelta(1L); } // bar?? isSuccess = createMetadata(zae, entryName, maxBarEntryFileSize, keyList, doneKeys); if (!isSuccess) { break; } // 90_contents?????? if (isContentsDir(zae)) { if (davCmpMap.isEmpty()) { writeOutputStream(true, "PL-BI-1004", zae.getName()); isSuccess = false; } else { writeOutputStream(false, "PL-BI-1003", zae.getName()); } doneKeys.add(zae.getName()); break; } } } catch (IOException ex) { isSuccess = false; log.info("IOException: " + ex.getMessage(), ex.fillInStackTrace()); } // 90_contents()??? if (isSuccess && isContentsDir(zae)) { isSuccess = createContents(); } // ?????????? // ??????? if (isSuccess) { Set<String> filenameList = barFileOrder.keySet(); for (String filename : filenameList) { Boolean isNecessary = barFileOrder.get(filename); if (isNecessary && !doneKeys.contains(filename)) { String message = PersoniumCoreMessageUtils.getMessage("PL-BI-2001"); writeOutputStream(true, "PL-BI-1004", filename, message); isSuccess = false; } } } } catch (Throwable ex) { isSuccess = false; String message = getErrorMessage(ex); log.info("Exception: " + message, ex.fillInStackTrace()); writeOutputStream(true, "PL-BI-1005", "", message); } finally { if (isSuccess) { writeOutputStream(false, CODE_BAR_INSTALL_COMPLETED, this.cell.getUrl() + boxName, ""); this.progressInfo.setStatus(ProgressInfo.STATUS.COMPLETED); } else { String message = PersoniumCoreMessageUtils.getMessage("PL-BI-2001"); writeOutputStream(false, CODE_BAR_INSTALL_FAILED, this.cell.getUrl() + boxName, message); this.progressInfo.setStatus(ProgressInfo.STATUS.FAILED); } this.progressInfo.setEndTime(); writeToProgressCache(true); IOUtils.closeQuietly(this.zipArchiveInputStream); if (this.barFile.exists() && !this.barFile.delete()) { log.warn("Failed to remove bar file. [" + this.barFile.getAbsolutePath() + "]."); } } }
From source file:com.fujitsu.dc.core.bar.BarFileReadRunner.java
/** * bar???.// ww w . ja va2 s. co m */ public void run() { boolean isSuccess = true; String path = "/" + this.cell.getName() + "/" + boxName + "/"; log.debug("install target: " + path); try { List<String> doneKeys = new ArrayList<String>(); try { this.zipArchiveInputStream = new ZipArchiveInputStream(new FileInputStream(barFile)); } catch (IOException e) { throw DcCoreException.Server.FILE_SYSTEM_ERROR.params(e.getMessage()); } // ("bar/")?? if (!isRootDir()) { String message = DcCoreMessageUtils.getMessage("PL-BI-2001"); writeOutputStream(true, "PL-BI-1004", ROOT_DIR, message); isSuccess = false; return; } // 00_meta?? if (!isMetadataDir()) { String message = DcCoreMessageUtils.getMessage("PL-BI-2001"); writeOutputStream(true, "PL-BI-1004", META_DIR, message); isSuccess = false; return; } // 00_meta??? ZipArchiveEntry zae = null; try { long maxBarEntryFileSize = getMaxBarEntryFileSize(); Set<String> keyList = barFileOrder.keySet(); while ((zae = this.zipArchiveInputStream.getNextZipEntry()) != null) { String entryName = zae.getName(); log.debug("Entry Name: " + entryName); log.debug("Entry Size: " + zae.getSize()); log.debug("Entry Compressed Size: " + zae.getCompressedSize()); if (!zae.isDirectory()) { this.progressInfo.addDelta(1L); } // bar?? isSuccess = createMetadata(zae, entryName, maxBarEntryFileSize, keyList, doneKeys); if (!isSuccess) { break; } // 90_contents?????? if (isContentsDir(zae)) { if (davCmpMap.isEmpty()) { writeOutputStream(true, "PL-BI-1004", zae.getName()); isSuccess = false; } else { writeOutputStream(false, "PL-BI-1003", zae.getName()); } doneKeys.add(zae.getName()); break; } } } catch (IOException ex) { isSuccess = false; log.info("IOException: " + ex.getMessage(), ex.fillInStackTrace()); } // 90_contents()??? if (isSuccess && isContentsDir(zae)) { isSuccess = createContents(); } // ?????????? // ??????? if (isSuccess) { Set<String> filenameList = barFileOrder.keySet(); for (String filename : filenameList) { Boolean isNecessary = barFileOrder.get(filename); if (isNecessary && !doneKeys.contains(filename)) { String message = DcCoreMessageUtils.getMessage("PL-BI-2001"); writeOutputStream(true, "PL-BI-1004", filename, message); isSuccess = false; } } } } catch (Throwable ex) { isSuccess = false; String message = getErrorMessage(ex); log.info("Exception: " + message, ex.fillInStackTrace()); writeOutputStream(true, "PL-BI-1005", "", message); } finally { if (isSuccess) { writeOutputStream(false, CODE_BAR_INSTALL_COMPLETED, this.cell.getUrl() + boxName, ""); this.progressInfo.setStatus(ProgressInfo.STATUS.COMPLETED); } else { String message = DcCoreMessageUtils.getMessage("PL-BI-2001"); writeOutputStream(false, CODE_BAR_INSTALL_FAILED, this.cell.getUrl() + boxName, message); this.progressInfo.setStatus(ProgressInfo.STATUS.FAILED); } this.progressInfo.setEndTime(); writeToProgressCache(true); IOUtils.closeQuietly(this.zipArchiveInputStream); if (this.barFile.exists() && !this.barFile.delete()) { log.warn("Failed to remove bar file. [" + this.barFile.getAbsolutePath() + "]."); } } }
From source file:io.personium.core.bar.BarFileReadRunner.java
/** * bar?(bar/90_contents)1????.//from w w w . j av a 2s.c o m * @return boolean ???? */ protected boolean createContents() { boolean isSuccess = true; // Collection???Map?????? Map<String, DavCmp> odataCols = getCollections(DavCmp.TYPE_COL_ODATA); Map<String, DavCmp> webdavCols = getCollections(DavCmp.TYPE_COL_WEBDAV); Map<String, DavCmp> serviceCols = getCollections(DavCmp.TYPE_COL_SVC); DavCmp davCmp = null; List<String> doneKeys = new ArrayList<String>(); try { ZipArchiveEntry zae = null; String currentPath = null; int userDataCount = 0; List<JSONMappedObject> userDataLinks = new ArrayList<JSONMappedObject>(); LinkedHashMap<String, BulkRequest> bulkRequests = new LinkedHashMap<String, BulkRequest>(); Map<String, String> fileNameMap = new HashMap<String, String>(); PersoniumODataProducer producer = null; while ((zae = this.zipArchiveInputStream.getNextZipEntry()) != null) { String entryName = zae.getName(); log.debug("Entry Name: " + entryName); log.debug("Entry Size: " + zae.getSize()); log.debug("Entry Compressed Size: " + zae.getCompressedSize()); if (!zae.isDirectory()) { this.progressInfo.addDelta(1L); } writeOutputStream(false, CODE_BAR_INSTALL_STARTED, entryName); // ODataCollection?Dav/ServiceCollection/ODataCollection????????? // ?????????? if (currentPath != null && !entryName.startsWith(currentPath)) { if (!execBulkRequest(davCmp.getCell().getId(), bulkRequests, fileNameMap, producer)) { return false; } if (!createUserdataLinks(producer, userDataLinks)) { return false; } userDataLinks = new ArrayList<JSONMappedObject>(); currentPath = null; } int entryType = getEntryType(entryName, odataCols, webdavCols, serviceCols, this.davFileMap); switch (entryType) { case TYPE_ODATA_COLLECTION: // OData? if (!odataCols.isEmpty()) { if (!isValidODataContents(entryName, odataCols, doneKeys)) { return false; } Pattern formatPattern = Pattern.compile(CONTENTS_DIR + ".+/90_data/"); Matcher formatMatcher = formatPattern.matcher(entryName); if (formatMatcher.matches()) { currentPath = entryName; } Pattern userodataDirPattern = Pattern.compile(CONTENTS_DIR + ".+/90_data/.+"); Matcher userodataDirMatcher = userodataDirPattern.matcher(entryName); if (getFileExtension(entryName).equals(".xml")) { // 00_$metadata.xml?? davCmp = getCollection(entryName, odataCols); // OData???????? producer = davCmp.getODataProducer(); if (!registUserSchema(entryName, this.zipArchiveInputStream, davCmp)) { doneKeys.add(entryName); return false; } writeOutputStream(false, "PL-BI-1003", entryName); doneKeys.add(entryName); continue; } else if (entryName.endsWith(USERDATA_LINKS_JSON)) { userDataLinks = registJsonLinksUserdata(entryName, this.zipArchiveInputStream); if (userDataLinks == null) { doneKeys.add(entryName); return false; } writeOutputStream(false, "PL-BI-1003", entryName); doneKeys.add(entryName); continue; } else if (userodataDirMatcher.matches() && getFileExtension(entryName).equals(".json")) { userDataCount++; if (!setBulkRequests(entryName, producer, bulkRequests, fileNameMap)) { return false; } doneKeys.add(entryName); if ((userDataCount % bulkSize) == 0 && !execBulkRequest(davCmp.getCell().getId(), bulkRequests, fileNameMap, producer)) { return false; } continue; } else if (!entryName.endsWith("/")) { // xml,json????????? String message = PersoniumCoreMessageUtils.getMessage("PL-BI-2001"); log.info(message + " [" + entryName + "]"); writeOutputStream(true, "PL-BI-1004", entryName, message); return false; } } break; case TYPE_DAV_FILE: // WebDAV? // bar/90_contents/{davcol_name}??1???? if (!registWebDavFile(entryName, this.zipArchiveInputStream, webdavCols)) { return false; } break; case TYPE_SVC_FILE: // Service? if (!installSvcCollection(webdavCols, entryName)) { return false; } break; case TYPE_MISMATCH: // OData??????????rootprops?????? String message = PersoniumCoreMessageUtils.getMessage("PL-BI-2006"); log.info(message + " [" + entryName + "]"); writeOutputStream(true, "PL-BI-1004", entryName, message); return false; default: break; } writeOutputStream(false, "PL-BI-1003", entryName); doneKeys.add(entryName); } // ODataCollection?????????????????? if (currentPath != null) { if (!execBulkRequest(davCmp.getCell().getId(), bulkRequests, fileNameMap, producer)) { return false; } if (!createUserdataLinks(producer, userDataLinks)) { return false; } userDataLinks = null; } } catch (IOException ex) { isSuccess = false; log.info("IOException: " + ex.getMessage(), ex.fillInStackTrace()); String message = PersoniumCoreMessageUtils.getMessage("PL-BI-2000"); writeOutputStream(true, CODE_BAR_INSTALL_FAILED, "", message); } // bar/90_contents/{odatacol_name}/00_$metadata.xml)?? isSuccess = checkNecessaryFile(isSuccess, odataCols, doneKeys); return isSuccess; }
From source file:com.fujitsu.dc.core.bar.BarFileReadRunner.java
/** * bar?(bar/90_contents)1????./*from w ww.jav a 2 s . com*/ * @return boolean ???? */ protected boolean createContents() { boolean isSuccess = true; // Collection???Map?????? Map<String, DavCmpEsImpl> odataCols = getCollections(DavCmp.TYPE_COL_ODATA); Map<String, DavCmpEsImpl> webdavCols = getCollections(DavCmp.TYPE_COL_WEBDAV); Map<String, DavCmpEsImpl> serviceCols = getCollections(DavCmp.TYPE_COL_SVC); DavCmpEsImpl davCmp = null; List<String> doneKeys = new ArrayList<String>(); try { ZipArchiveEntry zae = null; String currentPath = null; int userDataCount = 0; List<JSONMappedObject> userDataLinks = new ArrayList<JSONMappedObject>(); LinkedHashMap<String, BulkRequest> bulkRequests = new LinkedHashMap<String, BulkRequest>(); Map<String, String> fileNameMap = new HashMap<String, String>(); DcODataProducer producer = null; while ((zae = this.zipArchiveInputStream.getNextZipEntry()) != null) { String entryName = zae.getName(); log.debug("Entry Name: " + entryName); log.debug("Entry Size: " + zae.getSize()); log.debug("Entry Compressed Size: " + zae.getCompressedSize()); if (!zae.isDirectory()) { this.progressInfo.addDelta(1L); } writeOutputStream(false, CODE_BAR_INSTALL_STARTED, entryName); // ODataCollection?Dav/ServiceCollection/ODataCollection????????? // ?????????? if (currentPath != null && !entryName.startsWith(currentPath)) { if (!execBulkRequest(davCmp.getCellId(), bulkRequests, fileNameMap, producer)) { return false; } if (!createUserdataLinks(producer, userDataLinks)) { return false; } userDataLinks = new ArrayList<JSONMappedObject>(); currentPath = null; } int entryType = getEntryType(entryName, odataCols, webdavCols, serviceCols, this.davFileMap); switch (entryType) { case TYPE_ODATA_COLLECTION: // OData? if (!odataCols.isEmpty()) { if (!isValidODataContents(entryName, odataCols, doneKeys)) { return false; } Pattern formatPattern = Pattern.compile(CONTENTS_DIR + ".+/90_data/"); Matcher formatMatcher = formatPattern.matcher(entryName); if (formatMatcher.matches()) { currentPath = entryName; } Pattern userodataDirPattern = Pattern.compile(CONTENTS_DIR + ".+/90_data/.+"); Matcher userodataDirMatcher = userodataDirPattern.matcher(entryName); if (getFileExtension(entryName).equals(".xml")) { // 00_$metadata.xml?? davCmp = getCollection(entryName, odataCols); // OData???????? producer = davCmp.getODataProducer(); if (!registUserSchema(entryName, this.zipArchiveInputStream, davCmp)) { doneKeys.add(entryName); return false; } writeOutputStream(false, "PL-BI-1003", entryName); doneKeys.add(entryName); continue; } else if (entryName.endsWith(USERDATA_LINKS_JSON)) { userDataLinks = registJsonLinksUserdata(entryName, this.zipArchiveInputStream); if (userDataLinks == null) { doneKeys.add(entryName); return false; } writeOutputStream(false, "PL-BI-1003", entryName); doneKeys.add(entryName); continue; } else if (userodataDirMatcher.matches() && getFileExtension(entryName).equals(".json")) { userDataCount++; if (!setBulkRequests(entryName, producer, bulkRequests, fileNameMap)) { return false; } doneKeys.add(entryName); if ((userDataCount % bulkSize) == 0 && !execBulkRequest(davCmp.getCellId(), bulkRequests, fileNameMap, producer)) { return false; } continue; } else if (!entryName.endsWith("/")) { // xml,json????????? String message = DcCoreMessageUtils.getMessage("PL-BI-2001"); log.info(message + " [" + entryName + "]"); writeOutputStream(true, "PL-BI-1004", entryName, message); return false; } } break; case TYPE_DAV_FILE: // WebDAV? // bar/90_contents/{davcol_name}??1???? if (!registWebDavFile(entryName, this.zipArchiveInputStream, webdavCols)) { return false; } break; case TYPE_SVC_FILE: // Service? if (!installSvcCollection(webdavCols, entryName)) { return false; } break; case TYPE_MISMATCH: // OData??????????rootprops?????? String message = DcCoreMessageUtils.getMessage("PL-BI-2006"); log.info(message + " [" + entryName + "]"); writeOutputStream(true, "PL-BI-1004", entryName, message); return false; default: break; } writeOutputStream(false, "PL-BI-1003", entryName); doneKeys.add(entryName); } // ODataCollection?????????????????? if (currentPath != null) { if (!execBulkRequest(davCmp.getCellId(), bulkRequests, fileNameMap, producer)) { return false; } if (!createUserdataLinks(producer, userDataLinks)) { return false; } userDataLinks = null; } } catch (IOException ex) { isSuccess = false; log.info("IOException: " + ex.getMessage(), ex.fillInStackTrace()); String message = DcCoreMessageUtils.getMessage("PL-BI-2000"); writeOutputStream(true, CODE_BAR_INSTALL_FAILED, "", message); } // bar/90_contents/{odatacol_name}/00_$metadata.xml)?? isSuccess = checkNecessaryFile(isSuccess, odataCols, doneKeys); return isSuccess; }
From source file:org.jbpm.executor.impl.AvailableJobsExecutor.java
@SuppressWarnings("unchecked") public void executeJob() { logger.debug("Executor Thread {} Waking Up!!!", this.toString()); try {/* w w w. j av a 2 s . c om*/ RequestInfo request = (RequestInfo) queryService.getRequestForProcessing(); if (request != null) { boolean processReoccurring = false; Command cmd = null; CommandContext ctx = null; List<CommandCallback> callbacks = null; ClassLoader cl = getClassLoader(request.getDeploymentId()); try { logger.debug("Processing Request Id: {}, status {} command {}", request.getId(), request.getStatus(), request.getCommandName()); byte[] reqData = request.getRequestData(); if (reqData != null) { ObjectInputStream in = null; try { in = new ClassLoaderObjectInputStream(cl, new ByteArrayInputStream(reqData)); ctx = (CommandContext) in.readObject(); } catch (IOException e) { logger.warn("Exception while serializing context data", e); return; } finally { if (in != null) { in.close(); } } } for (Map.Entry<String, Object> entry : contextData.entrySet()) { ctx.setData(entry.getKey(), entry.getValue()); } // add class loader so internally classes can be created with valid (kjar) deployment ctx.setData("ClassLoader", cl); cmd = classCacheManager.findCommand(request.getCommandName(), cl); ExecutionResults results = cmd.execute(ctx); callbacks = classCacheManager.buildCommandCallback(ctx, cl); for (CommandCallback handler : callbacks) { handler.onCommandDone(ctx, results); } if (results != null) { try { ByteArrayOutputStream bout = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(bout); out.writeObject(results); byte[] respData = bout.toByteArray(); request.setResponseData(respData); } catch (IOException e) { request.setResponseData(null); } } request.setStatus(STATUS.DONE); executorStoreService.updateRequest(request); processReoccurring = true; } catch (InterruptedException e) { Thread.currentThread().interrupt(); } catch (Throwable e) { callbacks = classCacheManager.buildCommandCallback(ctx, cl); logger.warn("Error during command {} execution {}", request.getCommandName(), e.getMessage()); ErrorInfo errorInfo = new ErrorInfo(e.getMessage(), ExceptionUtils.getFullStackTrace(e.fillInStackTrace())); errorInfo.setRequestInfo(request); ((List<ErrorInfo>) request.getErrorInfo()).add(errorInfo); logger.debug("Error Number: {}", request.getErrorInfo().size()); if (request.getRetries() > 0) { request.setStatus(STATUS.RETRYING); request.setRetries(request.getRetries() - 1); request.setExecutions(request.getExecutions() + 1); logger.debug("Retrying ({}) still available!", request.getRetries()); executorStoreService.updateRequest(request); } else { logger.debug("Error no retries left!"); request.setStatus(STATUS.ERROR); request.setExecutions(request.getExecutions() + 1); executorStoreService.updateRequest(request); if (callbacks != null) { for (CommandCallback handler : callbacks) { handler.onCommandError(ctx, e); } } processReoccurring = true; } } finally { if (processReoccurring && cmd != null && cmd instanceof Reoccurring) { Date current = new Date(); Date nextScheduleTime = ((Reoccurring) cmd).getScheduleTime(); if (nextScheduleTime != null && nextScheduleTime.after(current)) { String businessKey = (String) ctx.getData("businessKey"); RequestInfo requestInfo = new RequestInfo(); requestInfo.setCommandName(cmd.getClass().getName()); requestInfo.setKey(businessKey); requestInfo.setStatus(STATUS.QUEUED); requestInfo.setTime(nextScheduleTime); requestInfo.setMessage("Rescheduled reoccurring job"); requestInfo.setDeploymentId((String) ctx.getData("deploymentId")); requestInfo.setOwner((String) ctx.getData("owner")); if (ctx.getData("retries") != null) { requestInfo.setRetries(Integer.valueOf(String.valueOf(ctx.getData("retries")))); } else { requestInfo.setRetries(retries); } if (ctx != null) { try { // remove transient data ctx.getData().remove("ClassLoader"); ByteArrayOutputStream bout = new ByteArrayOutputStream(); ObjectOutputStream oout = new ObjectOutputStream(bout); oout.writeObject(ctx); requestInfo.setRequestData(bout.toByteArray()); } catch (IOException e) { logger.warn("Error serializing context data", e); requestInfo.setRequestData(null); } } executorStoreService.persistRequest(requestInfo); } } } } } catch (Exception e) { logger.warn("Unexpected error while processin executor's job {}", e.getMessage(), e); } }