List of usage examples for java.lang Error Error
public Error(Throwable cause)
From source file:com.extremeboredom.wordattack.utils.JSONUtils.java
private JSONUtils() { throw new Error("Do not need instantiate!"); //No i18n }
From source file:io.servicecomb.swagger.generator.springmvc.processor.annotation.RequestMappingMethodAnnotationProcessor.java
@Override public void process(Object annotation, OperationGenerator operationGenerator) { RequestMapping requestMapping = (RequestMapping) annotation; Operation operation = operationGenerator.getOperation(); // path/value? this.processPath(requestMapping.path(), operationGenerator); this.processPath(requestMapping.value(), operationGenerator); this.processMethod(requestMapping.method(), operationGenerator); this.processConsumes(requestMapping.consumes(), operation); this.processProduces(requestMapping.produces(), operation); if (StringUtils.isEmpty(operationGenerator.getHttpMethod()) && StringUtils.isEmpty(operationGenerator.getSwaggerGenerator().getHttpMethod())) { throw new Error("HttpMethod must not both be empty in class and method"); }/*from w ww . j a va 2s . co m*/ }
From source file:io.servicecomb.swagger.generator.springmvc.processor.annotation.DeleteMappingMethodAnnotationProcessor.java
@Override public void process(Object annotation, OperationGenerator operationGenerator) { DeleteMapping mappingAnnotation = (DeleteMapping) annotation; Operation operation = operationGenerator.getOperation(); // path/value? this.processPath(mappingAnnotation.path(), operationGenerator); this.processPath(mappingAnnotation.value(), operationGenerator); this.processMethod(RequestMethod.DELETE, operationGenerator); this.processConsumes(mappingAnnotation.consumes(), operation); this.processProduces(mappingAnnotation.produces(), operation); if (StringUtils.isEmpty(operationGenerator.getHttpMethod()) && StringUtils.isEmpty(operationGenerator.getSwaggerGenerator().getHttpMethod())) { throw new Error("HttpMethod must not both be empty in class and method"); }//from w ww. j ava2 s . c o m }
From source file:chat.Models.java
/** @param test whether use the testing database */ public static AnnotationConfiguration build(boolean test) throws Exception { AnnotationConfiguration conf = new AnnotationConfiguration() { private static final long serialVersionUID = 1L; @Override// w w w . j a va2 s .c o m public SessionFactory buildSessionFactory() throws HibernateException { if (!"org.hsqldb.jdbcDriver".equals(getProperty(Environment.DRIVER))) return super.buildSessionFactory(); // fix the issue of hsqldb write delay stupid default value SessionFactory fac = super.buildSessionFactory(); try { SessionImpl hib = (SessionImpl) fac.openSession(); hib.beginTransaction(); Statement stat = hib.getJDBCContext().borrowConnection().createStatement(); stat.executeUpdate("SET WRITE_DELAY FALSE"); hib.getTransaction().commit(); stat.close(); hib.close(); LOG.info("SET WRITE_DELAY FALSE"); } catch (Exception e) { throw new Error(e); } return fac; } }; InputStreamReader connect = new InputStreamReader( Models.class.getResourceAsStream("/hibernate.connect.properties"), "UTF-8"); conf.getProperties().load(connect); connect.close(); conf.setNamingStrategy(new NamingStrategy() { @Override public String classToTableName(String entity) { return StringHelper.unqualify(entity); } @Override public String propertyToColumnName(String property) { return StringHelper.unqualify(property); } @Override public String tableName(String table) { return table; } @Override public String columnName(String column) { return column; } @Override public String collectionTableName(String ownerEntity, String ownerTable, String associatedEntity, String associatedTable, String property) { return ownerTable + "_" + StringHelper.unqualify(property); } @Override public String joinKeyColumnName(String joinedColumn, String joinedTable) { return joinedColumn; } @Override public String foreignKeyColumnName(String property, String propertyEntity, String propertyTable, String referencedColumn) { return property != null ? StringHelper.unqualify(property) : propertyTable; } @Override public String logicalColumnName(String column, String property) { return StringHelper.isEmpty(column) ? StringHelper.unqualify(property) : column; } @Override public String logicalCollectionTableName(String table, String ownerTable, String associatedTable, String property) { if (table != null) return table; return ownerTable + "_" + StringHelper.unqualify(property); } @Override public String logicalCollectionColumnName(String column, String property, String referencedColumn) { return StringHelper.isEmpty(column) ? property + "_" + referencedColumn : column; } }); for (Class<?> c : Class2.packageClasses(Id.class)) conf.addAnnotatedClass(c); if (!"false".equals(conf.getProperty(Environment.AUTOCOMMIT))) throw new RuntimeException(Environment.AUTOCOMMIT + " must be false"); if (test) conf.setProperty(Environment.URL, conf.getProperty(Environment.URL + ".test")); return conf; }
From source file:com.manydesigns.portofino.actions.admin.tables.forms.DatabaseSelectionProviderForm.java
public DatabaseSelectionProviderForm(DatabaseSelectionProvider copyFrom) { try {//from ww w .ja va 2s . c om BeanUtils.copyProperties(this, copyFrom); } catch (Exception e) { throw new Error(e); } }
From source file:io.servicecomb.swagger.TestSwaggerUtils.java
@Test public void swaggerToStringException(@Mocked Swagger swagger) throws JsonProcessingException { new Expectations() { {/* ww w .j a v a2s.c om*/ swagger.getBasePath(); result = new Error("failed"); } }; expectedException.expect(ServiceCombException.class); expectedException.expectMessage("Convert swagger to string failed, "); SwaggerUtils.swaggerToString(swagger); }
From source file:org.dojotoolkit.zazl.internal.XMLHttpRequestUtils.java
@SuppressWarnings({ "unchecked", "rawtypes" }) public static String xhrRequest(String shrDataString) { InputStream is = null;/* w w w .j av a 2 s. c om*/ String json = null; try { logger.logp(Level.FINER, XMLHttpRequestUtils.class.getName(), "xhrRequest", "shrDataString [" + shrDataString + "]"); Map<String, Object> xhrData = (Map<String, Object>) JSONParser.parse(new StringReader(shrDataString)); String url = (String) xhrData.get("url"); String method = (String) xhrData.get("method"); List headers = (List) xhrData.get("headers"); URL requestURL = createURL(url); URI uri = new URI(requestURL.toString()); HashMap httpMethods = new HashMap(7); httpMethods.put("DELETE", new HttpDelete(uri)); httpMethods.put("GET", new HttpGet(uri)); httpMethods.put("HEAD", new HttpHead(uri)); httpMethods.put("OPTIONS", new HttpOptions(uri)); httpMethods.put("POST", new HttpPost(uri)); httpMethods.put("PUT", new HttpPut(uri)); httpMethods.put("TRACE", new HttpTrace(uri)); HttpUriRequest request = (HttpUriRequest) httpMethods.get(method.toUpperCase()); if (request.equals(null)) { throw new Error("SYNTAX_ERR"); } for (Object header : headers) { StringTokenizer st = new StringTokenizer((String) header, ":"); String name = st.nextToken(); String value = st.nextToken(); request.addHeader(name, value); } HttpClient client = new DefaultHttpClient(); HttpResponse response = client.execute(request); Map headerMap = new HashMap(); HeaderIterator headerIter = response.headerIterator(); while (headerIter.hasNext()) { Header header = headerIter.nextHeader(); headerMap.put(header.getName(), header.getValue()); } int status = response.getStatusLine().getStatusCode(); String statusText = response.getStatusLine().toString(); is = response.getEntity().getContent(); BufferedReader br = new BufferedReader(new InputStreamReader(is)); String line = null; StringBuffer sb = new StringBuffer(); while ((line = br.readLine()) != null) { sb.append(line); sb.append('\n'); } Map m = new HashMap(); m.put("status", new Integer(status)); m.put("statusText", statusText); m.put("responseText", sb.toString()); m.put("headers", headerMap.toString()); StringWriter w = new StringWriter(); JSONSerializer.serialize(w, m); json = w.toString(); logger.logp(Level.FINER, XMLHttpRequestUtils.class.getName(), "xhrRequest", "json [" + json + "]"); } catch (Throwable e) { logger.logp(Level.SEVERE, XMLHttpRequestUtils.class.getName(), "xhrRequest", "Failed request for [" + shrDataString + "]", e); } finally { if (is != null) { try { is.close(); } catch (IOException e) { } } } return json; }
From source file:com.termmed.utils.ResourceUtils.java
/** * Gets the resources from jar file./*from www . ja v a2s. c om*/ * * @param file the file * @param pattern the pattern * @return the resources from jar file */ private static Collection<String> getResourcesFromJarFile(final File file, final Pattern pattern) { final ArrayList<String> retval = new ArrayList<String>(); ZipFile zf; try { zf = new ZipFile(file); } catch (final ZipException e) { throw new Error(e); } catch (final IOException e) { throw new Error(e); } final Enumeration e = zf.entries(); while (e.hasMoreElements()) { final ZipEntry ze = (ZipEntry) e.nextElement(); final String fileName = ze.getName(); final boolean accept = pattern.matcher(fileName).matches(); if (accept) { retval.add(fileName); } } try { zf.close(); } catch (final IOException e1) { throw new Error(e1); } return retval; }
From source file:com.manydesigns.portofino.actions.admin.tables.forms.TableForm.java
public Table copyTo(Table table) { try {//from w w w .java 2 s . c om BeanUtils.copyProperties(table, this); } catch (Exception e) { throw new Error(e); } return table; }
From source file:net.sourceforge.jasa.agent.strategy.AbstractTradingStrategy.java
public Object protoClone() { try {/*from w ww . j ava 2 s. c o m*/ AbstractTradingStrategy copy = (AbstractTradingStrategy) clone(); copy.reset(); return copy; } catch (CloneNotSupportedException e) { throw new Error(e); } }