List of usage examples for java.lang Exception fillInStackTrace
public synchronized Throwable fillInStackTrace()
From source file:org.asqatasun.runner.Asqatasun.java
@Override public void auditCrashed(Audit audit, Exception exception) { exception.printStackTrace();/* w ww. ja v a2 s. co m*/ System.out.println("crash (id+message): " + audit.getId() + " " + exception.fillInStackTrace()); }
From source file:com.sebuilder.interpreter.TestRun.java
/** * Executes the next step.// www . j a va 2s. c om * @return True on success. */ public boolean next() { if (stepIndex == -1) { log.debug("Starting test run."); } initRemoteWebDriver(); log.debug("Running step " + (stepIndex + 2) + ": " + script.steps.get(stepIndex + 1).toPrettyString()); boolean result = false; try { result = script.steps.get(++stepIndex).type.run(this); } catch (Exception e) { throw new RuntimeException(currentStep() + " failed.", e); } if (!result) { // If a verify failed, we just note this but continue. if (currentStep().type instanceof Verify) { log.error(currentStep() + " failed."); return false; } // In all other cases, we throw an exception to stop the run. RuntimeException e = new RuntimeException(currentStep() + " failed."); e.fillInStackTrace(); log.fatal(e); throw e; } else { return true; } }
From source file:com.microsoft.tfs.client.eclipse.filemodification.TFSFileModificationValidator.java
public IStatus validateEdit(final IFile[] files, final boolean attemptUi, final Object shell) { final ResourceDataManager resourceDataManager = TFSEclipseClientPlugin.getDefault() .getResourceDataManager();/* w w w. j a v a 2 s . c o m*/ final TFSRepository repository = repositoryProvider.getRepository(); if (repositoryProvider.getRepositoryStatus() == ProjectRepositoryStatus.CONNECTING) { getStatusReporter(attemptUi, shell).reportError( Messages.getString("TFSFileModificationValidator.ErrorConnectionInProgress"), //$NON-NLS-1$ new Status(IStatus.ERROR, TFSEclipseClientPlugin.PLUGIN_ID, 0, Messages.getString("TFSFileModificationValidator.ErrorConnectionInProgressDescription"), //$NON-NLS-1$ null)); return Status.CANCEL_STATUS; } /* * Offline server workspace. Simply mark files as writable and continue. */ if (repository == null) { for (int i = 0; i < files.length; i++) { log.info( MessageFormat.format("Setting {0} writable, project is offline from TFS server", files[i])); //$NON-NLS-1$ files[i].setReadOnly(false); } return Status.OK_STATUS; } /* * Local workspace: ignore this entirely. This method is only called for * read-only files. A read only file in a local workspace was not placed * by us and we should not set them writable. */ if (WorkspaceLocation.LOCAL.equals(repository.getWorkspace().getLocation())) { for (int i = 0; i < files.length; i++) { log.info(MessageFormat.format("Ignoring read-only file {0} in local TFS workspace", files[i])); //$NON-NLS-1$ } return Status.OK_STATUS; } /* * HACK: avoid "phantom pending changes" that arise from the undo * manager. If we have no undoable context (ie, no Shell), then check to * see if we're being called from the undo manager and simply defer this * operation. * * This bug is hard to reproduce, so details are thus far limited. The * best guess is that the Eclipse undo manager watches edits using a * resource changed listener (for post-change and post-build * notifications.) It then realizes that the current contents of a file * are identical to a previous undo state, and therefore needs to * resynchronize the file history. It then, for some reason, calls * validateEdit on that file. This causes the file to be checked out * (here.) */ if (attemptUi == false && shell == null) { /* * Since this is a terrible hack, we may need to have users disable * this functionality with a sysprop. */ if ("false".equalsIgnoreCase(System.getProperty(IGNORE_UNDO_MANAGER_PROPERTY_NAME)) == false) //$NON-NLS-1$ { /* Build an exception to get our stack trace. */ final Exception e = new Exception(""); //$NON-NLS-1$ e.fillInStackTrace(); final StackTraceElement[] stackTrace = e.getStackTrace(); if (stackTrace != null) { for (int i = 0; i < stackTrace.length; i++) { if (stackTrace[i].getClassName() .equals("org.eclipse.ui.internal.ide.undo.WorkspaceUndoMonitor")) //$NON-NLS-1$ { log.info("Ignoring file modification request from WorkspaceUndoMonitor"); //$NON-NLS-1$ return Status.OK_STATUS; } } } } } /* Pend edits for these files. */ final List<String> pathList = new ArrayList<String>(); final Set<String> projectSet = new HashSet<String>(); for (int i = 0; i < files.length; i++) { if (IGNORED_RESOURCES_FILTER.filter(files[i]) == ResourceFilterResult.REJECT) { log.info(MessageFormat.format("Setting {0} writable, file matches automatic validation filter", //$NON-NLS-1$ files[i])); files[i].setReadOnly(false); continue; } /* Make sure that this file exists on the server. */ if (!resourceDataManager.hasResourceData(files[i]) && resourceDataManager.hasCompletedRefresh(files[i].getProject())) { continue; } final String path = Resources.getLocation(files[i], LocationUnavailablePolicy.IGNORE_RESOURCE); final String serverPath = repository.getWorkspace().getMappedServerPath(path); if (path == null) { continue; } final PendingChange pendingChange = repository.getPendingChangeCache() .getPendingChangeByLocalPath(path); /* Don't pend changes when there's already an add or edit pended. */ if (pendingChange != null && (pendingChange.getChangeType().contains(ChangeType.ADD) || pendingChange.getChangeType().contains(ChangeType.EDIT))) { log.debug(MessageFormat.format("File {0} has pending change {1}, ignoring", //$NON-NLS-1$ files[i], pendingChange.getChangeType().toUIString(true, pendingChange))); continue; } pathList.add(path); log.info(MessageFormat.format("File {0} is being modified, checking out", files[i])); //$NON-NLS-1$ if (serverPath != null) { projectSet.add(ServerPath.getTeamProject(serverPath)); } } if (pathList.size() == 0) { return Status.OK_STATUS; } LockLevel forcedLockLevel = null; boolean forcedGetLatest = false; /* * Query the server's default checkout lock and get latest on checkout * setting */ for (final Iterator<String> i = projectSet.iterator(); i.hasNext();) { final String teamProject = i.next(); final String exclusiveCheckoutAnnotation = repository.getAnnotationCache() .getAnnotationValue(VersionControlConstants.EXCLUSIVE_CHECKOUT_ANNOTATION, teamProject, 0); final String getLatestAnnotation = repository.getAnnotationCache() .getAnnotationValue(VersionControlConstants.GET_LATEST_ON_CHECKOUT_ANNOTATION, teamProject, 0); if ("true".equalsIgnoreCase(exclusiveCheckoutAnnotation)) //$NON-NLS-1$ { forcedLockLevel = LockLevel.CHECKOUT; break; } /* Server get latest on checkout forces us to work synchronously */ if ("true".equalsIgnoreCase(getLatestAnnotation)) //$NON-NLS-1$ { forcedGetLatest = true; } } /* Allow UI hooks to handle prompt before checkout. */ final TFSFileModificationOptions checkoutOptions = getOptions(attemptUi, shell, pathList.toArray(new String[pathList.size()]), forcedLockLevel); if (!checkoutOptions.getStatus().isOK()) { return checkoutOptions.getStatus(); } final String[] paths = checkoutOptions.getFiles(); final LockLevel lockLevel = checkoutOptions.getLockLevel(); final boolean getLatest = checkoutOptions.isGetLatest(); final boolean synchronousCheckout = checkoutOptions.isSynchronous(); final boolean foregroundCheckout = checkoutOptions.isForeground(); if (paths.length == 0) { return Status.OK_STATUS; } final ItemSpec[] itemSpecs = new ItemSpec[paths.length]; for (int i = 0; i < paths.length; i++) { itemSpecs[i] = new ItemSpec(paths[i], RecursionType.NONE); } /* * Query get latest on checkout preference (and ensure server supports * the feature) */ GetOptions getOptions = GetOptions.NO_DISK_UPDATE; PendChangesOptions pendChangesOptions = PendChangesOptions.NONE; if (repository.getWorkspace().getClient().getServerSupportedFeatures() .contains(SupportedFeatures.GET_LATEST_ON_CHECKOUT) && getLatest) { /* * If we're doing get latest on checkout, we need add the overwrite * flag: we need to set the file writable before this method exits * (in order for Eclipse to pick up the change, but we need to do * the get in another thread (so that we can clear the resource lock * on this file.) Thus we need to set the file writable, then fire a * synchronous worker to overwrite it. This is safe as this method * will ONLY be called when the file is readonly. */ pendChangesOptions = PendChangesOptions.GET_LATEST_ON_CHECKOUT; getOptions = GetOptions.NONE; } /* * Build the checkout command - no need to query conflicts here, the * only conflicts that can arise from a pend edit are writable file * conflicts (when get latest on checkout is true.) This method is never * called for writable files. */ final EditCommand editCommand = new EditCommand(repository, itemSpecs, lockLevel, null, getOptions, pendChangesOptions, false); /* * Pend changes in the foreground if get latest on checkout is * requested. A disk update may be required, so we want to block user * input. */ if (synchronousCheckout || pendChangesOptions.contains(PendChangesOptions.GET_LATEST_ON_CHECKOUT) || forcedGetLatest) { /* * Wrap this edit command in one that disables the plugin's * automatic resource refresh behavior. This is required to avoid * deadlocks: the calling thread has taken a resource lock on the * resource it wishes to check out - the plugin will also require a * resource lock to do the refresh in another thread. */ final ICommand wrappedEditCommand = new IgnoreResourceRefreshesEditCommand(editCommand); final IStatus editStatus = getSynchronousCommandExecutor(attemptUi, shell).execute(wrappedEditCommand); /* Refresh files on this thread, since it has the resource lock. */ for (int i = 0; i < files.length; i++) { try { files[i].refreshLocal(IResource.DEPTH_ZERO, new NullProgressMonitor()); } catch (final Throwable e) { log.warn(MessageFormat.format("Could not refresh {0}", files[i].getName()), e); //$NON-NLS-1$ } } return editStatus; } /* Pend changes in the background */ else { synchronized (backgroundFiles) { for (int i = 0; i < files.length; i++) { files[i].setReadOnly(false); backgroundFiles.put(files[i], new TFSFileModificationStatusData(files[i])); } } final JobCommandAdapter editJob = new JobCommandAdapter(editCommand); editJob.setPriority(Job.INTERACTIVE); editJob.setUser(foregroundCheckout); editJob.schedule(); final Thread editThread = new Thread(new Runnable() { @Override public void run() { IStatus editStatus; try { /* * We don't need to safe-wait with * ExtensionPointAsyncObjectWaiter because we're * guaranteed not on the UI thread. */ editJob.join(); editStatus = editJob.getResult(); } catch (final Exception e) { editStatus = new Status(IStatus.ERROR, TFSEclipseClientPlugin.PLUGIN_ID, 0, null, e); } if (editStatus.isOK()) { synchronized (backgroundFiles) { for (int i = 0; i < files.length; i++) { final TFSFileModificationStatusData statusData = backgroundFiles.remove(files[i]); if (statusData != null) { log.info(MessageFormat.format("File {0} checked out in {1} seconds", //$NON-NLS-1$ files[i], (int) ((System.currentTimeMillis() - statusData.getStartTime()) / 1000))); } } } } else { final List<TFSFileModificationStatusData> statusDataList = new ArrayList<TFSFileModificationStatusData>(); synchronized (backgroundFiles) { for (int i = 0; i < files.length; i++) { final TFSFileModificationStatusData statusData = backgroundFiles.remove(files[i]); if (statusData != null) { log.info(MessageFormat.format("File {0} failed to check out in {1} seconds", //$NON-NLS-1$ files[i], (int) ((System.currentTimeMillis() - statusData.getStartTime()) / 1000))); statusDataList.add(statusData); } } } /* * Unfortunately, we have to roll back ALL FILES when an * edit fails. We could (in theory) be better about this * and use the non fatal listener in EditCommand to give * us the paths that failed, but at the moment, the use * case is only for one file at a time, so this is okay. */ final TFSFileModificationStatusData[] statusData = statusDataList .toArray(new TFSFileModificationStatusData[statusDataList.size()]); getStatusReporter(attemptUi, shell).reportStatus(repository, statusData, editStatus); } } }); editThread.start(); return Status.OK_STATUS; } }
From source file:org.asqatasun.sebuilder.interpreter.TgTestRun.java
/** * Executes the next step./*from w w w . j a v a 2s .c o m*/ * * @return True on success. */ @Override public boolean next() { if (stepIndex == -1) { getLog().debug("Starting test run."); } initRemoteWebDriver(); isStepOpenNewPage = false; getLog().debug("Running step " + (stepIndex + 2) + ":" + getScript().steps.get(stepIndex + 1).type.toString() + " step."); boolean result = false; String previousUrl = null; try { previousUrl = getDriver().getCurrentUrl(); result = getScript().steps.get(++stepIndex).type.run(this); // wait a second to make sure the page is fully loaded Thread.sleep(500); if (!isStepOpenNewPage && !StringUtils.equals(previousUrl, getDriver().getCurrentUrl())) { fireNewPage(); } } catch (TimeoutException te) { result = true; if (!isStepOpenNewPage && !StringUtils.equals(previousUrl, getDriver().getCurrentUrl())) { getLog().debug(" The page " + getDriver().getCurrentUrl() + " is fired as new page but" + " is incomplete : " + te.getMessage()); fireNewPage(); } } catch (UnhandledAlertException uae) { getLog().warn(uae.getMessage()); properlyCloseWebDriver(); throw new TestRunException(currentStep() + " failed.", uae, currentStep().toString(), stepIndex); } catch (Exception e) { getLog().warn(e.getCause()); getLog().warn(e.getMessage()); properlyCloseWebDriver(); throw new TestRunException(currentStep() + " failed.", e, currentStep().toString(), stepIndex); } if (!result) { // If a verify failed, we just note this but continue. if (currentStep().type instanceof Verify) { getLog().error(currentStep() + " failed."); return false; } // In all other cases, we throw an exception to stop the run. RuntimeException e = new TestRunException(currentStep() + " failed.", currentStep().toString(), stepIndex); e.fillInStackTrace(); getLog().error(e); properlyCloseWebDriver(); throw e; } else { return true; } }
From source file:com.netease.dagger.BrowserEmulator.java
/** * Switch to new page//from www .j a v a 2 s.c o m */ public void switchToNewPage() { pause(stepInterval); Set<String> handles = new HashSet<String>(); try { String currentHandle = browserCore.getWindowHandle(); handles = browserCore.getWindowHandles(); Iterator<String> it = handles.iterator(); while (it.hasNext()) { if (currentHandle == it.next()) continue; browserCore.switchTo().window(it.next()); logger.info("Switch to page: " + browserCore.getCurrentUrl() + " success"); } } catch (Exception e) { logger.info("Switch to page failed and current page: " + browserCore.getCurrentUrl() + e.fillInStackTrace()); } }
From source file:edu.stanford.muse.email.EmailFetcherStats.java
/** * recursively processes attachments, fetching and saving it if needed * parses the given part p, and adds it to hte attachmentsList. * in some cases, like a text/html type without a filename, we instead append it to the textlist * @throws MessagingException/*from w w w .ja v a2s. co m*/ */ private void handleAttachments(int idx, Message m, Part p, List<String> textList, List<Blob> attachmentsList) throws MessagingException { String ct = null; if (!(m instanceof MimeMessage)) { Exception e = new IllegalArgumentException("Not a MIME message!"); e.fillInStackTrace(); log.warn(Util.stackTrace(e)); return; } String filename = null; try { filename = p.getFileName(); } catch (Exception e) { // seen this happen with: // Folders__gmail-sent Message #12185 Expected ';', got "Message" // javax.mail.internet.ParseException: Expected ';', got "Message" dataErrors.add("Unable to read attachment name: " + folder_name() + " Message# " + idx); return; } String sanitizedFName = Util.sanitizeFolderName(emailStore.getAccountID() + "." + folder_name()); if (filename == null) { String tempFname = sanitizedFName + "." + idx; dataErrors.add("attachment filename is null for " + sanitizedFName + " Message#" + idx + " assigning it the name: " + tempFname); if (p.isMimeType("text/html")) { try { log.info("Turning message " + sanitizedFName + " Message#" + idx + " into text although it is an attachment"); String html = (String) p.getContent(); String text = Util.unescapeHTML(html); org.jsoup.nodes.Document doc = Jsoup.parse(text); StringBuilder sb = new StringBuilder(); HTMLUtils.extractTextFromHTML(doc.body(), sb); textList.add(sb.toString()); return; } catch (Exception e) { Util.print_exception("Error reading contents of text/html multipart without a filename!", e, log); return; } } filename = tempFname; } // Replacing any of the disallowed filename characters (\/:*?"<>|&) to _ // (note: & causes problems with URLs for serveAttachment etc, so it's also replaced) String newFilename = Util.sanitizeFileName(filename); // Updating filename if it's changed after sanitizing. if (!newFilename.equals(filename)) { log.info("Filename changed from " + filename + " to " + newFilename); filename = newFilename; } try { ct = p.getContentType(); if (filename.indexOf(".") < 0) // no ext in filename... let's fix it if possible { // Using startsWith instead of equals because sometimes the ct has crud beyond the image/jpeg;...crud.... // Below are the most common file types, more type can be added if needed // Most common APPLICATION TYPE if (ct.startsWith("application/pdf")) filename = filename + ".pdf"; if (ct.startsWith("application/zip")) filename = filename + ",zip"; // Most common IMAGE TYPE if (ct.startsWith("image/jpeg")) filename = filename + ".jpg"; if (ct.startsWith("image/gif")) filename = filename + ".gif"; if (ct.startsWith("image/png")) filename = filename + ".png"; // Most Common VIDEO TYPE if (ct.startsWith("video/x-ms-wmv")) filename = filename + ".wmv"; // Most Common AUDIO TYPE if (ct.startsWith("audio/mpeg")) filename = filename + ".mp3"; if (ct.startsWith("audio/mp4")) filename = filename + ".mp4"; // Most Common TEXT TYPE if (ct.startsWith("text/html")) filename = filename + ".html"; // Windows Office if (ct.startsWith("application/vnd.openxmlformats-officedocument.wordprocessingml.document")) //Word filename = filename + ".docx"; if (ct.startsWith("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")) //Excel filename = filename + ".xlsx"; if (ct.startsWith("application/vnd.openxmlformats-officedocument.presentationml.presentation")) //PowerPoint filename = filename + ".pptx"; } // retain only up to first semi-colon; often ct is something like text/plain; name="filename"' we don't want to log the filename int x = ct.indexOf(";"); if (x >= 0) ct = ct.substring(0, x); log.info("Attachment content type: " + ct + " filename = " + Util.blurKeepingExtension(filename)); } catch (Exception pex) { dataErrors.add("Can't read CONTENT-TYPE: " + ct + " filename:" + filename + " size = " + p.getSize() + " subject: " + m.getSubject() + " Date : " + m.getSentDate().toString() + "\n Exception: " + pex + "\n" + Util.stackTrace(pex)); return; } // if (filename == null && !p.isMimeType("text/html") && !p.isMimeType("message/partial")) // expected not to have a filename with mime type text/html // log.warn ("Attachment filename is null: " + Util.stackTrace()); boolean success = true; // the size passed in here is the part size, which is not really the binary blob size. // when we read the stream below in blobStore.add(), we'll set it again to the binary blob size Blob b = new EmailAttachmentBlob(filename, p.getSize(), (MimeMessage) m, p); if (fetchConfig.downloadAttachments) { // this containment check is only on the basis of file name and size currently, // not on the actual hash if (archive.getBlobStore().contains(b)) { log.debug("Cache hit! " + b); } else { try { if (filename.endsWith(".tif")) log.info("Fetching attachment..." + Util.blurKeepingExtension(filename)); // performance critical! use large buffer! currently 256KB // stream will be closed by callee long start = System.currentTimeMillis(); long nBytes = archive.getBlobStore().add(b, new BufferedInputStream(p.getInputStream(), 256 * 1024)); long end = System.currentTimeMillis(); if (nBytes != -1) { long diff = end - start; String s = "attachment size " + nBytes + " bytes, fetched in " + diff + " millis"; if (diff > 0) s += " (" + (nBytes / diff) + " KB/s)"; log.info(s); } Util.ASSERT(archive.getBlobStore().contains(b)); } catch (IOException ioe) { success = false; dataErrors.add("WARNING: Unable to fetch attachment: filename: " + filename + " size = " + p.getSize() + " subject: " + m.getSubject() + " Date : " + m.getSentDate().toString() + "\nException: " + ioe); ioe.printStackTrace(System.out); } } if (success) { attachmentsList.add(b); /// generate thumbnail only if not already cached try { archive.getBlobStore().generate_thumbnail(b); // supplement } catch (IOException ioe) { log.warn("failed to create thumbnail, filename: " + filename + " size = " + p.getSize() + " subject: " + m.getSubject() + " Date : " + m.getSentDate().toString() + "\nException: " + ioe); ioe.printStackTrace(System.out); } } } }
From source file:io.personium.core.bar.BarFileReadRunner.java
/** * 00_$metadata_xml??????.//from w w w .j a v a2 s .c o m * @param entryName ?? * @param inputStream * @param davCmp Collection? * @return ????true */ protected boolean registUserSchema(String entryName, InputStream inputStream, DavCmp davCmp) { EdmDataServices metadata = null; // XML(StAX,SAX,DOM)?InputStream??????????? // ????????????????? try { InputStreamReader isr = new InputStreamReader(new CloseShieldInputStream(inputStream)); // 00_$metadata.xml???? XMLFactoryProvider2 provider = StaxXMLFactoryProvider2.getInstance(); XMLInputFactory2 factory = provider.newXMLInputFactory2(); XMLEventReader2 reader = factory.createXMLEventReader(isr); PersoniumEdmxFormatParser parser = new PersoniumEdmxFormatParser(); metadata = parser.parseMetadata(reader); } catch (Exception ex) { log.info("XMLParseException: " + ex.getMessage(), ex.fillInStackTrace()); String message = PersoniumCoreMessageUtils.getMessage("PL-BI-2002"); writeOutputStream(true, "PL-BI-1004", entryName, message); return false; } catch (StackOverflowError tw) { // ComplexType???StackOverFlowError?? log.info("XMLParseException: " + tw.getMessage(), tw.fillInStackTrace()); String message = PersoniumCoreMessageUtils.getMessage("PL-BI-2002"); writeOutputStream(true, "PL-BI-1004", entryName, message); return false; } // Entity/Property? // Property/ComplexProperty????ComplexType??????? // ??ComplexType????EntityType? // PersoniumODataProducer producer = davCmp.getODataProducer(); try { createComplexTypes(metadata, davCmp); createEntityTypes(metadata, davCmp); createAssociations(metadata, davCmp); } catch (PersoniumCoreException e) { writeOutputStream(true, "PL-BI-1004", entryName, e.getMessage()); log.info("PersoniumCoreException: " + e.getMessage()); return false; } catch (Exception e) { log.info("Regist Entity Error: " + e.getMessage(), e.fillInStackTrace()); String message = PersoniumCoreMessageUtils.getMessage("PL-BI-2003"); writeOutputStream(true, "PL-BI-1004", entryName, message); return false; } return true; }
From source file:com.fujitsu.dc.core.bar.BarFileReadRunner.java
/** * 00_$metadata_xml??????.//from w w w . j av a2 s. c om * @param entryName ?? * @param inputStream * @param davCmp Collection? * @return ????true */ protected boolean registUserSchema(String entryName, InputStream inputStream, DavCmpEsImpl davCmp) { EdmDataServices metadata = null; // XML(StAX,SAX,DOM)?InputStream??????????? // ????????????????? try { InputStreamReader isr = new InputStreamReader(new CloseShieldInputStream(inputStream)); // 00_$metadata.xml???? XMLFactoryProvider2 provider = StaxXMLFactoryProvider2.getInstance(); XMLInputFactory2 factory = provider.newXMLInputFactory2(); XMLEventReader2 reader = factory.createXMLEventReader(isr); DcEdmxFormatParser parser = new DcEdmxFormatParser(); metadata = parser.parseMetadata(reader); } catch (Exception ex) { log.info("XMLParseException: " + ex.getMessage(), ex.fillInStackTrace()); String message = DcCoreMessageUtils.getMessage("PL-BI-2002"); writeOutputStream(true, "PL-BI-1004", entryName, message); return false; } catch (StackOverflowError tw) { // ComplexType???StackOverFlowError?? log.info("XMLParseException: " + tw.getMessage(), tw.fillInStackTrace()); String message = DcCoreMessageUtils.getMessage("PL-BI-2002"); writeOutputStream(true, "PL-BI-1004", entryName, message); return false; } // Entity/Property? // Property/ComplexProperty????ComplexType??????? // ??ComplexType????EntityType? // DcODataProducer producer = davCmp.getODataProducer(); try { createComplexTypes(metadata, davCmp); createEntityTypes(metadata, davCmp); createAssociations(metadata, davCmp); } catch (DcCoreException e) { writeOutputStream(true, "PL-BI-1004", entryName, e.getMessage()); log.info("DcCoreException: " + e.getMessage()); return false; } catch (Exception e) { log.info("Regist Entity Error: " + e.getMessage(), e.fillInStackTrace()); String message = DcCoreMessageUtils.getMessage("PL-BI-2003"); writeOutputStream(true, "PL-BI-1004", entryName, message); return false; } return true; }
From source file:io.personium.core.bar.BarFileReadRunner.java
/** * WebDAV??.//from w w w. j av a 2s. co m * @param entryName bar??? * @param inputStream * @param webdavCols WebDAV * @return true: ??false: */ protected boolean registWebDavFile(String entryName, InputStream inputStream, Map<String, DavCmp> webdavCols) { // ???? String filePath = entryName.replaceAll(CONTENTS_DIR, ""); String colPath = entryName.substring(0, entryName.lastIndexOf("/") + 1); // DavCmp? DavCmp parentCmp = webdavCols.get(colPath); // ??? int maxChildResource = PersoniumUnitConfig.getMaxChildResourceCount(); if (parentCmp.getChildrenCount() >= maxChildResource) { // ????????????? String message = PersoniumCoreMessageUtils.getMessage("PR400-DV-0007"); log.info(message); writeOutputStream(true, "PL-BI-1004", entryName, message); return false; } // ??? // ?? String fileName = ""; fileName = filePath.substring(filePath.lastIndexOf("/") + 1); // ? DavCmp fileCmp = parentCmp.getChild(fileName); // Content-Type?? String contentType = null; try { contentType = this.davFileMap.get(entryName); RuntimeDelegate.getInstance().createHeaderDelegate(MediaType.class).fromString(contentType); } catch (Exception e) { String message = PersoniumCoreMessageUtils.getMessage("PL-BI-2005"); log.info(message + ": " + e.getMessage(), e.fillInStackTrace()); writeOutputStream(true, "PL-BI-1004", entryName, message); return false; } // try { fileCmp.putForCreate(contentType, new CloseShieldInputStream(inputStream)); } catch (Exception e) { String message = PersoniumCoreMessageUtils.getMessage("PL-BI-2004"); log.info(message + ": " + e.getMessage(), e.fillInStackTrace()); writeOutputStream(true, "PL-BI-1004", entryName, message); return false; } return true; }
From source file:com.fujitsu.dc.core.bar.BarFileReadRunner.java
/** * WebDAV??./* w ww . ja v a2s. c o m*/ * @param entryName bar??? * @param inputStream * @param webdavCols WebDAV * @return true: ??false: */ protected boolean registWebDavFile(String entryName, InputStream inputStream, Map<String, DavCmpEsImpl> webdavCols) { // ???? String filePath = entryName.replaceAll(CONTENTS_DIR, ""); String colPath = entryName.substring(0, entryName.lastIndexOf("/") + 1); // DavCmp? DavCmpEsImpl parentCmp = webdavCols.get(colPath); String parentId = parentCmp.getId(); // ??? int maxChildResource = DcCoreConfig.getMaxChildResourceCount(); if (parentCmp.getChildrenCount() >= maxChildResource) { // ????????????? String message = DcCoreMessageUtils.getMessage("PR400-DV-0007"); log.info(message); writeOutputStream(true, "PL-BI-1004", entryName, message); return false; } // ??? DavNode davNode = new DavNode(this.cell.getId(), this.box.getId(), DavCmp.TYPE_DAV_FILE); davNode.setParentId(parentId); // ?? String fileName = ""; fileName = filePath.substring(filePath.lastIndexOf("/") + 1); String davNodeId = davNode.getId(); DavCmpEsImpl fileCmp = new DavCmpEsImpl(fileName, parentCmp, this.cell, this.box, davNodeId); // Content-Type?? String contentType = null; try { contentType = this.davFileMap.get(entryName); RuntimeDelegate.getInstance().createHeaderDelegate(MediaType.class).fromString(contentType); } catch (Exception e) { String message = DcCoreMessageUtils.getMessage("PL-BI-2005"); log.info(message + ": " + e.getMessage(), e.fillInStackTrace()); writeOutputStream(true, "PL-BI-1004", entryName, message); return false; } // try { fileCmp.putForCreate(contentType, new CloseShieldInputStream(inputStream)); } catch (Exception e) { String message = DcCoreMessageUtils.getMessage("PL-BI-2004"); log.info(message + ": " + e.getMessage(), e.fillInStackTrace()); writeOutputStream(true, "PL-BI-1004", entryName, message); return false; } return true; }