List of usage examples for java.lang Exception Exception
public Exception(Throwable cause)
From source file:com.thoughtworks.go.config.validation.CommandRepositoryLocationValidator.java
public void validate(CruiseConfig cruiseConfig) throws Exception { String taskRepositoryLocation = cruiseConfig.server().getCommandRepositoryLocation(); if (taskRepositoryLocation == null || isEmpty(taskRepositoryLocation.trim())) { throw new Exception("Command Repository Location cannot be empty"); }/*w ww .j av a2s . c o m*/ if (taskRepositoryLocation.startsWith("/") || taskRepositoryLocation.startsWith("\\") || taskRepositoryLocation.contains("~") || taskRepositoryLocation.contains(":")) { throw new Exception("Invalid Repository Location"); } String taskRepositoryRootLocation = systemEnvironment.get(COMMAND_REPOSITORY_DIRECTORY); File taskRepositoryRootDirectory = new File(taskRepositoryRootLocation); File repository = new File(taskRepositoryRootLocation, taskRepositoryLocation); if (!FileUtil.isChildOf(taskRepositoryRootDirectory, repository)) { throw new Exception( String.format("Invalid Repository Location, repository should be a subdirectory under %s", taskRepositoryRootDirectory.getAbsolutePath())); } }
From source file:com.card.loop.xyz.service.LearningElementService.java
public boolean demoteLE(LearningElementDto le) throws UnknownHostException, Exception { boolean ok = false; LearningElement model = dao.getLE(le.getId()); if (model != null) { model.setStatus(0);/*w w w. j a v a2 s . co m*/ dao.demoteLE(model); ok = true; } else throw new Exception("LearningElement does not exist. "); return ok; }
From source file:com.myapp.common.AES4MEncrypt.java
/** * //from www .ja v a2 s . c om * * @param sSrc ? * @param sKey KEY * @return * @throws Exception * @author cdduqiang * @date 201443 */ public static String decrypt(String sSrc, String sKey) throws Exception { if (sKey == null) { log.error("Decrypt Key ??"); throw new Exception("Decrypt Key ??"); } byte[] raw = hex2byte(sKey); SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES"); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); IvParameterSpec iv = new IvParameterSpec("0102030405060708".getBytes()); cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv); byte[] encrypted1 = hex2byte(sSrc); byte[] original = cipher.doFinal(encrypted1); return new String(original, ENCODING);// anslBytes2String(original); }
From source file:feedzilla.Feed.java
public Feed(int category, int subcategory, Element entry) throws Exception { this.category = category; this.subcategory = subcategory; parser(entry);// w w w .j a v a 2 s . c o m if (verifyIfNewsAlredyExists()) { throw new Exception("News " + this.category + "/" + this.subcategory + "/" + newsXMLFile.getName() + " - Already Exists"); } }
From source file:controllers.GWT2Controller.java
public static void invoke(String module, String service) throws Exception { // find the module GWT2Module mod = GWT2Plugin.getModule(module, service); if (mod == null) notFound("module not found !"); if (mod.service == null) throw new NullArgumentException("module.service is null"); // create service instance GWT2Service gwtService;//from w w w.j a v a 2 s. co m try { gwtService = (GWT2Service) mod.service.newInstance(); if (!GWT2Service.class.isAssignableFrom(mod.service)) throw new Exception("module.service is not GWT2Service instance"); } catch (Exception e) { StackTraceElement element = PlayException.getInterestingStrackTraceElement(e); if (element != null) { throw new JavaExecutionException(Play.classes.getApplicationClass(element.getClassName()), element.getLineNumber(), e); } throw new JavaExecutionException(e); } // decode rpc request RPCRequest rpcRequest = RPC.decodeRequest(IO.readContentAsString(request.body), gwtService.getClass(), gwtService); // response load String responseload = null; // check GWT2ServiceAsync GWT2ServiceAsync gwt2AsyncCall = mod.service.getAnnotation(GWT2ServiceAsync.class); if (gwt2AsyncCall != null && gwt2AsyncCall.value()) { // async invokation responseload = invokeAsync(gwtService, rpcRequest); } else { // synced invokation // bt service can use GWT2Chain to do async job responseload = invoke(gwtService, rpcRequest); } renderText(responseload); }
From source file:com.ferdinan.belajar.web.model.service.controller.RoleController.java
@RequestMapping(value = "/role", method = RequestMethod.POST) public void simpanData(@RequestBody Role role) throws Exception { if (role == null) { throw new Exception("Role tidak boleh null"); }// ww w.j a va 2 s . c om roleService.save(role); }
From source file:com.liferay.mobile.android.v62.contact.ContactService.java
public JSONObject getContact(long contactId) throws Exception { JSONObject _command = new JSONObject(); try {//from www.j a v a 2 s. c o m JSONObject _params = new JSONObject(); _params.put("contactId", contactId); _command.put("/contact/get-contact", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getJSONObject(0); }
From source file:com.artivisi.salary.payroll.system.controller.PinjamanController.java
@RequestMapping(value = "/pinjaman", method = RequestMethod.POST) public void savePinjaman(@RequestBody Pinjaman pinjaman) throws Exception { if (pinjaman == null) { throw new Exception("User tidak boleh kosong"); }//from w w w . j av a2 s . co m pinjamanService.save(pinjaman); }
From source file:com.artivisi.salary.payroll.system.controller.PotonganController.java
@RequestMapping(value = "/potongan", method = RequestMethod.POST) public void savePotongan(@RequestBody Potongan potongan) throws Exception { if (potongan == null) { throw new Exception("User tidak boleh kosong"); }/*from w w w . j a v a 2 s .c o m*/ potonganService.save(potongan); }
From source file:com.termmed.reconciliation.test.IdReconciliationTest.java
/** * Test id reconciliation.// ww w . j a v a 2 s . c om * * @throws Exception the exception */ public void testIdReconciliation() throws Exception { File TestGroupMumberReconciliationFile = new File( "src/test/resources/com/termmed/reconciliation/test/IdReconciliationConfig.xml"); if (!TestGroupMumberReconciliationFile.exists()) { throw new Exception("Config file for testGroupMumberReconciliation doesn't exist."); } RelationshipReconciliation cc = new RelationshipReconciliation(TestGroupMumberReconciliationFile); cc.execute(); String outputFile = getOutputFile(TestGroupMumberReconciliationFile); ArrayList<Relationship> outputRelationships = new ArrayList<Relationship>(); String[] outputFiles = new String[] { outputFile }; loadOutputInferredRelationship(outputFiles, outputRelationships, 1); String[] previousFiles = getPreviousFile(TestGroupMumberReconciliationFile); ArrayList<Relationship> previousRelationships = new ArrayList<Relationship>(); loadOutputInferredRelationship(previousFiles, previousRelationships, 1); for (Relationship prevRelationship : previousRelationships) { Relationship outputRelationship = getSameReconciledRel(prevRelationship, outputRelationships); if (outputRelationship != null) { assertTrue(outputRelationship.sourceId == prevRelationship.sourceId && outputRelationship.destinationId == prevRelationship.destinationId && outputRelationship.typeId == prevRelationship.typeId); } else { assertFalse(existsSameTripleWithoutId(prevRelationship, outputRelationships)); } } }