List of usage examples for java.lang Exception getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:iddb.web.security.service.CommonUserService.java
@Override public Subject getCurrentUser() { try {//from w w w. j a v a 2 s .co m return getContext().getSubject(); } catch (Exception e) { log.error("{}: {}", e.getClass().getName(), e.getMessage()); return new AnonymousSubject(); } }
From source file:com.ericsson.eiffel.remrem.semantics.validator.EiffelValidator.java
public EiffelValidator(String schemaResourceName, String eventType, List<String> requiredLinkTypes, List<String> optionalLinkTypes, List<String> allLinkTypes) { this.schemaResourceName = schemaResourceName; this.eventType = eventType; this.requiredLinkTypes = requiredLinkTypes; this.optionalLinkTypes = optionalLinkTypes; this.allLinkTypes = allLinkTypes; ObjectMapper mapper = new ObjectMapper(); JsonSchemaFactory factory = JsonSchemaFactory.byDefault(); ClassLoader classLoader = getClass().getClassLoader(); try {/*from w w w .ja v a 2s . c o m*/ validationSchema = factory .getJsonSchema(mapper.readTree(classLoader.getResourceAsStream(schemaResourceName))); log.debug("Validation schema loaded: {}", schemaResourceName); } catch (Exception e) { String message = "Cannot parse JSON schema. The resource: " + schemaResourceName + ". " + e.getClass() + ": " + e.getMessage(); log.error(message, e); throw new IllegalArgumentException(message, e); } }
From source file:com.dojo.parkinglot.resource.ParkingResource.java
@POST @Path(EXIT_RESOURCE)//w w w.j a v a 2 s . c o m @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces(MediaType.TEXT_HTML) public Response exit(@FormParam("licensePlate") String licensePlate) { LOG.debug(String.format("licensePLate: '%s'.", licensePlate)); if (StringUtils.isBlank(licensePlate)) { return Response.status(Status.PRECONDITION_FAILED).build(); } if (!parkingService.getParkingLot().isParked(licensePlate)) { ExitFailureModel model = new ExitFailureModel(licensePlate, "this vehicle is not parked here!"); return Response.status(Status.BAD_REQUEST) .entity(new Viewable(getFailureTemplate(EXIT_RESOURCE), model)).build(); } try { ParkingTicket ticket = parkingService.releaseSpace(licensePlate); ExitSuccessModel model = new ExitSuccessModel(ticket); return Response.ok().entity(new Viewable(getSuccessTemplate(EXIT_RESOURCE), model)).build(); } catch (Exception ex) { ExitFailureModel model = new ExitFailureModel(licensePlate, "error processing exit request..." + ex.getClass()); ex.printStackTrace(); return Response.status(Status.INTERNAL_SERVER_ERROR) .entity(new Viewable(getFailureTemplate(EXIT_RESOURCE), model)).build(); } }
From source file:org.opendaylight.sfc.sbrest.json.SffExporterTest.java
@Test // put wrong parameter, illegal argument exception expected public void testExportJsonException() throws Exception { ServiceFunctionGroupBuilder serviceFunctionGroupBuilder = new ServiceFunctionGroupBuilder(); SffExporter sffExporter = new SffExporter(); try {//w ww. j a va 2 s.c o m sffExporter.exportJson(serviceFunctionGroupBuilder.build()); } catch (Exception exception) { assertEquals("Must be true", exception.getClass(), IllegalArgumentException.class); } try { sffExporter.exportJsonNameOnly(serviceFunctionGroupBuilder.build()); } catch (Exception exception) { assertEquals("Must be true", exception.getClass(), IllegalArgumentException.class); } }
From source file:org.scrutmydocs.webapp.service.settings.rivers.RiverService.java
/** * Start a river//from w ww. j a va 2s.c o m * @param river The river to start * @param xb JSON River definition */ public void start(BasicRiver river, XContentBuilder xb) { if (logger.isDebugEnabled()) logger.debug("add({})", river); // If our river is a FS River for document, we can manage the index creation if (river instanceof AbstractFSRiver) { AbstractFSRiver fsriver = (AbstractFSRiver) river; createIndexIfNeeded(fsriver); } try { client.prepareIndex("_river", river.getId(), "_meta").setRefresh(true).setSource(xb).execute().isDone(); boolean riverStarted = false; int nbChecks = 0; // We try 30 times before stopping while (!riverStarted && nbChecks++ < 30) { riverStarted = checkState(river); // We wait for 1 second Thread.sleep(1000); } } catch (Exception e) { logger.warn("add({}) : Exception raised : {}", river, e.getClass()); if (logger.isDebugEnabled()) logger.debug("- Exception stacktrace :", e); } if (logger.isDebugEnabled()) logger.debug("/add({})", river); }
From source file:com.clustercontrol.jmx.session.JmxMasterControllerBean.java
/** * JMX ????// w ww . j av a 2 s .c o m * * @return ??????true * @throws HinemosUnknown */ public boolean deleteJmxMasterAll() throws HinemosUnknown { JpaTransactionManager jtm = null; boolean ret = false; try { jtm = new JpaTransactionManager(); jtm.begin(); HinemosEntityManager em = jtm.getEntityManager(); List<JmxMasterInfo> entities = em.createNamedQuery("MonitorJmxMstEntity.findAll", JmxMasterInfo.class) .getResultList(); for (JmxMasterInfo entity : entities) { // ? em.remove(entity); } jtm.commit(); ret = true; } catch (Exception e) { m_log.warn("deleteJmxMasterAll() : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e); if (jtm != null) jtm.rollback(); throw new HinemosUnknown(e.getMessage(), e); } finally { if (jtm != null) { jtm.close(); } } return ret; }
From source file:com.clustercontrol.jmx.session.JmxMasterControllerBean.java
/** * JMX ???//from w ww . j a va 2 s .c om * * @return ??????true * @throws HinemosUnknown */ public boolean deleteJmxMasterList(List<String> ids) throws HinemosUnknown { JpaTransactionManager jtm = null; boolean ret = false; try { jtm = new JpaTransactionManager(); jtm.begin(); HinemosEntityManager em = jtm.getEntityManager(); List<JmxMasterInfo> entities = em.createNamedQuery("MonitorJmxMstEntity.findList", JmxMasterInfo.class) .setParameter("ids", ids).getResultList(); for (JmxMasterInfo entity : entities) { // ? em.remove(entity); } jtm.commit(); ret = true; } catch (Exception e) { m_log.warn("deleteJmxMasterList() : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e); if (jtm != null) jtm.rollback(); throw new HinemosUnknown(e.getMessage(), e); } finally { if (jtm != null) { jtm.close(); } } return ret; }
From source file:org.jongo.AggregateTest.java
@Test public void shouldCheckIfCommandHasErrors() throws Exception { try {//from ww w. j a v a 2 s.co m collection.aggregate("{$invalid:{}}").as(Article.class); fail(); } catch (Exception e) { assertThat(MongoCommandException.class).isAssignableFrom(e.getClass()); } }
From source file:org.scrutmydocs.webapp.service.settings.rivers.RiverService.java
/** * Check if the river exists and if it's started * @param river//from w ww .j av a2 s . c o m */ public boolean checkState(BasicRiver river) { if (logger.isDebugEnabled()) logger.debug("checkState({})", river); // We only check the river if you provide its definition if (river == null) return false; try { GetResponse responseEs = client.prepareGet("_river", river.getId(), "_status").execute().actionGet(); if (!responseEs.isExists()) { return false; } // We can also check if status is ok Map<String, Object> source = responseEs.sourceAsMap(); if (source != null) { boolean status = FSRiverHelper.getSingleBooleanValue("ok", source); if (status) return true; } } catch (Exception e) { logger.warn("checkState({}) : Exception raised : {}", river, e.getClass()); if (logger.isDebugEnabled()) logger.debug("- Exception stacktrace :", e); } if (logger.isDebugEnabled()) logger.debug("/checkState({})", river); return false; }
From source file:net.community.chest.gitcloud.facade.AbstractContextInitializer.java
protected void scanArtifactsManifests(Predicate<Pair<URL, Manifest>> manifestHandler) { ClassLoader loader = ExtendedClassUtils.getDefaultClassLoader(getClass()); try {// ww w .j a v a 2 s . c om for (Enumeration<URL> manifests = loader.getResources(JarFile.MANIFEST_NAME); (manifests != null) && manifests.hasMoreElements();) { URL url = manifests.nextElement(); try { Manifest manifest = ManifestUtils.loadManifest(url); if (manifestHandler.evaluate(Pair.of(url, manifest))) { logger.info("Scanning stopped by handler at URL=" + url.toExternalForm()); break; } } catch (Exception e) { logger.warn(e.getClass().getSimpleName() + " while handle URL=" + url.toExternalForm() + ": " + e.getMessage()); } } } catch (IOException e) { logger.warn("Failed (" + e.getClass().getSimpleName() + ") to get manifests URLs: " + e.getMessage()); } }