List of usage examples for java.lang Exception fillInStackTrace
public synchronized Throwable fillInStackTrace()
From source file:io.personium.core.bar.BarFileReadRunner.java
/** * 90_rootprops_xml???Collectoin/ACL/WebDAV???. * @param rootPropsName 90_rootprops_xml?bar?? * @param inputStream //w ww . j a v a2s . c o m * @param boxUrl box?URL * @return ????true */ protected boolean registXmlEntry(String rootPropsName, InputStream inputStream, String boxUrl) { // XML(StAX,SAX,DOM)?InputStream??????????? // ????????????????? try { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); StringBuffer buf = new StringBuffer(); String str; while ((str = bufferedReader.readLine()) != null) { buf.append(str); } Multistatus multiStatus = Multistatus.unmarshal(new ByteArrayInputStream(buf.toString().getBytes())); // 90_rootprops.xml?????? // ????????????? if (!validateCollectionDefinitions(multiStatus, rootPropsName)) { return false; } for (Response response : multiStatus.getResponse()) { int collectionType = TYPE_WEBDAV_COLLECTION; boolean hasCollection = false; boolean isBox = false; List<String> hrefs = response.getHref(); String href = hrefs.get(0); if (href.equals("dcbox:")) { href = DCBOX; } if (href.equals(DCBOX)) { isBox = true; } String collectionUrl = null; collectionUrl = href.replaceFirst(DCBOX, boxUrl + "/"); List<Element> propElements = new ArrayList<Element>(); Element aclElement = null; String contentType = null; for (Propstat propstat : response.getPropstat()) { Prop prop = propstat.getProp(); Resourcetype resourceType = prop.getResourcetype(); if (resourceType != null) { if (resourceType.getCollection() != null) { hasCollection = true; } List<Element> elements = resourceType.getAny(); for (Element element : elements) { String nodeName = element.getNodeName(); if (nodeName.equals("p:odata")) { collectionType = TYPE_ODATA_COLLECTION; } else if (nodeName.equals("p:service")) { collectionType = TYPE_SERVICE_COLLECTION; } } } // prop?? Getcontenttype getContentType = prop.getGetcontenttype(); if (getContentType != null) { contentType = getContentType.getValue(); } List<Element> pElements = prop.getAny(); for (Element element : pElements) { String nodeName = element.getNodeName(); if (nodeName.equals("creationdate") || nodeName.equals("getlastmodified") || nodeName.equals("resourcetype")) { continue; } if (nodeName.equals("acl")) { if (!BarFileUtils.aclNameSpaceValidate(rootPropsName, element, this.schemaUrl)) { String message = PersoniumCoreMessageUtils.getMessage("PL-BI-2007"); log.info(message + " [" + rootPropsName + "]"); writeOutputStream(true, "PL-BI-1004", rootPropsName, message); return false; } aclElement = element; continue; } propElements.add(element); } } String entryName = CONTENTS_DIR + href.replaceFirst(DCBOX, ""); if (isBox) { // Box???ACL registBoxAclAndProppatch(this.box, aclElement, propElements, collectionUrl); } else if (hasCollection) { if (!entryName.endsWith("/")) { entryName += "/"; } // ????ACL?PROPPATH log.info(entryName); createCollection(collectionUrl, entryName, this.cell, this.box, collectionType, aclElement, propElements); } else { // WebDAV this.davFileMap.put(entryName, contentType); } } } catch (PersoniumCoreException e) { log.info("PersoniumCoreException: " + e.getMessage()); writeOutputStream(true, "PL-BI-1004", rootPropsName, e.getMessage()); return false; } catch (Exception ex) { String message = getErrorMessage(ex); log.info("XMLParseException: " + message, ex.fillInStackTrace()); writeOutputStream(true, "PL-BI-1004", rootPropsName, message); return false; } return true; }
From source file:com.fujitsu.dc.core.bar.BarFileReadRunner.java
/** * 90_rootprops_xml???Collectoin/ACL/WebDAV???. * @param rootPropsName 90_rootprops_xml?bar?? * @param inputStream //from ww w . j av a2 s . co m * @param boxUrl box?URL * @return ????true */ protected boolean registXmlEntry(String rootPropsName, InputStream inputStream, String boxUrl) { // XML(StAX,SAX,DOM)?InputStream??????????? // ????????????????? try { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); StringBuffer buf = new StringBuffer(); String str; while ((str = bufferedReader.readLine()) != null) { buf.append(str); } Multistatus multiStatus = Multistatus.unmarshal(new ByteArrayInputStream(buf.toString().getBytes())); // 90_rootprops.xml?????? // ????????????? if (!validateCollectionDefinitions(multiStatus, rootPropsName)) { return false; } for (Response response : multiStatus.getResponse()) { int collectionType = TYPE_WEBDAV_COLLECTION; boolean hasCollection = false; boolean isBox = false; List<String> hrefs = response.getHref(); String href = hrefs.get(0); if (href.equals("dcbox:")) { href = DCBOX; } if (href.equals(DCBOX)) { isBox = true; } String collectionUrl = null; collectionUrl = href.replaceFirst(DCBOX, boxUrl + "/"); List<Element> propElements = new ArrayList<Element>(); Element aclElement = null; String contentType = null; for (Propstat propstat : response.getPropstat()) { Prop prop = propstat.getProp(); Resourcetype resourceType = prop.getResourcetype(); if (resourceType != null) { if (resourceType.getCollection() != null) { hasCollection = true; } List<Element> elements = resourceType.getAny(); for (Element element : elements) { String nodeName = element.getNodeName(); if (nodeName.equals("dc:odata")) { collectionType = TYPE_ODATA_COLLECTION; } else if (nodeName.equals("dc:service")) { collectionType = TYPE_SERVICE_COLLECTION; } } } // prop?? Getcontenttype getContentType = prop.getGetcontenttype(); if (getContentType != null) { contentType = getContentType.getValue(); } List<Element> pElements = prop.getAny(); for (Element element : pElements) { String nodeName = element.getNodeName(); if (nodeName.equals("creationdate") || nodeName.equals("getlastmodified") || nodeName.equals("resourcetype")) { continue; } if (nodeName.equals("acl")) { if (!BarFileUtils.aclNameSpaceValidate(rootPropsName, element, this.schemaUrl)) { String message = DcCoreMessageUtils.getMessage("PL-BI-2007"); log.info(message + " [" + rootPropsName + "]"); writeOutputStream(true, "PL-BI-1004", rootPropsName, message); return false; } aclElement = element; continue; } propElements.add(element); } } String entryName = CONTENTS_DIR + href.replaceFirst(DCBOX, ""); if (isBox) { // Box???ACL registBoxAclAndProppatch(this.box, aclElement, propElements, collectionUrl); } else if (hasCollection) { if (!entryName.endsWith("/")) { entryName += "/"; } // ????ACL?PROPPATH log.info(entryName); createCollection(collectionUrl, entryName, this.cell, this.box, collectionType, aclElement, propElements); } else { // WebDAV this.davFileMap.put(entryName, contentType); } } } catch (DcCoreException e) { log.info("DcCoreException: " + e.getMessage()); writeOutputStream(true, "PL-BI-1004", rootPropsName, e.getMessage()); return false; } catch (Exception ex) { String message = getErrorMessage(ex); log.info("XMLParseException: " + message, ex.fillInStackTrace()); writeOutputStream(true, "PL-BI-1004", rootPropsName, message); return false; } return true; }
From source file:io.personium.core.bar.BarFileReadRunner.java
/** * 10_odatarelations.json????ES??.//from w ww.jav a 2 s.c om * @param mappedObject JSON??? */ private boolean createUserdataLink(JSONMappedObject mappedObject, PersoniumODataProducer producer) { OEntityId sourceEntity = null; OEntityId newTargetEntity = null; try { Map<String, String> fromId = ((JSONUserDataLinks) mappedObject).getFromId(); String fromKey = ""; Iterator<Entry<String, String>> fromIterator = fromId.entrySet().iterator(); fromKey = String.format("('%s')", fromIterator.next().getValue()); OEntityKey fromOEKey = OEntityKey.parse(fromKey); sourceEntity = OEntityIds.create(((JSONUserDataLinks) mappedObject).getFromType(), fromOEKey); String targetNavProp = ((JSONUserDataLinks) mappedObject).getNavPropToType(); // ??? odataEntityResource.getOdataResource().beforeLinkCreate(sourceEntity, targetNavProp); Map<String, String> toId = ((JSONUserDataLinks) mappedObject).getToId(); String toKey = ""; Iterator<Entry<String, String>> toIterator = toId.entrySet().iterator(); toKey = String.format("('%s')", toIterator.next().getValue()); OEntityKey toOEKey = OEntityKey.parse(toKey); newTargetEntity = OEntityIds.create(((JSONUserDataLinks) mappedObject).getToType(), toOEKey); // $links? producer.createLink(sourceEntity, targetNavProp, newTargetEntity); } catch (Exception e) { String path = ""; String targetPath = ""; if (sourceEntity != null) { path = sourceEntity.getEntitySetName() + sourceEntity.getEntityKey(); } if (newTargetEntity != null) { targetPath = "Target Link to " + newTargetEntity.getEntitySetName() + newTargetEntity.getEntityKey(); } log.info(e.getMessage() + " [" + path + "]", e.fillInStackTrace()); writeOutputStream(true, "PL-BI-1004", path, targetPath); return false; } return true; }
From source file:com.fujitsu.dc.core.bar.BarFileReadRunner.java
/** * 10_odatarelations.json????ES??./*w w w . j a va2 s.c o m*/ * @param mappedObject JSON??? */ private boolean createUserdataLink(JSONMappedObject mappedObject, DcODataProducer producer) { OEntityId sourceEntity = null; OEntityId newTargetEntity = null; try { Map<String, String> fromId = ((JSONUserDataLinks) mappedObject).getFromId(); String fromKey = ""; for (Map.Entry<String, String> entry : fromId.entrySet()) { fromKey = String.format("('%s')", entry.getValue()); break; } OEntityKey fromOEKey = OEntityKey.parse(fromKey); sourceEntity = OEntityIds.create(((JSONUserDataLinks) mappedObject).getFromType(), fromOEKey); String targetNavProp = ((JSONUserDataLinks) mappedObject).getNavPropToType(); // ??? odataEntityResource.getOdataResource().beforeLinkCreate(sourceEntity, targetNavProp); Map<String, String> toId = ((JSONUserDataLinks) mappedObject).getToId(); String toKey = ""; for (Map.Entry<String, String> entry : toId.entrySet()) { toKey = String.format("('%s')", entry.getValue()); break; } OEntityKey toOEKey = OEntityKey.parse(toKey); newTargetEntity = OEntityIds.create(((JSONUserDataLinks) mappedObject).getToType(), toOEKey); // $links? producer.createLink(sourceEntity, targetNavProp, newTargetEntity); } catch (Exception e) { String path = ""; String targetPath = ""; if (sourceEntity != null) { path = sourceEntity.getEntitySetName() + sourceEntity.getEntityKey(); } if (newTargetEntity != null) { targetPath = "Target Link to " + newTargetEntity.getEntitySetName() + newTargetEntity.getEntityKey(); } log.info(e.getMessage() + " [" + path + "]", e.fillInStackTrace()); writeOutputStream(true, "PL-BI-1004", path, targetPath); return false; } return true; }
From source file:org.eurekastreams.server.service.actions.strategies.galleryitem.PluginDefinitionPopulator.java
/** * Populates a plugin definition.// ww w . j a v a 2 s . co m * * @param inPluginDefinition * the plugin definition to populate * @param inPluginDefinitionUrl * the plugin definition url. */ @Override public void populate(final PluginDefinition inPluginDefinition, final String inPluginDefinitionUrl) { boolean hasFeature = false; ValidationException ve = new ValidationException(); String errorMessage = ""; // ensure the gadget is a plugin type. try { hasFeature = checkForRequiredFeature(inPluginDefinitionUrl); } catch (Exception ex) { log.debug(CANT_FIND_PLUGIN, ex); ve.addError("url", CANT_FIND_PLUGIN); throw ve; } final Map<String, GeneralGadgetDefinition> gadgetDefs = new HashMap<String, GeneralGadgetDefinition>(); gadgetDefs.put(inPluginDefinitionUrl, inPluginDefinition); log.info("Fetching gadget data"); try { List<GadgetMetaDataDTO> meta = metaDataFetcher.getGadgetsMetaData(gadgetDefs); if (meta.size() > 0) { /* * These two fields are the only fields being populated because the other values are populate via * Shindig on each ui request. */ GadgetMetaDataDTO metadata = meta.get(0); for (UserPrefDTO up : metadata.getUserPrefs()) { if ("updateFrequency".equals(up.getName())) { try { Long updateFreq = Long.parseLong(up.getDefaultValue()); inPluginDefinition.setUpdateFrequency(updateFreq); } catch (Exception ex) { errorMessage += UPDATE_FREQUENCY_ERROR; } } else if ("objectType".equals(up.getName())) { try { inPluginDefinition.setObjectType(BaseObjectType.valueOf(up.getDefaultValue())); } catch (Exception ex) { errorMessage += OBJECTTYPE_ERROR; } } } } // Check for all required elements if (!hasFeature) { errorMessage += FEATURE_ERROR; } // add see if a error message was created. If so add it as a validation exceptions. If not check for // defaults. if (!errorMessage.equals("")) { ve.addError("url", errorMessage); } else { if (inPluginDefinition.getObjectType() == null) { inPluginDefinition.setObjectType(defaultObjectType); } if (inPluginDefinition.getUpdateFrequency() == null) { inPluginDefinition.setUpdateFrequency(defaultUpdateFrequency); } } // Check if any errors exist if (!ve.getErrors().isEmpty()) { throw ve; } } catch (ValidationException ve2) { throw ve2; } catch (Exception ex) { ve.addError("url", "Error retreiving plugin data."); log.debug(ex.fillInStackTrace()); throw ve; } }
From source file:weka.server.knowledgeFlow.FlowRunnerRemote.java
/** * Execute the current flow remotely on the server * //from w w w . j av a 2 s. co m * @throws Exception if a problem occurs */ public void executeFlowRemote() throws Exception { Exception exception = null; NamedTask taskToRun = null; if (m_schedule == null) { taskToRun = new UnscheduledNamedKFTask(NAME_PREFIX + m_name, m_flowXML, m_sequential, m_parameters); } else { taskToRun = new ScheduledNamedKFTask(NAME_PREFIX + m_name, m_flowXML, m_sequential, m_parameters, m_schedule); } InputStream is = null; // BufferedInputStream bi = null; PostMethod post = null; try { // serialized and compressed byte[] serializedTask = WekaServer.serializeTask(taskToRun); System.out.println("Sending " + serializedTask.length + " bytes..."); String service = ExecuteTaskServlet.CONTEXT_PATH + "/?client=Y"; post = new PostMethod(constructURL(service)); RequestEntity entity = new ByteArrayRequestEntity(serializedTask); post.setRequestEntity(entity); post.setDoAuthentication(true); post.addRequestHeader(new Header("Content-Type", "application/octet-stream")); // Get HTTP client HttpClient client = WekaServer.ConnectionManager.getSingleton().createHttpClient(); WekaServer.ConnectionManager.addCredentials(client, m_username, m_password); // Execute request int result = client.executeMethod(post); System.out.println("Response status from server : " + result); // the response /* * is = post.getResponseBodyAsStream(); bi = new BufferedInputStream(is); * StringBuffer bodyB = new StringBuffer(); int c; while ((c = * bi.read())!=-1) { bodyB.append((char)c); } */ if (result == 401) { // Security problem - authentication required /* * bodyB.setLength(0); bodyB.append("Unable to send task to server - " + * "authentication required.\n"); */ System.err.println("Unable to send task to server - authentication required.\n"); } else { is = post.getResponseBodyAsStream(); ObjectInputStream ois = new ObjectInputStream(is); // System.out.println("Number of bytes in response " + ois.available()); Object response = ois.readObject(); if (response.toString().startsWith(WekaServlet.RESPONSE_ERROR)) { System.err.println("A problem occurred at the sever : \n" + "\t" + response.toString()); } else { System.out.println("Task ID from server : " + response.toString()); } /* * String body = bodyB.toString(); if * (body.startsWith(WekaServlet.RESPONSE_ERROR)) { * System.err.println("A problem occurred at the sever : \n" + "\t" + * body); } else { System.out.println("Task ID from server : " + body); * } */ } } catch (Exception ex) { ex.printStackTrace(); exception = ex; } finally { /* * if (bi != null) { bi.close(); } */ if (is != null) { is.close(); } if (post != null) { // Release current connection to the connection pool post.releaseConnection(); } } if (exception != null) { throw new Exception(exception.fillInStackTrace()); } }
From source file:weka.server.knowledgeFlow.legacy.FlowRunnerRemote.java
/** * Execute the current flow remotely on the server * //from w w w . java 2 s . com * @throws Exception if a problem occurs */ public void executeFlowRemote() throws Exception { Exception exception = null; NamedTask taskToRun = null; if (m_schedule == null) { taskToRun = new LegacyUnscheduledNamedKFTask(NAME_PREFIX + m_name, m_flowXML, m_sequential, m_parameters); } else { taskToRun = new LegacyScheduledNamedKFTask(NAME_PREFIX + m_name, m_flowXML, m_sequential, m_parameters, m_schedule); } InputStream is = null; // BufferedInputStream bi = null; PostMethod post = null; try { // serialized and compressed byte[] serializedTask = WekaServer.serializeTask(taskToRun); System.out.println("Sending " + serializedTask.length + " bytes..."); String service = ExecuteTaskServlet.CONTEXT_PATH + "/?client=Y"; post = new PostMethod(constructURL(service)); RequestEntity entity = new ByteArrayRequestEntity(serializedTask); post.setRequestEntity(entity); post.setDoAuthentication(true); post.addRequestHeader(new Header("Content-Type", "application/octet-stream")); // Get HTTP client HttpClient client = WekaServer.ConnectionManager.getSingleton().createHttpClient(); WekaServer.ConnectionManager.addCredentials(client, m_username, m_password); // Execute request int result = client.executeMethod(post); System.out.println("Response status from server : " + result); // the response /* * is = post.getResponseBodyAsStream(); bi = new BufferedInputStream(is); * StringBuffer bodyB = new StringBuffer(); int c; while ((c = * bi.read())!=-1) { bodyB.append((char)c); } */ if (result == 401) { // Security problem - authentication required /* * bodyB.setLength(0); bodyB.append("Unable to send task to server - " + * "authentication required.\n"); */ System.err.println("Unable to send task to server - authentication required.\n"); } else { is = post.getResponseBodyAsStream(); ObjectInputStream ois = new ObjectInputStream(is); // System.out.println("Number of bytes in response " + ois.available()); Object response = ois.readObject(); if (response.toString().startsWith(WekaServlet.RESPONSE_ERROR)) { System.err.println("A problem occurred at the sever : \n" + "\t" + response.toString()); } else { System.out.println("Task ID from server : " + response.toString()); } /* * String body = bodyB.toString(); if * (body.startsWith(WekaServlet.RESPONSE_ERROR)) { * System.err.println("A problem occurred at the sever : \n" + "\t" + * body); } else { System.out.println("Task ID from server : " + body); * } */ } } catch (Exception ex) { ex.printStackTrace(); exception = ex; } finally { /* * if (bi != null) { bi.close(); } */ if (is != null) { is.close(); } if (post != null) { // Release current connection to the connection pool post.releaseConnection(); } } if (exception != null) { throw new Exception(exception.fillInStackTrace()); } }
From source file:org.exoplatform.calendar.service.impl.JCRDataStorage.java
/** * {@inheritDoc}/*from www . ja v a 2s . c o m*/ */ public void confirmInvitation(String fromUserId, String confirmingEmail, String confirmingUser, int calType, String calendarId, String eventId, int answer) throws Exception { try { Map<String, String> pars = new HashMap<String, String>(); CalendarEvent event = getInvitationEvent(calType, calendarId, eventId, fromUserId); if (event != null) { if (event.getParticipantStatus() != null) { for (String parStatus : event.getParticipantStatus()) { String[] entry = parStatus.split(":"); if (entry.length > 1) pars.put(entry[0], entry[1]); else pars.put(entry[0], Utils.EMPTY_STR); } } String status = Utils.EMPTY_STR; switch (answer) { case Utils.DENY: status = Utils.STATUS_NO; break; case Utils.ACCEPT: status = Utils.STATUS_YES; break; case Utils.NOTSURE: status = Utils.STATUS_PENDING; break; default: break; } if (pars.containsKey(confirmingUser)) { pars.remove(confirmingUser); pars.put(confirmingUser, status); } if (pars.containsKey(confirmingEmail)) { pars.remove(confirmingEmail); pars.put(confirmingEmail, status); } Map<String, String> participant = new HashMap<String, String>(); for (Entry<String, String> par : pars.entrySet()) { participant.put(par.getKey() + ":" + par.getValue(), Utils.EMPTY_STR); } event.setParticipantStatus(participant.keySet().toArray(new String[participant.keySet().size()])); if (Calendar.TYPE_PRIVATE == calType) { saveUserEvent(fromUserId, calendarId, event, false); } else if (Calendar.TYPE_SHARED == calType) { saveEventToSharedCalendar(fromUserId, calendarId, event, false); } else if (Calendar.TYPE_PUBLIC == calType) { savePublicEvent(calendarId, event, false); } } } catch (Exception e) { throw new Exception(e.getClass().toString(), e.fillInStackTrace()); } finally { // session.close() ; } }