List of usage examples for java.lang Throwable getStackTrace
public StackTraceElement[] getStackTrace()
From source file:ome.services.util.ServiceHandler.java
protected Throwable getAndLogException(Throwable t) { if (null == t) { log.error("Exception thrown. (null)"); return new InternalException("Exception thrown with null message"); } else {//w w w. j ava 2s . c o m String msg = " Wrapped Exception: (" + t.getClass().getName() + "):\n" + t.getMessage(); // Base type of the hierarchy that we are converting to. // Just rethrow. if (RootException.class.isAssignableFrom(t.getClass())) { return t; } // // Spring's transient exception hierarchy // if (DeadlockLoserDataAccessException.class.isAssignableFrom(t.getClass())) { DeadlockLoserDataAccessException dldae = (DeadlockLoserDataAccessException) t; TryAgain ta = new TryAgain(dldae.getMessage(), 500L); // ticket:5639 ta.setStackTrace(t.getStackTrace()); printException("Deadlock exception thrown.", t); return ta; } else if (OptimisticLockingFailureException.class.isAssignableFrom(t.getClass())) { OptimisticLockException ole = new OptimisticLockException(t.getMessage()); ole.setStackTrace(t.getStackTrace()); printException("OptimisticLockingFailureException thrown.", t); return ole; } else if (ConcurrencyFailureException.class.isAssignableFrom(t.getClass())) { ConcurrencyFailureException cfe = (ConcurrencyFailureException) t; ConcurrencyException ce = new ConcurrencyException(cfe.getMessage(), 500); ce.setStackTrace(t.getStackTrace()); printException("Unknown concurrency failure", t); return ce; } else if (TransientDataAccessResourceException.class.isAssignableFrom(t.getClass())) { ConcurrencyFailureException cfe = (ConcurrencyFailureException) t; ConcurrencyException ce = new ConcurrencyException(cfe.getMessage(), 500); ce.setStackTrace(t.getStackTrace()); printException("Unknown transient failure", t); return ce; } else if (IllegalArgumentException.class.isAssignableFrom(t.getClass())) { ApiUsageException aue = new ApiUsageException(t.getMessage()); aue.setStackTrace(t.getStackTrace()); printException("IllegalArgumentException thrown.", t); return aue; } else if (InvalidDataAccessResourceUsageException.class.isAssignableFrom(t.getClass())) { ApiUsageException aue = new ApiUsageException(t.getMessage()); aue.setStackTrace(t.getStackTrace()); printException("InvalidDataAccessResourceUsageException thrown.", t); return aue; } else if (DataIntegrityViolationException.class.isAssignableFrom(t.getClass())) { ValidationException ve = new ValidationException(t.getMessage()); ve.setStackTrace(t.getStackTrace()); printException("DataIntegrityViolationException thrown.", t); return ve; } else if (CannotCreateTransactionException.class.isAssignableFrom(t.getClass())) { DatabaseBusyException dbe = new DatabaseBusyException("cannot create transaction", 5000L); dbe.setStackTrace(t.getStackTrace()); printException("CannotCreateTransactionException thrown.", t); return dbe; } else if (HibernateObjectRetrievalFailureException.class.isAssignableFrom(t.getClass())) { ValidationException ve = new ValidationException(t.getMessage()); ve.setStackTrace(t.getStackTrace()); printException("HibernateObjectRetrievealFailureException thrown.", t); return ve; } else if (HibernateSystemException.class.isAssignableFrom(t.getClass())) { Throwable cause = t.getCause(); if (cause == null || cause == t) { return wrapUnknown(t, msg); } else if (PropertyValueException.class.isAssignableFrom(cause.getClass())) { ValidationException ve = new ValidationException(cause.getMessage()); ve.setStackTrace(cause.getStackTrace()); printException("PropertyValueException thrown.", cause); return ve; } else { return wrapUnknown(t, msg); } } return wrapUnknown(t, msg); } }
From source file:cn.sinobest.jzpt.framework.utils.string.StringUtils.java
/** * /*from w w w .ja v a 2 s .c o m*/ * * @param e * @return */ public static String exceptionSummary(Throwable e) { String msg = e.getLocalizedMessage(); StackTraceElement[] stacks = e.getStackTrace(); if (msg == null && e.getCause() != null) { msg = exceptionSummary(e.getCause()); } String stack = stacks.length > 0 ? stacks[0].toString() : ""; return StringUtils.concat(e.getClass().getSimpleName(), ":", msg, "\r\n", stack); }
From source file:biz.bokhorst.xprivacy.Util.java
public static void bug(XHook hook, Throwable ex) { if (ex instanceof InvocationTargetException) { InvocationTargetException exex = (InvocationTargetException) ex; if (exex.getTargetException() != null) ex = exex.getTargetException(); }/*from www . j av a 2 s .c om*/ int priority; if (ex instanceof ActivityShare.AbortException) priority = Log.WARN; else if (ex instanceof ActivityShare.ServerException) priority = Log.WARN; else if (ex instanceof ConnectTimeoutException) priority = Log.WARN; else if (ex instanceof FileNotFoundException) priority = Log.WARN; else if (ex instanceof HttpHostConnectException) priority = Log.WARN; else if (ex instanceof NameNotFoundException) priority = Log.WARN; else if (ex instanceof NoClassDefFoundError) priority = Log.WARN; else if (ex instanceof OutOfMemoryError) priority = Log.WARN; else if (ex instanceof RuntimeException) priority = Log.WARN; else if (ex instanceof SecurityException) priority = Log.WARN; else if (ex instanceof SocketTimeoutException) priority = Log.WARN; else if (ex instanceof SSLPeerUnverifiedException) priority = Log.WARN; else if (ex instanceof StackOverflowError) priority = Log.WARN; else if (ex instanceof TransactionTooLargeException) priority = Log.WARN; else if (ex instanceof UnknownHostException) priority = Log.WARN; else if (ex instanceof UnsatisfiedLinkError) priority = Log.WARN; else priority = Log.ERROR; boolean xprivacy = false; for (StackTraceElement frame : ex.getStackTrace()) if (frame.getClassName() != null && frame.getClassName().startsWith("biz.bokhorst.xprivacy")) { xprivacy = true; break; } if (!xprivacy) priority = Log.WARN; log(hook, priority, ex.toString() + " uid=" + Process.myUid() + "\n" + Log.getStackTraceString(ex)); }
From source file:cn.sinobest.jzpt.framework.utils.string.StringUtils.java
/** * StringBuilder//from w w w . j a va 2s .com * * @param e * @param sb */ public static void exceptionSummary(Throwable e, StringBuilder sb) { String msg = e.getLocalizedMessage(); StackTraceElement[] stacks = e.getStackTrace(); if (msg == null && e.getCause() != null) { exceptionSummary(e.getCause(), sb); } String stack = stacks.length > 0 ? stacks[0].toString() : ""; sb.append(e.getClass().getSimpleName()).append(':').append(msg).append('\n').append(stack); }
From source file:pro.dbro.bart.TheActivity.java
public void displayRouteResponse(routeResponse routeResponse) { // Log.d("displayRouteResponse","Is this real?: "+routeResponse.toString()); // Previously, if the device's locale wasn't in Pacific Standard Time // Responses with all expired routes could present, causing a looping refresh cycle // This is now remedied by coercing response dates into PST boolean expiredResponse = false; if (routeResponse.routes.size() == 0) { Log.d("displayRouteResponse", "no routes to display"); expiredResponse = true;//from w ww . j av a 2 s . com } if (timer != null) timer.cancel(); // cancel previous timer timerViews = new ArrayList(); // release old ETA text views maxTimer = 0; try { tableLayout.removeAllViews(); //Log.v("DATE",new Date().toString()); long now = new Date().getTime(); if (!expiredResponse) { fareTv.setVisibility(0); fareTv.setText("$" + routeResponse.routes.get(0).fare); for (int x = 0; x < routeResponse.routes.size(); x++) { route thisRoute = routeResponse.routes.get(x); TableRow tr = (TableRow) View.inflate(c, R.layout.tablerow, null); tr.setPadding(0, 20, 0, 0); LinearLayout legLayout = (LinearLayout) View.inflate(c, R.layout.routelinearlayout, null); for (int y = 0; y < thisRoute.legs.size(); y++) { TextView trainTv = (TextView) View.inflate(c, R.layout.tabletext, null); trainTv.setPadding(0, 0, 0, 0); trainTv.setTextSize(20); trainTv.setGravity(3); // set left gravity // If route has multiple legs, generate "Transfer At [station name]" and "To [train name] " rows for each leg after the first if (y > 0) { trainTv.setText("transfer at " + BART.REVERSE_STATION_MAP .get(((leg) thisRoute.legs.get(y - 1)).disembarkStation.toLowerCase())); trainTv.setPadding(0, 0, 0, 0); legLayout.addView(trainTv); trainTv.setTextSize(14); trainTv = (TextView) View.inflate(c, R.layout.tabletext, null); trainTv.setPadding(0, 0, 0, 0); trainTv.setTextSize(20); trainTv.setGravity(3); // set left gravity trainTv.setText("to " + BART.REVERSE_STATION_MAP .get(((leg) thisRoute.legs.get(y)).trainHeadStation.toLowerCase())); } else { // For first route leg, display "Take [train name]" row trainTv.setText("take " + BART.REVERSE_STATION_MAP.get(((leg) thisRoute.legs.get(y)).trainHeadStation)); } legLayout.addView(trainTv); } if (thisRoute.legs.size() == 1) { legLayout.setPadding(0, 10, 0, 0); // Address detination train and ETA not aligning } tr.addView(legLayout); // Prepare ETA TextView TextView arrivalTimeTv = (TextView) View.inflate(c, R.layout.tabletext, null); arrivalTimeTv.setPadding(10, 0, 0, 0); //Log.v("DEPART_DATE",thisRoute.departureDate.toString()); // Don't report a train that may JUST be leaving with a negative ETA long eta; if (thisRoute.departureDate.getTime() - now <= 0) { eta = 0; } else { eta = thisRoute.departureDate.getTime() - now; } if (eta > maxTimer) { maxTimer = eta; } // Set timeTv Tag to departure date for interpretation by ViewCountDownTimer arrivalTimeTv.setTag(thisRoute.departureDate.getTime()); // Print arrival as time, not eta if greater than BART.ETA_THRESHOLD_MS if (thisRoute.departureDate.getTime() - now > BART.ETA_IN_MINUTES_THRESHOLD_MS) { SimpleDateFormat sdf = new SimpleDateFormat("h:mm a"); arrivalTimeTv.setText(sdf.format(thisRoute.departureDate)); arrivalTimeTv.setTextSize(20); } // Display ETA as minutes until arrival else { arrivalTimeTv.setTextSize(36); // Display eta less than 1m as "<1" if (eta < 60 * 1000) arrivalTimeTv.setText("<1"); // TODO - remove this? Does countdown tick on start else arrivalTimeTv.setText(String.valueOf(eta / (1000 * 60))); // TODO - remove this? Does countdown tick on start // Add the timerView to the list of views to be passed to the ViewCountDownTimer timerViews.add(arrivalTimeTv); } //new ViewCountDownTimer(arrivalTimeTv, eta, 60*1000).start(); tr.addView(arrivalTimeTv); // Set the Row View (containing train names and times) Tag to the route it represents tr.setTag(thisRoute); tableLayout.addView(tr); tr.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View arg0) { Log.d("RouteViewTag", ((route) arg0.getTag()).toString()); usherRoute = (route) arg0.getTag(); TextView guidanceTv = (TextView) View.inflate(c, R.layout.tabletext, null); guidanceTv.setText(Html.fromHtml(getString(R.string.service_prompt))); guidanceTv.setTextSize(18); guidanceTv.setPadding(0, 0, 0, 0); new AlertDialog.Builder(c).setTitle("Route Guidance").setIcon(R.drawable.ic_launcher) .setView(guidanceTv).setPositiveButton(R.string.service_start_button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent i = new Intent(c, UsherService.class); //i.putExtra("departure", ((leg)usherRoute.legs.get(0)).boardStation); //Log.v("SERVICE","Starting"); if (usherServiceIsRunning()) { stopService(i); } startService(i); } }) .setNeutralButton("Cancel", null).show(); return true; // consumed the long click } }); tr.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { int index = tableLayout.indexOfChild(arg0); // index of clicked view. Expanded view will always be +1 route thisRoute = (route) arg0.getTag(); if (!thisRoute.isExpanded) { // if route not expanded thisRoute.isExpanded = true; LinearLayout routeDetail = (LinearLayout) View.inflate(c, R.layout.routedetail, null); TextView arrivalTv = (TextView) View.inflate(c, R.layout.tabletext, null); SimpleDateFormat curFormater = new SimpleDateFormat("h:mm a"); //arrivalTv.setTextColor(0xFFC9C7C8); arrivalTv.setText("arrives " + curFormater.format(thisRoute.arrivalDate)); arrivalTv.setTextSize(20); routeDetail.addView(arrivalTv); ImageView bikeIv = (ImageView) View.inflate(c, R.layout.bikeimage, null); if (!thisRoute.bikes) { bikeIv.setImageResource(R.drawable.no_bicycle); } routeDetail.addView(bikeIv); tableLayout.addView(routeDetail, index + 1); } else { thisRoute.isExpanded = false; tableLayout.removeViewAt(index + 1); } } }); } // end route iteration } // end expiredResponse check // expiredResponse == True // If a late-night routeResponse includes the next morning's routes, they will be // presented with HH:MM ETAs, instead of minutes // Else if a late-night routeResponse includes routes from earlier in the evening // We will display "This route has stopped for tonight" else { String message = "This route has stopped for tonight"; TextView specialScheduleTextView = (TextView) View.inflate(c, R.layout.tabletext, null); specialScheduleTextView.setText(message); specialScheduleTextView.setPadding(0, 0, 0, 0); tableLayout.addView(specialScheduleTextView); } if (routeResponse.specialSchedule != null) { ImageView specialSchedule = (ImageView) View.inflate(c, R.layout.specialschedulelayout, null); specialSchedule.setTag(routeResponse.specialSchedule); specialSchedule.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { TextView specialScheduleTv = (TextView) View.inflate(c, R.layout.tabletext, null); specialScheduleTv.setPadding(0, 0, 0, 0); specialScheduleTv.setText(Html.fromHtml(arg0.getTag().toString())); specialScheduleTv.setTextSize(16); specialScheduleTv.setMovementMethod(LinkMovementMethod.getInstance()); new AlertDialog.Builder(c).setTitle("Route Alerts").setIcon(R.drawable.warning) .setView(specialScheduleTv).setPositiveButton("Okay!", null).show(); } }); tableLayout.addView(specialSchedule); } // Don't set timer if response is expired if (!expiredResponse) { timer = new ViewCountDownTimer(timerViews, "route", maxTimer, 30 * 1000); timer.start(); } } catch (Throwable t) { Log.d("displayRouteResponseError", t.getStackTrace().toString()); } }
From source file:com.itemanalysis.psychometrics.optimization.BOBYQAOptimizer.java
private static String caller(int n) { final Throwable t = new Throwable(); final StackTraceElement[] elements = t.getStackTrace(); final StackTraceElement e = elements[n]; return e.getMethodName() + " (at line " + e.getLineNumber() + ")"; }
From source file:com.collabnet.ccf.core.hospital.CCFExceptionToOrderedMapConvertor.java
/** * Converts the <code>record</code> into an <code>IOrderedMap</code> . * //from ww w. jav a 2s . c om * @param record * Object which should be a MessageException instance * @return an IOrderedMap representation of the MessageException contents */ protected Object convert(Object record) { try { boolean quarantineException = true; // we have to set these columns due to an SQL incompatibility issue // with // these fields setFixedColName(FIXED); setReprocessedColName(REPROCESSED); // log.warn("Artifact reached ambulance"); // first of all we pass the record in our parent method Object preprocessedMap = super.convert(record); if (preprocessedMap == null || (!(preprocessedMap instanceof IOrderedMap))) { return preprocessedMap; } IOrderedMap map = (IOrderedMap) preprocessedMap; // remove entities with wrong data type (string instead of boolean) map.remove(FIXED); map.remove(REPROCESSED); map.put(FIXED, false); map.put(REPROCESSED, false); MessageException messageException = (MessageException) record; map.put(exceptionMessageColName, messageException.getException().getMessage()); Throwable cause = messageException.getException().getCause(); if (cause != null) { map.put(causeExceptionClassColName, cause.getClass().getName()); map.put(causeExceptionMessageColName, cause.getMessage()); } else { map.put(causeExceptionClassColName, NO_CAUSE_EXCEPTION); map.put(causeExceptionMessageColName, NO_CAUSE_EXCEPTION); } Exception exception = messageException.getException(); StringBuffer stackTraceBuf = new StringBuffer(); StackTraceElement[] stackTrace = exception.getStackTrace(); for (int i = 0; i < stackTrace.length; i++) { stackTraceBuf.append(stackTrace[i]); stackTraceBuf.append("\n"); } /* Append cause exception stack trace */ if (cause != null) { stackTraceBuf.append("\n\n"); stackTrace = cause.getStackTrace(); for (int i = 0; i < stackTrace.length; i++) { stackTraceBuf.append(stackTrace[i]); stackTraceBuf.append("\n"); } } map.put(stackTraceColName, stackTraceBuf.toString()); String adaptorName = null == adaptor ? "Unknown" : adaptor.getId(); map.put(adaptorColName, adaptorName); Object data = messageException.getData(); String dataType = null; if (data != null) { dataType = data.getClass().getName(); } map.put(dataTypeColName, dataType); Element element = null; Document dataDoc = null; if (data instanceof Document) { dataDoc = (Document) data; element = dataDoc.getRootElement(); } if (element != null) { try { GenericArtifact ga = GenericArtifactHelper.createGenericArtifactJavaObject(dataDoc); String sourceArtifactId = ga.getSourceArtifactId(); String sourceSystemId = ga.getSourceSystemId(); String sourceSystemKind = ga.getSourceSystemKind(); String sourceRepositoryId = ga.getSourceRepositoryId(); String sourceRepositoryKind = ga.getSourceRepositoryKind(); String targetArtifactId = ga.getTargetArtifactId(); String targetSystemId = ga.getTargetSystemId(); String targetSystemKind = ga.getTargetSystemKind(); String targetRepositoryId = ga.getTargetRepositoryId(); String targetRepositoryKind = ga.getTargetRepositoryKind(); String artifactErrorCode = ga.getErrorCode(); String sourceArtifactLastModifiedDateString = ga.getSourceArtifactLastModifiedDate(); String targetArtifactLastModifiedDateString = ga.getTargetArtifactLastModifiedDate(); String sourceArtifactVersion = ga.getSourceArtifactVersion(); String targetArtifactVersion = ga.getTargetArtifactVersion(); String artifactType = XPathUtils.getAttributeValue(element, GenericArtifactHelper.ARTIFACT_TYPE); Date sourceLastModifiedDate = null; if (!sourceArtifactLastModifiedDateString.equalsIgnoreCase(GenericArtifact.VALUE_UNKNOWN)) { sourceLastModifiedDate = DateUtil.parse(sourceArtifactLastModifiedDateString); } else { // use the earliest date possible sourceLastModifiedDate = new Date(0); } if (sourceLastModifiedDate == null) { sourceLastModifiedDate = new Date(0); } java.sql.Timestamp sourceTime = new Timestamp(sourceLastModifiedDate.getTime()); java.util.Date targetLastModifiedDate = null; if (!targetArtifactLastModifiedDateString.equalsIgnoreCase(GenericArtifact.VALUE_UNKNOWN)) { targetLastModifiedDate = DateUtil.parse(targetArtifactLastModifiedDateString); } else { // use the earliest date possible targetLastModifiedDate = new Date(0); } java.sql.Timestamp targetTime = new Timestamp(targetLastModifiedDate.getTime()); // TODO Should we allow to set different column names for // these // properties? map.put(SOURCE_SYSTEM_ID, sourceSystemId); map.put(SOURCE_REPOSITORY_ID, sourceRepositoryId); map.put(TARGET_SYSTEM_ID, targetSystemId); map.put(TARGET_REPOSITORY_ID, targetRepositoryId); map.put(SOURCE_SYSTEM_KIND, sourceSystemKind); map.put(SOURCE_REPOSITORY_KIND, sourceRepositoryKind); map.put(TARGET_SYSTEM_KIND, targetSystemKind); map.put(TARGET_REPOSITORY_KIND, targetRepositoryKind); map.put(SOURCE_ARTIFACT_ID, sourceArtifactId); map.put(TARGET_ARTIFACT_ID, targetArtifactId); map.put(ERROR_CODE, artifactErrorCode); map.put(SOURCE_LAST_MODIFICATION_TIME, sourceTime); map.put(TARGET_LAST_MODIFICATION_TIME, targetTime); map.put(SOURCE_ARTIFACT_VERSION, sourceArtifactVersion); map.put(TARGET_ARTIFACT_VERSION, targetArtifactVersion); map.put(ARTIFACT_TYPE, artifactType); //log.info("Removing invalid XML characters if any before we proceed ..."); map.put(GENERICARTIFACT, removeInvalidXmlCharacters(dataDoc.asXML())); // these attributes will be considered for CCF 2.x only map.put(DESCRIPTION, "This hospital entry has been inserted by CCF Core."); map.put(REPOSITORY_MAPPING_DIRECTION, sourceSystemKind); map.put(VERSION, 0); } catch (GenericArtifactParsingException e) { // log // .warn( // "The data that reached the hospital is not a valid Generic Artifact" // ); if (isOnlyQuarantineGenericArtifacts()) { quarantineException = false; } map.put(SOURCE_SYSTEM_ID, null); map.put(SOURCE_REPOSITORY_ID, null); map.put(TARGET_SYSTEM_ID, null); map.put(TARGET_REPOSITORY_ID, null); map.put(SOURCE_SYSTEM_KIND, null); map.put(SOURCE_REPOSITORY_KIND, null); map.put(TARGET_SYSTEM_KIND, null); map.put(TARGET_REPOSITORY_KIND, null); map.put(SOURCE_ARTIFACT_ID, null); map.put(TARGET_ARTIFACT_ID, null); //log.info("Removing invalid XML characters if any before we proceed ..."); map.put(GENERICARTIFACT, removeInvalidXmlCharacters(dataDoc.asXML())); map.put(ERROR_CODE, null); map.put(SOURCE_LAST_MODIFICATION_TIME, null); map.put(TARGET_LAST_MODIFICATION_TIME, null); map.put(SOURCE_ARTIFACT_VERSION, null); map.put(TARGET_ARTIFACT_VERSION, null); map.put(ARTIFACT_TYPE, null); } } else { if (isOnlyQuarantineGenericArtifacts()) { quarantineException = false; } map.put(SOURCE_SYSTEM_ID, null); map.put(SOURCE_REPOSITORY_ID, null); map.put(TARGET_SYSTEM_ID, null); map.put(TARGET_REPOSITORY_ID, null); map.put(SOURCE_SYSTEM_KIND, null); map.put(SOURCE_REPOSITORY_KIND, null); map.put(TARGET_SYSTEM_KIND, null); map.put(TARGET_REPOSITORY_KIND, null); map.put(SOURCE_ARTIFACT_ID, null); map.put(TARGET_ARTIFACT_ID, null); map.put(GENERICARTIFACT, null); map.put(ERROR_CODE, null); map.put(SOURCE_LAST_MODIFICATION_TIME, null); map.put(TARGET_LAST_MODIFICATION_TIME, null); map.put(SOURCE_ARTIFACT_VERSION, null); map.put(TARGET_ARTIFACT_VERSION, null); map.put(ARTIFACT_TYPE, null); } if (quarantineException) { // TODO Do we have to care about the fact that the substituted // values // could potentially contain the place holders again? String logMessage = logMessageTemplate; for (Object key : map.keys()) { Object value = map.get(key); logMessage = logMessage.replace("<" + key.toString() + ">", value == null ? "undefined" : value.toString()); } log.error(logMessage); return map; } else { StringBuffer errorMessage = new StringBuffer(); errorMessage.append("Exception caught that is not going to be quarantined. Characteristics:\n"); for (Object key : map.keys()) { errorMessage.append(key.toString() + ": " + map.get(key) + "\n"); } log.warn(errorMessage.toString()); return null; } } catch (Exception e) { log.error("While trying to quarantine an exception, an exception occured", e); return null; } }
From source file:ai.grakn.engine.backgroundtasks.taskstorage.GraknStateStorage.java
public Boolean updateState(String id, TaskStatus status, String statusChangeBy, String engineID, Throwable failure, String checkpoint, JSONObject configuration) { if (id == null) return false; if (status == null && statusChangeBy == null && engineID == null && failure == null && checkpoint == null && configuration == null) return false; // Existing resource relations to remove final Set<String> resourcesToDettach = new HashSet<String>(); // New resources to add Var resources = var(TASK_VAR).id(id); if (status != null) { resourcesToDettach.add(STATUS);//from www . ja va 2s . c om resourcesToDettach.add(STATUS_CHANGE_TIME); resources.has(STATUS, status.toString()).has(STATUS_CHANGE_TIME, new Date().getTime()); } if (statusChangeBy != null) { resourcesToDettach.add(STATUS_CHANGE_BY); resources.has(STATUS_CHANGE_BY, statusChangeBy); } if (engineID != null) { resourcesToDettach.add(ENGINE_ID); resources.has(ENGINE_ID, engineID); } if (failure != null) { resourcesToDettach.add(TASK_EXCEPTION); resourcesToDettach.add(STACK_TRACE); resources.has(TASK_EXCEPTION, failure.toString()); if (failure.getStackTrace().length > 0) resources.has(STACK_TRACE, Arrays.toString(failure.getStackTrace())); } if (checkpoint != null) { resourcesToDettach.add(TASK_CHECKPOINT); resources.has(TASK_CHECKPOINT, checkpoint); } if (configuration != null) { resourcesToDettach.add(TASK_CONFIGURATION); resources.has(TASK_CONFIGURATION, configuration.toString()); } Optional<Boolean> result = attemptCommitToSystemGraph((graph) -> { LOG.debug("dettaching: " + resourcesToDettach); LOG.debug("inserting " + resources); final Entity task = (Entity) graph.getConcept(id); // Remove relations to any resources we want to currently update resourcesToDettach.forEach(typeName -> { RoleType roleType = graph.getRoleType(Schema.Resource.HAS_RESOURCE_OWNER.getName(typeName)); if (roleType == null) System.err.println("NO ROLE TYPE FOR RESOURCE " + typeName); task.relations(roleType).forEach(Concept::delete); }); // Insert new resources with new values graph.graql().insert(resources).execute(); return true; }, true); return result.isPresent(); }
From source file:com.sun.honeycomb.adm.client.AdminClientImpl.java
public static void throwException(Throwable e, String method) throws MgmtException { if (e instanceof IllegalArgumentException) { throw new MgmtException("failed to invoke method " + method + " " + e); } else if (e instanceof InvocationTargetException) { Throwable th = ((InvocationTargetException) e).getTargetException(); String err = "failed to invoke method " + method + " " + "Message : " + th.getMessage(); throw new MgmtException(err + "Stack trace : " + th.getStackTrace()); } else if (e instanceof ExceptionInInitializerError) { throw new MgmtException("failed to invoke method " + method + " " + e); } else if (e instanceof Exception) { throw new MgmtException("failed to invoke method " + method + " " + e); }/*from w ww . j ava2 s . c om*/ }
From source file:org.evosuite.testcase.TestCodeVisitor.java
private String getSourceClassName(Throwable exception) { if (exception.getStackTrace().length == 0) { return null; }/*from w ww .j a v a2s . c o m*/ return exception.getStackTrace()[0].getClassName(); }