List of usage examples for com.google.common.io Resources getResource
public static URL getResource(Class<?> contextClass, String resourceName)
From source file:org.sonar.server.language.ws.ListAction.java
void define(WebService.NewController controller) { NewAction action = controller.createAction("list").setDescription("List supported programming languages") .setSince("5.1").setHandler(this) .setResponseExample(Resources.getResource(getClass(), "example-list.json")); action.createParam(Param.TEXT_QUERY).setDescription("A pattern to match language keys/names against") .setExampleValue("java"); action.createParam("ps").setDescription("The size of the list to return, 0 for all languages") .setExampleValue("25").setDefaultValue("0"); }
From source file:org.sonar.server.project.ws.IndexAction.java
@Override public void define(WebService.NewController context) { WebService.NewAction action = context.createAction(ACTION_INDEX) .setDescription("This web service is deprecated, please use api/components/search instead") .setSince("2.10").setDeprecatedSince("6.3").setHandler(this) .setResponseExample(Resources.getResource(this.getClass(), "index-example.json")); action.setChangelog(/*from www . ja va 2 s . c o m*/ new Change("6.3", "The parameters 'desc', 'views', 'libs' and 'versions' have no effect.")); action.createParam(PARAM_PROJECT).setDescription("key or ID of the project").setDeprecatedKey("key", "6.4") .setExampleValue(KEY_PROJECT_EXAMPLE_001); action.createParam(PARAM_SEARCH) .setDescription("Substring of project name, case insensitive. Ignored if the parameter key is set") .setExampleValue("Sonar"); action.createParam(PARAM_SUB_PROJECTS) .setDescription("Load sub-projects. Ignored if the parameter key is set").setDefaultValue("false") .setBooleanPossibleValues(); action.createParam(PARAM_FORMAT).setDescription("Only json response format is available") .setPossibleValues("json"); addRemovedParameter("desc", action); addRemovedParameter("views", action); addRemovedParameter("libs", action); addRemovedParameter("versions", action); }
From source file:co.jirm.core.util.ResourceUtils.java
private static String _getClasspathResourceAsString(Class<?> k, String path) throws IOException { return Resources.toString(Resources.getResource(k, path), Charsets.UTF_8); }
From source file:org.arkhamnetwork.uuid.ArkhamUUIDLogger.java
private void setupSQLTables() throws IOException, SQLException { URL resource = Resources.getResource(ArkhamUUIDLogger.class, "/tables.sql"); String[] databaseStructure = Resources.toString(resource, Charsets.UTF_8).split(";"); if (databaseStructure.length == 0) { return;//from ww w. j a va 2s .c o m } Statement statement = null; try { C.setAutoCommit(false); statement = C.createStatement(); for (String query : databaseStructure) { query = query.trim(); if (query.isEmpty()) { continue; } statement.execute(query); } C.commit(); } finally { C.setAutoCommit(true); if (statement != null && !statement.isClosed()) { statement.close(); } } }
From source file:org.sonar.server.webhook.ws.WebhookDeliveryAction.java
@Override public void define(WebService.NewController controller) { WebService.NewAction action = controller.createAction("delivery").setSince("6.2") .setDescription(// w w w . ja v a2 s .c om "Get a webhook delivery by its id.<br/>" + "Require 'Administer System' permission.<br/>" + "Note that additional information are returned by api/webhooks/delivery.") .setResponseExample(Resources.getResource(this.getClass(), "example-delivery.json")) .setHandler(this); action.createParam(PARAM_ID).setDescription("Id of delivery").setRequired(true) .setExampleValue(Uuids.UUID_EXAMPLE_06); }
From source file:org.sonar.server.duplication.ws.ShowAction.java
void define(WebService.NewController controller) { WebService.NewAction action = controller.createAction("show") .setDescription("Get duplications. Require Browse permission on file's project").setSince("4.4") .setHandler(this).setResponseExample(Resources.getResource(this.getClass(), "example-show.json")); action.createParam("key").setDescription("File key").setExampleValue("my_project:/src/foo/Bar.php"); action.createParam("uuid").setDescription("File UUID") .setExampleValue("584a89f2-8037-4f7b-b82c-8b45d2d63fb2"); }
From source file:com.msiiplab.recsys.rwr.GroupLensDataModel.java
public static File readResourceToTempFile(String resourceName) throws IOException { InputSupplier<? extends InputStream> inSupplier; try {//from www.jav a 2 s .c o m URL resourceURL = Resources.getResource(Recommender.class, resourceName); inSupplier = Resources.newInputStreamSupplier(resourceURL); } catch (IllegalArgumentException iae) { File resourceFile = new File(resourceName); inSupplier = Files.newInputStreamSupplier(resourceFile); } File tempFile = File.createTempFile("taste", null); tempFile.deleteOnExit(); Files.copy(inSupplier, tempFile); return tempFile; }
From source file:uk.co.blackpepper.support.okhttp.test.MockWebServerRule.java
protected final String getContent(String name) throws IOException { return Resources.toString(Resources.getResource(getClass(), name), Charsets.UTF_8); }
From source file:de.ii.ldproxy.rest.filter.RestRootFilter.java
private void writeContent(ContainerResponse response, final String file, final String mimeType) { response.reset();//from w w w . j a v a 2 s . c o m StreamingOutput stream = new StreamingOutput() { @Override public void write(OutputStream output) throws IOException, WebApplicationException { Resources.asByteSource(Resources.getResource(DatasetView.class, file)).copyTo(output); } }; Response r = Response.ok(stream, mimeType).build(); response.setResponse(r); }
From source file:org.sonar.server.computation.ws.ActiveAnalysisReportsAction.java
void define(WebService.NewController controller) { controller.createAction("active").setDescription("List all the active analysis reports").setSince("5.0") .setResponseExample(Resources.getResource(getClass(), "example-list.json")).setHandler(this); }