List of usage examples for java.lang Exception getCause
public synchronized Throwable getCause()
From source file:com.siblinks.ws.service.impl.PlaylistServiceImpl.java
/** * {@inheritDoc}/*w w w . j av a2 s .c o m*/ */ @Override @RequestMapping(value = "/deleteMultiplePlaylist", method = RequestMethod.POST) public ResponseEntity<Response> deleteMultiplePlaylist(@RequestBody final RequestData request) { String uid = request.getRequest_playlist().getCreateBy(); ArrayList<String> plids = request.getRequest_playlist().getPlids(); SimpleResponse reponse = null; int countSuccess = 0; int countFail = 0; boolean status = false; for (String plid : plids) { status = deletePlaylist(plid, uid); if (status) { countSuccess++; } else { countFail++; } } try { activiLogService.insertActivityLog( new ActivityLogData(SibConstants.TYPE_PLAYLIST, "D", "You deleted a playlist", uid, null)); } catch (Exception e) { logger.debug(e.getCause()); e.printStackTrace(); } String msg = String.format("Delete success %d playlist and failed %d playlist", countSuccess, countFail); reponse = new SimpleResponse(SibConstants.SUCCESS, "playlist", "deleteMultiplePlaylist", msg); return new ResponseEntity<Response>(reponse, HttpStatus.OK); }
From source file:com.mpower.daktar.android.tasks.DownloadFormsTask.java
@Override protected HashMap<String, String> doInBackground(final ArrayList<FormDetails>... values) { final ArrayList<FormDetails> toDownload = values[0]; final int total = toDownload.size(); int count = 1; final HashMap<String, String> result = new HashMap<String, String>(); for (int i = 0; i < total; i++) { final FormDetails fd = toDownload.get(i); publishProgress(fd.formName, Integer.valueOf(count).toString(), Integer.valueOf(total).toString()); String message = ""; try {/*from w ww.jav a2s. co m*/ // get the xml file // if we've downloaded a duplicate, this gives us the file final File dl = downloadXform(fd.formName, fd.downloadUrl); final String[] projection = { BaseColumns._ID, FormsColumns.FORM_FILE_PATH }; final String[] selectionArgs = { dl.getAbsolutePath() }; final String selection = FormsColumns.FORM_FILE_PATH + "=?"; final Cursor alreadyExists = MIntel.getInstance().getContentResolver() .query(FormsColumns.CONTENT_URI, projection, selection, selectionArgs, null); Uri uri = null; if (alreadyExists.getCount() <= 0) { // doesn't exist, so insert it final ContentValues v = new ContentValues(); v.put(FormsColumns.FORM_FILE_PATH, dl.getAbsolutePath()); final HashMap<String, String> formInfo = FileUtils.parseXML(dl); v.put(FormsColumns.DISPLAY_NAME, formInfo.get(FileUtils.TITLE)); v.put(FormsColumns.MODEL_VERSION, formInfo.get(FileUtils.MODEL)); v.put(FormsColumns.UI_VERSION, formInfo.get(FileUtils.UI)); v.put(FormsColumns.JR_FORM_ID, formInfo.get(FileUtils.FORMID)); v.put(FormsColumns.SUBMISSION_URI, formInfo.get(FileUtils.SUBMISSIONURI)); uri = MIntel.getInstance().getContentResolver().insert(FormsColumns.CONTENT_URI, v); } else { alreadyExists.moveToFirst(); uri = Uri.withAppendedPath(FormsColumns.CONTENT_URI, alreadyExists.getString(alreadyExists.getColumnIndex(BaseColumns._ID))); } if (fd.manifestUrl != null) { final Cursor c = MIntel.getInstance().getContentResolver().query(uri, null, null, null, null); if (c.getCount() > 0) { // should be exactly 1 c.moveToFirst(); final String error = downloadManifestAndMediaFiles( c.getString(c.getColumnIndex(FormsColumns.FORM_MEDIA_PATH)), fd, count, total); if (error != null) { message += error; } } } else { // TODO: manifest was null? Log.e(t, "Manifest was null. PANIC"); } } catch (final SocketTimeoutException se) { se.printStackTrace(); message += se.getMessage(); } catch (final Exception e) { e.printStackTrace(); if (e.getCause() != null) { message += e.getCause().getMessage(); } else { message += e.getMessage(); } } count++; if (message.equalsIgnoreCase("")) { message = MIntel.getInstance().getString(R.string.success); } result.put(fd.formName, message); } return result; }
From source file:com.evolveum.midpoint.provisioning.impl.mock.SynchornizationServiceMock.java
@Override public void notifyChange(ResourceObjectShadowChangeDescription change, Task task, OperationResult parentResult) {/*from w w w. j a va2 s . c om*/ LOGGER.debug("Notify change mock called with {}", change); // Some basic sanity checks assertNotNull("No change", change); assertNotNull("No task", task); assertNotNull("No resource", change.getResource()); assertNotNull("No parent result", parentResult); assertTrue("Either current shadow or delta must be present", change.getCurrentShadow() != null || change.getObjectDelta() != null); if (change.isUnrelatedChange() || isDryRun(task) || (change.getCurrentShadow() != null && change.getCurrentShadow().asObjectable().isProtectedObject() == Boolean.TRUE)) { return; } if (change.getCurrentShadow() != null) { ShadowType currentShadowType = change.getCurrentShadow().asObjectable(); if (currentShadowType != null) { // not a useful check..the current shadow could be null assertNotNull("Current shadow does not have an OID", change.getCurrentShadow().getOid()); assertNotNull("Current shadow does not have resourceRef", currentShadowType.getResourceRef()); assertNotNull("Current shadow has null attributes", currentShadowType.getAttributes()); assertFalse("Current shadow has empty attributes", ShadowUtil.getAttributesContainer(currentShadowType).isEmpty()); // Check if the shadow is already present in repo try { repositoryService.getObject(currentShadowType.getClass(), currentShadowType.getOid(), null, new OperationResult("mockSyncService.notifyChange")); } catch (Exception e) { AssertJUnit.fail("Got exception while trying to read current shadow " + currentShadowType + ": " + e.getCause() + ": " + e.getMessage()); } // Check resource String resourceOid = ShadowUtil.getResourceOid(currentShadowType); assertFalse("No resource OID in current shadow " + currentShadowType, StringUtils.isBlank(resourceOid)); try { repositoryService.getObject(ResourceType.class, resourceOid, null, new OperationResult("mockSyncService.notifyChange")); } catch (Exception e) { AssertJUnit.fail("Got exception while trying to read resource " + resourceOid + " as specified in current shadow " + currentShadowType + ": " + e.getCause() + ": " + e.getMessage()); } if (change.getCurrentShadow().asObjectable().getKind() == ShadowKindType.ACCOUNT) { ShadowType account = change.getCurrentShadow().asObjectable(); if (supportActivation) { assertNotNull("Current shadow does not have activation", account.getActivation()); assertNotNull("Current shadow activation status is null", account.getActivation().getAdministrativeStatus()); } else { assertNull("Activation sneaked into current shadow", account.getActivation()); } } } } if (change.getOldShadow() != null) { assertNotNull("Old shadow does not have an OID", change.getOldShadow().getOid()); assertNotNull("Old shadow does not have an resourceRef", change.getOldShadow().asObjectable().getResourceRef()); } if (change.getObjectDelta() != null) { assertNotNull("Delta has null OID", change.getObjectDelta().getOid()); } if (changeChecker != null) { changeChecker.check(change); } // remember ... callCountNotifyChange++; lastChange = change; }
From source file:com.evolveum.midpoint.provisioning.impl.mock.SynchornizationServiceMock.java
private void notifyOp(String notificationDesc, ResourceOperationDescription opDescription, Task task, OperationResult parentResult, boolean failure) { LOGGER.debug("Notify " + notificationDesc + " mock called with:\n{}", opDescription.debugDump()); // Some basic sanity checks assertNotNull("No op description", opDescription); assertNotNull("No task", task); assertNotNull("No result", opDescription.getResult()); assertNotNull("No resource", opDescription.getResource()); assertNotNull("No parent result", parentResult); assertNotNull("Current shadow not present", opDescription.getCurrentShadow()); assertNotNull("Delta not present", opDescription.getObjectDelta()); if (opDescription.getCurrentShadow() != null) { ShadowType currentShadowType = opDescription.getCurrentShadow().asObjectable(); if (currentShadowType != null) { // not a useful check..the current shadow could be null if (!failure) { assertNotNull("Current shadow does not have an OID", opDescription.getCurrentShadow().getOid()); assertNotNull("Current shadow has null attributes", currentShadowType.getAttributes()); assertFalse("Current shadow has empty attributes", ShadowUtil.getAttributesContainer(currentShadowType).isEmpty()); }//from w w w. j ava 2s . c om assertNotNull("Current shadow does not have resourceRef", currentShadowType.getResourceRef()); // Check if the shadow is already present in repo (if it is not a delete case) if (!opDescription.getObjectDelta().isDelete() && !failure) { try { repositoryService.getObject(currentShadowType.getClass(), currentShadowType.getOid(), null, new OperationResult("mockSyncService." + notificationDesc)); } catch (Exception e) { AssertJUnit.fail("Got exception while trying to read current shadow " + currentShadowType + ": " + e.getCause() + ": " + e.getMessage()); } } // Check resource String resourceOid = ShadowUtil.getResourceOid(currentShadowType); assertFalse("No resource OID in current shadow " + currentShadowType, StringUtils.isBlank(resourceOid)); try { repositoryService.getObject(ResourceType.class, resourceOid, null, new OperationResult("mockSyncService." + notificationDesc)); } catch (Exception e) { AssertJUnit.fail("Got exception while trying to read resource " + resourceOid + " as specified in current shadow " + currentShadowType + ": " + e.getCause() + ": " + e.getMessage()); } // FIXME: enable this check later..but for example, opendj // resource does not have native capability and if the reosurce // does not have sprecified simulated capability, this will // produce an error // if (opDescription.getCurrentShadow().asObjectable() instanceof AccountShadowType) { // AccountShadowType account = (AccountShadowType) opDescription.getCurrentShadow().asObjectable(); // assertNotNull("Current shadow does not have activation", account.getActivation()); // assertNotNull("Current shadow activation/enabled is null", account.getActivation() // .isEnabled()); // } else { // // We don't support other types now // AssertJUnit.fail("Unexpected type of shadow " + opDescription.getCurrentShadow().getClass()); // } } } if (opDescription.getObjectDelta() != null && !failure) { assertNotNull("Delta has null OID", opDescription.getObjectDelta().getOid()); } if (changeChecker != null) { changeChecker.check(opDescription); } // remember ... callCountNotifyOperation++; lastOperationDescription = opDescription; }
From source file:com.oneops.opamp.util.EventUtil.java
/** * This is a convenient api to determine, if the event should trigger * notification. True only if there is a change in state of CI or relation * attribute of 'watchedBy' on ci is set to true. * // ww w . j a va2 s .c o m * @param event * The change event got from the sensor. * @param oEvent * the Underlying opsEvent which resulted this event. * @return true if notification needs to be generated ,false otherwise. * @throws OpampException * If manifestId could not be determined for some reason and * hence the NOTE: The oEvent could be derived from * <code>CiChangeStateEvent</code>,this provides where you have * marshaled the payload already into ops event. */ public boolean shouldNotify(CiChangeStateEvent event, OpsBaseEvent oEvent) throws OpampException { // default to Notify true;dont skip notification i boolean shouldNotify = true; String notifyOnStateChangeEvent = null; // change in event state; trigger notification // if new event notify. logger.debug(gson.toJson(oEvent)); if (oEvent.getStatus().equals(Status.NEW)) { shouldNotify = true; } else { // check if notifyOnStateChangeEvent is set on the relation, // notify only if state changes String key = getKey(oEvent); try { notifyOnStateChangeEvent = getCache().instance().get(key); } catch (Exception e) { // in case the attribute is not obtained, the default value is // to notifyOnlyOnStateChange notifyOnStateChangeEvent = TRUE_VALUE; logger.warn("Could not obtain the attribute " + NOTIFY_ON_STATE_CHANGE_ATTR + " for key:" + key); logger.error("Error occured while getting the attribute value", e.getCause()); } // by default notify only when there are state changes. shouldNotify = (StringUtils.isEmpty(notifyOnStateChangeEvent) || TRUE_VALUE.equalsIgnoreCase(notifyOnStateChangeEvent)) ? false : true; } logger.info("notify " + shouldNotify + " for cid: " + event.getCiId() + " " + oEvent.getSource() + " state " + oEvent.getState() + " status " + oEvent.getStatus() + " ostate:" + event.getOldState() + " nstate: " + event.getNewState() + " relattrval: " + notifyOnStateChangeEvent); return shouldNotify; }
From source file:fedora.server.security.servletfilters.pubcookie.ConnectPubcookie.java
public final void connect(String urlString, Map requestParameters, Cookie[] requestCookies, String truststoreLocation, String truststorePassword) { log.debug(this.getClass().getName() + ".connect() " + " url==" + urlString + " requestParameters==" + requestParameters + " requestCookies==" + requestCookies); responseCookies2 = null;//from w w w .j a v a2 s . co m URL url = null; try { url = new URL(urlString); } catch (MalformedURLException mue) { log.error(this.getClass().getName() + ".connect() " + "bad configured url==" + urlString); } if (urlString.startsWith("https:") && null != truststoreLocation && !"".equals(truststoreLocation) && null != truststorePassword && !"".equals(truststorePassword)) { log.debug("setting " + FilterPubcookie.TRUSTSTORE_LOCATION_KEY + " to " + truststoreLocation); System.setProperty(FilterPubcookie.TRUSTSTORE_LOCATION_KEY, truststoreLocation); log.debug("setting " + FilterPubcookie.TRUSTSTORE_PASSWORD_KEY + " to " + truststorePassword); System.setProperty(FilterPubcookie.TRUSTSTORE_PASSWORD_KEY, truststorePassword); log.debug("setting " + FilterPubcookie.KEYSTORE_LOCATION_KEY + " to " + truststoreLocation); System.setProperty(FilterPubcookie.KEYSTORE_LOCATION_KEY, truststoreLocation); log.debug("setting " + FilterPubcookie.KEYSTORE_PASSWORD_KEY + " to " + truststorePassword); System.setProperty(FilterPubcookie.KEYSTORE_PASSWORD_KEY, truststorePassword); System.setProperty("javax.net.debug", "ssl,handshake,data,trustmanager"); } else { log.debug("DIAGNOSTIC urlString==" + urlString); log.debug("didn't set " + FilterPubcookie.TRUSTSTORE_LOCATION_KEY + " to " + truststoreLocation); log.debug("didn't set " + FilterPubcookie.TRUSTSTORE_PASSWORD_KEY + " to " + truststorePassword); } /* * log.debug("\n-a-"); Protocol easyhttps = null; try { easyhttps = new * Protocol("https", (ProtocolSocketFactory) new * EasySSLProtocolSocketFactory(), 443); } catch (Throwable t) { * log.debug(t); log.debug(t.getMessage()); if (t.getCause() != null) * log.debug(t.getCause().getMessage()); } log.debug("\n-b-"); * Protocol.registerProtocol("https", easyhttps); log.debug("\n-c-"); */ HttpClient client = new HttpClient(); log.debug(this.getClass().getName() + ".connect() " + " b4 calling setup"); log.debug(this.getClass().getName() + ".connect() requestCookies==" + requestCookies); HttpMethodBase method = setup(client, url, requestParameters, requestCookies); log.debug(this.getClass().getName() + ".connect() " + " after calling setup"); int statusCode = 0; try { log.debug(this.getClass().getName() + ".connect() " + " b4 calling executeMethod"); client.executeMethod(method); log.debug(this.getClass().getName() + ".connect() " + " after calling executeMethod"); statusCode = method.getStatusCode(); log.debug( this.getClass().getName() + ".connect() " + "(with configured url) statusCode==" + statusCode); } catch (Exception e) { log.error(this.getClass().getName() + ".connect() " + "failed original connect, url==" + urlString); log.error(e); log.error(e.getMessage()); if (e.getCause() != null) { log.error(e.getCause().getMessage()); } e.printStackTrace(); } log.debug(this.getClass().getName() + ".connect() " + " status code==" + statusCode); if (302 == statusCode) { Header redirectHeader = method.getResponseHeader("Location"); if (redirectHeader != null) { String redirectString = redirectHeader.getValue(); if (redirectString != null) { URL redirectURL = null; try { redirectURL = new URL(redirectString); method = setup(client, redirectURL, requestParameters, requestCookies); } catch (MalformedURLException mue) { log.error(this.getClass().getName() + ".connect() " + "bad redirect, url==" + urlString); } statusCode = 0; try { client.executeMethod(method); statusCode = method.getStatusCode(); log.debug(this.getClass().getName() + ".connect() " + "(on redirect) statusCode==" + statusCode); } catch (Exception e) { log.error(this.getClass().getName() + ".connect() " + "failed redirect connect"); } } } } if (statusCode == 200) { // this is either the original, non-302, status code or the status code after redirect log.debug(this.getClass().getName() + ".connect() " + "status code 200"); String content = null; try { log.debug(this.getClass().getName() + ".connect() " + "b4 gRBAS()"); content = method.getResponseBodyAsString(); log.debug(this.getClass().getName() + ".connect() " + "after gRBAS() content==" + content); } catch (IOException e) { log.error(this.getClass().getName() + ".connect() " + "couldn't get content"); return; } if (content == null) { log.error(this.getClass().getName() + ".connect() content==null"); return; } else { log.debug(this.getClass().getName() + ".connect() content != null, about to new Tidy"); Tidy tidy = null; try { tidy = new Tidy(); } catch (Throwable t) { log.debug("new Tidy didn't"); log.debug(t); log.debug(t.getMessage()); if (t != null) { log.debug(t.getCause().getMessage()); } } log.debug(this.getClass().getName() + ".connect() after newing Tidy, tidy==" + tidy); byte[] inputBytes = content.getBytes(); log.debug(this.getClass().getName() + ".connect() A1"); ByteArrayInputStream inputStream = new ByteArrayInputStream(inputBytes); log.debug(this.getClass().getName() + ".connect() A2"); responseDocument = tidy.parseDOM(inputStream, null); //use returned root node as only output log.debug(this.getClass().getName() + ".connect() A3"); } log.debug(this.getClass().getName() + ".connect() " + "b4 getState()"); HttpState state = client.getState(); log.debug(this.getClass().getName() + ".connect() state==" + state); try { responseCookies2 = method.getRequestHeaders(); log.debug(this.getClass().getName() + ".connect() just got headers"); for (Header element : responseCookies2) { log.debug(this.getClass().getName() + ".connect() header==" + element); } responseCookies = state.getCookies(); log.debug(this.getClass().getName() + ".connect() responseCookies==" + responseCookies); } catch (Throwable t) { log.error(this.getClass().getName() + ".connect() exception==" + t.getMessage()); if (t.getCause() != null) { log.error(this.getClass().getName() + ".connect() cause==" + t.getCause().getMessage()); } } completedFully = true; log.debug(this.getClass().getName() + ".connect() completedFully==" + completedFully); } }
From source file:pl.nask.hsn2.service.task.WebClientObjectTreeNode.java
private String getReason(Exception e, String alternativeMsg) { String msg = e.getMessage();//from w w w.jav a2 s . com if (msg != null) { return msg; } else { Throwable cause = e.getCause(); if (cause != null && cause.getMessage() != null) { return cause.getMessage(); } else { return alternativeMsg; } } }
From source file:Verifier.java
/** * Verifies whether expectation is met based on the instance's values. * The values to compare come in as strings. * getCls() indicates whether or not the class of the objects to compare is not the (default) String. * @throws Exception/* w w w. ja v a2s.co m*/ */ public void verify() throws Exception { if (getCls().equalsIgnoreCase("string")) setCls(""); // String is the default class we deal with // If appropriate, perform the blank verification (the Actual value is (or is not) blank / null / empty) // This is done before having to convert the (possibly empty) actual value to some object... if (isBlankVerification()) { verifyBlank(); return; } try { switch (getCls().toLowerCase()) { case "": verifyStrings(); break; case "int": case "integer": { IntegerVerifier verifier = new IntegerVerifier(getEv(), getAv(), getComp(), getOpt(), getCls(), getStripWhiteSpace()); if (isBlank(verifier.getErrors())) verifier.verify(); addComment(verifier.getComments()); addError(verifier.getErrors()); break; } case "long": { LongVerifier verifier = new LongVerifier(getEv(), getAv(), getComp(), getOpt(), getCls(), getStripWhiteSpace()); if (isBlank(verifier.getErrors())) verifier.verify(); addComment(verifier.getComments()); addError(verifier.getErrors()); break; } case "double": case "float": case "decimal": { DecimalVerifier verifier = new DecimalVerifier(getEv(), getAv(), getComp(), getOpt(), getCls(), getStripWhiteSpace()); if (isBlank(verifier.getErrors())) verifier.verify(); addComment(verifier.getComments()); addError(verifier.getErrors()); break; } case "amount": case "currency": case "money": { AmountVerifier verifier = new AmountVerifier(getEv(), getAv(), getComp(), getOpt(), getCls(), getStripWhiteSpace()); if (isBlank(verifier.getErrors())) verifier.verify(); addComment(verifier.getComments()); addError(verifier.getErrors()); break; } case "date": { DateVerifier verifier = new DateVerifier(getEv(), getAv(), getComp(), getOpt(), getCls(), getStripWhiteSpace()); if (isBlank(verifier.getErrors())) verifier.verify(); addComment(verifier.getComments()); addError(verifier.getErrors()); break; } default: addError("Invalid object class specified: " + Util.sq(getCls())); } // Switch } //Try catch (Exception e) { addError("Verifier generated general exception " + e.getCause().toString()); } }