repo_name
stringlengths
7
104
file_path
stringlengths
13
198
context
stringlengths
67
7.15k
import_statement
stringlengths
16
4.43k
code
stringlengths
40
6.98k
prompt
stringlengths
227
8.27k
next_line
stringlengths
8
795
WASdev/tool.accelerate.core
starter-microservice-template/src/test/java/com/ibm/liberty/starter/service/template/api/v1/it/TestApplication.java
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public class Dependency { // private Scope scope; // private String groupId; // private String artifactId; // private String version; // // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // @ApiModelProperty(required = true) // public Scope getScope() { // return scope; // } // // public void setScope(Scope scope) { // this.scope = scope; // } // // @ApiModelProperty(required = false) // public String getGroupId() { // return groupId; // } // // public void setGroupId(String groupId) { // this.groupId = groupId; // } // // @ApiModelProperty(required = true) // public String getArtifactId() { // return artifactId; // } // // public void setArtifactId(String artifactId) { // this.artifactId = artifactId; // } // // @ApiModelProperty(required = true) // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Location.java // public class Location { // private String path; // private String url; // // public Location(String path, String url) { // this.path = path; // this.url = url; // } // // public Location(String url) { // this.url = url; // } // // public Location() { // //JSON serialisation // } // // @ApiModelProperty(value="Relative path to insert the file within the sample project structure", required=false) // public String getPath() { // return path; // } // public void setPath(String path) { // this.path = path; // } // // @ApiModelProperty(value="URL to retrieve the file from", required=true) // public String getUrl() { // return url; // } // public void setUrl(String url) { // this.url = url; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Provider.java // public class Provider { // private String description; // private Dependency[] dependencies; // private Location repoUrl; // // @ApiModelProperty(value = "Description of the technology provider to be inserted into index.html", required = true) // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value = "Dependencies to be specified to the user when they get the download", required = true) // public Dependency[] getDependencies() { // return dependencies; // } // // public void setDependencies(Dependency[] dependencies) { // this.dependencies = dependencies; // } // // @ApiModelProperty(value = "The location of the repository for this microservice.") // public Location getRepoUrl() { // return repoUrl; // } // // public void setRepoUrl(Location repoUrl) { // this.repoUrl = repoUrl; // } // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Sample.java // public class Sample { // private String base; // private Location[] locations; // // @ApiModelProperty(value="If specified, then this path will be used to create a relative path from any location URLs which do not have a path specified.", required=false) // public String getBase() { // return base; // } // public void setBase(String base) { // this.base = base; // } // // @ApiModelProperty(value="Files which make up the sample", required=true) // public Location[] getLocations() { // return locations; // } // public void setLocations(Location[] locations) { // this.locations = locations; // } // // // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; import com.ibm.liberty.starter.api.v1.model.provider.Dependency; import com.ibm.liberty.starter.api.v1.model.provider.Location; import com.ibm.liberty.starter.api.v1.model.provider.Provider; import com.ibm.liberty.starter.api.v1.model.provider.Sample;
/******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.template.api.v1.it; /** * Test the deployed service responds as expected * */ public class TestApplication extends EndpointTest { @Before public void checkSetup() { checkAvailability("/api/v1/provider/"); } @Test public void testProvider() throws Exception { Provider provider = testEndpoint("/api/v1/provider/", Provider.class); assertNotNull("No response from API for provider", provider); /* Change this to expect the header for your technology */ assertTrue("Description was not found.", provider.getDescription().contains("<h2></h2>"));
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public class Dependency { // private Scope scope; // private String groupId; // private String artifactId; // private String version; // // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // @ApiModelProperty(required = true) // public Scope getScope() { // return scope; // } // // public void setScope(Scope scope) { // this.scope = scope; // } // // @ApiModelProperty(required = false) // public String getGroupId() { // return groupId; // } // // public void setGroupId(String groupId) { // this.groupId = groupId; // } // // @ApiModelProperty(required = true) // public String getArtifactId() { // return artifactId; // } // // public void setArtifactId(String artifactId) { // this.artifactId = artifactId; // } // // @ApiModelProperty(required = true) // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Location.java // public class Location { // private String path; // private String url; // // public Location(String path, String url) { // this.path = path; // this.url = url; // } // // public Location(String url) { // this.url = url; // } // // public Location() { // //JSON serialisation // } // // @ApiModelProperty(value="Relative path to insert the file within the sample project structure", required=false) // public String getPath() { // return path; // } // public void setPath(String path) { // this.path = path; // } // // @ApiModelProperty(value="URL to retrieve the file from", required=true) // public String getUrl() { // return url; // } // public void setUrl(String url) { // this.url = url; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Provider.java // public class Provider { // private String description; // private Dependency[] dependencies; // private Location repoUrl; // // @ApiModelProperty(value = "Description of the technology provider to be inserted into index.html", required = true) // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value = "Dependencies to be specified to the user when they get the download", required = true) // public Dependency[] getDependencies() { // return dependencies; // } // // public void setDependencies(Dependency[] dependencies) { // this.dependencies = dependencies; // } // // @ApiModelProperty(value = "The location of the repository for this microservice.") // public Location getRepoUrl() { // return repoUrl; // } // // public void setRepoUrl(Location repoUrl) { // this.repoUrl = repoUrl; // } // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Sample.java // public class Sample { // private String base; // private Location[] locations; // // @ApiModelProperty(value="If specified, then this path will be used to create a relative path from any location URLs which do not have a path specified.", required=false) // public String getBase() { // return base; // } // public void setBase(String base) { // this.base = base; // } // // @ApiModelProperty(value="Files which make up the sample", required=true) // public Location[] getLocations() { // return locations; // } // public void setLocations(Location[] locations) { // this.locations = locations; // } // // // } // Path: starter-microservice-template/src/test/java/com/ibm/liberty/starter/service/template/api/v1/it/TestApplication.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; import com.ibm.liberty.starter.api.v1.model.provider.Dependency; import com.ibm.liberty.starter.api.v1.model.provider.Location; import com.ibm.liberty.starter.api.v1.model.provider.Provider; import com.ibm.liberty.starter.api.v1.model.provider.Sample; /******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.template.api.v1.it; /** * Test the deployed service responds as expected * */ public class TestApplication extends EndpointTest { @Before public void checkSetup() { checkAvailability("/api/v1/provider/"); } @Test public void testProvider() throws Exception { Provider provider = testEndpoint("/api/v1/provider/", Provider.class); assertNotNull("No response from API for provider", provider); /* Change this to expect the header for your technology */ assertTrue("Description was not found.", provider.getDescription().contains("<h2></h2>"));
Location location = provider.getRepoUrl();
WASdev/tool.accelerate.core
starter-microservice-template/src/test/java/com/ibm/liberty/starter/service/template/api/v1/it/TestApplication.java
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public class Dependency { // private Scope scope; // private String groupId; // private String artifactId; // private String version; // // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // @ApiModelProperty(required = true) // public Scope getScope() { // return scope; // } // // public void setScope(Scope scope) { // this.scope = scope; // } // // @ApiModelProperty(required = false) // public String getGroupId() { // return groupId; // } // // public void setGroupId(String groupId) { // this.groupId = groupId; // } // // @ApiModelProperty(required = true) // public String getArtifactId() { // return artifactId; // } // // public void setArtifactId(String artifactId) { // this.artifactId = artifactId; // } // // @ApiModelProperty(required = true) // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Location.java // public class Location { // private String path; // private String url; // // public Location(String path, String url) { // this.path = path; // this.url = url; // } // // public Location(String url) { // this.url = url; // } // // public Location() { // //JSON serialisation // } // // @ApiModelProperty(value="Relative path to insert the file within the sample project structure", required=false) // public String getPath() { // return path; // } // public void setPath(String path) { // this.path = path; // } // // @ApiModelProperty(value="URL to retrieve the file from", required=true) // public String getUrl() { // return url; // } // public void setUrl(String url) { // this.url = url; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Provider.java // public class Provider { // private String description; // private Dependency[] dependencies; // private Location repoUrl; // // @ApiModelProperty(value = "Description of the technology provider to be inserted into index.html", required = true) // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value = "Dependencies to be specified to the user when they get the download", required = true) // public Dependency[] getDependencies() { // return dependencies; // } // // public void setDependencies(Dependency[] dependencies) { // this.dependencies = dependencies; // } // // @ApiModelProperty(value = "The location of the repository for this microservice.") // public Location getRepoUrl() { // return repoUrl; // } // // public void setRepoUrl(Location repoUrl) { // this.repoUrl = repoUrl; // } // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Sample.java // public class Sample { // private String base; // private Location[] locations; // // @ApiModelProperty(value="If specified, then this path will be used to create a relative path from any location URLs which do not have a path specified.", required=false) // public String getBase() { // return base; // } // public void setBase(String base) { // this.base = base; // } // // @ApiModelProperty(value="Files which make up the sample", required=true) // public Location[] getLocations() { // return locations; // } // public void setLocations(Location[] locations) { // this.locations = locations; // } // // // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; import com.ibm.liberty.starter.api.v1.model.provider.Dependency; import com.ibm.liberty.starter.api.v1.model.provider.Location; import com.ibm.liberty.starter.api.v1.model.provider.Provider; import com.ibm.liberty.starter.api.v1.model.provider.Sample;
/******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.template.api.v1.it; /** * Test the deployed service responds as expected * */ public class TestApplication extends EndpointTest { @Before public void checkSetup() { checkAvailability("/api/v1/provider/"); } @Test public void testProvider() throws Exception { Provider provider = testEndpoint("/api/v1/provider/", Provider.class); assertNotNull("No response from API for provider", provider); /* Change this to expect the header for your technology */ assertTrue("Description was not found.", provider.getDescription().contains("<h2></h2>")); Location location = provider.getRepoUrl(); assertNotNull("Repo url null.", location.getUrl()); assertTrue("Repo url incorrect.", location.getUrl().endsWith("/artifacts")); testDependencies(provider.getDependencies()); }
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public class Dependency { // private Scope scope; // private String groupId; // private String artifactId; // private String version; // // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // @ApiModelProperty(required = true) // public Scope getScope() { // return scope; // } // // public void setScope(Scope scope) { // this.scope = scope; // } // // @ApiModelProperty(required = false) // public String getGroupId() { // return groupId; // } // // public void setGroupId(String groupId) { // this.groupId = groupId; // } // // @ApiModelProperty(required = true) // public String getArtifactId() { // return artifactId; // } // // public void setArtifactId(String artifactId) { // this.artifactId = artifactId; // } // // @ApiModelProperty(required = true) // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Location.java // public class Location { // private String path; // private String url; // // public Location(String path, String url) { // this.path = path; // this.url = url; // } // // public Location(String url) { // this.url = url; // } // // public Location() { // //JSON serialisation // } // // @ApiModelProperty(value="Relative path to insert the file within the sample project structure", required=false) // public String getPath() { // return path; // } // public void setPath(String path) { // this.path = path; // } // // @ApiModelProperty(value="URL to retrieve the file from", required=true) // public String getUrl() { // return url; // } // public void setUrl(String url) { // this.url = url; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Provider.java // public class Provider { // private String description; // private Dependency[] dependencies; // private Location repoUrl; // // @ApiModelProperty(value = "Description of the technology provider to be inserted into index.html", required = true) // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value = "Dependencies to be specified to the user when they get the download", required = true) // public Dependency[] getDependencies() { // return dependencies; // } // // public void setDependencies(Dependency[] dependencies) { // this.dependencies = dependencies; // } // // @ApiModelProperty(value = "The location of the repository for this microservice.") // public Location getRepoUrl() { // return repoUrl; // } // // public void setRepoUrl(Location repoUrl) { // this.repoUrl = repoUrl; // } // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Sample.java // public class Sample { // private String base; // private Location[] locations; // // @ApiModelProperty(value="If specified, then this path will be used to create a relative path from any location URLs which do not have a path specified.", required=false) // public String getBase() { // return base; // } // public void setBase(String base) { // this.base = base; // } // // @ApiModelProperty(value="Files which make up the sample", required=true) // public Location[] getLocations() { // return locations; // } // public void setLocations(Location[] locations) { // this.locations = locations; // } // // // } // Path: starter-microservice-template/src/test/java/com/ibm/liberty/starter/service/template/api/v1/it/TestApplication.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; import com.ibm.liberty.starter.api.v1.model.provider.Dependency; import com.ibm.liberty.starter.api.v1.model.provider.Location; import com.ibm.liberty.starter.api.v1.model.provider.Provider; import com.ibm.liberty.starter.api.v1.model.provider.Sample; /******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.template.api.v1.it; /** * Test the deployed service responds as expected * */ public class TestApplication extends EndpointTest { @Before public void checkSetup() { checkAvailability("/api/v1/provider/"); } @Test public void testProvider() throws Exception { Provider provider = testEndpoint("/api/v1/provider/", Provider.class); assertNotNull("No response from API for provider", provider); /* Change this to expect the header for your technology */ assertTrue("Description was not found.", provider.getDescription().contains("<h2></h2>")); Location location = provider.getRepoUrl(); assertNotNull("Repo url null.", location.getUrl()); assertTrue("Repo url incorrect.", location.getUrl().endsWith("/artifacts")); testDependencies(provider.getDependencies()); }
private void testDependencies(Dependency[] dependencies) {
WASdev/tool.accelerate.core
liberty-starter-application/src/test/java/com/ibm/liberty/starter/it/api/v1/RepositoryTest.java
// Path: liberty-starter-application/src/test/java/com/ibm/liberty/starter/it/api/v1/utils/RepositoryClient.java // public class RepositoryClient { // // public static String invoke(String file, int expectedStatus) throws Exception { // Client client = ClientBuilder.newClient(); // String port = System.getProperty("liberty.test.port"); // String url = "http://localhost:" + port + "/start/api/v1/repo/" + file; // System.out.println("Testing " + url); // Response response = client.target(url).request().get(); // try { // int responseStatus = response.getStatus(); // InputStream responseStream = response.readEntity(InputStream.class); // String output = inputStreamToString(responseStream); // assertTrue("Response status is: " + responseStatus + " Response message: " + output, responseStatus == expectedStatus); // return output; // } finally { // response.close(); // } // } // // private static String inputStreamToString(InputStream inputStream) throws IOException { // InputStreamReader isr = new InputStreamReader(inputStream); // char[] chars = new char[1024]; // StringBuilder responseBuilder = new StringBuilder(); // // int read; // while ((read = isr.read(chars)) != -1) { // responseBuilder.append(chars, 0, read); // } // return responseBuilder.toString(); // } // // }
import static org.junit.Assert.assertTrue; import org.junit.Test; import com.ibm.liberty.starter.it.api.v1.utils.RepositoryClient;
/******************************************************************************* * Copyright (c) 2016,2017 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.it.api.v1; public class RepositoryTest { @Test public void testTestProvidedPom() throws Exception {
// Path: liberty-starter-application/src/test/java/com/ibm/liberty/starter/it/api/v1/utils/RepositoryClient.java // public class RepositoryClient { // // public static String invoke(String file, int expectedStatus) throws Exception { // Client client = ClientBuilder.newClient(); // String port = System.getProperty("liberty.test.port"); // String url = "http://localhost:" + port + "/start/api/v1/repo/" + file; // System.out.println("Testing " + url); // Response response = client.target(url).request().get(); // try { // int responseStatus = response.getStatus(); // InputStream responseStream = response.readEntity(InputStream.class); // String output = inputStreamToString(responseStream); // assertTrue("Response status is: " + responseStatus + " Response message: " + output, responseStatus == expectedStatus); // return output; // } finally { // response.close(); // } // } // // private static String inputStreamToString(InputStream inputStream) throws IOException { // InputStreamReader isr = new InputStreamReader(inputStream); // char[] chars = new char[1024]; // StringBuilder responseBuilder = new StringBuilder(); // // int read; // while ((read = isr.read(chars)) != -1) { // responseBuilder.append(chars, 0, read); // } // return responseBuilder.toString(); // } // // } // Path: liberty-starter-application/src/test/java/com/ibm/liberty/starter/it/api/v1/RepositoryTest.java import static org.junit.Assert.assertTrue; import org.junit.Test; import com.ibm.liberty.starter.it.api.v1.utils.RepositoryClient; /******************************************************************************* * Copyright (c) 2016,2017 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.it.api.v1; public class RepositoryTest { @Test public void testTestProvidedPom() throws Exception {
String file = RepositoryClient.invoke("net/wasdev/wlp/starters/test/provided-pom/0.0.1/provided-pom-0.0.1.pom", 200);
WASdev/tool.accelerate.core
starter-microservice-test/src/test/java/com/ibm/liberty/starter/service/test/api/v1/it/TestApplication.java
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public class Dependency { // private Scope scope; // private String groupId; // private String artifactId; // private String version; // // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // @ApiModelProperty(required = true) // public Scope getScope() { // return scope; // } // // public void setScope(Scope scope) { // this.scope = scope; // } // // @ApiModelProperty(required = false) // public String getGroupId() { // return groupId; // } // // public void setGroupId(String groupId) { // this.groupId = groupId; // } // // @ApiModelProperty(required = true) // public String getArtifactId() { // return artifactId; // } // // public void setArtifactId(String artifactId) { // this.artifactId = artifactId; // } // // @ApiModelProperty(required = true) // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Location.java // public class Location { // private String path; // private String url; // // public Location(String path, String url) { // this.path = path; // this.url = url; // } // // public Location(String url) { // this.url = url; // } // // public Location() { // //JSON serialisation // } // // @ApiModelProperty(value="Relative path to insert the file within the sample project structure", required=false) // public String getPath() { // return path; // } // public void setPath(String path) { // this.path = path; // } // // @ApiModelProperty(value="URL to retrieve the file from", required=true) // public String getUrl() { // return url; // } // public void setUrl(String url) { // this.url = url; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Provider.java // public class Provider { // private String description; // private Dependency[] dependencies; // private Location repoUrl; // // @ApiModelProperty(value = "Description of the technology provider to be inserted into index.html", required = true) // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value = "Dependencies to be specified to the user when they get the download", required = true) // public Dependency[] getDependencies() { // return dependencies; // } // // public void setDependencies(Dependency[] dependencies) { // this.dependencies = dependencies; // } // // @ApiModelProperty(value = "The location of the repository for this microservice.") // public Location getRepoUrl() { // return repoUrl; // } // // public void setRepoUrl(Location repoUrl) { // this.repoUrl = repoUrl; // } // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Sample.java // public class Sample { // private String base; // private Location[] locations; // // @ApiModelProperty(value="If specified, then this path will be used to create a relative path from any location URLs which do not have a path specified.", required=false) // public String getBase() { // return base; // } // public void setBase(String base) { // this.base = base; // } // // @ApiModelProperty(value="Files which make up the sample", required=true) // public Location[] getLocations() { // return locations; // } // public void setLocations(Location[] locations) { // this.locations = locations; // } // // // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; import com.ibm.liberty.starter.api.v1.model.provider.Dependency; import com.ibm.liberty.starter.api.v1.model.provider.Location; import com.ibm.liberty.starter.api.v1.model.provider.Provider; import com.ibm.liberty.starter.api.v1.model.provider.Sample;
/******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.test.api.v1.it; /** * Test the deployed service responds as expected * */ public class TestApplication extends EndpointTest { @Before public void checkSetup() { checkAvailability("/api/v1/provider/"); } @Test public void testProvider() throws Exception {
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public class Dependency { // private Scope scope; // private String groupId; // private String artifactId; // private String version; // // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // @ApiModelProperty(required = true) // public Scope getScope() { // return scope; // } // // public void setScope(Scope scope) { // this.scope = scope; // } // // @ApiModelProperty(required = false) // public String getGroupId() { // return groupId; // } // // public void setGroupId(String groupId) { // this.groupId = groupId; // } // // @ApiModelProperty(required = true) // public String getArtifactId() { // return artifactId; // } // // public void setArtifactId(String artifactId) { // this.artifactId = artifactId; // } // // @ApiModelProperty(required = true) // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Location.java // public class Location { // private String path; // private String url; // // public Location(String path, String url) { // this.path = path; // this.url = url; // } // // public Location(String url) { // this.url = url; // } // // public Location() { // //JSON serialisation // } // // @ApiModelProperty(value="Relative path to insert the file within the sample project structure", required=false) // public String getPath() { // return path; // } // public void setPath(String path) { // this.path = path; // } // // @ApiModelProperty(value="URL to retrieve the file from", required=true) // public String getUrl() { // return url; // } // public void setUrl(String url) { // this.url = url; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Provider.java // public class Provider { // private String description; // private Dependency[] dependencies; // private Location repoUrl; // // @ApiModelProperty(value = "Description of the technology provider to be inserted into index.html", required = true) // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value = "Dependencies to be specified to the user when they get the download", required = true) // public Dependency[] getDependencies() { // return dependencies; // } // // public void setDependencies(Dependency[] dependencies) { // this.dependencies = dependencies; // } // // @ApiModelProperty(value = "The location of the repository for this microservice.") // public Location getRepoUrl() { // return repoUrl; // } // // public void setRepoUrl(Location repoUrl) { // this.repoUrl = repoUrl; // } // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Sample.java // public class Sample { // private String base; // private Location[] locations; // // @ApiModelProperty(value="If specified, then this path will be used to create a relative path from any location URLs which do not have a path specified.", required=false) // public String getBase() { // return base; // } // public void setBase(String base) { // this.base = base; // } // // @ApiModelProperty(value="Files which make up the sample", required=true) // public Location[] getLocations() { // return locations; // } // public void setLocations(Location[] locations) { // this.locations = locations; // } // // // } // Path: starter-microservice-test/src/test/java/com/ibm/liberty/starter/service/test/api/v1/it/TestApplication.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; import com.ibm.liberty.starter.api.v1.model.provider.Dependency; import com.ibm.liberty.starter.api.v1.model.provider.Location; import com.ibm.liberty.starter.api.v1.model.provider.Provider; import com.ibm.liberty.starter.api.v1.model.provider.Sample; /******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.test.api.v1.it; /** * Test the deployed service responds as expected * */ public class TestApplication extends EndpointTest { @Before public void checkSetup() { checkAvailability("/api/v1/provider/"); } @Test public void testProvider() throws Exception {
Provider provider = testEndpoint("/api/v1/provider/", Provider.class);
WASdev/tool.accelerate.core
starter-microservice-test/src/test/java/com/ibm/liberty/starter/service/test/api/v1/it/TestApplication.java
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public class Dependency { // private Scope scope; // private String groupId; // private String artifactId; // private String version; // // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // @ApiModelProperty(required = true) // public Scope getScope() { // return scope; // } // // public void setScope(Scope scope) { // this.scope = scope; // } // // @ApiModelProperty(required = false) // public String getGroupId() { // return groupId; // } // // public void setGroupId(String groupId) { // this.groupId = groupId; // } // // @ApiModelProperty(required = true) // public String getArtifactId() { // return artifactId; // } // // public void setArtifactId(String artifactId) { // this.artifactId = artifactId; // } // // @ApiModelProperty(required = true) // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Location.java // public class Location { // private String path; // private String url; // // public Location(String path, String url) { // this.path = path; // this.url = url; // } // // public Location(String url) { // this.url = url; // } // // public Location() { // //JSON serialisation // } // // @ApiModelProperty(value="Relative path to insert the file within the sample project structure", required=false) // public String getPath() { // return path; // } // public void setPath(String path) { // this.path = path; // } // // @ApiModelProperty(value="URL to retrieve the file from", required=true) // public String getUrl() { // return url; // } // public void setUrl(String url) { // this.url = url; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Provider.java // public class Provider { // private String description; // private Dependency[] dependencies; // private Location repoUrl; // // @ApiModelProperty(value = "Description of the technology provider to be inserted into index.html", required = true) // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value = "Dependencies to be specified to the user when they get the download", required = true) // public Dependency[] getDependencies() { // return dependencies; // } // // public void setDependencies(Dependency[] dependencies) { // this.dependencies = dependencies; // } // // @ApiModelProperty(value = "The location of the repository for this microservice.") // public Location getRepoUrl() { // return repoUrl; // } // // public void setRepoUrl(Location repoUrl) { // this.repoUrl = repoUrl; // } // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Sample.java // public class Sample { // private String base; // private Location[] locations; // // @ApiModelProperty(value="If specified, then this path will be used to create a relative path from any location URLs which do not have a path specified.", required=false) // public String getBase() { // return base; // } // public void setBase(String base) { // this.base = base; // } // // @ApiModelProperty(value="Files which make up the sample", required=true) // public Location[] getLocations() { // return locations; // } // public void setLocations(Location[] locations) { // this.locations = locations; // } // // // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; import com.ibm.liberty.starter.api.v1.model.provider.Dependency; import com.ibm.liberty.starter.api.v1.model.provider.Location; import com.ibm.liberty.starter.api.v1.model.provider.Provider; import com.ibm.liberty.starter.api.v1.model.provider.Sample;
/******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.test.api.v1.it; /** * Test the deployed service responds as expected * */ public class TestApplication extends EndpointTest { @Before public void checkSetup() { checkAvailability("/api/v1/provider/"); } @Test public void testProvider() throws Exception { Provider provider = testEndpoint("/api/v1/provider/", Provider.class); assertNotNull("No response from API for provider", provider); assertTrue("Description was not found.", provider.getDescription().contains("<h2>Test</h2>"));
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public class Dependency { // private Scope scope; // private String groupId; // private String artifactId; // private String version; // // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // @ApiModelProperty(required = true) // public Scope getScope() { // return scope; // } // // public void setScope(Scope scope) { // this.scope = scope; // } // // @ApiModelProperty(required = false) // public String getGroupId() { // return groupId; // } // // public void setGroupId(String groupId) { // this.groupId = groupId; // } // // @ApiModelProperty(required = true) // public String getArtifactId() { // return artifactId; // } // // public void setArtifactId(String artifactId) { // this.artifactId = artifactId; // } // // @ApiModelProperty(required = true) // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Location.java // public class Location { // private String path; // private String url; // // public Location(String path, String url) { // this.path = path; // this.url = url; // } // // public Location(String url) { // this.url = url; // } // // public Location() { // //JSON serialisation // } // // @ApiModelProperty(value="Relative path to insert the file within the sample project structure", required=false) // public String getPath() { // return path; // } // public void setPath(String path) { // this.path = path; // } // // @ApiModelProperty(value="URL to retrieve the file from", required=true) // public String getUrl() { // return url; // } // public void setUrl(String url) { // this.url = url; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Provider.java // public class Provider { // private String description; // private Dependency[] dependencies; // private Location repoUrl; // // @ApiModelProperty(value = "Description of the technology provider to be inserted into index.html", required = true) // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value = "Dependencies to be specified to the user when they get the download", required = true) // public Dependency[] getDependencies() { // return dependencies; // } // // public void setDependencies(Dependency[] dependencies) { // this.dependencies = dependencies; // } // // @ApiModelProperty(value = "The location of the repository for this microservice.") // public Location getRepoUrl() { // return repoUrl; // } // // public void setRepoUrl(Location repoUrl) { // this.repoUrl = repoUrl; // } // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Sample.java // public class Sample { // private String base; // private Location[] locations; // // @ApiModelProperty(value="If specified, then this path will be used to create a relative path from any location URLs which do not have a path specified.", required=false) // public String getBase() { // return base; // } // public void setBase(String base) { // this.base = base; // } // // @ApiModelProperty(value="Files which make up the sample", required=true) // public Location[] getLocations() { // return locations; // } // public void setLocations(Location[] locations) { // this.locations = locations; // } // // // } // Path: starter-microservice-test/src/test/java/com/ibm/liberty/starter/service/test/api/v1/it/TestApplication.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; import com.ibm.liberty.starter.api.v1.model.provider.Dependency; import com.ibm.liberty.starter.api.v1.model.provider.Location; import com.ibm.liberty.starter.api.v1.model.provider.Provider; import com.ibm.liberty.starter.api.v1.model.provider.Sample; /******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.test.api.v1.it; /** * Test the deployed service responds as expected * */ public class TestApplication extends EndpointTest { @Before public void checkSetup() { checkAvailability("/api/v1/provider/"); } @Test public void testProvider() throws Exception { Provider provider = testEndpoint("/api/v1/provider/", Provider.class); assertNotNull("No response from API for provider", provider); assertTrue("Description was not found.", provider.getDescription().contains("<h2>Test</h2>"));
Location location = provider.getRepoUrl();
WASdev/tool.accelerate.core
starter-microservice-test/src/test/java/com/ibm/liberty/starter/service/test/api/v1/it/TestApplication.java
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public class Dependency { // private Scope scope; // private String groupId; // private String artifactId; // private String version; // // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // @ApiModelProperty(required = true) // public Scope getScope() { // return scope; // } // // public void setScope(Scope scope) { // this.scope = scope; // } // // @ApiModelProperty(required = false) // public String getGroupId() { // return groupId; // } // // public void setGroupId(String groupId) { // this.groupId = groupId; // } // // @ApiModelProperty(required = true) // public String getArtifactId() { // return artifactId; // } // // public void setArtifactId(String artifactId) { // this.artifactId = artifactId; // } // // @ApiModelProperty(required = true) // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Location.java // public class Location { // private String path; // private String url; // // public Location(String path, String url) { // this.path = path; // this.url = url; // } // // public Location(String url) { // this.url = url; // } // // public Location() { // //JSON serialisation // } // // @ApiModelProperty(value="Relative path to insert the file within the sample project structure", required=false) // public String getPath() { // return path; // } // public void setPath(String path) { // this.path = path; // } // // @ApiModelProperty(value="URL to retrieve the file from", required=true) // public String getUrl() { // return url; // } // public void setUrl(String url) { // this.url = url; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Provider.java // public class Provider { // private String description; // private Dependency[] dependencies; // private Location repoUrl; // // @ApiModelProperty(value = "Description of the technology provider to be inserted into index.html", required = true) // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value = "Dependencies to be specified to the user when they get the download", required = true) // public Dependency[] getDependencies() { // return dependencies; // } // // public void setDependencies(Dependency[] dependencies) { // this.dependencies = dependencies; // } // // @ApiModelProperty(value = "The location of the repository for this microservice.") // public Location getRepoUrl() { // return repoUrl; // } // // public void setRepoUrl(Location repoUrl) { // this.repoUrl = repoUrl; // } // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Sample.java // public class Sample { // private String base; // private Location[] locations; // // @ApiModelProperty(value="If specified, then this path will be used to create a relative path from any location URLs which do not have a path specified.", required=false) // public String getBase() { // return base; // } // public void setBase(String base) { // this.base = base; // } // // @ApiModelProperty(value="Files which make up the sample", required=true) // public Location[] getLocations() { // return locations; // } // public void setLocations(Location[] locations) { // this.locations = locations; // } // // // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; import com.ibm.liberty.starter.api.v1.model.provider.Dependency; import com.ibm.liberty.starter.api.v1.model.provider.Location; import com.ibm.liberty.starter.api.v1.model.provider.Provider; import com.ibm.liberty.starter.api.v1.model.provider.Sample;
/******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.test.api.v1.it; /** * Test the deployed service responds as expected * */ public class TestApplication extends EndpointTest { @Before public void checkSetup() { checkAvailability("/api/v1/provider/"); } @Test public void testProvider() throws Exception { Provider provider = testEndpoint("/api/v1/provider/", Provider.class); assertNotNull("No response from API for provider", provider); assertTrue("Description was not found.", provider.getDescription().contains("<h2>Test</h2>")); Location location = provider.getRepoUrl(); assertNotNull("Repo url null.", location.getUrl()); assertTrue("Repo url incorrect.", location.getUrl().endsWith("/artifacts")); testDependencies(provider.getDependencies()); }
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public class Dependency { // private Scope scope; // private String groupId; // private String artifactId; // private String version; // // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // @ApiModelProperty(required = true) // public Scope getScope() { // return scope; // } // // public void setScope(Scope scope) { // this.scope = scope; // } // // @ApiModelProperty(required = false) // public String getGroupId() { // return groupId; // } // // public void setGroupId(String groupId) { // this.groupId = groupId; // } // // @ApiModelProperty(required = true) // public String getArtifactId() { // return artifactId; // } // // public void setArtifactId(String artifactId) { // this.artifactId = artifactId; // } // // @ApiModelProperty(required = true) // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Location.java // public class Location { // private String path; // private String url; // // public Location(String path, String url) { // this.path = path; // this.url = url; // } // // public Location(String url) { // this.url = url; // } // // public Location() { // //JSON serialisation // } // // @ApiModelProperty(value="Relative path to insert the file within the sample project structure", required=false) // public String getPath() { // return path; // } // public void setPath(String path) { // this.path = path; // } // // @ApiModelProperty(value="URL to retrieve the file from", required=true) // public String getUrl() { // return url; // } // public void setUrl(String url) { // this.url = url; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Provider.java // public class Provider { // private String description; // private Dependency[] dependencies; // private Location repoUrl; // // @ApiModelProperty(value = "Description of the technology provider to be inserted into index.html", required = true) // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value = "Dependencies to be specified to the user when they get the download", required = true) // public Dependency[] getDependencies() { // return dependencies; // } // // public void setDependencies(Dependency[] dependencies) { // this.dependencies = dependencies; // } // // @ApiModelProperty(value = "The location of the repository for this microservice.") // public Location getRepoUrl() { // return repoUrl; // } // // public void setRepoUrl(Location repoUrl) { // this.repoUrl = repoUrl; // } // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Sample.java // public class Sample { // private String base; // private Location[] locations; // // @ApiModelProperty(value="If specified, then this path will be used to create a relative path from any location URLs which do not have a path specified.", required=false) // public String getBase() { // return base; // } // public void setBase(String base) { // this.base = base; // } // // @ApiModelProperty(value="Files which make up the sample", required=true) // public Location[] getLocations() { // return locations; // } // public void setLocations(Location[] locations) { // this.locations = locations; // } // // // } // Path: starter-microservice-test/src/test/java/com/ibm/liberty/starter/service/test/api/v1/it/TestApplication.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; import com.ibm.liberty.starter.api.v1.model.provider.Dependency; import com.ibm.liberty.starter.api.v1.model.provider.Location; import com.ibm.liberty.starter.api.v1.model.provider.Provider; import com.ibm.liberty.starter.api.v1.model.provider.Sample; /******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.test.api.v1.it; /** * Test the deployed service responds as expected * */ public class TestApplication extends EndpointTest { @Before public void checkSetup() { checkAvailability("/api/v1/provider/"); } @Test public void testProvider() throws Exception { Provider provider = testEndpoint("/api/v1/provider/", Provider.class); assertNotNull("No response from API for provider", provider); assertTrue("Description was not found.", provider.getDescription().contains("<h2>Test</h2>")); Location location = provider.getRepoUrl(); assertNotNull("Repo url null.", location.getUrl()); assertTrue("Repo url incorrect.", location.getUrl().endsWith("/artifacts")); testDependencies(provider.getDependencies()); }
private void testDependencies(Dependency[] dependencies) {
WASdev/tool.accelerate.core
liberty-starter-application/src/main/java/com/ibm/liberty/starter/ServiceConnector.java
// Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/api/v1/model/internal/Services.java // public class Services { // private List<Service> services; // // public List<Service> getServices() { // return services; // } // // public void setServices(List<Service> services) { // this.services = services; // } // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/registration/Service.java // public class Service { // // private String id; // private String name; // private String description; // private String endpoint; // private String configuration; // private boolean options; // private String image; // private String imageSelected; // // @ApiModelProperty(value="Unique ID for this technology", required=true) // public String getId() { // return id; // } // public void setId(String id) { // this.id = id; // } // // @ApiModelProperty(value="Name of the technology (does not have to be unique, although it will be confusing if it isn't)", required=true) // public String getName() { // return name; // } // public void setName(String name) { // this.name = name; // } // // @ApiModelProperty(value="Description of the technology", required=true) // public String getDescription() { // return description; // } // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value="The endpoint to access the service", required=true) // public String getEndpoint() { // return endpoint; // } // public void setEndpoint(String endpoint) { // this.endpoint = endpoint; // } // // @ApiModelProperty(value="Specifies whether this technology allows any configuration(s). Value could either be 'yes' or a list of other technologies, seperated by comma. If a list of technologies is specified then the configuration(s) will be enabled only if all technologies on the list are selected by user", required=false) // public String getConfiguration() { // return configuration; // } // public void setConfiguration(String configuration) { // this.configuration = configuration; // } // // @ApiModelProperty(value="Specifies whether this technology has any additional options that can be set by the user", required=false) // public boolean getOptions() { // return options; // } // public void setOptions(boolean options) { // this.options = options; // } // // @Override // public String toString() { // return "Service [id=" + id + ", endpoint=" + endpoint + "]"; // } // // @ApiModelProperty(value="Specifies an image to display on the technology button", required=false) // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // // @ApiModelProperty(value="Specifies an image to display on the technology button when it is selected", required=false) // public String getImageSelected() { // return imageSelected; // } // // public void setImageSelected(String image) { // this.imageSelected = image; // } // }
import java.io.InputStream; import java.net.URI; import java.util.logging.Logger; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.Invocation; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import com.ibm.liberty.starter.api.v1.model.internal.Services; import com.ibm.liberty.starter.api.v1.model.registration.Service;
/******************************************************************************* * Copyright (c) 2016,2017 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter; public class ServiceConnector { private static final Logger log = Logger.getLogger(ServiceConnector.class.getName());
// Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/api/v1/model/internal/Services.java // public class Services { // private List<Service> services; // // public List<Service> getServices() { // return services; // } // // public void setServices(List<Service> services) { // this.services = services; // } // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/registration/Service.java // public class Service { // // private String id; // private String name; // private String description; // private String endpoint; // private String configuration; // private boolean options; // private String image; // private String imageSelected; // // @ApiModelProperty(value="Unique ID for this technology", required=true) // public String getId() { // return id; // } // public void setId(String id) { // this.id = id; // } // // @ApiModelProperty(value="Name of the technology (does not have to be unique, although it will be confusing if it isn't)", required=true) // public String getName() { // return name; // } // public void setName(String name) { // this.name = name; // } // // @ApiModelProperty(value="Description of the technology", required=true) // public String getDescription() { // return description; // } // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value="The endpoint to access the service", required=true) // public String getEndpoint() { // return endpoint; // } // public void setEndpoint(String endpoint) { // this.endpoint = endpoint; // } // // @ApiModelProperty(value="Specifies whether this technology allows any configuration(s). Value could either be 'yes' or a list of other technologies, seperated by comma. If a list of technologies is specified then the configuration(s) will be enabled only if all technologies on the list are selected by user", required=false) // public String getConfiguration() { // return configuration; // } // public void setConfiguration(String configuration) { // this.configuration = configuration; // } // // @ApiModelProperty(value="Specifies whether this technology has any additional options that can be set by the user", required=false) // public boolean getOptions() { // return options; // } // public void setOptions(boolean options) { // this.options = options; // } // // @Override // public String toString() { // return "Service [id=" + id + ", endpoint=" + endpoint + "]"; // } // // @ApiModelProperty(value="Specifies an image to display on the technology button", required=false) // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // // @ApiModelProperty(value="Specifies an image to display on the technology button when it is selected", required=false) // public String getImageSelected() { // return imageSelected; // } // // public void setImageSelected(String image) { // this.imageSelected = image; // } // } // Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/ServiceConnector.java import java.io.InputStream; import java.net.URI; import java.util.logging.Logger; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.Invocation; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import com.ibm.liberty.starter.api.v1.model.internal.Services; import com.ibm.liberty.starter.api.v1.model.registration.Service; /******************************************************************************* * Copyright (c) 2016,2017 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter; public class ServiceConnector { private static final Logger log = Logger.getLogger(ServiceConnector.class.getName());
private final Services services;
WASdev/tool.accelerate.core
liberty-starter-application/src/main/java/com/ibm/liberty/starter/ServiceConnector.java
// Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/api/v1/model/internal/Services.java // public class Services { // private List<Service> services; // // public List<Service> getServices() { // return services; // } // // public void setServices(List<Service> services) { // this.services = services; // } // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/registration/Service.java // public class Service { // // private String id; // private String name; // private String description; // private String endpoint; // private String configuration; // private boolean options; // private String image; // private String imageSelected; // // @ApiModelProperty(value="Unique ID for this technology", required=true) // public String getId() { // return id; // } // public void setId(String id) { // this.id = id; // } // // @ApiModelProperty(value="Name of the technology (does not have to be unique, although it will be confusing if it isn't)", required=true) // public String getName() { // return name; // } // public void setName(String name) { // this.name = name; // } // // @ApiModelProperty(value="Description of the technology", required=true) // public String getDescription() { // return description; // } // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value="The endpoint to access the service", required=true) // public String getEndpoint() { // return endpoint; // } // public void setEndpoint(String endpoint) { // this.endpoint = endpoint; // } // // @ApiModelProperty(value="Specifies whether this technology allows any configuration(s). Value could either be 'yes' or a list of other technologies, seperated by comma. If a list of technologies is specified then the configuration(s) will be enabled only if all technologies on the list are selected by user", required=false) // public String getConfiguration() { // return configuration; // } // public void setConfiguration(String configuration) { // this.configuration = configuration; // } // // @ApiModelProperty(value="Specifies whether this technology has any additional options that can be set by the user", required=false) // public boolean getOptions() { // return options; // } // public void setOptions(boolean options) { // this.options = options; // } // // @Override // public String toString() { // return "Service [id=" + id + ", endpoint=" + endpoint + "]"; // } // // @ApiModelProperty(value="Specifies an image to display on the technology button", required=false) // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // // @ApiModelProperty(value="Specifies an image to display on the technology button when it is selected", required=false) // public String getImageSelected() { // return imageSelected; // } // // public void setImageSelected(String image) { // this.imageSelected = image; // } // }
import java.io.InputStream; import java.net.URI; import java.util.logging.Logger; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.Invocation; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import com.ibm.liberty.starter.api.v1.model.internal.Services; import com.ibm.liberty.starter.api.v1.model.registration.Service;
String authority = uri.getAuthority(); serverHostPort = scheme + "://" + authority; internalServerHostPort = "http://" + authority; services = parseServicesJson(); } public ServiceConnector(String hostPort, String internalHostPort) { serverHostPort = hostPort; internalServerHostPort = internalHostPort; services = parseServicesJson(); } public Services parseServicesJson() { log.fine("Parsing services json file. INTERNAL_SERVER_HOST_PORT=" + internalServerHostPort); Services services = getObjectFromEndpoint(Services.class, internalServerHostPort + "/start/api/v1/services", MediaType.APPLICATION_JSON_TYPE); log.fine("Setting SERVICES object to " + services.getServices()); return services; } public Services getServices() { return services; } public String getServerHostPort() { return serverHostPort; } // Returns the service object associated with the given id
// Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/api/v1/model/internal/Services.java // public class Services { // private List<Service> services; // // public List<Service> getServices() { // return services; // } // // public void setServices(List<Service> services) { // this.services = services; // } // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/registration/Service.java // public class Service { // // private String id; // private String name; // private String description; // private String endpoint; // private String configuration; // private boolean options; // private String image; // private String imageSelected; // // @ApiModelProperty(value="Unique ID for this technology", required=true) // public String getId() { // return id; // } // public void setId(String id) { // this.id = id; // } // // @ApiModelProperty(value="Name of the technology (does not have to be unique, although it will be confusing if it isn't)", required=true) // public String getName() { // return name; // } // public void setName(String name) { // this.name = name; // } // // @ApiModelProperty(value="Description of the technology", required=true) // public String getDescription() { // return description; // } // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value="The endpoint to access the service", required=true) // public String getEndpoint() { // return endpoint; // } // public void setEndpoint(String endpoint) { // this.endpoint = endpoint; // } // // @ApiModelProperty(value="Specifies whether this technology allows any configuration(s). Value could either be 'yes' or a list of other technologies, seperated by comma. If a list of technologies is specified then the configuration(s) will be enabled only if all technologies on the list are selected by user", required=false) // public String getConfiguration() { // return configuration; // } // public void setConfiguration(String configuration) { // this.configuration = configuration; // } // // @ApiModelProperty(value="Specifies whether this technology has any additional options that can be set by the user", required=false) // public boolean getOptions() { // return options; // } // public void setOptions(boolean options) { // this.options = options; // } // // @Override // public String toString() { // return "Service [id=" + id + ", endpoint=" + endpoint + "]"; // } // // @ApiModelProperty(value="Specifies an image to display on the technology button", required=false) // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // // @ApiModelProperty(value="Specifies an image to display on the technology button when it is selected", required=false) // public String getImageSelected() { // return imageSelected; // } // // public void setImageSelected(String image) { // this.imageSelected = image; // } // } // Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/ServiceConnector.java import java.io.InputStream; import java.net.URI; import java.util.logging.Logger; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.Invocation; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import com.ibm.liberty.starter.api.v1.model.internal.Services; import com.ibm.liberty.starter.api.v1.model.registration.Service; String authority = uri.getAuthority(); serverHostPort = scheme + "://" + authority; internalServerHostPort = "http://" + authority; services = parseServicesJson(); } public ServiceConnector(String hostPort, String internalHostPort) { serverHostPort = hostPort; internalServerHostPort = internalHostPort; services = parseServicesJson(); } public Services parseServicesJson() { log.fine("Parsing services json file. INTERNAL_SERVER_HOST_PORT=" + internalServerHostPort); Services services = getObjectFromEndpoint(Services.class, internalServerHostPort + "/start/api/v1/services", MediaType.APPLICATION_JSON_TYPE); log.fine("Setting SERVICES object to " + services.getServices()); return services; } public Services getServices() { return services; } public String getServerHostPort() { return serverHostPort; } // Returns the service object associated with the given id
public Service getServiceObjectFromId(String id) {
WASdev/tool.accelerate.core
liberty-starter-application/src/test/java/com/ibm/liberty/starter/it/api/v1/APIJarDownloadTest.java
// Path: liberty-starter-application/src/test/java/com/ibm/liberty/starter/it/api/v1/utils/RepositoryAPIJarClient.java // public class RepositoryAPIJarClient { // // public static final String CONFIG = "config"; // public static final String FAULT_TOLERANCE = "faulttolerance"; // // public static void assertJar(String id, String version, String type) throws Exception { // String url = "http://localhost:" + System.getProperty("liberty.test.port") + "/start/api/v1/repo/net/wasdev/wlp/starters/" + id + "/" + type + "/" + version + "/" + type + "-" + version + ".jar"; // Client client = ClientBuilder.newClient(); // Response response = client.target(url).request("application/zip").get(); // try { // int responseStatus = response.getStatus(); // if (responseStatus != 200) { // Assert.fail("Expected response status 200, instead found " + responseStatus + ". Response was " + response.readEntity(String.class)); // } // switch (type) { // case CONFIG: // assertTrue("Config class not found", findConfig(response)); // break; // case FAULT_TOLERANCE: // assertTrue("Fault tolerance class not found", findFaultTolerance(response)); // } // } finally { // response.close(); // } // } // // private static boolean findConfig(Response resp) throws Exception { // return findFile(resp, "Config.class", "config.jar"); // } // // private static boolean findFaultTolerance(Response resp) throws Exception { // return findFile(resp, "CircuitBreaker.class", "config.jar"); // } // // private static boolean findFile(Response response, String klass, String jar) throws Exception { // // Read the response into an InputStream // InputStream entityInputStream = response.readEntity(InputStream.class); // // Create a new ZipInputStream from the response InputStream // ZipInputStream zipIn = new ZipInputStream(entityInputStream); // // This system property is being set in the liberty-starter-application/build.gradle file // String tempDir = System.getProperty("liberty.temp.dir"); // File file = new File(tempDir + "/" + jar); // System.out.println("Creating zip file: " + file.toString()); // file.getParentFile().mkdirs(); // ZipEntry inputEntry = null; // boolean found = false; // while ((inputEntry = zipIn.getNextEntry()) != null) { // String entryName = inputEntry.getName(); // if (entryName.contains(klass)) { // System.out.println("Found " + klass + " file."); // found = true; // } // zipIn.closeEntry(); // } // zipIn.close(); // return found; // } // // }
import org.junit.Test; import com.ibm.liberty.starter.it.api.v1.utils.RepositoryAPIJarClient;
/******************************************************************************* * Copyright (c) 2016,2017 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.it.api.v1; public class APIJarDownloadTest { @Test public void testTestMicroserviceJar() throws Exception {
// Path: liberty-starter-application/src/test/java/com/ibm/liberty/starter/it/api/v1/utils/RepositoryAPIJarClient.java // public class RepositoryAPIJarClient { // // public static final String CONFIG = "config"; // public static final String FAULT_TOLERANCE = "faulttolerance"; // // public static void assertJar(String id, String version, String type) throws Exception { // String url = "http://localhost:" + System.getProperty("liberty.test.port") + "/start/api/v1/repo/net/wasdev/wlp/starters/" + id + "/" + type + "/" + version + "/" + type + "-" + version + ".jar"; // Client client = ClientBuilder.newClient(); // Response response = client.target(url).request("application/zip").get(); // try { // int responseStatus = response.getStatus(); // if (responseStatus != 200) { // Assert.fail("Expected response status 200, instead found " + responseStatus + ". Response was " + response.readEntity(String.class)); // } // switch (type) { // case CONFIG: // assertTrue("Config class not found", findConfig(response)); // break; // case FAULT_TOLERANCE: // assertTrue("Fault tolerance class not found", findFaultTolerance(response)); // } // } finally { // response.close(); // } // } // // private static boolean findConfig(Response resp) throws Exception { // return findFile(resp, "Config.class", "config.jar"); // } // // private static boolean findFaultTolerance(Response resp) throws Exception { // return findFile(resp, "CircuitBreaker.class", "config.jar"); // } // // private static boolean findFile(Response response, String klass, String jar) throws Exception { // // Read the response into an InputStream // InputStream entityInputStream = response.readEntity(InputStream.class); // // Create a new ZipInputStream from the response InputStream // ZipInputStream zipIn = new ZipInputStream(entityInputStream); // // This system property is being set in the liberty-starter-application/build.gradle file // String tempDir = System.getProperty("liberty.temp.dir"); // File file = new File(tempDir + "/" + jar); // System.out.println("Creating zip file: " + file.toString()); // file.getParentFile().mkdirs(); // ZipEntry inputEntry = null; // boolean found = false; // while ((inputEntry = zipIn.getNextEntry()) != null) { // String entryName = inputEntry.getName(); // if (entryName.contains(klass)) { // System.out.println("Found " + klass + " file."); // found = true; // } // zipIn.closeEntry(); // } // zipIn.close(); // return found; // } // // } // Path: liberty-starter-application/src/test/java/com/ibm/liberty/starter/it/api/v1/APIJarDownloadTest.java import org.junit.Test; import com.ibm.liberty.starter.it.api.v1.utils.RepositoryAPIJarClient; /******************************************************************************* * Copyright (c) 2016,2017 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.it.api.v1; public class APIJarDownloadTest { @Test public void testTestMicroserviceJar() throws Exception {
RepositoryAPIJarClient.assertJar("test", "0.0.1", RepositoryAPIJarClient.CONFIG);
WASdev/tool.accelerate.core
starter-microservice-persistence/src/test/java/com/ibm/liberty/starter/service/persistence/api/v1/it/TestApplication.java
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/EndpointResponse.java // public class EndpointResponse { // // private String status; // // public String getStatus() { // return status; // } // // public void setStatus(String status) { // this.status = status; // } // // }
import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; import com.ibm.liberty.starter.api.v1.model.provider.EndpointResponse;
/******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.persistence.api.v1.it; /** * Test the deployed service responds as expected * */ public class TestApplication extends EndpointTest { @Before public void checkSetup() { checkAvailability("/api/v1/provider/"); } @Test public void testProvider() throws Exception {
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/EndpointResponse.java // public class EndpointResponse { // // private String status; // // public String getStatus() { // return status; // } // // public void setStatus(String status) { // this.status = status; // } // // } // Path: starter-microservice-persistence/src/test/java/com/ibm/liberty/starter/service/persistence/api/v1/it/TestApplication.java import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; import com.ibm.liberty.starter.api.v1.model.provider.EndpointResponse; /******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.persistence.api.v1.it; /** * Test the deployed service responds as expected * */ public class TestApplication extends EndpointTest { @Before public void checkSetup() { checkAvailability("/api/v1/provider/"); } @Test public void testProvider() throws Exception {
EndpointResponse response = testEndpoint("/api/v1/provider/", EndpointResponse.class);
WASdev/tool.accelerate.core
starter-microservice-websocket/src/test/java/com/ibm/liberty/starter/service/websocket/api/v1/it/TestApplication.java
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/EndpointResponse.java // public class EndpointResponse { // // private String status; // // public String getStatus() { // return status; // } // // public void setStatus(String status) { // this.status = status; // } // // }
import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; import com.ibm.liberty.starter.api.v1.model.provider.EndpointResponse;
/******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.websocket.api.v1.it; /** * Test the deployed service responds as expected * */ public class TestApplication extends EndpointTest { @Before public void checkSetup() { checkAvailability("/api/v1/provider/"); } @Test public void testProvider() throws Exception {
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/EndpointResponse.java // public class EndpointResponse { // // private String status; // // public String getStatus() { // return status; // } // // public void setStatus(String status) { // this.status = status; // } // // } // Path: starter-microservice-websocket/src/test/java/com/ibm/liberty/starter/service/websocket/api/v1/it/TestApplication.java import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; import com.ibm.liberty.starter.api.v1.model.provider.EndpointResponse; /******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.websocket.api.v1.it; /** * Test the deployed service responds as expected * */ public class TestApplication extends EndpointTest { @Before public void checkSetup() { checkAvailability("/api/v1/provider/"); } @Test public void testProvider() throws Exception {
EndpointResponse response = testEndpoint("/api/v1/provider/", EndpointResponse.class);
WASdev/tool.accelerate.core
starter-microservice-microprofile/src/test/java/com/ibm/liberty/starter/service/microprofile/api/v1/it/TestApplication.java
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/EndpointResponse.java // public class EndpointResponse { // // private String status; // // public String getStatus() { // return status; // } // // public void setStatus(String status) { // this.status = status; // } // // }
import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; import com.ibm.liberty.starter.api.v1.model.provider.EndpointResponse;
/******************************************************************************* * Copyright (c) 2016,17 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.microprofile.api.v1.it; /** * Test the deployed service responds as expected * */ public class TestApplication extends EndpointTest { @Before public void checkSetup() { checkAvailability("/api/v1/provider/"); } @Test public void testProvider() throws Exception {
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/EndpointResponse.java // public class EndpointResponse { // // private String status; // // public String getStatus() { // return status; // } // // public void setStatus(String status) { // this.status = status; // } // // } // Path: starter-microservice-microprofile/src/test/java/com/ibm/liberty/starter/service/microprofile/api/v1/it/TestApplication.java import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; import com.ibm.liberty.starter.api.v1.model.provider.EndpointResponse; /******************************************************************************* * Copyright (c) 2016,17 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.microprofile.api.v1.it; /** * Test the deployed service responds as expected * */ public class TestApplication extends EndpointTest { @Before public void checkSetup() { checkAvailability("/api/v1/provider/"); } @Test public void testProvider() throws Exception {
EndpointResponse response = testEndpoint("/api/v1/provider/", EndpointResponse.class);
WASdev/tool.accelerate.core
liberty-starter-application/src/main/java/com/ibm/liberty/starter/ProjectConstructionInputData.java
// Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/ProjectConstructor.java // public enum DeployType { // LOCAL, BLUEMIX // } // // Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/api/v1/model/internal/Services.java // public class Services { // private List<Service> services; // // public List<Service> getServices() { // return services; // } // // public void setServices(List<Service> services) { // this.services = services; // } // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/registration/Service.java // public class Service { // // private String id; // private String name; // private String description; // private String endpoint; // private String configuration; // private boolean options; // private String image; // private String imageSelected; // // @ApiModelProperty(value="Unique ID for this technology", required=true) // public String getId() { // return id; // } // public void setId(String id) { // this.id = id; // } // // @ApiModelProperty(value="Name of the technology (does not have to be unique, although it will be confusing if it isn't)", required=true) // public String getName() { // return name; // } // public void setName(String name) { // this.name = name; // } // // @ApiModelProperty(value="Description of the technology", required=true) // public String getDescription() { // return description; // } // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value="The endpoint to access the service", required=true) // public String getEndpoint() { // return endpoint; // } // public void setEndpoint(String endpoint) { // this.endpoint = endpoint; // } // // @ApiModelProperty(value="Specifies whether this technology allows any configuration(s). Value could either be 'yes' or a list of other technologies, seperated by comma. If a list of technologies is specified then the configuration(s) will be enabled only if all technologies on the list are selected by user", required=false) // public String getConfiguration() { // return configuration; // } // public void setConfiguration(String configuration) { // this.configuration = configuration; // } // // @ApiModelProperty(value="Specifies whether this technology has any additional options that can be set by the user", required=false) // public boolean getOptions() { // return options; // } // public void setOptions(boolean options) { // this.options = options; // } // // @Override // public String toString() { // return "Service [id=" + id + ", endpoint=" + endpoint + "]"; // } // // @ApiModelProperty(value="Specifies an image to display on the technology button", required=false) // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // // @ApiModelProperty(value="Specifies an image to display on the technology button when it is selected", required=false) // public String getImageSelected() { // return imageSelected; // } // // public void setImageSelected(String image) { // this.imageSelected = image; // } // }
import java.util.List; import java.util.stream.Stream; import com.ibm.liberty.starter.ProjectConstructor.DeployType; import com.ibm.liberty.starter.api.v1.model.internal.Services; import com.ibm.liberty.starter.api.v1.model.registration.Service;
/******************************************************************************* * Copyright (c) 2016,2017 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter; public class ProjectConstructionInputData { public final Services services; public final ServiceConnector serviceConnector; public final String appName;
// Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/ProjectConstructor.java // public enum DeployType { // LOCAL, BLUEMIX // } // // Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/api/v1/model/internal/Services.java // public class Services { // private List<Service> services; // // public List<Service> getServices() { // return services; // } // // public void setServices(List<Service> services) { // this.services = services; // } // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/registration/Service.java // public class Service { // // private String id; // private String name; // private String description; // private String endpoint; // private String configuration; // private boolean options; // private String image; // private String imageSelected; // // @ApiModelProperty(value="Unique ID for this technology", required=true) // public String getId() { // return id; // } // public void setId(String id) { // this.id = id; // } // // @ApiModelProperty(value="Name of the technology (does not have to be unique, although it will be confusing if it isn't)", required=true) // public String getName() { // return name; // } // public void setName(String name) { // this.name = name; // } // // @ApiModelProperty(value="Description of the technology", required=true) // public String getDescription() { // return description; // } // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value="The endpoint to access the service", required=true) // public String getEndpoint() { // return endpoint; // } // public void setEndpoint(String endpoint) { // this.endpoint = endpoint; // } // // @ApiModelProperty(value="Specifies whether this technology allows any configuration(s). Value could either be 'yes' or a list of other technologies, seperated by comma. If a list of technologies is specified then the configuration(s) will be enabled only if all technologies on the list are selected by user", required=false) // public String getConfiguration() { // return configuration; // } // public void setConfiguration(String configuration) { // this.configuration = configuration; // } // // @ApiModelProperty(value="Specifies whether this technology has any additional options that can be set by the user", required=false) // public boolean getOptions() { // return options; // } // public void setOptions(boolean options) { // this.options = options; // } // // @Override // public String toString() { // return "Service [id=" + id + ", endpoint=" + endpoint + "]"; // } // // @ApiModelProperty(value="Specifies an image to display on the technology button", required=false) // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // // @ApiModelProperty(value="Specifies an image to display on the technology button when it is selected", required=false) // public String getImageSelected() { // return imageSelected; // } // // public void setImageSelected(String image) { // this.imageSelected = image; // } // } // Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/ProjectConstructionInputData.java import java.util.List; import java.util.stream.Stream; import com.ibm.liberty.starter.ProjectConstructor.DeployType; import com.ibm.liberty.starter.api.v1.model.internal.Services; import com.ibm.liberty.starter.api.v1.model.registration.Service; /******************************************************************************* * Copyright (c) 2016,2017 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter; public class ProjectConstructionInputData { public final Services services; public final ServiceConnector serviceConnector; public final String appName;
public final ProjectConstructor.DeployType deployType;
WASdev/tool.accelerate.core
liberty-starter-application/src/main/java/com/ibm/liberty/starter/ProjectConstructionInputData.java
// Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/ProjectConstructor.java // public enum DeployType { // LOCAL, BLUEMIX // } // // Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/api/v1/model/internal/Services.java // public class Services { // private List<Service> services; // // public List<Service> getServices() { // return services; // } // // public void setServices(List<Service> services) { // this.services = services; // } // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/registration/Service.java // public class Service { // // private String id; // private String name; // private String description; // private String endpoint; // private String configuration; // private boolean options; // private String image; // private String imageSelected; // // @ApiModelProperty(value="Unique ID for this technology", required=true) // public String getId() { // return id; // } // public void setId(String id) { // this.id = id; // } // // @ApiModelProperty(value="Name of the technology (does not have to be unique, although it will be confusing if it isn't)", required=true) // public String getName() { // return name; // } // public void setName(String name) { // this.name = name; // } // // @ApiModelProperty(value="Description of the technology", required=true) // public String getDescription() { // return description; // } // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value="The endpoint to access the service", required=true) // public String getEndpoint() { // return endpoint; // } // public void setEndpoint(String endpoint) { // this.endpoint = endpoint; // } // // @ApiModelProperty(value="Specifies whether this technology allows any configuration(s). Value could either be 'yes' or a list of other technologies, seperated by comma. If a list of technologies is specified then the configuration(s) will be enabled only if all technologies on the list are selected by user", required=false) // public String getConfiguration() { // return configuration; // } // public void setConfiguration(String configuration) { // this.configuration = configuration; // } // // @ApiModelProperty(value="Specifies whether this technology has any additional options that can be set by the user", required=false) // public boolean getOptions() { // return options; // } // public void setOptions(boolean options) { // this.options = options; // } // // @Override // public String toString() { // return "Service [id=" + id + ", endpoint=" + endpoint + "]"; // } // // @ApiModelProperty(value="Specifies an image to display on the technology button", required=false) // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // // @ApiModelProperty(value="Specifies an image to display on the technology button when it is selected", required=false) // public String getImageSelected() { // return imageSelected; // } // // public void setImageSelected(String image) { // this.imageSelected = image; // } // }
import java.util.List; import java.util.stream.Stream; import com.ibm.liberty.starter.ProjectConstructor.DeployType; import com.ibm.liberty.starter.api.v1.model.internal.Services; import com.ibm.liberty.starter.api.v1.model.registration.Service;
/******************************************************************************* * Copyright (c) 2016,2017 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter; public class ProjectConstructionInputData { public final Services services; public final ServiceConnector serviceConnector; public final String appName; public final ProjectConstructor.DeployType deployType; public final ProjectConstructor.BuildType buildType; public final String workspaceDirectory; public final String[] techOptions; public final String artifactId; public final String groupId; public final String generationId; public final boolean beta; public ProjectConstructionInputData(Services services, ServiceConnector serviceConnector, String appName, ProjectConstructor.DeployType deployType, ProjectConstructor.BuildType buildType, String workspaceDirectory, String[] techOptions, String artifactId, String groupId, String generationId, boolean beta) { this.services = services; this.serviceConnector = serviceConnector; this.appName = appName; this.deployType = deployType; this.buildType = buildType; this.workspaceDirectory = workspaceDirectory; this.techOptions = techOptions; this.artifactId = artifactId; this.groupId = groupId; this.generationId = generationId; this.beta = beta; } public String toBxJSON() {
// Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/ProjectConstructor.java // public enum DeployType { // LOCAL, BLUEMIX // } // // Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/api/v1/model/internal/Services.java // public class Services { // private List<Service> services; // // public List<Service> getServices() { // return services; // } // // public void setServices(List<Service> services) { // this.services = services; // } // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/registration/Service.java // public class Service { // // private String id; // private String name; // private String description; // private String endpoint; // private String configuration; // private boolean options; // private String image; // private String imageSelected; // // @ApiModelProperty(value="Unique ID for this technology", required=true) // public String getId() { // return id; // } // public void setId(String id) { // this.id = id; // } // // @ApiModelProperty(value="Name of the technology (does not have to be unique, although it will be confusing if it isn't)", required=true) // public String getName() { // return name; // } // public void setName(String name) { // this.name = name; // } // // @ApiModelProperty(value="Description of the technology", required=true) // public String getDescription() { // return description; // } // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value="The endpoint to access the service", required=true) // public String getEndpoint() { // return endpoint; // } // public void setEndpoint(String endpoint) { // this.endpoint = endpoint; // } // // @ApiModelProperty(value="Specifies whether this technology allows any configuration(s). Value could either be 'yes' or a list of other technologies, seperated by comma. If a list of technologies is specified then the configuration(s) will be enabled only if all technologies on the list are selected by user", required=false) // public String getConfiguration() { // return configuration; // } // public void setConfiguration(String configuration) { // this.configuration = configuration; // } // // @ApiModelProperty(value="Specifies whether this technology has any additional options that can be set by the user", required=false) // public boolean getOptions() { // return options; // } // public void setOptions(boolean options) { // this.options = options; // } // // @Override // public String toString() { // return "Service [id=" + id + ", endpoint=" + endpoint + "]"; // } // // @ApiModelProperty(value="Specifies an image to display on the technology button", required=false) // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // // @ApiModelProperty(value="Specifies an image to display on the technology button when it is selected", required=false) // public String getImageSelected() { // return imageSelected; // } // // public void setImageSelected(String image) { // this.imageSelected = image; // } // } // Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/ProjectConstructionInputData.java import java.util.List; import java.util.stream.Stream; import com.ibm.liberty.starter.ProjectConstructor.DeployType; import com.ibm.liberty.starter.api.v1.model.internal.Services; import com.ibm.liberty.starter.api.v1.model.registration.Service; /******************************************************************************* * Copyright (c) 2016,2017 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter; public class ProjectConstructionInputData { public final Services services; public final ServiceConnector serviceConnector; public final String appName; public final ProjectConstructor.DeployType deployType; public final ProjectConstructor.BuildType buildType; public final String workspaceDirectory; public final String[] techOptions; public final String artifactId; public final String groupId; public final String generationId; public final boolean beta; public ProjectConstructionInputData(Services services, ServiceConnector serviceConnector, String appName, ProjectConstructor.DeployType deployType, ProjectConstructor.BuildType buildType, String workspaceDirectory, String[] techOptions, String artifactId, String groupId, String generationId, boolean beta) { this.services = services; this.serviceConnector = serviceConnector; this.appName = appName; this.deployType = deployType; this.buildType = buildType; this.workspaceDirectory = workspaceDirectory; this.techOptions = techOptions; this.artifactId = artifactId; this.groupId = groupId; this.generationId = generationId; this.beta = beta; } public String toBxJSON() {
List<Service> serviceList = services.getServices();
WASdev/tool.accelerate.core
liberty-starter-application/src/main/java/com/ibm/liberty/starter/api/v1/WorkspaceEndpoint.java
// Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/StarterUtil.java // public class StarterUtil { // // private static final Logger log = Logger.getLogger(StarterUtil.class.getName()); // // private static String serverOutputDir; // // public static final String WORKAREA = "workarea"; // public static final String APP_ACCELERATOR_WORKAREA = "appAccelerator"; // public static final String PACKAGE_DIR = "package"; // // private static String processPath(String string) { // if(string == null){ // return ""; // } // return string.replace('\\', '/'); // } // // private static String getServerOutputDir() { // if(serverOutputDir == null){ // try{ // serverOutputDir = processPath(((String)(new InitialContext().lookup("serverOutputDir")))); // if(!serverOutputDir.endsWith("/")){ // serverOutputDir += "/"; // } // log.info("serverOutputDir=" + serverOutputDir); // }catch (NamingException ne){ // log.severe("NamingException occurred while retrieving the value of 'serverOutputDir': " + ne); // throw new ValidationException("NamingException occurred while retrieving the value of 'serverOutputDir': " + ne); // } // } // return serverOutputDir; // } // // public static String getWorkspaceDir(String workspaceId){ // return getServerOutputDir() + WORKAREA + "/" + APP_ACCELERATOR_WORKAREA + "/" + workspaceId; // } // // /** // * Generate the list of files in the directory and all of its sub-directories (recursive) // * // * @param dir - The directory // * @param filesListInDir - List to store the files // */ // public static void populateFilesList(File dir, List<File> filesListInDir) { // File[] files = dir.listFiles(); // for(File file : files){ // if(file.isFile()){ // filesListInDir.add(file); // }else{ // populateFilesList(file, filesListInDir); // } // } // } // // public static String createCleanWorkspace() throws IOException { // String uuid = UUID.randomUUID().toString(); // // //Clean up workspace directory if it already exists (from previous server run) // String workspaceDirPath = StarterUtil.getWorkspaceDir(uuid); // File workspaceDir = new File(workspaceDirPath); // if(workspaceDir.exists()){ // log.log(Level.FINE, "Workspace directory already exists : " + workspaceDirPath); // FileUtils.deleteDirectory(workspaceDir); // log.log(Level.FINE, "Deleted workspace directory : " + workspaceDirPath); // } // return uuid; // } // // }
import java.io.File; import java.io.IOException; import java.io.OutputStream; import java.util.Iterator; import java.util.logging.Logger; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import javax.ws.rs.core.StreamingOutput; import org.apache.commons.io.FileUtils; import org.apache.commons.io.filefilter.FileFilterUtils; import org.apache.commons.io.filefilter.IOFileFilter; import org.apache.commons.io.filefilter.NameFileFilter; import com.ibm.liberty.starter.StarterUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses;
/******************************************************************************* * Copyright (c) 2016,2017 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.api.v1; @Path("v1/workspace") @Api(value = "Workspace Identifier") public class WorkspaceEndpoint { private static final Logger log = Logger.getLogger(WorkspaceEndpoint.class.getName()); @GET @Path("/") @Produces(MediaType.TEXT_PLAIN) // Swagger annotations @ApiOperation(value = "Retrieve a unique workspace identifier", httpMethod = "GET", notes = "Get a unique workspace to store files.") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successfully created a unique workspace identifier") }) public Response workspace() throws IOException {
// Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/StarterUtil.java // public class StarterUtil { // // private static final Logger log = Logger.getLogger(StarterUtil.class.getName()); // // private static String serverOutputDir; // // public static final String WORKAREA = "workarea"; // public static final String APP_ACCELERATOR_WORKAREA = "appAccelerator"; // public static final String PACKAGE_DIR = "package"; // // private static String processPath(String string) { // if(string == null){ // return ""; // } // return string.replace('\\', '/'); // } // // private static String getServerOutputDir() { // if(serverOutputDir == null){ // try{ // serverOutputDir = processPath(((String)(new InitialContext().lookup("serverOutputDir")))); // if(!serverOutputDir.endsWith("/")){ // serverOutputDir += "/"; // } // log.info("serverOutputDir=" + serverOutputDir); // }catch (NamingException ne){ // log.severe("NamingException occurred while retrieving the value of 'serverOutputDir': " + ne); // throw new ValidationException("NamingException occurred while retrieving the value of 'serverOutputDir': " + ne); // } // } // return serverOutputDir; // } // // public static String getWorkspaceDir(String workspaceId){ // return getServerOutputDir() + WORKAREA + "/" + APP_ACCELERATOR_WORKAREA + "/" + workspaceId; // } // // /** // * Generate the list of files in the directory and all of its sub-directories (recursive) // * // * @param dir - The directory // * @param filesListInDir - List to store the files // */ // public static void populateFilesList(File dir, List<File> filesListInDir) { // File[] files = dir.listFiles(); // for(File file : files){ // if(file.isFile()){ // filesListInDir.add(file); // }else{ // populateFilesList(file, filesListInDir); // } // } // } // // public static String createCleanWorkspace() throws IOException { // String uuid = UUID.randomUUID().toString(); // // //Clean up workspace directory if it already exists (from previous server run) // String workspaceDirPath = StarterUtil.getWorkspaceDir(uuid); // File workspaceDir = new File(workspaceDirPath); // if(workspaceDir.exists()){ // log.log(Level.FINE, "Workspace directory already exists : " + workspaceDirPath); // FileUtils.deleteDirectory(workspaceDir); // log.log(Level.FINE, "Deleted workspace directory : " + workspaceDirPath); // } // return uuid; // } // // } // Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/api/v1/WorkspaceEndpoint.java import java.io.File; import java.io.IOException; import java.io.OutputStream; import java.util.Iterator; import java.util.logging.Logger; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import javax.ws.rs.core.StreamingOutput; import org.apache.commons.io.FileUtils; import org.apache.commons.io.filefilter.FileFilterUtils; import org.apache.commons.io.filefilter.IOFileFilter; import org.apache.commons.io.filefilter.NameFileFilter; import com.ibm.liberty.starter.StarterUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; /******************************************************************************* * Copyright (c) 2016,2017 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.api.v1; @Path("v1/workspace") @Api(value = "Workspace Identifier") public class WorkspaceEndpoint { private static final Logger log = Logger.getLogger(WorkspaceEndpoint.class.getName()); @GET @Path("/") @Produces(MediaType.TEXT_PLAIN) // Swagger annotations @ApiOperation(value = "Retrieve a unique workspace identifier", httpMethod = "GET", notes = "Get a unique workspace to store files.") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successfully created a unique workspace identifier") }) public Response workspace() throws IOException {
String uuid = StarterUtil.createCleanWorkspace();
WASdev/tool.accelerate.core
liberty-starter-application/src/test/java/com/ibm/liberty/starter/it/api/v1/TechnologyEndpointTest.java
// Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/api/v1/model/internal/Services.java // public class Services { // private List<Service> services; // // public List<Service> getServices() { // return services; // } // // public void setServices(List<Service> services) { // this.services = services; // } // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/registration/Service.java // public class Service { // // private String id; // private String name; // private String description; // private String endpoint; // private String configuration; // private boolean options; // private String image; // private String imageSelected; // // @ApiModelProperty(value="Unique ID for this technology", required=true) // public String getId() { // return id; // } // public void setId(String id) { // this.id = id; // } // // @ApiModelProperty(value="Name of the technology (does not have to be unique, although it will be confusing if it isn't)", required=true) // public String getName() { // return name; // } // public void setName(String name) { // this.name = name; // } // // @ApiModelProperty(value="Description of the technology", required=true) // public String getDescription() { // return description; // } // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value="The endpoint to access the service", required=true) // public String getEndpoint() { // return endpoint; // } // public void setEndpoint(String endpoint) { // this.endpoint = endpoint; // } // // @ApiModelProperty(value="Specifies whether this technology allows any configuration(s). Value could either be 'yes' or a list of other technologies, seperated by comma. If a list of technologies is specified then the configuration(s) will be enabled only if all technologies on the list are selected by user", required=false) // public String getConfiguration() { // return configuration; // } // public void setConfiguration(String configuration) { // this.configuration = configuration; // } // // @ApiModelProperty(value="Specifies whether this technology has any additional options that can be set by the user", required=false) // public boolean getOptions() { // return options; // } // public void setOptions(boolean options) { // this.options = options; // } // // @Override // public String toString() { // return "Service [id=" + id + ", endpoint=" + endpoint + "]"; // } // // @ApiModelProperty(value="Specifies an image to display on the technology button", required=false) // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // // @ApiModelProperty(value="Specifies an image to display on the technology button when it is selected", required=false) // public String getImageSelected() { // return imageSelected; // } // // public void setImageSelected(String image) { // this.imageSelected = image; // } // }
import com.ibm.liberty.starter.api.v1.model.internal.Services; import com.ibm.liberty.starter.api.v1.model.registration.Service; import org.junit.Ignore; import org.junit.Test; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.Invocation; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType; import java.util.List; import static org.junit.Assert.assertTrue;
/******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.it.api.v1; @Ignore //Currently broken tests, getting a message body reader not found error public class TechnologyEndpointTest { private String endpoint = "/start/api/v1/tech"; @Test public void testTechList() throws Exception {
// Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/api/v1/model/internal/Services.java // public class Services { // private List<Service> services; // // public List<Service> getServices() { // return services; // } // // public void setServices(List<Service> services) { // this.services = services; // } // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/registration/Service.java // public class Service { // // private String id; // private String name; // private String description; // private String endpoint; // private String configuration; // private boolean options; // private String image; // private String imageSelected; // // @ApiModelProperty(value="Unique ID for this technology", required=true) // public String getId() { // return id; // } // public void setId(String id) { // this.id = id; // } // // @ApiModelProperty(value="Name of the technology (does not have to be unique, although it will be confusing if it isn't)", required=true) // public String getName() { // return name; // } // public void setName(String name) { // this.name = name; // } // // @ApiModelProperty(value="Description of the technology", required=true) // public String getDescription() { // return description; // } // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value="The endpoint to access the service", required=true) // public String getEndpoint() { // return endpoint; // } // public void setEndpoint(String endpoint) { // this.endpoint = endpoint; // } // // @ApiModelProperty(value="Specifies whether this technology allows any configuration(s). Value could either be 'yes' or a list of other technologies, seperated by comma. If a list of technologies is specified then the configuration(s) will be enabled only if all technologies on the list are selected by user", required=false) // public String getConfiguration() { // return configuration; // } // public void setConfiguration(String configuration) { // this.configuration = configuration; // } // // @ApiModelProperty(value="Specifies whether this technology has any additional options that can be set by the user", required=false) // public boolean getOptions() { // return options; // } // public void setOptions(boolean options) { // this.options = options; // } // // @Override // public String toString() { // return "Service [id=" + id + ", endpoint=" + endpoint + "]"; // } // // @ApiModelProperty(value="Specifies an image to display on the technology button", required=false) // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // // @ApiModelProperty(value="Specifies an image to display on the technology button when it is selected", required=false) // public String getImageSelected() { // return imageSelected; // } // // public void setImageSelected(String image) { // this.imageSelected = image; // } // } // Path: liberty-starter-application/src/test/java/com/ibm/liberty/starter/it/api/v1/TechnologyEndpointTest.java import com.ibm.liberty.starter.api.v1.model.internal.Services; import com.ibm.liberty.starter.api.v1.model.registration.Service; import org.junit.Ignore; import org.junit.Test; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.Invocation; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType; import java.util.List; import static org.junit.Assert.assertTrue; /******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.it.api.v1; @Ignore //Currently broken tests, getting a message body reader not found error public class TechnologyEndpointTest { private String endpoint = "/start/api/v1/tech"; @Test public void testTechList() throws Exception {
Services services = getObjectFromEndpoint(Services.class, "", MediaType.APPLICATION_JSON_TYPE);
WASdev/tool.accelerate.core
liberty-starter-application/src/test/java/com/ibm/liberty/starter/it/api/v1/TechnologyEndpointTest.java
// Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/api/v1/model/internal/Services.java // public class Services { // private List<Service> services; // // public List<Service> getServices() { // return services; // } // // public void setServices(List<Service> services) { // this.services = services; // } // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/registration/Service.java // public class Service { // // private String id; // private String name; // private String description; // private String endpoint; // private String configuration; // private boolean options; // private String image; // private String imageSelected; // // @ApiModelProperty(value="Unique ID for this technology", required=true) // public String getId() { // return id; // } // public void setId(String id) { // this.id = id; // } // // @ApiModelProperty(value="Name of the technology (does not have to be unique, although it will be confusing if it isn't)", required=true) // public String getName() { // return name; // } // public void setName(String name) { // this.name = name; // } // // @ApiModelProperty(value="Description of the technology", required=true) // public String getDescription() { // return description; // } // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value="The endpoint to access the service", required=true) // public String getEndpoint() { // return endpoint; // } // public void setEndpoint(String endpoint) { // this.endpoint = endpoint; // } // // @ApiModelProperty(value="Specifies whether this technology allows any configuration(s). Value could either be 'yes' or a list of other technologies, seperated by comma. If a list of technologies is specified then the configuration(s) will be enabled only if all technologies on the list are selected by user", required=false) // public String getConfiguration() { // return configuration; // } // public void setConfiguration(String configuration) { // this.configuration = configuration; // } // // @ApiModelProperty(value="Specifies whether this technology has any additional options that can be set by the user", required=false) // public boolean getOptions() { // return options; // } // public void setOptions(boolean options) { // this.options = options; // } // // @Override // public String toString() { // return "Service [id=" + id + ", endpoint=" + endpoint + "]"; // } // // @ApiModelProperty(value="Specifies an image to display on the technology button", required=false) // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // // @ApiModelProperty(value="Specifies an image to display on the technology button when it is selected", required=false) // public String getImageSelected() { // return imageSelected; // } // // public void setImageSelected(String image) { // this.imageSelected = image; // } // }
import com.ibm.liberty.starter.api.v1.model.internal.Services; import com.ibm.liberty.starter.api.v1.model.registration.Service; import org.junit.Ignore; import org.junit.Test; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.Invocation; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType; import java.util.List; import static org.junit.Assert.assertTrue;
/******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.it.api.v1; @Ignore //Currently broken tests, getting a message body reader not found error public class TechnologyEndpointTest { private String endpoint = "/start/api/v1/tech"; @Test public void testTechList() throws Exception { Services services = getObjectFromEndpoint(Services.class, "", MediaType.APPLICATION_JSON_TYPE);
// Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/api/v1/model/internal/Services.java // public class Services { // private List<Service> services; // // public List<Service> getServices() { // return services; // } // // public void setServices(List<Service> services) { // this.services = services; // } // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/registration/Service.java // public class Service { // // private String id; // private String name; // private String description; // private String endpoint; // private String configuration; // private boolean options; // private String image; // private String imageSelected; // // @ApiModelProperty(value="Unique ID for this technology", required=true) // public String getId() { // return id; // } // public void setId(String id) { // this.id = id; // } // // @ApiModelProperty(value="Name of the technology (does not have to be unique, although it will be confusing if it isn't)", required=true) // public String getName() { // return name; // } // public void setName(String name) { // this.name = name; // } // // @ApiModelProperty(value="Description of the technology", required=true) // public String getDescription() { // return description; // } // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value="The endpoint to access the service", required=true) // public String getEndpoint() { // return endpoint; // } // public void setEndpoint(String endpoint) { // this.endpoint = endpoint; // } // // @ApiModelProperty(value="Specifies whether this technology allows any configuration(s). Value could either be 'yes' or a list of other technologies, seperated by comma. If a list of technologies is specified then the configuration(s) will be enabled only if all technologies on the list are selected by user", required=false) // public String getConfiguration() { // return configuration; // } // public void setConfiguration(String configuration) { // this.configuration = configuration; // } // // @ApiModelProperty(value="Specifies whether this technology has any additional options that can be set by the user", required=false) // public boolean getOptions() { // return options; // } // public void setOptions(boolean options) { // this.options = options; // } // // @Override // public String toString() { // return "Service [id=" + id + ", endpoint=" + endpoint + "]"; // } // // @ApiModelProperty(value="Specifies an image to display on the technology button", required=false) // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // // @ApiModelProperty(value="Specifies an image to display on the technology button when it is selected", required=false) // public String getImageSelected() { // return imageSelected; // } // // public void setImageSelected(String image) { // this.imageSelected = image; // } // } // Path: liberty-starter-application/src/test/java/com/ibm/liberty/starter/it/api/v1/TechnologyEndpointTest.java import com.ibm.liberty.starter.api.v1.model.internal.Services; import com.ibm.liberty.starter.api.v1.model.registration.Service; import org.junit.Ignore; import org.junit.Test; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.Invocation; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType; import java.util.List; import static org.junit.Assert.assertTrue; /******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.it.api.v1; @Ignore //Currently broken tests, getting a message body reader not found error public class TechnologyEndpointTest { private String endpoint = "/start/api/v1/tech"; @Test public void testTechList() throws Exception { Services services = getObjectFromEndpoint(Services.class, "", MediaType.APPLICATION_JSON_TYPE);
List<Service> servicesList= services.getServices();
WASdev/tool.accelerate.core
liberty-starter-common/src/main/java/com/ibm/liberty/starter/service/common/api/v1/ProviderEndpoint.java
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Provider.java // public class Provider { // private String description; // private Dependency[] dependencies; // private Location repoUrl; // // @ApiModelProperty(value = "Description of the technology provider to be inserted into index.html", required = true) // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value = "Dependencies to be specified to the user when they get the download", required = true) // public Dependency[] getDependencies() { // return dependencies; // } // // public void setDependencies(Dependency[] dependencies) { // this.dependencies = dependencies; // } // // @ApiModelProperty(value = "The location of the repository for this microservice.") // public Location getRepoUrl() { // return repoUrl; // } // // public void setRepoUrl(Location repoUrl) { // this.repoUrl = repoUrl; // } // // }
import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import com.ibm.liberty.starter.api.v1.model.provider.Provider;
/******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.common.api.v1; @Path("v1/provider") public abstract class ProviderEndpoint { @GET @Path("/") @Produces(MediaType.APPLICATION_JSON)
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Provider.java // public class Provider { // private String description; // private Dependency[] dependencies; // private Location repoUrl; // // @ApiModelProperty(value = "Description of the technology provider to be inserted into index.html", required = true) // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value = "Dependencies to be specified to the user when they get the download", required = true) // public Dependency[] getDependencies() { // return dependencies; // } // // public void setDependencies(Dependency[] dependencies) { // this.dependencies = dependencies; // } // // @ApiModelProperty(value = "The location of the repository for this microservice.") // public Location getRepoUrl() { // return repoUrl; // } // // public void setRepoUrl(Location repoUrl) { // this.repoUrl = repoUrl; // } // // } // Path: liberty-starter-common/src/main/java/com/ibm/liberty/starter/service/common/api/v1/ProviderEndpoint.java import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import com.ibm.liberty.starter.api.v1.model.provider.Provider; /******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.common.api.v1; @Path("v1/provider") public abstract class ProviderEndpoint { @GET @Path("/") @Produces(MediaType.APPLICATION_JSON)
public Provider details() {
WASdev/tool.accelerate.core
starter-microservice-web/src/test/java/it/TestApplication.java
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/EndpointResponse.java // public class EndpointResponse { // // private String status; // // public String getStatus() { // return status; // } // // public void setStatus(String status) { // this.status = status; // } // // }
import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; import com.ibm.liberty.starter.api.v1.model.provider.EndpointResponse;
/******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package it; public class TestApplication extends EndpointTest { @Before public void checkSetup() { checkAvailability("/api/v1/provider/"); } @Test public void testProvider() throws Exception {
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/EndpointResponse.java // public class EndpointResponse { // // private String status; // // public String getStatus() { // return status; // } // // public void setStatus(String status) { // this.status = status; // } // // } // Path: starter-microservice-web/src/test/java/it/TestApplication.java import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; import com.ibm.liberty.starter.api.v1.model.provider.EndpointResponse; /******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package it; public class TestApplication extends EndpointTest { @Before public void checkSetup() { checkAvailability("/api/v1/provider/"); } @Test public void testProvider() throws Exception {
EndpointResponse response = testEndpoint("/api/v1/provider/", EndpointResponse.class);
WASdev/tool.accelerate.core
starter-microservice-swagger/src/test/java/com/ibm/liberty/starter/service/swagger/api/v1/it/TestApplication.java
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/EndpointResponse.java // public class EndpointResponse { // // private String status; // // public String getStatus() { // return status; // } // // public void setStatus(String status) { // this.status = status; // } // // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.io.File; import java.util.UUID; import org.apache.commons.io.FileUtils; import org.junit.Before; import org.junit.Test; import com.ibm.liberty.starter.api.v1.model.provider.EndpointResponse;
/******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.swagger.api.v1.it; /** * Test the deployed service responds as expected * */ public class TestApplication extends EndpointTest { @Before public void checkSetup() { checkAvailability("/api/v1/provider/"); } @Test public void testProvider() throws Exception {
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/EndpointResponse.java // public class EndpointResponse { // // private String status; // // public String getStatus() { // return status; // } // // public void setStatus(String status) { // this.status = status; // } // // } // Path: starter-microservice-swagger/src/test/java/com/ibm/liberty/starter/service/swagger/api/v1/it/TestApplication.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.io.File; import java.util.UUID; import org.apache.commons.io.FileUtils; import org.junit.Before; import org.junit.Test; import com.ibm.liberty.starter.api.v1.model.provider.EndpointResponse; /******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.swagger.api.v1.it; /** * Test the deployed service responds as expected * */ public class TestApplication extends EndpointTest { @Before public void checkSetup() { checkAvailability("/api/v1/provider/"); } @Test public void testProvider() throws Exception {
EndpointResponse response = testEndpoint("/api/v1/provider/", EndpointResponse.class);
WASdev/tool.accelerate.core
liberty-starter-application/src/test/java/com/ibm/liberty/starter/it/api/v1/GenerateProjectEndpointTest.java
// Path: liberty-starter-application/src/test/java/com/ibm/liberty/starter/it/api/v1/utils/DownloadZip.java // public class DownloadZip { // public static Response get(String queryString) throws Exception { // Client client = ClientBuilder.newClient(); // String port = System.getProperty("liberty.test.port"); // String url = "http://localhost:" + port + "/start/api/v1/data?" + queryString; // System.out.println("Testing " + url); // Response response = client.target(url).request("application/zip").get(); // return response; // } // // public static void assertBasicContent(Response resp, String buildFile, boolean bluemix) throws Exception{ // boolean foundBuildFile = false; // boolean foundReadme = false; // boolean foundSrc = false; // boolean foundTests = false; // boolean foundBluemixFiles = false; // // Read the response into an InputStream // InputStream entityInputStream = resp.readEntity(InputStream.class); // // Create a new ZipInputStream from the response InputStream // ZipInputStream zipIn = new ZipInputStream(entityInputStream); // // This system property is being set in the liberty-starter-application/build.gradle file // String tempDir = System.getProperty("liberty.temp.dir"); // File file = new File(tempDir + "/TestApp.zip"); // System.out.println("Creating zip file: " + file.toString()); // file.getParentFile().mkdirs(); // ZipEntry inputEntry = null; // String zipEntries = ""; // while ((inputEntry = zipIn.getNextEntry()) != null) { // String entryName = inputEntry.getName(); // zipEntries += entryName + ","; // if (buildFile.equals(entryName)) { // foundBuildFile = true; // } // if ("README.md".equals(entryName)) { // foundReadme = true; // } // if (entryName.startsWith("src/main/java")) { // foundSrc = true; // } // if (entryName.startsWith("src/test/java")) { // foundTests = true; // } // if (entryName.equals("manifest.yml")) { // foundBluemixFiles = true; // } // zipIn.closeEntry(); // } // zipIn.close(); // assertTrue("Didn't find build file " + buildFile + ". Zip entries were: " + zipEntries, foundBuildFile); // assertTrue("Didn't find README.md file. Zip entries were: " + zipEntries, foundReadme); // assertTrue("Didn't find any Java source files i.e. files starting src/main/java. Zip entries were: " + zipEntries, foundSrc); // assertTrue("Didn't find any Java test files i.e. files starting src/test/java. Zip entries were: " + zipEntries, foundTests); // assertTrue("Expected foundBluemixFiles to be " + bluemix + ". Zip entries were: " + zipEntries, bluemix == foundBluemixFiles); // } // }
import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeTrue; import java.io.StringReader; import javax.json.Json; import javax.json.JsonReader; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.junit.Test; import com.ibm.liberty.starter.it.api.v1.utils.DownloadZip;
/******************************************************************************* * Copyright (c) 2017 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.it.api.v1; public class GenerateProjectEndpointTest { @Test public void generateMavenProjectTest() throws Exception { Response generateResponse = callGenerateEndpoint(); int generateResponseStatus = generateResponse.getStatus(); String generateOutput = ""; if (generateResponseStatus != 200) { generateOutput = generateResponse.readEntity(String.class); assumeTrue(!generateOutput.contains("Missing project generation configuration: generation URL, starter URL")); } assertTrue("Expected response status 200, instead found " + generateResponseStatus + " and output " + generateOutput, generateResponseStatus == 200); String responseString = generateResponse.readEntity(String.class); JsonReader jsonReader = Json.createReader(new StringReader(responseString)); String queryString = jsonReader.readObject().getString("requestQueryString");
// Path: liberty-starter-application/src/test/java/com/ibm/liberty/starter/it/api/v1/utils/DownloadZip.java // public class DownloadZip { // public static Response get(String queryString) throws Exception { // Client client = ClientBuilder.newClient(); // String port = System.getProperty("liberty.test.port"); // String url = "http://localhost:" + port + "/start/api/v1/data?" + queryString; // System.out.println("Testing " + url); // Response response = client.target(url).request("application/zip").get(); // return response; // } // // public static void assertBasicContent(Response resp, String buildFile, boolean bluemix) throws Exception{ // boolean foundBuildFile = false; // boolean foundReadme = false; // boolean foundSrc = false; // boolean foundTests = false; // boolean foundBluemixFiles = false; // // Read the response into an InputStream // InputStream entityInputStream = resp.readEntity(InputStream.class); // // Create a new ZipInputStream from the response InputStream // ZipInputStream zipIn = new ZipInputStream(entityInputStream); // // This system property is being set in the liberty-starter-application/build.gradle file // String tempDir = System.getProperty("liberty.temp.dir"); // File file = new File(tempDir + "/TestApp.zip"); // System.out.println("Creating zip file: " + file.toString()); // file.getParentFile().mkdirs(); // ZipEntry inputEntry = null; // String zipEntries = ""; // while ((inputEntry = zipIn.getNextEntry()) != null) { // String entryName = inputEntry.getName(); // zipEntries += entryName + ","; // if (buildFile.equals(entryName)) { // foundBuildFile = true; // } // if ("README.md".equals(entryName)) { // foundReadme = true; // } // if (entryName.startsWith("src/main/java")) { // foundSrc = true; // } // if (entryName.startsWith("src/test/java")) { // foundTests = true; // } // if (entryName.equals("manifest.yml")) { // foundBluemixFiles = true; // } // zipIn.closeEntry(); // } // zipIn.close(); // assertTrue("Didn't find build file " + buildFile + ". Zip entries were: " + zipEntries, foundBuildFile); // assertTrue("Didn't find README.md file. Zip entries were: " + zipEntries, foundReadme); // assertTrue("Didn't find any Java source files i.e. files starting src/main/java. Zip entries were: " + zipEntries, foundSrc); // assertTrue("Didn't find any Java test files i.e. files starting src/test/java. Zip entries were: " + zipEntries, foundTests); // assertTrue("Expected foundBluemixFiles to be " + bluemix + ". Zip entries were: " + zipEntries, bluemix == foundBluemixFiles); // } // } // Path: liberty-starter-application/src/test/java/com/ibm/liberty/starter/it/api/v1/GenerateProjectEndpointTest.java import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeTrue; import java.io.StringReader; import javax.json.Json; import javax.json.JsonReader; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.junit.Test; import com.ibm.liberty.starter.it.api.v1.utils.DownloadZip; /******************************************************************************* * Copyright (c) 2017 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.it.api.v1; public class GenerateProjectEndpointTest { @Test public void generateMavenProjectTest() throws Exception { Response generateResponse = callGenerateEndpoint(); int generateResponseStatus = generateResponse.getStatus(); String generateOutput = ""; if (generateResponseStatus != 200) { generateOutput = generateResponse.readEntity(String.class); assumeTrue(!generateOutput.contains("Missing project generation configuration: generation URL, starter URL")); } assertTrue("Expected response status 200, instead found " + generateResponseStatus + " and output " + generateOutput, generateResponseStatus == 200); String responseString = generateResponse.readEntity(String.class); JsonReader jsonReader = Json.createReader(new StringReader(responseString)); String queryString = jsonReader.readObject().getString("requestQueryString");
Response response = DownloadZip.get(queryString);
WASdev/tool.accelerate.core
liberty-starter-application/src/main/java/com/ibm/liberty/starter/client/BxCodegenClient.java
// Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/ProjectConstructionInputData.java // public class ProjectConstructionInputData { // public final Services services; // public final ServiceConnector serviceConnector; // public final String appName; // public final ProjectConstructor.DeployType deployType; // public final ProjectConstructor.BuildType buildType; // public final String workspaceDirectory; // public final String[] techOptions; // public final String artifactId; // public final String groupId; // public final String generationId; // public final boolean beta; // // public ProjectConstructionInputData(Services services, ServiceConnector serviceConnector, String appName, ProjectConstructor.DeployType deployType, ProjectConstructor.BuildType buildType, String workspaceDirectory, String[] techOptions, String artifactId, String groupId, String generationId, boolean beta) { // this.services = services; // this.serviceConnector = serviceConnector; // this.appName = appName; // this.deployType = deployType; // this.buildType = buildType; // this.workspaceDirectory = workspaceDirectory; // this.techOptions = techOptions; // this.artifactId = artifactId; // this.groupId = groupId; // this.generationId = generationId; // this.beta = beta; // } // // public String toBxJSON() { // List<Service> serviceList = services.getServices(); // Stream<Service> stream = serviceList.stream(); // StringBuffer technologies = new StringBuffer("\""); // stream.forEach((service) -> { // technologies.append(service.getId() + ","); // }); // String stringresult = technologies.length() == 1 ? "" : technologies.substring(0, technologies.length() - 1) + "\""; // String json = "{\"technologies\":" + stringresult + "," // + "\"appName\":\"" + appName + "\"," // + "\"buildType\":\"" + buildType.toString().toLowerCase() + "\"," // + "\"createType\":\"picnmix\""; // if (deployType.equals(DeployType.BLUEMIX)) { // json += ",\"platforms\":\"bluemix\""; // } else { // json += ",\"platforms\":\"\""; // } // if (artifactId != null) { // json += ",\"artifactId\":\"" + artifactId + "\""; // } // if (groupId != null) { // json += ",\"groupId\":\"" + groupId + "\""; // } // if (beta) { // json += ",\"libertybeta\":\"true\""; // } // json += "}"; // return json; // } // // public String toRequestQueryString(String id) { // List<Service> serviceList = services.getServices(); // Stream<Service> stream = serviceList.stream(); // StringBuffer technologies = new StringBuffer(""); // stream.forEach((service) -> { // technologies.append("&tech=" + service.getId()); // }); // String techOptionsString = ""; // for(String options : techOptions) { // techOptionsString += "&techoptions=" + options; // } // String[] workspaceArray = workspaceDirectory.split("/"); // String workspaceId = workspaceArray[workspaceArray.length -1]; // String genId = (id == null ? generationId : id); // return "name=" + appName + technologies + "&deploy=" + deployType.toString().toLowerCase() + "&build=" + buildType.toString() + "&workspace=" + workspaceId + techOptionsString + "&artifactId=" + artifactId + "&groupId=" + groupId + "&generationId=" + genId + "&beta=" + beta; // } // } // // Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/exception/ProjectGenerationException.java // public class ProjectGenerationException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public ProjectGenerationException() { // } // // public ProjectGenerationException(String message) { // super(message); // } // // public ProjectGenerationException(Throwable cause) { // super(cause); // } // // public ProjectGenerationException(String message, Throwable cause) { // super(message, cause); // } // // public ProjectGenerationException(String message, Throwable cause, boolean enableSuppression, // boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // }
import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.Map; import java.util.logging.Logger; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import javax.json.Json; import javax.json.JsonObject; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.Entity; import javax.ws.rs.client.Invocation; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import com.ibm.liberty.starter.ProjectConstructionInputData; import com.ibm.liberty.starter.exception.ProjectGenerationException;
/******************************************************************************* * Copyright (c) 2017 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.client; public class BxCodegenClient { private static final Logger log = Logger.getLogger(BxCodegenClient.class.getName()); public final String URL = System.getenv("bxCodegenEndpoint"); public final String STARTERKIT_URL = System.getenv("appAccelStarterkit"); private final int retriesAllowed = 18;
// Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/ProjectConstructionInputData.java // public class ProjectConstructionInputData { // public final Services services; // public final ServiceConnector serviceConnector; // public final String appName; // public final ProjectConstructor.DeployType deployType; // public final ProjectConstructor.BuildType buildType; // public final String workspaceDirectory; // public final String[] techOptions; // public final String artifactId; // public final String groupId; // public final String generationId; // public final boolean beta; // // public ProjectConstructionInputData(Services services, ServiceConnector serviceConnector, String appName, ProjectConstructor.DeployType deployType, ProjectConstructor.BuildType buildType, String workspaceDirectory, String[] techOptions, String artifactId, String groupId, String generationId, boolean beta) { // this.services = services; // this.serviceConnector = serviceConnector; // this.appName = appName; // this.deployType = deployType; // this.buildType = buildType; // this.workspaceDirectory = workspaceDirectory; // this.techOptions = techOptions; // this.artifactId = artifactId; // this.groupId = groupId; // this.generationId = generationId; // this.beta = beta; // } // // public String toBxJSON() { // List<Service> serviceList = services.getServices(); // Stream<Service> stream = serviceList.stream(); // StringBuffer technologies = new StringBuffer("\""); // stream.forEach((service) -> { // technologies.append(service.getId() + ","); // }); // String stringresult = technologies.length() == 1 ? "" : technologies.substring(0, technologies.length() - 1) + "\""; // String json = "{\"technologies\":" + stringresult + "," // + "\"appName\":\"" + appName + "\"," // + "\"buildType\":\"" + buildType.toString().toLowerCase() + "\"," // + "\"createType\":\"picnmix\""; // if (deployType.equals(DeployType.BLUEMIX)) { // json += ",\"platforms\":\"bluemix\""; // } else { // json += ",\"platforms\":\"\""; // } // if (artifactId != null) { // json += ",\"artifactId\":\"" + artifactId + "\""; // } // if (groupId != null) { // json += ",\"groupId\":\"" + groupId + "\""; // } // if (beta) { // json += ",\"libertybeta\":\"true\""; // } // json += "}"; // return json; // } // // public String toRequestQueryString(String id) { // List<Service> serviceList = services.getServices(); // Stream<Service> stream = serviceList.stream(); // StringBuffer technologies = new StringBuffer(""); // stream.forEach((service) -> { // technologies.append("&tech=" + service.getId()); // }); // String techOptionsString = ""; // for(String options : techOptions) { // techOptionsString += "&techoptions=" + options; // } // String[] workspaceArray = workspaceDirectory.split("/"); // String workspaceId = workspaceArray[workspaceArray.length -1]; // String genId = (id == null ? generationId : id); // return "name=" + appName + technologies + "&deploy=" + deployType.toString().toLowerCase() + "&build=" + buildType.toString() + "&workspace=" + workspaceId + techOptionsString + "&artifactId=" + artifactId + "&groupId=" + groupId + "&generationId=" + genId + "&beta=" + beta; // } // } // // Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/exception/ProjectGenerationException.java // public class ProjectGenerationException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public ProjectGenerationException() { // } // // public ProjectGenerationException(String message) { // super(message); // } // // public ProjectGenerationException(Throwable cause) { // super(cause); // } // // public ProjectGenerationException(String message, Throwable cause) { // super(message, cause); // } // // public ProjectGenerationException(String message, Throwable cause, boolean enableSuppression, // boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/client/BxCodegenClient.java import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.Map; import java.util.logging.Logger; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import javax.json.Json; import javax.json.JsonObject; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.Entity; import javax.ws.rs.client.Invocation; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import com.ibm.liberty.starter.ProjectConstructionInputData; import com.ibm.liberty.starter.exception.ProjectGenerationException; /******************************************************************************* * Copyright (c) 2017 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.client; public class BxCodegenClient { private static final Logger log = Logger.getLogger(BxCodegenClient.class.getName()); public final String URL = System.getenv("bxCodegenEndpoint"); public final String STARTERKIT_URL = System.getenv("appAccelStarterkit"); private final int retriesAllowed = 18;
public Map<String, byte[]> getFileMap(ProjectConstructionInputData inputData) throws ProjectGenerationException {
WASdev/tool.accelerate.core
liberty-starter-application/src/main/java/com/ibm/liberty/starter/client/BxCodegenClient.java
// Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/ProjectConstructionInputData.java // public class ProjectConstructionInputData { // public final Services services; // public final ServiceConnector serviceConnector; // public final String appName; // public final ProjectConstructor.DeployType deployType; // public final ProjectConstructor.BuildType buildType; // public final String workspaceDirectory; // public final String[] techOptions; // public final String artifactId; // public final String groupId; // public final String generationId; // public final boolean beta; // // public ProjectConstructionInputData(Services services, ServiceConnector serviceConnector, String appName, ProjectConstructor.DeployType deployType, ProjectConstructor.BuildType buildType, String workspaceDirectory, String[] techOptions, String artifactId, String groupId, String generationId, boolean beta) { // this.services = services; // this.serviceConnector = serviceConnector; // this.appName = appName; // this.deployType = deployType; // this.buildType = buildType; // this.workspaceDirectory = workspaceDirectory; // this.techOptions = techOptions; // this.artifactId = artifactId; // this.groupId = groupId; // this.generationId = generationId; // this.beta = beta; // } // // public String toBxJSON() { // List<Service> serviceList = services.getServices(); // Stream<Service> stream = serviceList.stream(); // StringBuffer technologies = new StringBuffer("\""); // stream.forEach((service) -> { // technologies.append(service.getId() + ","); // }); // String stringresult = technologies.length() == 1 ? "" : technologies.substring(0, technologies.length() - 1) + "\""; // String json = "{\"technologies\":" + stringresult + "," // + "\"appName\":\"" + appName + "\"," // + "\"buildType\":\"" + buildType.toString().toLowerCase() + "\"," // + "\"createType\":\"picnmix\""; // if (deployType.equals(DeployType.BLUEMIX)) { // json += ",\"platforms\":\"bluemix\""; // } else { // json += ",\"platforms\":\"\""; // } // if (artifactId != null) { // json += ",\"artifactId\":\"" + artifactId + "\""; // } // if (groupId != null) { // json += ",\"groupId\":\"" + groupId + "\""; // } // if (beta) { // json += ",\"libertybeta\":\"true\""; // } // json += "}"; // return json; // } // // public String toRequestQueryString(String id) { // List<Service> serviceList = services.getServices(); // Stream<Service> stream = serviceList.stream(); // StringBuffer technologies = new StringBuffer(""); // stream.forEach((service) -> { // technologies.append("&tech=" + service.getId()); // }); // String techOptionsString = ""; // for(String options : techOptions) { // techOptionsString += "&techoptions=" + options; // } // String[] workspaceArray = workspaceDirectory.split("/"); // String workspaceId = workspaceArray[workspaceArray.length -1]; // String genId = (id == null ? generationId : id); // return "name=" + appName + technologies + "&deploy=" + deployType.toString().toLowerCase() + "&build=" + buildType.toString() + "&workspace=" + workspaceId + techOptionsString + "&artifactId=" + artifactId + "&groupId=" + groupId + "&generationId=" + genId + "&beta=" + beta; // } // } // // Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/exception/ProjectGenerationException.java // public class ProjectGenerationException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public ProjectGenerationException() { // } // // public ProjectGenerationException(String message) { // super(message); // } // // public ProjectGenerationException(Throwable cause) { // super(cause); // } // // public ProjectGenerationException(String message, Throwable cause) { // super(message, cause); // } // // public ProjectGenerationException(String message, Throwable cause, boolean enableSuppression, // boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // }
import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.Map; import java.util.logging.Logger; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import javax.json.Json; import javax.json.JsonObject; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.Entity; import javax.ws.rs.client.Invocation; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import com.ibm.liberty.starter.ProjectConstructionInputData; import com.ibm.liberty.starter.exception.ProjectGenerationException;
/******************************************************************************* * Copyright (c) 2017 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.client; public class BxCodegenClient { private static final Logger log = Logger.getLogger(BxCodegenClient.class.getName()); public final String URL = System.getenv("bxCodegenEndpoint"); public final String STARTERKIT_URL = System.getenv("appAccelStarterkit"); private final int retriesAllowed = 18;
// Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/ProjectConstructionInputData.java // public class ProjectConstructionInputData { // public final Services services; // public final ServiceConnector serviceConnector; // public final String appName; // public final ProjectConstructor.DeployType deployType; // public final ProjectConstructor.BuildType buildType; // public final String workspaceDirectory; // public final String[] techOptions; // public final String artifactId; // public final String groupId; // public final String generationId; // public final boolean beta; // // public ProjectConstructionInputData(Services services, ServiceConnector serviceConnector, String appName, ProjectConstructor.DeployType deployType, ProjectConstructor.BuildType buildType, String workspaceDirectory, String[] techOptions, String artifactId, String groupId, String generationId, boolean beta) { // this.services = services; // this.serviceConnector = serviceConnector; // this.appName = appName; // this.deployType = deployType; // this.buildType = buildType; // this.workspaceDirectory = workspaceDirectory; // this.techOptions = techOptions; // this.artifactId = artifactId; // this.groupId = groupId; // this.generationId = generationId; // this.beta = beta; // } // // public String toBxJSON() { // List<Service> serviceList = services.getServices(); // Stream<Service> stream = serviceList.stream(); // StringBuffer technologies = new StringBuffer("\""); // stream.forEach((service) -> { // technologies.append(service.getId() + ","); // }); // String stringresult = technologies.length() == 1 ? "" : technologies.substring(0, technologies.length() - 1) + "\""; // String json = "{\"technologies\":" + stringresult + "," // + "\"appName\":\"" + appName + "\"," // + "\"buildType\":\"" + buildType.toString().toLowerCase() + "\"," // + "\"createType\":\"picnmix\""; // if (deployType.equals(DeployType.BLUEMIX)) { // json += ",\"platforms\":\"bluemix\""; // } else { // json += ",\"platforms\":\"\""; // } // if (artifactId != null) { // json += ",\"artifactId\":\"" + artifactId + "\""; // } // if (groupId != null) { // json += ",\"groupId\":\"" + groupId + "\""; // } // if (beta) { // json += ",\"libertybeta\":\"true\""; // } // json += "}"; // return json; // } // // public String toRequestQueryString(String id) { // List<Service> serviceList = services.getServices(); // Stream<Service> stream = serviceList.stream(); // StringBuffer technologies = new StringBuffer(""); // stream.forEach((service) -> { // technologies.append("&tech=" + service.getId()); // }); // String techOptionsString = ""; // for(String options : techOptions) { // techOptionsString += "&techoptions=" + options; // } // String[] workspaceArray = workspaceDirectory.split("/"); // String workspaceId = workspaceArray[workspaceArray.length -1]; // String genId = (id == null ? generationId : id); // return "name=" + appName + technologies + "&deploy=" + deployType.toString().toLowerCase() + "&build=" + buildType.toString() + "&workspace=" + workspaceId + techOptionsString + "&artifactId=" + artifactId + "&groupId=" + groupId + "&generationId=" + genId + "&beta=" + beta; // } // } // // Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/exception/ProjectGenerationException.java // public class ProjectGenerationException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public ProjectGenerationException() { // } // // public ProjectGenerationException(String message) { // super(message); // } // // public ProjectGenerationException(Throwable cause) { // super(cause); // } // // public ProjectGenerationException(String message, Throwable cause) { // super(message, cause); // } // // public ProjectGenerationException(String message, Throwable cause, boolean enableSuppression, // boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/client/BxCodegenClient.java import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.Map; import java.util.logging.Logger; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import javax.json.Json; import javax.json.JsonObject; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.Entity; import javax.ws.rs.client.Invocation; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import com.ibm.liberty.starter.ProjectConstructionInputData; import com.ibm.liberty.starter.exception.ProjectGenerationException; /******************************************************************************* * Copyright (c) 2017 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.client; public class BxCodegenClient { private static final Logger log = Logger.getLogger(BxCodegenClient.class.getName()); public final String URL = System.getenv("bxCodegenEndpoint"); public final String STARTERKIT_URL = System.getenv("appAccelStarterkit"); private final int retriesAllowed = 18;
public Map<String, byte[]> getFileMap(ProjectConstructionInputData inputData) throws ProjectGenerationException {
WASdev/tool.accelerate.core
starter-microservice-template/src/main/java/com/ibm/liberty/starter/service/template/api/v1/ProviderEndpoint.java
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public class Dependency { // private Scope scope; // private String groupId; // private String artifactId; // private String version; // // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // @ApiModelProperty(required = true) // public Scope getScope() { // return scope; // } // // public void setScope(Scope scope) { // this.scope = scope; // } // // @ApiModelProperty(required = false) // public String getGroupId() { // return groupId; // } // // public void setGroupId(String groupId) { // this.groupId = groupId; // } // // @ApiModelProperty(required = true) // public String getArtifactId() { // return artifactId; // } // // public void setArtifactId(String artifactId) { // this.artifactId = artifactId; // } // // @ApiModelProperty(required = true) // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Location.java // public class Location { // private String path; // private String url; // // public Location(String path, String url) { // this.path = path; // this.url = url; // } // // public Location(String url) { // this.url = url; // } // // public Location() { // //JSON serialisation // } // // @ApiModelProperty(value="Relative path to insert the file within the sample project structure", required=false) // public String getPath() { // return path; // } // public void setPath(String path) { // this.path = path; // } // // @ApiModelProperty(value="URL to retrieve the file from", required=true) // public String getUrl() { // return url; // } // public void setUrl(String url) { // this.url = url; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Provider.java // public class Provider { // private String description; // private Dependency[] dependencies; // private Location repoUrl; // // @ApiModelProperty(value = "Description of the technology provider to be inserted into index.html", required = true) // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value = "Dependencies to be specified to the user when they get the download", required = true) // public Dependency[] getDependencies() { // return dependencies; // } // // public void setDependencies(Dependency[] dependencies) { // this.dependencies = dependencies; // } // // @ApiModelProperty(value = "The location of the repository for this microservice.") // public Location getRepoUrl() { // return repoUrl; // } // // public void setRepoUrl(Location repoUrl) { // this.repoUrl = repoUrl; // } // // }
import com.ibm.liberty.starter.api.v1.model.provider.Provider; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import com.ibm.liberty.starter.api.v1.model.provider.Dependency; import com.ibm.liberty.starter.api.v1.model.provider.Dependency.Scope; import com.ibm.liberty.starter.api.v1.model.provider.Location;
/******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.template.api.v1; @Path("v1/provider") public class ProviderEndpoint { private static final String GROUP_SUFFIX = "template"; @GET @Path("/") @Produces(MediaType.APPLICATION_JSON)
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public class Dependency { // private Scope scope; // private String groupId; // private String artifactId; // private String version; // // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // @ApiModelProperty(required = true) // public Scope getScope() { // return scope; // } // // public void setScope(Scope scope) { // this.scope = scope; // } // // @ApiModelProperty(required = false) // public String getGroupId() { // return groupId; // } // // public void setGroupId(String groupId) { // this.groupId = groupId; // } // // @ApiModelProperty(required = true) // public String getArtifactId() { // return artifactId; // } // // public void setArtifactId(String artifactId) { // this.artifactId = artifactId; // } // // @ApiModelProperty(required = true) // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Location.java // public class Location { // private String path; // private String url; // // public Location(String path, String url) { // this.path = path; // this.url = url; // } // // public Location(String url) { // this.url = url; // } // // public Location() { // //JSON serialisation // } // // @ApiModelProperty(value="Relative path to insert the file within the sample project structure", required=false) // public String getPath() { // return path; // } // public void setPath(String path) { // this.path = path; // } // // @ApiModelProperty(value="URL to retrieve the file from", required=true) // public String getUrl() { // return url; // } // public void setUrl(String url) { // this.url = url; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Provider.java // public class Provider { // private String description; // private Dependency[] dependencies; // private Location repoUrl; // // @ApiModelProperty(value = "Description of the technology provider to be inserted into index.html", required = true) // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value = "Dependencies to be specified to the user when they get the download", required = true) // public Dependency[] getDependencies() { // return dependencies; // } // // public void setDependencies(Dependency[] dependencies) { // this.dependencies = dependencies; // } // // @ApiModelProperty(value = "The location of the repository for this microservice.") // public Location getRepoUrl() { // return repoUrl; // } // // public void setRepoUrl(Location repoUrl) { // this.repoUrl = repoUrl; // } // // } // Path: starter-microservice-template/src/main/java/com/ibm/liberty/starter/service/template/api/v1/ProviderEndpoint.java import com.ibm.liberty.starter.api.v1.model.provider.Provider; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import com.ibm.liberty.starter.api.v1.model.provider.Dependency; import com.ibm.liberty.starter.api.v1.model.provider.Dependency.Scope; import com.ibm.liberty.starter.api.v1.model.provider.Location; /******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.template.api.v1; @Path("v1/provider") public class ProviderEndpoint { private static final String GROUP_SUFFIX = "template"; @GET @Path("/") @Produces(MediaType.APPLICATION_JSON)
public Provider details(@Context UriInfo info) {
WASdev/tool.accelerate.core
starter-microservice-template/src/main/java/com/ibm/liberty/starter/service/template/api/v1/ProviderEndpoint.java
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public class Dependency { // private Scope scope; // private String groupId; // private String artifactId; // private String version; // // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // @ApiModelProperty(required = true) // public Scope getScope() { // return scope; // } // // public void setScope(Scope scope) { // this.scope = scope; // } // // @ApiModelProperty(required = false) // public String getGroupId() { // return groupId; // } // // public void setGroupId(String groupId) { // this.groupId = groupId; // } // // @ApiModelProperty(required = true) // public String getArtifactId() { // return artifactId; // } // // public void setArtifactId(String artifactId) { // this.artifactId = artifactId; // } // // @ApiModelProperty(required = true) // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Location.java // public class Location { // private String path; // private String url; // // public Location(String path, String url) { // this.path = path; // this.url = url; // } // // public Location(String url) { // this.url = url; // } // // public Location() { // //JSON serialisation // } // // @ApiModelProperty(value="Relative path to insert the file within the sample project structure", required=false) // public String getPath() { // return path; // } // public void setPath(String path) { // this.path = path; // } // // @ApiModelProperty(value="URL to retrieve the file from", required=true) // public String getUrl() { // return url; // } // public void setUrl(String url) { // this.url = url; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Provider.java // public class Provider { // private String description; // private Dependency[] dependencies; // private Location repoUrl; // // @ApiModelProperty(value = "Description of the technology provider to be inserted into index.html", required = true) // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value = "Dependencies to be specified to the user when they get the download", required = true) // public Dependency[] getDependencies() { // return dependencies; // } // // public void setDependencies(Dependency[] dependencies) { // this.dependencies = dependencies; // } // // @ApiModelProperty(value = "The location of the repository for this microservice.") // public Location getRepoUrl() { // return repoUrl; // } // // public void setRepoUrl(Location repoUrl) { // this.repoUrl = repoUrl; // } // // }
import com.ibm.liberty.starter.api.v1.model.provider.Provider; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import com.ibm.liberty.starter.api.v1.model.provider.Dependency; import com.ibm.liberty.starter.api.v1.model.provider.Dependency.Scope; import com.ibm.liberty.starter.api.v1.model.provider.Location;
/******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.template.api.v1; @Path("v1/provider") public class ProviderEndpoint { private static final String GROUP_SUFFIX = "template"; @GET @Path("/") @Produces(MediaType.APPLICATION_JSON) public Provider details(@Context UriInfo info) { Provider details = new Provider(); String description = getStringResource("/description.html"); details.setDescription(description);
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public class Dependency { // private Scope scope; // private String groupId; // private String artifactId; // private String version; // // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // @ApiModelProperty(required = true) // public Scope getScope() { // return scope; // } // // public void setScope(Scope scope) { // this.scope = scope; // } // // @ApiModelProperty(required = false) // public String getGroupId() { // return groupId; // } // // public void setGroupId(String groupId) { // this.groupId = groupId; // } // // @ApiModelProperty(required = true) // public String getArtifactId() { // return artifactId; // } // // public void setArtifactId(String artifactId) { // this.artifactId = artifactId; // } // // @ApiModelProperty(required = true) // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Location.java // public class Location { // private String path; // private String url; // // public Location(String path, String url) { // this.path = path; // this.url = url; // } // // public Location(String url) { // this.url = url; // } // // public Location() { // //JSON serialisation // } // // @ApiModelProperty(value="Relative path to insert the file within the sample project structure", required=false) // public String getPath() { // return path; // } // public void setPath(String path) { // this.path = path; // } // // @ApiModelProperty(value="URL to retrieve the file from", required=true) // public String getUrl() { // return url; // } // public void setUrl(String url) { // this.url = url; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Provider.java // public class Provider { // private String description; // private Dependency[] dependencies; // private Location repoUrl; // // @ApiModelProperty(value = "Description of the technology provider to be inserted into index.html", required = true) // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value = "Dependencies to be specified to the user when they get the download", required = true) // public Dependency[] getDependencies() { // return dependencies; // } // // public void setDependencies(Dependency[] dependencies) { // this.dependencies = dependencies; // } // // @ApiModelProperty(value = "The location of the repository for this microservice.") // public Location getRepoUrl() { // return repoUrl; // } // // public void setRepoUrl(Location repoUrl) { // this.repoUrl = repoUrl; // } // // } // Path: starter-microservice-template/src/main/java/com/ibm/liberty/starter/service/template/api/v1/ProviderEndpoint.java import com.ibm.liberty.starter.api.v1.model.provider.Provider; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import com.ibm.liberty.starter.api.v1.model.provider.Dependency; import com.ibm.liberty.starter.api.v1.model.provider.Dependency.Scope; import com.ibm.liberty.starter.api.v1.model.provider.Location; /******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.template.api.v1; @Path("v1/provider") public class ProviderEndpoint { private static final String GROUP_SUFFIX = "template"; @GET @Path("/") @Produces(MediaType.APPLICATION_JSON) public Provider details(@Context UriInfo info) { Provider details = new Provider(); String description = getStringResource("/description.html"); details.setDescription(description);
Location repoLocation = new Location();
WASdev/tool.accelerate.core
starter-microservice-template/src/main/java/com/ibm/liberty/starter/service/template/api/v1/ProviderEndpoint.java
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public class Dependency { // private Scope scope; // private String groupId; // private String artifactId; // private String version; // // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // @ApiModelProperty(required = true) // public Scope getScope() { // return scope; // } // // public void setScope(Scope scope) { // this.scope = scope; // } // // @ApiModelProperty(required = false) // public String getGroupId() { // return groupId; // } // // public void setGroupId(String groupId) { // this.groupId = groupId; // } // // @ApiModelProperty(required = true) // public String getArtifactId() { // return artifactId; // } // // public void setArtifactId(String artifactId) { // this.artifactId = artifactId; // } // // @ApiModelProperty(required = true) // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Location.java // public class Location { // private String path; // private String url; // // public Location(String path, String url) { // this.path = path; // this.url = url; // } // // public Location(String url) { // this.url = url; // } // // public Location() { // //JSON serialisation // } // // @ApiModelProperty(value="Relative path to insert the file within the sample project structure", required=false) // public String getPath() { // return path; // } // public void setPath(String path) { // this.path = path; // } // // @ApiModelProperty(value="URL to retrieve the file from", required=true) // public String getUrl() { // return url; // } // public void setUrl(String url) { // this.url = url; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Provider.java // public class Provider { // private String description; // private Dependency[] dependencies; // private Location repoUrl; // // @ApiModelProperty(value = "Description of the technology provider to be inserted into index.html", required = true) // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value = "Dependencies to be specified to the user when they get the download", required = true) // public Dependency[] getDependencies() { // return dependencies; // } // // public void setDependencies(Dependency[] dependencies) { // this.dependencies = dependencies; // } // // @ApiModelProperty(value = "The location of the repository for this microservice.") // public Location getRepoUrl() { // return repoUrl; // } // // public void setRepoUrl(Location repoUrl) { // this.repoUrl = repoUrl; // } // // }
import com.ibm.liberty.starter.api.v1.model.provider.Provider; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import com.ibm.liberty.starter.api.v1.model.provider.Dependency; import com.ibm.liberty.starter.api.v1.model.provider.Dependency.Scope; import com.ibm.liberty.starter.api.v1.model.provider.Location;
/******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.template.api.v1; @Path("v1/provider") public class ProviderEndpoint { private static final String GROUP_SUFFIX = "template"; @GET @Path("/") @Produces(MediaType.APPLICATION_JSON) public Provider details(@Context UriInfo info) { Provider details = new Provider(); String description = getStringResource("/description.html"); details.setDescription(description); Location repoLocation = new Location(); String url = info.getBaseUri().resolve("../artifacts").toString(); repoLocation.setUrl(url); details.setRepoUrl(repoLocation);
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public class Dependency { // private Scope scope; // private String groupId; // private String artifactId; // private String version; // // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // @ApiModelProperty(required = true) // public Scope getScope() { // return scope; // } // // public void setScope(Scope scope) { // this.scope = scope; // } // // @ApiModelProperty(required = false) // public String getGroupId() { // return groupId; // } // // public void setGroupId(String groupId) { // this.groupId = groupId; // } // // @ApiModelProperty(required = true) // public String getArtifactId() { // return artifactId; // } // // public void setArtifactId(String artifactId) { // this.artifactId = artifactId; // } // // @ApiModelProperty(required = true) // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Location.java // public class Location { // private String path; // private String url; // // public Location(String path, String url) { // this.path = path; // this.url = url; // } // // public Location(String url) { // this.url = url; // } // // public Location() { // //JSON serialisation // } // // @ApiModelProperty(value="Relative path to insert the file within the sample project structure", required=false) // public String getPath() { // return path; // } // public void setPath(String path) { // this.path = path; // } // // @ApiModelProperty(value="URL to retrieve the file from", required=true) // public String getUrl() { // return url; // } // public void setUrl(String url) { // this.url = url; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Provider.java // public class Provider { // private String description; // private Dependency[] dependencies; // private Location repoUrl; // // @ApiModelProperty(value = "Description of the technology provider to be inserted into index.html", required = true) // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value = "Dependencies to be specified to the user when they get the download", required = true) // public Dependency[] getDependencies() { // return dependencies; // } // // public void setDependencies(Dependency[] dependencies) { // this.dependencies = dependencies; // } // // @ApiModelProperty(value = "The location of the repository for this microservice.") // public Location getRepoUrl() { // return repoUrl; // } // // public void setRepoUrl(Location repoUrl) { // this.repoUrl = repoUrl; // } // // } // Path: starter-microservice-template/src/main/java/com/ibm/liberty/starter/service/template/api/v1/ProviderEndpoint.java import com.ibm.liberty.starter.api.v1.model.provider.Provider; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import com.ibm.liberty.starter.api.v1.model.provider.Dependency; import com.ibm.liberty.starter.api.v1.model.provider.Dependency.Scope; import com.ibm.liberty.starter.api.v1.model.provider.Location; /******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.template.api.v1; @Path("v1/provider") public class ProviderEndpoint { private static final String GROUP_SUFFIX = "template"; @GET @Path("/") @Produces(MediaType.APPLICATION_JSON) public Provider details(@Context UriInfo info) { Provider details = new Provider(); String description = getStringResource("/description.html"); details.setDescription(description); Location repoLocation = new Location(); String url = info.getBaseUri().resolve("../artifacts").toString(); repoLocation.setUrl(url); details.setRepoUrl(repoLocation);
Dependency providedDependency = new Dependency();
WASdev/tool.accelerate.core
starter-microservice-template/src/main/java/com/ibm/liberty/starter/service/template/api/v1/ProviderEndpoint.java
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public class Dependency { // private Scope scope; // private String groupId; // private String artifactId; // private String version; // // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // @ApiModelProperty(required = true) // public Scope getScope() { // return scope; // } // // public void setScope(Scope scope) { // this.scope = scope; // } // // @ApiModelProperty(required = false) // public String getGroupId() { // return groupId; // } // // public void setGroupId(String groupId) { // this.groupId = groupId; // } // // @ApiModelProperty(required = true) // public String getArtifactId() { // return artifactId; // } // // public void setArtifactId(String artifactId) { // this.artifactId = artifactId; // } // // @ApiModelProperty(required = true) // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Location.java // public class Location { // private String path; // private String url; // // public Location(String path, String url) { // this.path = path; // this.url = url; // } // // public Location(String url) { // this.url = url; // } // // public Location() { // //JSON serialisation // } // // @ApiModelProperty(value="Relative path to insert the file within the sample project structure", required=false) // public String getPath() { // return path; // } // public void setPath(String path) { // this.path = path; // } // // @ApiModelProperty(value="URL to retrieve the file from", required=true) // public String getUrl() { // return url; // } // public void setUrl(String url) { // this.url = url; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Provider.java // public class Provider { // private String description; // private Dependency[] dependencies; // private Location repoUrl; // // @ApiModelProperty(value = "Description of the technology provider to be inserted into index.html", required = true) // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value = "Dependencies to be specified to the user when they get the download", required = true) // public Dependency[] getDependencies() { // return dependencies; // } // // public void setDependencies(Dependency[] dependencies) { // this.dependencies = dependencies; // } // // @ApiModelProperty(value = "The location of the repository for this microservice.") // public Location getRepoUrl() { // return repoUrl; // } // // public void setRepoUrl(Location repoUrl) { // this.repoUrl = repoUrl; // } // // }
import com.ibm.liberty.starter.api.v1.model.provider.Provider; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import com.ibm.liberty.starter.api.v1.model.provider.Dependency; import com.ibm.liberty.starter.api.v1.model.provider.Dependency.Scope; import com.ibm.liberty.starter.api.v1.model.provider.Location;
/******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.template.api.v1; @Path("v1/provider") public class ProviderEndpoint { private static final String GROUP_SUFFIX = "template"; @GET @Path("/") @Produces(MediaType.APPLICATION_JSON) public Provider details(@Context UriInfo info) { Provider details = new Provider(); String description = getStringResource("/description.html"); details.setDescription(description); Location repoLocation = new Location(); String url = info.getBaseUri().resolve("../artifacts").toString(); repoLocation.setUrl(url); details.setRepoUrl(repoLocation); Dependency providedDependency = new Dependency();
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public class Dependency { // private Scope scope; // private String groupId; // private String artifactId; // private String version; // // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // @ApiModelProperty(required = true) // public Scope getScope() { // return scope; // } // // public void setScope(Scope scope) { // this.scope = scope; // } // // @ApiModelProperty(required = false) // public String getGroupId() { // return groupId; // } // // public void setGroupId(String groupId) { // this.groupId = groupId; // } // // @ApiModelProperty(required = true) // public String getArtifactId() { // return artifactId; // } // // public void setArtifactId(String artifactId) { // this.artifactId = artifactId; // } // // @ApiModelProperty(required = true) // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Location.java // public class Location { // private String path; // private String url; // // public Location(String path, String url) { // this.path = path; // this.url = url; // } // // public Location(String url) { // this.url = url; // } // // public Location() { // //JSON serialisation // } // // @ApiModelProperty(value="Relative path to insert the file within the sample project structure", required=false) // public String getPath() { // return path; // } // public void setPath(String path) { // this.path = path; // } // // @ApiModelProperty(value="URL to retrieve the file from", required=true) // public String getUrl() { // return url; // } // public void setUrl(String url) { // this.url = url; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Provider.java // public class Provider { // private String description; // private Dependency[] dependencies; // private Location repoUrl; // // @ApiModelProperty(value = "Description of the technology provider to be inserted into index.html", required = true) // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value = "Dependencies to be specified to the user when they get the download", required = true) // public Dependency[] getDependencies() { // return dependencies; // } // // public void setDependencies(Dependency[] dependencies) { // this.dependencies = dependencies; // } // // @ApiModelProperty(value = "The location of the repository for this microservice.") // public Location getRepoUrl() { // return repoUrl; // } // // public void setRepoUrl(Location repoUrl) { // this.repoUrl = repoUrl; // } // // } // Path: starter-microservice-template/src/main/java/com/ibm/liberty/starter/service/template/api/v1/ProviderEndpoint.java import com.ibm.liberty.starter.api.v1.model.provider.Provider; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import com.ibm.liberty.starter.api.v1.model.provider.Dependency; import com.ibm.liberty.starter.api.v1.model.provider.Dependency.Scope; import com.ibm.liberty.starter.api.v1.model.provider.Location; /******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.template.api.v1; @Path("v1/provider") public class ProviderEndpoint { private static final String GROUP_SUFFIX = "template"; @GET @Path("/") @Produces(MediaType.APPLICATION_JSON) public Provider details(@Context UriInfo info) { Provider details = new Provider(); String description = getStringResource("/description.html"); details.setDescription(description); Location repoLocation = new Location(); String url = info.getBaseUri().resolve("../artifacts").toString(); repoLocation.setUrl(url); details.setRepoUrl(repoLocation); Dependency providedDependency = new Dependency();
providedDependency.setScope(Scope.PROVIDED);
WASdev/tool.accelerate.core
starter-microservice-test/src/main/java/com/ibm/liberty/starter/service/test/api/v1/ProviderEndpoint.java
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public class Dependency { // private Scope scope; // private String groupId; // private String artifactId; // private String version; // // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // @ApiModelProperty(required = true) // public Scope getScope() { // return scope; // } // // public void setScope(Scope scope) { // this.scope = scope; // } // // @ApiModelProperty(required = false) // public String getGroupId() { // return groupId; // } // // public void setGroupId(String groupId) { // this.groupId = groupId; // } // // @ApiModelProperty(required = true) // public String getArtifactId() { // return artifactId; // } // // public void setArtifactId(String artifactId) { // this.artifactId = artifactId; // } // // @ApiModelProperty(required = true) // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Location.java // public class Location { // private String path; // private String url; // // public Location(String path, String url) { // this.path = path; // this.url = url; // } // // public Location(String url) { // this.url = url; // } // // public Location() { // //JSON serialisation // } // // @ApiModelProperty(value="Relative path to insert the file within the sample project structure", required=false) // public String getPath() { // return path; // } // public void setPath(String path) { // this.path = path; // } // // @ApiModelProperty(value="URL to retrieve the file from", required=true) // public String getUrl() { // return url; // } // public void setUrl(String url) { // this.url = url; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Provider.java // public class Provider { // private String description; // private Dependency[] dependencies; // private Location repoUrl; // // @ApiModelProperty(value = "Description of the technology provider to be inserted into index.html", required = true) // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value = "Dependencies to be specified to the user when they get the download", required = true) // public Dependency[] getDependencies() { // return dependencies; // } // // public void setDependencies(Dependency[] dependencies) { // this.dependencies = dependencies; // } // // @ApiModelProperty(value = "The location of the repository for this microservice.") // public Location getRepoUrl() { // return repoUrl; // } // // public void setRepoUrl(Location repoUrl) { // this.repoUrl = repoUrl; // } // // }
import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import org.apache.commons.io.FileUtils; import com.ibm.liberty.starter.api.v1.model.provider.Dependency; import com.ibm.liberty.starter.api.v1.model.provider.Dependency.Scope; import com.ibm.liberty.starter.api.v1.model.provider.Location; import com.ibm.liberty.starter.api.v1.model.provider.Provider;
/******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.test.api.v1; @Path("v1/provider") public class ProviderEndpoint { @GET @Path("/") @Produces(MediaType.APPLICATION_JSON)
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public class Dependency { // private Scope scope; // private String groupId; // private String artifactId; // private String version; // // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // @ApiModelProperty(required = true) // public Scope getScope() { // return scope; // } // // public void setScope(Scope scope) { // this.scope = scope; // } // // @ApiModelProperty(required = false) // public String getGroupId() { // return groupId; // } // // public void setGroupId(String groupId) { // this.groupId = groupId; // } // // @ApiModelProperty(required = true) // public String getArtifactId() { // return artifactId; // } // // public void setArtifactId(String artifactId) { // this.artifactId = artifactId; // } // // @ApiModelProperty(required = true) // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Location.java // public class Location { // private String path; // private String url; // // public Location(String path, String url) { // this.path = path; // this.url = url; // } // // public Location(String url) { // this.url = url; // } // // public Location() { // //JSON serialisation // } // // @ApiModelProperty(value="Relative path to insert the file within the sample project structure", required=false) // public String getPath() { // return path; // } // public void setPath(String path) { // this.path = path; // } // // @ApiModelProperty(value="URL to retrieve the file from", required=true) // public String getUrl() { // return url; // } // public void setUrl(String url) { // this.url = url; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Provider.java // public class Provider { // private String description; // private Dependency[] dependencies; // private Location repoUrl; // // @ApiModelProperty(value = "Description of the technology provider to be inserted into index.html", required = true) // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value = "Dependencies to be specified to the user when they get the download", required = true) // public Dependency[] getDependencies() { // return dependencies; // } // // public void setDependencies(Dependency[] dependencies) { // this.dependencies = dependencies; // } // // @ApiModelProperty(value = "The location of the repository for this microservice.") // public Location getRepoUrl() { // return repoUrl; // } // // public void setRepoUrl(Location repoUrl) { // this.repoUrl = repoUrl; // } // // } // Path: starter-microservice-test/src/main/java/com/ibm/liberty/starter/service/test/api/v1/ProviderEndpoint.java import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import org.apache.commons.io.FileUtils; import com.ibm.liberty.starter.api.v1.model.provider.Dependency; import com.ibm.liberty.starter.api.v1.model.provider.Dependency.Scope; import com.ibm.liberty.starter.api.v1.model.provider.Location; import com.ibm.liberty.starter.api.v1.model.provider.Provider; /******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.test.api.v1; @Path("v1/provider") public class ProviderEndpoint { @GET @Path("/") @Produces(MediaType.APPLICATION_JSON)
public Provider details(@Context UriInfo info) {
WASdev/tool.accelerate.core
starter-microservice-test/src/main/java/com/ibm/liberty/starter/service/test/api/v1/ProviderEndpoint.java
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public class Dependency { // private Scope scope; // private String groupId; // private String artifactId; // private String version; // // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // @ApiModelProperty(required = true) // public Scope getScope() { // return scope; // } // // public void setScope(Scope scope) { // this.scope = scope; // } // // @ApiModelProperty(required = false) // public String getGroupId() { // return groupId; // } // // public void setGroupId(String groupId) { // this.groupId = groupId; // } // // @ApiModelProperty(required = true) // public String getArtifactId() { // return artifactId; // } // // public void setArtifactId(String artifactId) { // this.artifactId = artifactId; // } // // @ApiModelProperty(required = true) // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Location.java // public class Location { // private String path; // private String url; // // public Location(String path, String url) { // this.path = path; // this.url = url; // } // // public Location(String url) { // this.url = url; // } // // public Location() { // //JSON serialisation // } // // @ApiModelProperty(value="Relative path to insert the file within the sample project structure", required=false) // public String getPath() { // return path; // } // public void setPath(String path) { // this.path = path; // } // // @ApiModelProperty(value="URL to retrieve the file from", required=true) // public String getUrl() { // return url; // } // public void setUrl(String url) { // this.url = url; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Provider.java // public class Provider { // private String description; // private Dependency[] dependencies; // private Location repoUrl; // // @ApiModelProperty(value = "Description of the technology provider to be inserted into index.html", required = true) // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value = "Dependencies to be specified to the user when they get the download", required = true) // public Dependency[] getDependencies() { // return dependencies; // } // // public void setDependencies(Dependency[] dependencies) { // this.dependencies = dependencies; // } // // @ApiModelProperty(value = "The location of the repository for this microservice.") // public Location getRepoUrl() { // return repoUrl; // } // // public void setRepoUrl(Location repoUrl) { // this.repoUrl = repoUrl; // } // // }
import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import org.apache.commons.io.FileUtils; import com.ibm.liberty.starter.api.v1.model.provider.Dependency; import com.ibm.liberty.starter.api.v1.model.provider.Dependency.Scope; import com.ibm.liberty.starter.api.v1.model.provider.Location; import com.ibm.liberty.starter.api.v1.model.provider.Provider;
/******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.test.api.v1; @Path("v1/provider") public class ProviderEndpoint { @GET @Path("/") @Produces(MediaType.APPLICATION_JSON) public Provider details(@Context UriInfo info) { Provider details = new Provider(); String description = getStringResource("/description.html"); details.setDescription(description);
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public class Dependency { // private Scope scope; // private String groupId; // private String artifactId; // private String version; // // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // @ApiModelProperty(required = true) // public Scope getScope() { // return scope; // } // // public void setScope(Scope scope) { // this.scope = scope; // } // // @ApiModelProperty(required = false) // public String getGroupId() { // return groupId; // } // // public void setGroupId(String groupId) { // this.groupId = groupId; // } // // @ApiModelProperty(required = true) // public String getArtifactId() { // return artifactId; // } // // public void setArtifactId(String artifactId) { // this.artifactId = artifactId; // } // // @ApiModelProperty(required = true) // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Location.java // public class Location { // private String path; // private String url; // // public Location(String path, String url) { // this.path = path; // this.url = url; // } // // public Location(String url) { // this.url = url; // } // // public Location() { // //JSON serialisation // } // // @ApiModelProperty(value="Relative path to insert the file within the sample project structure", required=false) // public String getPath() { // return path; // } // public void setPath(String path) { // this.path = path; // } // // @ApiModelProperty(value="URL to retrieve the file from", required=true) // public String getUrl() { // return url; // } // public void setUrl(String url) { // this.url = url; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Provider.java // public class Provider { // private String description; // private Dependency[] dependencies; // private Location repoUrl; // // @ApiModelProperty(value = "Description of the technology provider to be inserted into index.html", required = true) // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value = "Dependencies to be specified to the user when they get the download", required = true) // public Dependency[] getDependencies() { // return dependencies; // } // // public void setDependencies(Dependency[] dependencies) { // this.dependencies = dependencies; // } // // @ApiModelProperty(value = "The location of the repository for this microservice.") // public Location getRepoUrl() { // return repoUrl; // } // // public void setRepoUrl(Location repoUrl) { // this.repoUrl = repoUrl; // } // // } // Path: starter-microservice-test/src/main/java/com/ibm/liberty/starter/service/test/api/v1/ProviderEndpoint.java import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import org.apache.commons.io.FileUtils; import com.ibm.liberty.starter.api.v1.model.provider.Dependency; import com.ibm.liberty.starter.api.v1.model.provider.Dependency.Scope; import com.ibm.liberty.starter.api.v1.model.provider.Location; import com.ibm.liberty.starter.api.v1.model.provider.Provider; /******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.test.api.v1; @Path("v1/provider") public class ProviderEndpoint { @GET @Path("/") @Produces(MediaType.APPLICATION_JSON) public Provider details(@Context UriInfo info) { Provider details = new Provider(); String description = getStringResource("/description.html"); details.setDescription(description);
Location repoLocation = new Location();
WASdev/tool.accelerate.core
starter-microservice-test/src/main/java/com/ibm/liberty/starter/service/test/api/v1/ProviderEndpoint.java
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public class Dependency { // private Scope scope; // private String groupId; // private String artifactId; // private String version; // // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // @ApiModelProperty(required = true) // public Scope getScope() { // return scope; // } // // public void setScope(Scope scope) { // this.scope = scope; // } // // @ApiModelProperty(required = false) // public String getGroupId() { // return groupId; // } // // public void setGroupId(String groupId) { // this.groupId = groupId; // } // // @ApiModelProperty(required = true) // public String getArtifactId() { // return artifactId; // } // // public void setArtifactId(String artifactId) { // this.artifactId = artifactId; // } // // @ApiModelProperty(required = true) // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Location.java // public class Location { // private String path; // private String url; // // public Location(String path, String url) { // this.path = path; // this.url = url; // } // // public Location(String url) { // this.url = url; // } // // public Location() { // //JSON serialisation // } // // @ApiModelProperty(value="Relative path to insert the file within the sample project structure", required=false) // public String getPath() { // return path; // } // public void setPath(String path) { // this.path = path; // } // // @ApiModelProperty(value="URL to retrieve the file from", required=true) // public String getUrl() { // return url; // } // public void setUrl(String url) { // this.url = url; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Provider.java // public class Provider { // private String description; // private Dependency[] dependencies; // private Location repoUrl; // // @ApiModelProperty(value = "Description of the technology provider to be inserted into index.html", required = true) // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value = "Dependencies to be specified to the user when they get the download", required = true) // public Dependency[] getDependencies() { // return dependencies; // } // // public void setDependencies(Dependency[] dependencies) { // this.dependencies = dependencies; // } // // @ApiModelProperty(value = "The location of the repository for this microservice.") // public Location getRepoUrl() { // return repoUrl; // } // // public void setRepoUrl(Location repoUrl) { // this.repoUrl = repoUrl; // } // // }
import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import org.apache.commons.io.FileUtils; import com.ibm.liberty.starter.api.v1.model.provider.Dependency; import com.ibm.liberty.starter.api.v1.model.provider.Dependency.Scope; import com.ibm.liberty.starter.api.v1.model.provider.Location; import com.ibm.liberty.starter.api.v1.model.provider.Provider;
/******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.test.api.v1; @Path("v1/provider") public class ProviderEndpoint { @GET @Path("/") @Produces(MediaType.APPLICATION_JSON) public Provider details(@Context UriInfo info) { Provider details = new Provider(); String description = getStringResource("/description.html"); details.setDescription(description); Location repoLocation = new Location(); String url = info.getBaseUri().resolve("../artifacts").toString(); repoLocation.setUrl(url); details.setRepoUrl(repoLocation);
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public class Dependency { // private Scope scope; // private String groupId; // private String artifactId; // private String version; // // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // @ApiModelProperty(required = true) // public Scope getScope() { // return scope; // } // // public void setScope(Scope scope) { // this.scope = scope; // } // // @ApiModelProperty(required = false) // public String getGroupId() { // return groupId; // } // // public void setGroupId(String groupId) { // this.groupId = groupId; // } // // @ApiModelProperty(required = true) // public String getArtifactId() { // return artifactId; // } // // public void setArtifactId(String artifactId) { // this.artifactId = artifactId; // } // // @ApiModelProperty(required = true) // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Location.java // public class Location { // private String path; // private String url; // // public Location(String path, String url) { // this.path = path; // this.url = url; // } // // public Location(String url) { // this.url = url; // } // // public Location() { // //JSON serialisation // } // // @ApiModelProperty(value="Relative path to insert the file within the sample project structure", required=false) // public String getPath() { // return path; // } // public void setPath(String path) { // this.path = path; // } // // @ApiModelProperty(value="URL to retrieve the file from", required=true) // public String getUrl() { // return url; // } // public void setUrl(String url) { // this.url = url; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Provider.java // public class Provider { // private String description; // private Dependency[] dependencies; // private Location repoUrl; // // @ApiModelProperty(value = "Description of the technology provider to be inserted into index.html", required = true) // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value = "Dependencies to be specified to the user when they get the download", required = true) // public Dependency[] getDependencies() { // return dependencies; // } // // public void setDependencies(Dependency[] dependencies) { // this.dependencies = dependencies; // } // // @ApiModelProperty(value = "The location of the repository for this microservice.") // public Location getRepoUrl() { // return repoUrl; // } // // public void setRepoUrl(Location repoUrl) { // this.repoUrl = repoUrl; // } // // } // Path: starter-microservice-test/src/main/java/com/ibm/liberty/starter/service/test/api/v1/ProviderEndpoint.java import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import org.apache.commons.io.FileUtils; import com.ibm.liberty.starter.api.v1.model.provider.Dependency; import com.ibm.liberty.starter.api.v1.model.provider.Dependency.Scope; import com.ibm.liberty.starter.api.v1.model.provider.Location; import com.ibm.liberty.starter.api.v1.model.provider.Provider; /******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.test.api.v1; @Path("v1/provider") public class ProviderEndpoint { @GET @Path("/") @Produces(MediaType.APPLICATION_JSON) public Provider details(@Context UriInfo info) { Provider details = new Provider(); String description = getStringResource("/description.html"); details.setDescription(description); Location repoLocation = new Location(); String url = info.getBaseUri().resolve("../artifacts").toString(); repoLocation.setUrl(url); details.setRepoUrl(repoLocation);
Dependency providedDependency = new Dependency();
WASdev/tool.accelerate.core
starter-microservice-test/src/main/java/com/ibm/liberty/starter/service/test/api/v1/ProviderEndpoint.java
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public class Dependency { // private Scope scope; // private String groupId; // private String artifactId; // private String version; // // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // @ApiModelProperty(required = true) // public Scope getScope() { // return scope; // } // // public void setScope(Scope scope) { // this.scope = scope; // } // // @ApiModelProperty(required = false) // public String getGroupId() { // return groupId; // } // // public void setGroupId(String groupId) { // this.groupId = groupId; // } // // @ApiModelProperty(required = true) // public String getArtifactId() { // return artifactId; // } // // public void setArtifactId(String artifactId) { // this.artifactId = artifactId; // } // // @ApiModelProperty(required = true) // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Location.java // public class Location { // private String path; // private String url; // // public Location(String path, String url) { // this.path = path; // this.url = url; // } // // public Location(String url) { // this.url = url; // } // // public Location() { // //JSON serialisation // } // // @ApiModelProperty(value="Relative path to insert the file within the sample project structure", required=false) // public String getPath() { // return path; // } // public void setPath(String path) { // this.path = path; // } // // @ApiModelProperty(value="URL to retrieve the file from", required=true) // public String getUrl() { // return url; // } // public void setUrl(String url) { // this.url = url; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Provider.java // public class Provider { // private String description; // private Dependency[] dependencies; // private Location repoUrl; // // @ApiModelProperty(value = "Description of the technology provider to be inserted into index.html", required = true) // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value = "Dependencies to be specified to the user when they get the download", required = true) // public Dependency[] getDependencies() { // return dependencies; // } // // public void setDependencies(Dependency[] dependencies) { // this.dependencies = dependencies; // } // // @ApiModelProperty(value = "The location of the repository for this microservice.") // public Location getRepoUrl() { // return repoUrl; // } // // public void setRepoUrl(Location repoUrl) { // this.repoUrl = repoUrl; // } // // }
import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import org.apache.commons.io.FileUtils; import com.ibm.liberty.starter.api.v1.model.provider.Dependency; import com.ibm.liberty.starter.api.v1.model.provider.Dependency.Scope; import com.ibm.liberty.starter.api.v1.model.provider.Location; import com.ibm.liberty.starter.api.v1.model.provider.Provider;
/******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.test.api.v1; @Path("v1/provider") public class ProviderEndpoint { @GET @Path("/") @Produces(MediaType.APPLICATION_JSON) public Provider details(@Context UriInfo info) { Provider details = new Provider(); String description = getStringResource("/description.html"); details.setDescription(description); Location repoLocation = new Location(); String url = info.getBaseUri().resolve("../artifacts").toString(); repoLocation.setUrl(url); details.setRepoUrl(repoLocation); Dependency providedDependency = new Dependency();
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public class Dependency { // private Scope scope; // private String groupId; // private String artifactId; // private String version; // // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // @ApiModelProperty(required = true) // public Scope getScope() { // return scope; // } // // public void setScope(Scope scope) { // this.scope = scope; // } // // @ApiModelProperty(required = false) // public String getGroupId() { // return groupId; // } // // public void setGroupId(String groupId) { // this.groupId = groupId; // } // // @ApiModelProperty(required = true) // public String getArtifactId() { // return artifactId; // } // // public void setArtifactId(String artifactId) { // this.artifactId = artifactId; // } // // @ApiModelProperty(required = true) // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Dependency.java // public enum Scope { // PROVIDED, COMPILE, RUNTIME; // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Location.java // public class Location { // private String path; // private String url; // // public Location(String path, String url) { // this.path = path; // this.url = url; // } // // public Location(String url) { // this.url = url; // } // // public Location() { // //JSON serialisation // } // // @ApiModelProperty(value="Relative path to insert the file within the sample project structure", required=false) // public String getPath() { // return path; // } // public void setPath(String path) { // this.path = path; // } // // @ApiModelProperty(value="URL to retrieve the file from", required=true) // public String getUrl() { // return url; // } // public void setUrl(String url) { // this.url = url; // } // // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/Provider.java // public class Provider { // private String description; // private Dependency[] dependencies; // private Location repoUrl; // // @ApiModelProperty(value = "Description of the technology provider to be inserted into index.html", required = true) // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value = "Dependencies to be specified to the user when they get the download", required = true) // public Dependency[] getDependencies() { // return dependencies; // } // // public void setDependencies(Dependency[] dependencies) { // this.dependencies = dependencies; // } // // @ApiModelProperty(value = "The location of the repository for this microservice.") // public Location getRepoUrl() { // return repoUrl; // } // // public void setRepoUrl(Location repoUrl) { // this.repoUrl = repoUrl; // } // // } // Path: starter-microservice-test/src/main/java/com/ibm/liberty/starter/service/test/api/v1/ProviderEndpoint.java import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import org.apache.commons.io.FileUtils; import com.ibm.liberty.starter.api.v1.model.provider.Dependency; import com.ibm.liberty.starter.api.v1.model.provider.Dependency.Scope; import com.ibm.liberty.starter.api.v1.model.provider.Location; import com.ibm.liberty.starter.api.v1.model.provider.Provider; /******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.test.api.v1; @Path("v1/provider") public class ProviderEndpoint { @GET @Path("/") @Produces(MediaType.APPLICATION_JSON) public Provider details(@Context UriInfo info) { Provider details = new Provider(); String description = getStringResource("/description.html"); details.setDescription(description); Location repoLocation = new Location(); String url = info.getBaseUri().resolve("../artifacts").toString(); repoLocation.setUrl(url); details.setRepoUrl(repoLocation); Dependency providedDependency = new Dependency();
providedDependency.setScope(Scope.PROVIDED);
WASdev/tool.accelerate.core
starter-microservice-watsonsdk/src/test/java/com/ibm/liberty/starter/service/watsonsdk/api/v1/it/TestApplication.java
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/EndpointResponse.java // public class EndpointResponse { // // private String status; // // public String getStatus() { // return status; // } // // public void setStatus(String status) { // this.status = status; // } // // }
import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; import com.ibm.liberty.starter.api.v1.model.provider.EndpointResponse;
/******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.watsonsdk.api.v1.it; /** * Test the deployed service responds as expected * */ public class TestApplication extends EndpointTest { @Before public void checkSetup() { checkAvailability("/api/v1/provider/"); } @Test public void testProvider() throws Exception {
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/EndpointResponse.java // public class EndpointResponse { // // private String status; // // public String getStatus() { // return status; // } // // public void setStatus(String status) { // this.status = status; // } // // } // Path: starter-microservice-watsonsdk/src/test/java/com/ibm/liberty/starter/service/watsonsdk/api/v1/it/TestApplication.java import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; import com.ibm.liberty.starter.api.v1.model.provider.EndpointResponse; /******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.watsonsdk.api.v1.it; /** * Test the deployed service responds as expected * */ public class TestApplication extends EndpointTest { @Before public void checkSetup() { checkAvailability("/api/v1/provider/"); } @Test public void testProvider() throws Exception {
EndpointResponse response = testEndpoint("/api/v1/provider/", EndpointResponse.class);
WASdev/tool.accelerate.core
starter-microservice-rest/src/test/java/com/ibm/liberty/starter/service/rest/api/v1/it/TestApplication.java
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/EndpointResponse.java // public class EndpointResponse { // // private String status; // // public String getStatus() { // return status; // } // // public void setStatus(String status) { // this.status = status; // } // // }
import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; import com.ibm.liberty.starter.api.v1.model.provider.EndpointResponse;
/******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.rest.api.v1.it; /** * Test the deployed service responds as expected * */ public class TestApplication extends EndpointTest { @Before public void checkSetup() { checkAvailability("/api/v1/provider/"); } @Test public void testProvider() throws Exception {
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/EndpointResponse.java // public class EndpointResponse { // // private String status; // // public String getStatus() { // return status; // } // // public void setStatus(String status) { // this.status = status; // } // // } // Path: starter-microservice-rest/src/test/java/com/ibm/liberty/starter/service/rest/api/v1/it/TestApplication.java import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; import com.ibm.liberty.starter.api.v1.model.provider.EndpointResponse; /******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.rest.api.v1.it; /** * Test the deployed service responds as expected * */ public class TestApplication extends EndpointTest { @Before public void checkSetup() { checkAvailability("/api/v1/provider/"); } @Test public void testProvider() throws Exception {
EndpointResponse response = testEndpoint("/api/v1/provider/", EndpointResponse.class);
WASdev/tool.accelerate.core
starter-microservice-springboot-web/src/test/java/com/ibm/liberty/starter/service/springboot/api/v1/it/TestApplication.java
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/EndpointResponse.java // public class EndpointResponse { // // private String status; // // public String getStatus() { // return status; // } // // public void setStatus(String status) { // this.status = status; // } // // }
import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; import com.ibm.liberty.starter.api.v1.model.provider.EndpointResponse;
/******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.springboot.api.v1.it; /** * Test the deployed service responds as expected * */ public class TestApplication extends EndpointTest { @Before public void checkSetup() { checkAvailability("/api/v1/provider/"); } @Test public void testProvider() throws Exception {
// Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/provider/EndpointResponse.java // public class EndpointResponse { // // private String status; // // public String getStatus() { // return status; // } // // public void setStatus(String status) { // this.status = status; // } // // } // Path: starter-microservice-springboot-web/src/test/java/com/ibm/liberty/starter/service/springboot/api/v1/it/TestApplication.java import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; import com.ibm.liberty.starter.api.v1.model.provider.EndpointResponse; /******************************************************************************* * Copyright (c) 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.service.springboot.api.v1.it; /** * Test the deployed service responds as expected * */ public class TestApplication extends EndpointTest { @Before public void checkSetup() { checkAvailability("/api/v1/provider/"); } @Test public void testProvider() throws Exception {
EndpointResponse response = testEndpoint("/api/v1/provider/", EndpointResponse.class);
WASdev/tool.accelerate.core
liberty-starter-application/src/test/java/com/ibm/liberty/starter/it/api/v1/WorkspaceEndpointTest.java
// Path: liberty-starter-application/src/test/java/com/ibm/liberty/starter/it/api/v1/utils/UploadEndpointUtils.java // public static String getBasicSwagger(String modelName) { // String swaggerContent = "{\"swagger\": \"2.0\",\"info\": {\"description\": \"Info APIs for Collective\",\"version\": \"1.0.0\"},\"basePath\": \"/\"," // + "\"paths\": {\"/ibm/api/root1/v1/info\": {\"get\": {\"summary\": \"Retrieve collective's core information\"," // + "\"description\": \"Returns a JSON with core information about collective\",\"operationId\": \"getInfo\",\"produces\": " // + "[\"application/json\"],\"responses\": {\"200\": {\"description\": \"successful operation\"," // + "\"schema\": {\"$ref\": \"#/definitions/" + modelName + "\"}},\"404\": {\"description\": \"Invalid path\"}}}}},\"definitions\": {" // + "\"" + modelName + "\": {\"properties\": {\"name\": {\"type\": \"string\",\"description\": \"Name of the collective\"}}}}}"; // return swaggerContent; // } // // Path: liberty-starter-application/src/test/java/com/ibm/liberty/starter/it/api/v1/utils/UploadEndpointUtils.java // public static int invokeUploadEndpoint(String params, String fileName, String fileContent) throws Exception { // String port = System.getProperty("liberty.test.port"); // String path = "http://localhost:" + port + "/start/api/v1/upload" + ((params != null && !params.trim().isEmpty()) ? ("?" + params) : ""); // System.out.println("Testing " + path); // // String boundary = "----WebKitFormBoundarybcoFJqLu81T8NPk8"; // URL url = new URL(path); // HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection(); // httpConnection.setUseCaches(false); // httpConnection.setDoInput(true); // httpConnection.setDoOutput(true); // // httpConnection.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary); // OutputStream outputStream = httpConnection.getOutputStream(); // PrintWriter writer = new PrintWriter(new OutputStreamWriter(outputStream), true); // // final String NEW_LINE = "\r\n"; // writer.append("--" + boundary).append(NEW_LINE); // writer.append("Content-Disposition: form-data; name=\"fileFormData\"; filename=\"" + fileName + "\"").append(NEW_LINE); // writer.append("Content-Type: application/octet-stream").append(NEW_LINE).append(NEW_LINE); // writer.append(fileContent).append(NEW_LINE); // writer.append(NEW_LINE).flush(); // writer.append("--" + boundary + "--").append(NEW_LINE); // writer.close(); // // httpConnection.disconnect(); // return httpConnection.getResponseCode(); // }
import org.junit.Test; import static com.ibm.liberty.starter.it.api.v1.utils.UploadEndpointUtils.getBasicSwagger; import static com.ibm.liberty.starter.it.api.v1.utils.UploadEndpointUtils.invokeUploadEndpoint; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeTrue; import java.io.InputStream; import java.util.UUID; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.core.Response;
/******************************************************************************* * Copyright (c) 2017 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.it.api.v1; public class WorkspaceEndpointTest { @Test public void testStarterWorkspaceEndpoint() throws Exception { String endpoint = "/start/api/v1/workspace"; Client client = ClientBuilder.newClient(); String port = System.getProperty("liberty.test.port"); String url = "http://localhost:" + port + endpoint; System.out.println("Testing " + url); Response response = client.target(url).request().get(); try { int status = response.getStatus(); assertEquals("Response incorrect, response status was " + status, 200, status); String workspaceId = response.readEntity(String.class); assertNotNull("Returned workspace ID was not a valid UUID : " + workspaceId, UUID.fromString(workspaceId)); } finally { response.close(); } } @Test public void testWorkspaceFileDownloadEndpoint() throws Exception { String uuid = UUID.randomUUID().toString();
// Path: liberty-starter-application/src/test/java/com/ibm/liberty/starter/it/api/v1/utils/UploadEndpointUtils.java // public static String getBasicSwagger(String modelName) { // String swaggerContent = "{\"swagger\": \"2.0\",\"info\": {\"description\": \"Info APIs for Collective\",\"version\": \"1.0.0\"},\"basePath\": \"/\"," // + "\"paths\": {\"/ibm/api/root1/v1/info\": {\"get\": {\"summary\": \"Retrieve collective's core information\"," // + "\"description\": \"Returns a JSON with core information about collective\",\"operationId\": \"getInfo\",\"produces\": " // + "[\"application/json\"],\"responses\": {\"200\": {\"description\": \"successful operation\"," // + "\"schema\": {\"$ref\": \"#/definitions/" + modelName + "\"}},\"404\": {\"description\": \"Invalid path\"}}}}},\"definitions\": {" // + "\"" + modelName + "\": {\"properties\": {\"name\": {\"type\": \"string\",\"description\": \"Name of the collective\"}}}}}"; // return swaggerContent; // } // // Path: liberty-starter-application/src/test/java/com/ibm/liberty/starter/it/api/v1/utils/UploadEndpointUtils.java // public static int invokeUploadEndpoint(String params, String fileName, String fileContent) throws Exception { // String port = System.getProperty("liberty.test.port"); // String path = "http://localhost:" + port + "/start/api/v1/upload" + ((params != null && !params.trim().isEmpty()) ? ("?" + params) : ""); // System.out.println("Testing " + path); // // String boundary = "----WebKitFormBoundarybcoFJqLu81T8NPk8"; // URL url = new URL(path); // HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection(); // httpConnection.setUseCaches(false); // httpConnection.setDoInput(true); // httpConnection.setDoOutput(true); // // httpConnection.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary); // OutputStream outputStream = httpConnection.getOutputStream(); // PrintWriter writer = new PrintWriter(new OutputStreamWriter(outputStream), true); // // final String NEW_LINE = "\r\n"; // writer.append("--" + boundary).append(NEW_LINE); // writer.append("Content-Disposition: form-data; name=\"fileFormData\"; filename=\"" + fileName + "\"").append(NEW_LINE); // writer.append("Content-Type: application/octet-stream").append(NEW_LINE).append(NEW_LINE); // writer.append(fileContent).append(NEW_LINE); // writer.append(NEW_LINE).flush(); // writer.append("--" + boundary + "--").append(NEW_LINE); // writer.close(); // // httpConnection.disconnect(); // return httpConnection.getResponseCode(); // } // Path: liberty-starter-application/src/test/java/com/ibm/liberty/starter/it/api/v1/WorkspaceEndpointTest.java import org.junit.Test; import static com.ibm.liberty.starter.it.api.v1.utils.UploadEndpointUtils.getBasicSwagger; import static com.ibm.liberty.starter.it.api.v1.utils.UploadEndpointUtils.invokeUploadEndpoint; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeTrue; import java.io.InputStream; import java.util.UUID; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.core.Response; /******************************************************************************* * Copyright (c) 2017 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.it.api.v1; public class WorkspaceEndpointTest { @Test public void testStarterWorkspaceEndpoint() throws Exception { String endpoint = "/start/api/v1/workspace"; Client client = ClientBuilder.newClient(); String port = System.getProperty("liberty.test.port"); String url = "http://localhost:" + port + endpoint; System.out.println("Testing " + url); Response response = client.target(url).request().get(); try { int status = response.getStatus(); assertEquals("Response incorrect, response status was " + status, 200, status); String workspaceId = response.readEntity(String.class); assertNotNull("Returned workspace ID was not a valid UUID : " + workspaceId, UUID.fromString(workspaceId)); } finally { response.close(); } } @Test public void testWorkspaceFileDownloadEndpoint() throws Exception { String uuid = UUID.randomUUID().toString();
int responseCode = invokeUploadEndpoint("tech=swagger&process=true&cleanup=true&workspace=" + uuid, "sampleUpload.json", getBasicSwagger("CollectiveInfo"));
WASdev/tool.accelerate.core
liberty-starter-application/src/test/java/com/ibm/liberty/starter/it/api/v1/WorkspaceEndpointTest.java
// Path: liberty-starter-application/src/test/java/com/ibm/liberty/starter/it/api/v1/utils/UploadEndpointUtils.java // public static String getBasicSwagger(String modelName) { // String swaggerContent = "{\"swagger\": \"2.0\",\"info\": {\"description\": \"Info APIs for Collective\",\"version\": \"1.0.0\"},\"basePath\": \"/\"," // + "\"paths\": {\"/ibm/api/root1/v1/info\": {\"get\": {\"summary\": \"Retrieve collective's core information\"," // + "\"description\": \"Returns a JSON with core information about collective\",\"operationId\": \"getInfo\",\"produces\": " // + "[\"application/json\"],\"responses\": {\"200\": {\"description\": \"successful operation\"," // + "\"schema\": {\"$ref\": \"#/definitions/" + modelName + "\"}},\"404\": {\"description\": \"Invalid path\"}}}}},\"definitions\": {" // + "\"" + modelName + "\": {\"properties\": {\"name\": {\"type\": \"string\",\"description\": \"Name of the collective\"}}}}}"; // return swaggerContent; // } // // Path: liberty-starter-application/src/test/java/com/ibm/liberty/starter/it/api/v1/utils/UploadEndpointUtils.java // public static int invokeUploadEndpoint(String params, String fileName, String fileContent) throws Exception { // String port = System.getProperty("liberty.test.port"); // String path = "http://localhost:" + port + "/start/api/v1/upload" + ((params != null && !params.trim().isEmpty()) ? ("?" + params) : ""); // System.out.println("Testing " + path); // // String boundary = "----WebKitFormBoundarybcoFJqLu81T8NPk8"; // URL url = new URL(path); // HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection(); // httpConnection.setUseCaches(false); // httpConnection.setDoInput(true); // httpConnection.setDoOutput(true); // // httpConnection.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary); // OutputStream outputStream = httpConnection.getOutputStream(); // PrintWriter writer = new PrintWriter(new OutputStreamWriter(outputStream), true); // // final String NEW_LINE = "\r\n"; // writer.append("--" + boundary).append(NEW_LINE); // writer.append("Content-Disposition: form-data; name=\"fileFormData\"; filename=\"" + fileName + "\"").append(NEW_LINE); // writer.append("Content-Type: application/octet-stream").append(NEW_LINE).append(NEW_LINE); // writer.append(fileContent).append(NEW_LINE); // writer.append(NEW_LINE).flush(); // writer.append("--" + boundary + "--").append(NEW_LINE); // writer.close(); // // httpConnection.disconnect(); // return httpConnection.getResponseCode(); // }
import org.junit.Test; import static com.ibm.liberty.starter.it.api.v1.utils.UploadEndpointUtils.getBasicSwagger; import static com.ibm.liberty.starter.it.api.v1.utils.UploadEndpointUtils.invokeUploadEndpoint; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeTrue; import java.io.InputStream; import java.util.UUID; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.core.Response;
/******************************************************************************* * Copyright (c) 2017 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.it.api.v1; public class WorkspaceEndpointTest { @Test public void testStarterWorkspaceEndpoint() throws Exception { String endpoint = "/start/api/v1/workspace"; Client client = ClientBuilder.newClient(); String port = System.getProperty("liberty.test.port"); String url = "http://localhost:" + port + endpoint; System.out.println("Testing " + url); Response response = client.target(url).request().get(); try { int status = response.getStatus(); assertEquals("Response incorrect, response status was " + status, 200, status); String workspaceId = response.readEntity(String.class); assertNotNull("Returned workspace ID was not a valid UUID : " + workspaceId, UUID.fromString(workspaceId)); } finally { response.close(); } } @Test public void testWorkspaceFileDownloadEndpoint() throws Exception { String uuid = UUID.randomUUID().toString();
// Path: liberty-starter-application/src/test/java/com/ibm/liberty/starter/it/api/v1/utils/UploadEndpointUtils.java // public static String getBasicSwagger(String modelName) { // String swaggerContent = "{\"swagger\": \"2.0\",\"info\": {\"description\": \"Info APIs for Collective\",\"version\": \"1.0.0\"},\"basePath\": \"/\"," // + "\"paths\": {\"/ibm/api/root1/v1/info\": {\"get\": {\"summary\": \"Retrieve collective's core information\"," // + "\"description\": \"Returns a JSON with core information about collective\",\"operationId\": \"getInfo\",\"produces\": " // + "[\"application/json\"],\"responses\": {\"200\": {\"description\": \"successful operation\"," // + "\"schema\": {\"$ref\": \"#/definitions/" + modelName + "\"}},\"404\": {\"description\": \"Invalid path\"}}}}},\"definitions\": {" // + "\"" + modelName + "\": {\"properties\": {\"name\": {\"type\": \"string\",\"description\": \"Name of the collective\"}}}}}"; // return swaggerContent; // } // // Path: liberty-starter-application/src/test/java/com/ibm/liberty/starter/it/api/v1/utils/UploadEndpointUtils.java // public static int invokeUploadEndpoint(String params, String fileName, String fileContent) throws Exception { // String port = System.getProperty("liberty.test.port"); // String path = "http://localhost:" + port + "/start/api/v1/upload" + ((params != null && !params.trim().isEmpty()) ? ("?" + params) : ""); // System.out.println("Testing " + path); // // String boundary = "----WebKitFormBoundarybcoFJqLu81T8NPk8"; // URL url = new URL(path); // HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection(); // httpConnection.setUseCaches(false); // httpConnection.setDoInput(true); // httpConnection.setDoOutput(true); // // httpConnection.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary); // OutputStream outputStream = httpConnection.getOutputStream(); // PrintWriter writer = new PrintWriter(new OutputStreamWriter(outputStream), true); // // final String NEW_LINE = "\r\n"; // writer.append("--" + boundary).append(NEW_LINE); // writer.append("Content-Disposition: form-data; name=\"fileFormData\"; filename=\"" + fileName + "\"").append(NEW_LINE); // writer.append("Content-Type: application/octet-stream").append(NEW_LINE).append(NEW_LINE); // writer.append(fileContent).append(NEW_LINE); // writer.append(NEW_LINE).flush(); // writer.append("--" + boundary + "--").append(NEW_LINE); // writer.close(); // // httpConnection.disconnect(); // return httpConnection.getResponseCode(); // } // Path: liberty-starter-application/src/test/java/com/ibm/liberty/starter/it/api/v1/WorkspaceEndpointTest.java import org.junit.Test; import static com.ibm.liberty.starter.it.api.v1.utils.UploadEndpointUtils.getBasicSwagger; import static com.ibm.liberty.starter.it.api.v1.utils.UploadEndpointUtils.invokeUploadEndpoint; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeTrue; import java.io.InputStream; import java.util.UUID; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.core.Response; /******************************************************************************* * Copyright (c) 2017 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter.it.api.v1; public class WorkspaceEndpointTest { @Test public void testStarterWorkspaceEndpoint() throws Exception { String endpoint = "/start/api/v1/workspace"; Client client = ClientBuilder.newClient(); String port = System.getProperty("liberty.test.port"); String url = "http://localhost:" + port + endpoint; System.out.println("Testing " + url); Response response = client.target(url).request().get(); try { int status = response.getStatus(); assertEquals("Response incorrect, response status was " + status, 200, status); String workspaceId = response.readEntity(String.class); assertNotNull("Returned workspace ID was not a valid UUID : " + workspaceId, UUID.fromString(workspaceId)); } finally { response.close(); } } @Test public void testWorkspaceFileDownloadEndpoint() throws Exception { String uuid = UUID.randomUUID().toString();
int responseCode = invokeUploadEndpoint("tech=swagger&process=true&cleanup=true&workspace=" + uuid, "sampleUpload.json", getBasicSwagger("CollectiveInfo"));
WASdev/tool.accelerate.core
liberty-starter-application/src/main/java/com/ibm/liberty/starter/ProjectConstructionInput.java
// Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/api/v1/model/internal/Services.java // public class Services { // private List<Service> services; // // public List<Service> getServices() { // return services; // } // // public void setServices(List<Service> services) { // this.services = services; // } // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/registration/Service.java // public class Service { // // private String id; // private String name; // private String description; // private String endpoint; // private String configuration; // private boolean options; // private String image; // private String imageSelected; // // @ApiModelProperty(value="Unique ID for this technology", required=true) // public String getId() { // return id; // } // public void setId(String id) { // this.id = id; // } // // @ApiModelProperty(value="Name of the technology (does not have to be unique, although it will be confusing if it isn't)", required=true) // public String getName() { // return name; // } // public void setName(String name) { // this.name = name; // } // // @ApiModelProperty(value="Description of the technology", required=true) // public String getDescription() { // return description; // } // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value="The endpoint to access the service", required=true) // public String getEndpoint() { // return endpoint; // } // public void setEndpoint(String endpoint) { // this.endpoint = endpoint; // } // // @ApiModelProperty(value="Specifies whether this technology allows any configuration(s). Value could either be 'yes' or a list of other technologies, seperated by comma. If a list of technologies is specified then the configuration(s) will be enabled only if all technologies on the list are selected by user", required=false) // public String getConfiguration() { // return configuration; // } // public void setConfiguration(String configuration) { // this.configuration = configuration; // } // // @ApiModelProperty(value="Specifies whether this technology has any additional options that can be set by the user", required=false) // public boolean getOptions() { // return options; // } // public void setOptions(boolean options) { // this.options = options; // } // // @Override // public String toString() { // return "Service [id=" + id + ", endpoint=" + endpoint + "]"; // } // // @ApiModelProperty(value="Specifies an image to display on the technology button", required=false) // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // // @ApiModelProperty(value="Specifies an image to display on the technology button when it is selected", required=false) // public String getImageSelected() { // return imageSelected; // } // // public void setImageSelected(String image) { // this.imageSelected = image; // } // }
import com.ibm.liberty.starter.api.v1.model.internal.Services; import com.ibm.liberty.starter.api.v1.model.registration.Service; import io.jsonwebtoken.*; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.validation.ValidationException; import java.util.ArrayList; import java.util.Calendar; import java.util.List; import java.util.logging.Logger; import java.util.stream.Collectors;
/******************************************************************************* * Copyright (c) 2016,2017 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter; public class ProjectConstructionInput { private static final Logger log = Logger.getLogger(ProjectConstructionInput.class.getName()); private static final String SERVICE_IDS_KEY = "serviceIds"; private static final String BUILD_KEY = "build"; private static final String WORKSPACE_DIR_KEY = "workspaceDir"; private static final String TECH_OPTIONS_KEY = "techOptions"; private static final String DEPLOY_KEY = "deploy"; private static final String NAME_KEY = "name"; private static final String GROUP_ID_KEY = "groupId"; private static final String ARTIFACT_ID_KEY = "artifactId"; private static final String GENERATION_ID_KEY = "generationId"; private static final String BETA_KEY = "beta"; private final ServiceConnector serviceConnector; public ProjectConstructionInput(ServiceConnector serviceConnector) { this.serviceConnector = serviceConnector; } public ProjectConstructionInputData processInput(String[] techs, String[] techOptions, String name, String deploy, String workspaceId, String build, String artifactId, String groupId, String generationId, boolean beta, boolean prepareDynamicPackages) {
// Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/api/v1/model/internal/Services.java // public class Services { // private List<Service> services; // // public List<Service> getServices() { // return services; // } // // public void setServices(List<Service> services) { // this.services = services; // } // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/registration/Service.java // public class Service { // // private String id; // private String name; // private String description; // private String endpoint; // private String configuration; // private boolean options; // private String image; // private String imageSelected; // // @ApiModelProperty(value="Unique ID for this technology", required=true) // public String getId() { // return id; // } // public void setId(String id) { // this.id = id; // } // // @ApiModelProperty(value="Name of the technology (does not have to be unique, although it will be confusing if it isn't)", required=true) // public String getName() { // return name; // } // public void setName(String name) { // this.name = name; // } // // @ApiModelProperty(value="Description of the technology", required=true) // public String getDescription() { // return description; // } // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value="The endpoint to access the service", required=true) // public String getEndpoint() { // return endpoint; // } // public void setEndpoint(String endpoint) { // this.endpoint = endpoint; // } // // @ApiModelProperty(value="Specifies whether this technology allows any configuration(s). Value could either be 'yes' or a list of other technologies, seperated by comma. If a list of technologies is specified then the configuration(s) will be enabled only if all technologies on the list are selected by user", required=false) // public String getConfiguration() { // return configuration; // } // public void setConfiguration(String configuration) { // this.configuration = configuration; // } // // @ApiModelProperty(value="Specifies whether this technology has any additional options that can be set by the user", required=false) // public boolean getOptions() { // return options; // } // public void setOptions(boolean options) { // this.options = options; // } // // @Override // public String toString() { // return "Service [id=" + id + ", endpoint=" + endpoint + "]"; // } // // @ApiModelProperty(value="Specifies an image to display on the technology button", required=false) // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // // @ApiModelProperty(value="Specifies an image to display on the technology button when it is selected", required=false) // public String getImageSelected() { // return imageSelected; // } // // public void setImageSelected(String image) { // this.imageSelected = image; // } // } // Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/ProjectConstructionInput.java import com.ibm.liberty.starter.api.v1.model.internal.Services; import com.ibm.liberty.starter.api.v1.model.registration.Service; import io.jsonwebtoken.*; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.validation.ValidationException; import java.util.ArrayList; import java.util.Calendar; import java.util.List; import java.util.logging.Logger; import java.util.stream.Collectors; /******************************************************************************* * Copyright (c) 2016,2017 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.ibm.liberty.starter; public class ProjectConstructionInput { private static final Logger log = Logger.getLogger(ProjectConstructionInput.class.getName()); private static final String SERVICE_IDS_KEY = "serviceIds"; private static final String BUILD_KEY = "build"; private static final String WORKSPACE_DIR_KEY = "workspaceDir"; private static final String TECH_OPTIONS_KEY = "techOptions"; private static final String DEPLOY_KEY = "deploy"; private static final String NAME_KEY = "name"; private static final String GROUP_ID_KEY = "groupId"; private static final String ARTIFACT_ID_KEY = "artifactId"; private static final String GENERATION_ID_KEY = "generationId"; private static final String BETA_KEY = "beta"; private final ServiceConnector serviceConnector; public ProjectConstructionInput(ServiceConnector serviceConnector) { this.serviceConnector = serviceConnector; } public ProjectConstructionInputData processInput(String[] techs, String[] techOptions, String name, String deploy, String workspaceId, String build, String artifactId, String groupId, String generationId, boolean beta, boolean prepareDynamicPackages) {
List<Service> serviceList = new ArrayList<Service>();
WASdev/tool.accelerate.core
liberty-starter-application/src/main/java/com/ibm/liberty/starter/ProjectConstructionInput.java
// Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/api/v1/model/internal/Services.java // public class Services { // private List<Service> services; // // public List<Service> getServices() { // return services; // } // // public void setServices(List<Service> services) { // this.services = services; // } // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/registration/Service.java // public class Service { // // private String id; // private String name; // private String description; // private String endpoint; // private String configuration; // private boolean options; // private String image; // private String imageSelected; // // @ApiModelProperty(value="Unique ID for this technology", required=true) // public String getId() { // return id; // } // public void setId(String id) { // this.id = id; // } // // @ApiModelProperty(value="Name of the technology (does not have to be unique, although it will be confusing if it isn't)", required=true) // public String getName() { // return name; // } // public void setName(String name) { // this.name = name; // } // // @ApiModelProperty(value="Description of the technology", required=true) // public String getDescription() { // return description; // } // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value="The endpoint to access the service", required=true) // public String getEndpoint() { // return endpoint; // } // public void setEndpoint(String endpoint) { // this.endpoint = endpoint; // } // // @ApiModelProperty(value="Specifies whether this technology allows any configuration(s). Value could either be 'yes' or a list of other technologies, seperated by comma. If a list of technologies is specified then the configuration(s) will be enabled only if all technologies on the list are selected by user", required=false) // public String getConfiguration() { // return configuration; // } // public void setConfiguration(String configuration) { // this.configuration = configuration; // } // // @ApiModelProperty(value="Specifies whether this technology has any additional options that can be set by the user", required=false) // public boolean getOptions() { // return options; // } // public void setOptions(boolean options) { // this.options = options; // } // // @Override // public String toString() { // return "Service [id=" + id + ", endpoint=" + endpoint + "]"; // } // // @ApiModelProperty(value="Specifies an image to display on the technology button", required=false) // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // // @ApiModelProperty(value="Specifies an image to display on the technology button when it is selected", required=false) // public String getImageSelected() { // return imageSelected; // } // // public void setImageSelected(String image) { // this.imageSelected = image; // } // }
import com.ibm.liberty.starter.api.v1.model.internal.Services; import com.ibm.liberty.starter.api.v1.model.registration.Service; import io.jsonwebtoken.*; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.validation.ValidationException; import java.util.ArrayList; import java.util.Calendar; import java.util.List; import java.util.logging.Logger; import java.util.stream.Collectors;
private static final String WORKSPACE_DIR_KEY = "workspaceDir"; private static final String TECH_OPTIONS_KEY = "techOptions"; private static final String DEPLOY_KEY = "deploy"; private static final String NAME_KEY = "name"; private static final String GROUP_ID_KEY = "groupId"; private static final String ARTIFACT_ID_KEY = "artifactId"; private static final String GENERATION_ID_KEY = "generationId"; private static final String BETA_KEY = "beta"; private final ServiceConnector serviceConnector; public ProjectConstructionInput(ServiceConnector serviceConnector) { this.serviceConnector = serviceConnector; } public ProjectConstructionInputData processInput(String[] techs, String[] techOptions, String name, String deploy, String workspaceId, String build, String artifactId, String groupId, String generationId, boolean beta, boolean prepareDynamicPackages) { List<Service> serviceList = new ArrayList<Service>(); for (String tech : techs) { if (PatternValidation.checkPattern(PatternValidation.PatternType.TECH, tech)) { Service service = serviceConnector.getServiceObjectFromId(tech); if (service != null) { serviceList.add(service); if (prepareDynamicPackages) { prepareDynamicPackages(service, workspaceId, getTechOptions(techOptions, tech), techs); } } } else { log.info("Invalid tech type: " + tech); throw new ValidationException("Invalid technology type."); } }
// Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/api/v1/model/internal/Services.java // public class Services { // private List<Service> services; // // public List<Service> getServices() { // return services; // } // // public void setServices(List<Service> services) { // this.services = services; // } // // } // // Path: liberty-starter-model/src/main/java/com/ibm/liberty/starter/api/v1/model/registration/Service.java // public class Service { // // private String id; // private String name; // private String description; // private String endpoint; // private String configuration; // private boolean options; // private String image; // private String imageSelected; // // @ApiModelProperty(value="Unique ID for this technology", required=true) // public String getId() { // return id; // } // public void setId(String id) { // this.id = id; // } // // @ApiModelProperty(value="Name of the technology (does not have to be unique, although it will be confusing if it isn't)", required=true) // public String getName() { // return name; // } // public void setName(String name) { // this.name = name; // } // // @ApiModelProperty(value="Description of the technology", required=true) // public String getDescription() { // return description; // } // public void setDescription(String description) { // this.description = description; // } // // @ApiModelProperty(value="The endpoint to access the service", required=true) // public String getEndpoint() { // return endpoint; // } // public void setEndpoint(String endpoint) { // this.endpoint = endpoint; // } // // @ApiModelProperty(value="Specifies whether this technology allows any configuration(s). Value could either be 'yes' or a list of other technologies, seperated by comma. If a list of technologies is specified then the configuration(s) will be enabled only if all technologies on the list are selected by user", required=false) // public String getConfiguration() { // return configuration; // } // public void setConfiguration(String configuration) { // this.configuration = configuration; // } // // @ApiModelProperty(value="Specifies whether this technology has any additional options that can be set by the user", required=false) // public boolean getOptions() { // return options; // } // public void setOptions(boolean options) { // this.options = options; // } // // @Override // public String toString() { // return "Service [id=" + id + ", endpoint=" + endpoint + "]"; // } // // @ApiModelProperty(value="Specifies an image to display on the technology button", required=false) // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // // @ApiModelProperty(value="Specifies an image to display on the technology button when it is selected", required=false) // public String getImageSelected() { // return imageSelected; // } // // public void setImageSelected(String image) { // this.imageSelected = image; // } // } // Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/ProjectConstructionInput.java import com.ibm.liberty.starter.api.v1.model.internal.Services; import com.ibm.liberty.starter.api.v1.model.registration.Service; import io.jsonwebtoken.*; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.validation.ValidationException; import java.util.ArrayList; import java.util.Calendar; import java.util.List; import java.util.logging.Logger; import java.util.stream.Collectors; private static final String WORKSPACE_DIR_KEY = "workspaceDir"; private static final String TECH_OPTIONS_KEY = "techOptions"; private static final String DEPLOY_KEY = "deploy"; private static final String NAME_KEY = "name"; private static final String GROUP_ID_KEY = "groupId"; private static final String ARTIFACT_ID_KEY = "artifactId"; private static final String GENERATION_ID_KEY = "generationId"; private static final String BETA_KEY = "beta"; private final ServiceConnector serviceConnector; public ProjectConstructionInput(ServiceConnector serviceConnector) { this.serviceConnector = serviceConnector; } public ProjectConstructionInputData processInput(String[] techs, String[] techOptions, String name, String deploy, String workspaceId, String build, String artifactId, String groupId, String generationId, boolean beta, boolean prepareDynamicPackages) { List<Service> serviceList = new ArrayList<Service>(); for (String tech : techs) { if (PatternValidation.checkPattern(PatternValidation.PatternType.TECH, tech)) { Service service = serviceConnector.getServiceObjectFromId(tech); if (service != null) { serviceList.add(service); if (prepareDynamicPackages) { prepareDynamicPackages(service, workspaceId, getTechOptions(techOptions, tech), techs); } } } else { log.info("Invalid tech type: " + tech); throw new ValidationException("Invalid technology type."); } }
Services services = new Services();
WASdev/tool.accelerate.core
liberty-starter-application/src/test/java/com/ibm/liberty/starter/it/api/v1/RepositoryRegressionTest.java
// Path: liberty-starter-application/src/test/java/com/ibm/liberty/starter/it/api/v1/utils/RepositoryClient.java // public class RepositoryClient { // // public static String invoke(String file, int expectedStatus) throws Exception { // Client client = ClientBuilder.newClient(); // String port = System.getProperty("liberty.test.port"); // String url = "http://localhost:" + port + "/start/api/v1/repo/" + file; // System.out.println("Testing " + url); // Response response = client.target(url).request().get(); // try { // int responseStatus = response.getStatus(); // InputStream responseStream = response.readEntity(InputStream.class); // String output = inputStreamToString(responseStream); // assertTrue("Response status is: " + responseStatus + " Response message: " + output, responseStatus == expectedStatus); // return output; // } finally { // response.close(); // } // } // // private static String inputStreamToString(InputStream inputStream) throws IOException { // InputStreamReader isr = new InputStreamReader(inputStream); // char[] chars = new char[1024]; // StringBuilder responseBuilder = new StringBuilder(); // // int read; // while ((read = isr.read(chars)) != -1) { // responseBuilder.append(chars, 0, read); // } // return responseBuilder.toString(); // } // // }
import static org.junit.Assert.assertTrue; import org.junit.Test; import com.ibm.liberty.starter.it.api.v1.utils.RepositoryClient;
assertPom(id, version, COMPILE); } assertMetadata(id, COMPILE); } @Test public void testServlet() throws Exception { String id = "web"; String[] versions = {"0.0.1", "0.0.2", "0.0.3"}; for (String version : versions) { assertPom(id, version, PROVIDED); assertPom(id, version, RUNTIME); assertServerXml(id, version); } assertMetadata(id, PROVIDED); } @Test public void testWebsocket() throws Exception { String id = "websocket"; String[] versions = {"0.0.2", "0.0.3", "0.0.4"}; for (String version : versions) { assertPom(id, version, PROVIDED); assertPom(id, version, RUNTIME); assertServerXml(id, version); } assertMetadata(id, PROVIDED); } private void assertPom(String id, String version, String type) throws Exception {
// Path: liberty-starter-application/src/test/java/com/ibm/liberty/starter/it/api/v1/utils/RepositoryClient.java // public class RepositoryClient { // // public static String invoke(String file, int expectedStatus) throws Exception { // Client client = ClientBuilder.newClient(); // String port = System.getProperty("liberty.test.port"); // String url = "http://localhost:" + port + "/start/api/v1/repo/" + file; // System.out.println("Testing " + url); // Response response = client.target(url).request().get(); // try { // int responseStatus = response.getStatus(); // InputStream responseStream = response.readEntity(InputStream.class); // String output = inputStreamToString(responseStream); // assertTrue("Response status is: " + responseStatus + " Response message: " + output, responseStatus == expectedStatus); // return output; // } finally { // response.close(); // } // } // // private static String inputStreamToString(InputStream inputStream) throws IOException { // InputStreamReader isr = new InputStreamReader(inputStream); // char[] chars = new char[1024]; // StringBuilder responseBuilder = new StringBuilder(); // // int read; // while ((read = isr.read(chars)) != -1) { // responseBuilder.append(chars, 0, read); // } // return responseBuilder.toString(); // } // // } // Path: liberty-starter-application/src/test/java/com/ibm/liberty/starter/it/api/v1/RepositoryRegressionTest.java import static org.junit.Assert.assertTrue; import org.junit.Test; import com.ibm.liberty.starter.it.api.v1.utils.RepositoryClient; assertPom(id, version, COMPILE); } assertMetadata(id, COMPILE); } @Test public void testServlet() throws Exception { String id = "web"; String[] versions = {"0.0.1", "0.0.2", "0.0.3"}; for (String version : versions) { assertPom(id, version, PROVIDED); assertPom(id, version, RUNTIME); assertServerXml(id, version); } assertMetadata(id, PROVIDED); } @Test public void testWebsocket() throws Exception { String id = "websocket"; String[] versions = {"0.0.2", "0.0.3", "0.0.4"}; for (String version : versions) { assertPom(id, version, PROVIDED); assertPom(id, version, RUNTIME); assertServerXml(id, version); } assertMetadata(id, PROVIDED); } private void assertPom(String id, String version, String type) throws Exception {
String pom = RepositoryClient.invoke("net/wasdev/wlp/starters/" + id + "/" + type + "/" + version + "/" + type + "-" + version + ".pom", 200);
orientechnologies/orientdb-lucene
src/main/java/com/orientechnologies/lucene/manager/OLuceneFullTextIndexManager.java
// Path: src/main/java/com/orientechnologies/lucene/query/QueryContext.java // public class QueryContext { // // public final OCommandContext context; // public final IndexSearcher searcher; // public final Query query; // public final Filter filter; // public final Sort sort; // public QueryContextCFG cfg; // public boolean facet = false; // public boolean drillDown = false; // public TaxonomyReader reader; // private FacetsConfig facetConfig; // private String facetField; // private String drillDownQuery; // // public QueryContext(OCommandContext context, IndexSearcher searcher, Query query) { // this(context, searcher, query, null, null); // } // // public QueryContext(OCommandContext context, IndexSearcher searcher, Query query, Filter filter) { // this(context, searcher, query, filter, null); // } // // public QueryContext(OCommandContext context, IndexSearcher searcher, Query query, Filter filter, Sort sort) { // this.context = context; // this.searcher = searcher; // this.query = query; // this.filter = filter; // this.sort = sort; // initCFG(); // } // // private void initCFG() { // if (filter != null && sort != null) { // cfg = QueryContextCFG.FILTER_SORT; // } else if (filter == null && sort == null) { // cfg = QueryContextCFG.NO_FILTER_NO_SORT; // } else if (filter != null) { // cfg = QueryContextCFG.FILTER; // } else { // cfg = QueryContextCFG.SORT; // } // } // // public QueryContext setFacet(boolean facet) { // this.facet = facet; // return this; // } // // public QueryContext setReader(TaxonomyReader reader) { // this.reader = reader; // return this; // } // // public void setFacetConfig(FacetsConfig facetConfig) { // this.facetConfig = facetConfig; // } // // public FacetsConfig getFacetConfig() { // return facetConfig; // } // // public void setFacetField(String facetField) { // this.facetField = facetField; // } // // public String getFacetField() { // return facetField; // } // // public void setDrillDownQuery(String drillDownQuery) { // this.drillDownQuery = drillDownQuery; // drillDown = drillDownQuery != null; // } // // public boolean isDrillDown() { // return drillDown; // } // // public String getDrillDownQuery() { // return drillDownQuery; // } // // public enum QueryContextCFG { // NO_FILTER_NO_SORT, FILTER_SORT, FILTER, SORT // } // }
import com.orientechnologies.common.log.OLogManager; import com.orientechnologies.lucene.OLuceneIndexType; import com.orientechnologies.lucene.collections.LuceneResultSet; import com.orientechnologies.lucene.collections.OFullTextCompositeKey; import com.orientechnologies.lucene.query.QueryContext; import com.orientechnologies.orient.core.command.OCommandContext; import com.orientechnologies.orient.core.db.record.OIdentifiable; import com.orientechnologies.orient.core.id.OContextualRecordId; import com.orientechnologies.orient.core.id.ORID; import com.orientechnologies.orient.core.index.*; import com.orientechnologies.orient.core.record.impl.ODocument; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.queryparser.classic.ParseException; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Query; import org.apache.lucene.search.ScoreDoc; import org.apache.lucene.store.Directory; import org.apache.lucene.util.Version; import java.io.IOException; import java.util.*;
for (Object o : keys) { doc.add(OLuceneIndexType.createField("k" + k, o, Field.Store.NO, Field.Index.ANALYZED)); } } else { val = key; doc.add(OLuceneIndexType.createField("k0", val, Field.Store.NO, Field.Index.ANALYZED)); } } if (facetManager.supportsFacets()) { try { addDocument(facetManager.buildDocument(doc)); } catch (IOException e) { e.printStackTrace(); } } else { addDocument(doc); } facetManager.commit(); if (!index.isAutomatic()) { commit(); } } } private Set<OIdentifiable> getResults(Query query, OCommandContext context, Object key) { try { IndexSearcher searcher = getSearcher();
// Path: src/main/java/com/orientechnologies/lucene/query/QueryContext.java // public class QueryContext { // // public final OCommandContext context; // public final IndexSearcher searcher; // public final Query query; // public final Filter filter; // public final Sort sort; // public QueryContextCFG cfg; // public boolean facet = false; // public boolean drillDown = false; // public TaxonomyReader reader; // private FacetsConfig facetConfig; // private String facetField; // private String drillDownQuery; // // public QueryContext(OCommandContext context, IndexSearcher searcher, Query query) { // this(context, searcher, query, null, null); // } // // public QueryContext(OCommandContext context, IndexSearcher searcher, Query query, Filter filter) { // this(context, searcher, query, filter, null); // } // // public QueryContext(OCommandContext context, IndexSearcher searcher, Query query, Filter filter, Sort sort) { // this.context = context; // this.searcher = searcher; // this.query = query; // this.filter = filter; // this.sort = sort; // initCFG(); // } // // private void initCFG() { // if (filter != null && sort != null) { // cfg = QueryContextCFG.FILTER_SORT; // } else if (filter == null && sort == null) { // cfg = QueryContextCFG.NO_FILTER_NO_SORT; // } else if (filter != null) { // cfg = QueryContextCFG.FILTER; // } else { // cfg = QueryContextCFG.SORT; // } // } // // public QueryContext setFacet(boolean facet) { // this.facet = facet; // return this; // } // // public QueryContext setReader(TaxonomyReader reader) { // this.reader = reader; // return this; // } // // public void setFacetConfig(FacetsConfig facetConfig) { // this.facetConfig = facetConfig; // } // // public FacetsConfig getFacetConfig() { // return facetConfig; // } // // public void setFacetField(String facetField) { // this.facetField = facetField; // } // // public String getFacetField() { // return facetField; // } // // public void setDrillDownQuery(String drillDownQuery) { // this.drillDownQuery = drillDownQuery; // drillDown = drillDownQuery != null; // } // // public boolean isDrillDown() { // return drillDown; // } // // public String getDrillDownQuery() { // return drillDownQuery; // } // // public enum QueryContextCFG { // NO_FILTER_NO_SORT, FILTER_SORT, FILTER, SORT // } // } // Path: src/main/java/com/orientechnologies/lucene/manager/OLuceneFullTextIndexManager.java import com.orientechnologies.common.log.OLogManager; import com.orientechnologies.lucene.OLuceneIndexType; import com.orientechnologies.lucene.collections.LuceneResultSet; import com.orientechnologies.lucene.collections.OFullTextCompositeKey; import com.orientechnologies.lucene.query.QueryContext; import com.orientechnologies.orient.core.command.OCommandContext; import com.orientechnologies.orient.core.db.record.OIdentifiable; import com.orientechnologies.orient.core.id.OContextualRecordId; import com.orientechnologies.orient.core.id.ORID; import com.orientechnologies.orient.core.index.*; import com.orientechnologies.orient.core.record.impl.ODocument; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.queryparser.classic.ParseException; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Query; import org.apache.lucene.search.ScoreDoc; import org.apache.lucene.store.Directory; import org.apache.lucene.util.Version; import java.io.IOException; import java.util.*; for (Object o : keys) { doc.add(OLuceneIndexType.createField("k" + k, o, Field.Store.NO, Field.Index.ANALYZED)); } } else { val = key; doc.add(OLuceneIndexType.createField("k0", val, Field.Store.NO, Field.Index.ANALYZED)); } } if (facetManager.supportsFacets()) { try { addDocument(facetManager.buildDocument(doc)); } catch (IOException e) { e.printStackTrace(); } } else { addDocument(doc); } facetManager.commit(); if (!index.isAutomatic()) { commit(); } } } private Set<OIdentifiable> getResults(Query query, OCommandContext context, Object key) { try { IndexSearcher searcher = getSearcher();
QueryContext queryContext = new QueryContext(context, searcher, query);
ashish-chopra/Structures
src/test/java/com/graph/BFSTest.java
// Path: src/main/java/com/graphs/BreadthFirstSearch.java // public class BreadthFirstSearch { // // private boolean marked[]; // vertices marked while traversing in BFS. // private int edgeTo[]; // mark the parent vertex for a given vertex // // public BreadthFirstSearch(Graph graph, int source) { // marked = new boolean[graph.V()]; // edgeTo = new int[graph.V()]; // bfs(graph, source); // } // // private void bfs(Graph G, int s) { // marked[s] = true; // Queue<Integer> queue = new Queue<Integer>(); // queue.enqueue(s); // // while (!queue.isEmpty()) { // int v = queue.dequeue(); // marked[v] = true; // for (int w: G.adj(v)) { // if (!marked[w]) { // queue.enqueue(w); // edgeTo[w] = v; // } // } // } // } // // /** // * returns the path between source vertex and // * given vertex as an Iterable set. // * @param v // * @return // */ // public Iterable<Integer> pathTo(int v) { // Stack<Integer> stack = new Stack<Integer>(); // while (v != 0) { // stack.push(v); // v = edgeTo[v]; // } // stack.push(v); // return stack; // } // // /** // * checks to see if there is a path between source vertex and // * given vertex v. // * @param v // * @return // */ // public boolean hasPathTo(int v) { // return marked[v]; // } // } // // Path: src/main/java/com/graphs/Graph.java // public class Graph { // private int V; // private int E; // private List<Bag<Integer>> adj; // adjacency list of vertices // // /** // * creates an empty graph with zero edges with // * given number of vertices as input. // * @param totalVertices Total number of vertices in the graph. // */ // public Graph(int totalVertices) { // if (totalVertices <= 0) // throw new IllegalArgumentException("No. of vertices is zero or negative."); // this.V = totalVertices; // this.E = 0; // adj = new ArrayList<Bag<Integer>>(); // for (int i = 0; i < V; i++) { // adj.add(new Bag<Integer>()); // } // } // // /** // * creates a graph by reading input from // * the input stream. // * <pre> // * The input format is like: // * 5 // number of vertices // * 6 // number of edges // * 0 3 // edge wise pair in E lines // * 2 4 // * 3 4 // * 1 2 // * </pre> // * @param s // */ // public Graph(Scanner s) { // this(s.nextInt()); // int noOfEdges = s.nextInt(); // for (int i = 0; i < noOfEdges; i++) { // addEdge(s.nextInt(), s.nextInt()); // } // } // // /** // * adds an edge v-w in the graph. // * @param v one vertex // * @param w other vertex // */ // public void addEdge(int v, int w) { // adj.get(v).add(w); // adj.get(w).add(v); // E++; // } // // /** // * gets the total number of vertices in the graph. // * @return // */ // public int V() { // return V; // } // // /** // * gets the total number of edges in the graph. // * @return // */ // public int E() { // return E; // } // // /** // * returns a list of adjacent vertices of a // * given vertex in the graph. // * @param v the vertex whose adjacency list is required. // * @return // */ // public Iterable<Integer> adj(int v) { // return adj.get(v); // } // // /** // * checks to see if there is an edge v-w in the graph. // * @param v one vertex // * @param w other vertex // * @return // */ // public boolean hasEdge(int v, int w) { // for (int k: adj(v)) { // if (w == k) return true; // } // return false; // } // // /** // * returns a String representation of the graph. // */ // public String toString() { // StringBuilder sb = new StringBuilder(); // sb.append("Graph with V = " + V + " and E = " + E + "\n"); // for (int v = 0; v < V; v++) { // sb.append(v + ": "); // for (int w: adj(v)) { // sb.append(w + " "); // } // sb.append("\n"); // } // return sb.toString(); // } // }
import java.io.File; import java.net.URL; import java.util.Scanner; import com.graphs.BreadthFirstSearch; import com.graphs.Graph; import junit.framework.TestCase;
package com.graph; public class BFSTest extends TestCase { Graph graph; public void setUp() { Scanner scn = null; try { URL url = this.getClass().getClassLoader().getResource("tinyGraph.txt"); scn = new Scanner(new File(url.getFile())); } catch (Exception e) { e.printStackTrace(); } this.graph = new Graph(scn); } public void testBFSOperations() { int sourceVertex = 0; int destinationVertex = 5;
// Path: src/main/java/com/graphs/BreadthFirstSearch.java // public class BreadthFirstSearch { // // private boolean marked[]; // vertices marked while traversing in BFS. // private int edgeTo[]; // mark the parent vertex for a given vertex // // public BreadthFirstSearch(Graph graph, int source) { // marked = new boolean[graph.V()]; // edgeTo = new int[graph.V()]; // bfs(graph, source); // } // // private void bfs(Graph G, int s) { // marked[s] = true; // Queue<Integer> queue = new Queue<Integer>(); // queue.enqueue(s); // // while (!queue.isEmpty()) { // int v = queue.dequeue(); // marked[v] = true; // for (int w: G.adj(v)) { // if (!marked[w]) { // queue.enqueue(w); // edgeTo[w] = v; // } // } // } // } // // /** // * returns the path between source vertex and // * given vertex as an Iterable set. // * @param v // * @return // */ // public Iterable<Integer> pathTo(int v) { // Stack<Integer> stack = new Stack<Integer>(); // while (v != 0) { // stack.push(v); // v = edgeTo[v]; // } // stack.push(v); // return stack; // } // // /** // * checks to see if there is a path between source vertex and // * given vertex v. // * @param v // * @return // */ // public boolean hasPathTo(int v) { // return marked[v]; // } // } // // Path: src/main/java/com/graphs/Graph.java // public class Graph { // private int V; // private int E; // private List<Bag<Integer>> adj; // adjacency list of vertices // // /** // * creates an empty graph with zero edges with // * given number of vertices as input. // * @param totalVertices Total number of vertices in the graph. // */ // public Graph(int totalVertices) { // if (totalVertices <= 0) // throw new IllegalArgumentException("No. of vertices is zero or negative."); // this.V = totalVertices; // this.E = 0; // adj = new ArrayList<Bag<Integer>>(); // for (int i = 0; i < V; i++) { // adj.add(new Bag<Integer>()); // } // } // // /** // * creates a graph by reading input from // * the input stream. // * <pre> // * The input format is like: // * 5 // number of vertices // * 6 // number of edges // * 0 3 // edge wise pair in E lines // * 2 4 // * 3 4 // * 1 2 // * </pre> // * @param s // */ // public Graph(Scanner s) { // this(s.nextInt()); // int noOfEdges = s.nextInt(); // for (int i = 0; i < noOfEdges; i++) { // addEdge(s.nextInt(), s.nextInt()); // } // } // // /** // * adds an edge v-w in the graph. // * @param v one vertex // * @param w other vertex // */ // public void addEdge(int v, int w) { // adj.get(v).add(w); // adj.get(w).add(v); // E++; // } // // /** // * gets the total number of vertices in the graph. // * @return // */ // public int V() { // return V; // } // // /** // * gets the total number of edges in the graph. // * @return // */ // public int E() { // return E; // } // // /** // * returns a list of adjacent vertices of a // * given vertex in the graph. // * @param v the vertex whose adjacency list is required. // * @return // */ // public Iterable<Integer> adj(int v) { // return adj.get(v); // } // // /** // * checks to see if there is an edge v-w in the graph. // * @param v one vertex // * @param w other vertex // * @return // */ // public boolean hasEdge(int v, int w) { // for (int k: adj(v)) { // if (w == k) return true; // } // return false; // } // // /** // * returns a String representation of the graph. // */ // public String toString() { // StringBuilder sb = new StringBuilder(); // sb.append("Graph with V = " + V + " and E = " + E + "\n"); // for (int v = 0; v < V; v++) { // sb.append(v + ": "); // for (int w: adj(v)) { // sb.append(w + " "); // } // sb.append("\n"); // } // return sb.toString(); // } // } // Path: src/test/java/com/graph/BFSTest.java import java.io.File; import java.net.URL; import java.util.Scanner; import com.graphs.BreadthFirstSearch; import com.graphs.Graph; import junit.framework.TestCase; package com.graph; public class BFSTest extends TestCase { Graph graph; public void setUp() { Scanner scn = null; try { URL url = this.getClass().getClassLoader().getResource("tinyGraph.txt"); scn = new Scanner(new File(url.getFile())); } catch (Exception e) { e.printStackTrace(); } this.graph = new Graph(scn); } public void testBFSOperations() { int sourceVertex = 0; int destinationVertex = 5;
BreadthFirstSearch bfs = new BreadthFirstSearch(graph, sourceVertex);
ashish-chopra/Structures
src/test/java/com/graph/CycleTest.java
// Path: src/main/java/com/graphs/Cycle.java // public class Cycle { // // private boolean marked[]; // list of vertices marked true if visited. // private boolean hasCycle; // flag to record if cycle exists. // private Graph graph; // the graph under consideration // // // /** // * creates a Cycle object which processes the // * given graph from the given source vertex s. // * @param graph The Graph under processing. // * @param sourceVertex source vertex // */ // public Cycle(Graph graph, int sourceVertex) { // this.graph = graph; // this.marked = new boolean[graph.V()]; // this.hasCycle = false; // dfs(sourceVertex); // } // // /* // * runs DFS on a given graph and identifies cycle. // * If any vertex which has already been marked/visited, // * is seen again, then cycle exists. // * // */ // private void dfs(int s) { // marked[s] = true; // for (int w: graph.adj(s)) { // if (!marked[w]) // dfs(w); // else { // hasCycle = true; // break; // } // } // } // // /** // * determines if the given Graph graph has cycle. // * @return true if cycle exists, false otherwise. // */ // public boolean hasCycle() { // return hasCycle; // } // } // // Path: src/main/java/com/graphs/Graph.java // public class Graph { // private int V; // private int E; // private List<Bag<Integer>> adj; // adjacency list of vertices // // /** // * creates an empty graph with zero edges with // * given number of vertices as input. // * @param totalVertices Total number of vertices in the graph. // */ // public Graph(int totalVertices) { // if (totalVertices <= 0) // throw new IllegalArgumentException("No. of vertices is zero or negative."); // this.V = totalVertices; // this.E = 0; // adj = new ArrayList<Bag<Integer>>(); // for (int i = 0; i < V; i++) { // adj.add(new Bag<Integer>()); // } // } // // /** // * creates a graph by reading input from // * the input stream. // * <pre> // * The input format is like: // * 5 // number of vertices // * 6 // number of edges // * 0 3 // edge wise pair in E lines // * 2 4 // * 3 4 // * 1 2 // * </pre> // * @param s // */ // public Graph(Scanner s) { // this(s.nextInt()); // int noOfEdges = s.nextInt(); // for (int i = 0; i < noOfEdges; i++) { // addEdge(s.nextInt(), s.nextInt()); // } // } // // /** // * adds an edge v-w in the graph. // * @param v one vertex // * @param w other vertex // */ // public void addEdge(int v, int w) { // adj.get(v).add(w); // adj.get(w).add(v); // E++; // } // // /** // * gets the total number of vertices in the graph. // * @return // */ // public int V() { // return V; // } // // /** // * gets the total number of edges in the graph. // * @return // */ // public int E() { // return E; // } // // /** // * returns a list of adjacent vertices of a // * given vertex in the graph. // * @param v the vertex whose adjacency list is required. // * @return // */ // public Iterable<Integer> adj(int v) { // return adj.get(v); // } // // /** // * checks to see if there is an edge v-w in the graph. // * @param v one vertex // * @param w other vertex // * @return // */ // public boolean hasEdge(int v, int w) { // for (int k: adj(v)) { // if (w == k) return true; // } // return false; // } // // /** // * returns a String representation of the graph. // */ // public String toString() { // StringBuilder sb = new StringBuilder(); // sb.append("Graph with V = " + V + " and E = " + E + "\n"); // for (int v = 0; v < V; v++) { // sb.append(v + ": "); // for (int w: adj(v)) { // sb.append(w + " "); // } // sb.append("\n"); // } // return sb.toString(); // } // }
import java.io.File; import java.net.URL; import java.util.Scanner; import com.graphs.Cycle; import com.graphs.Graph; import junit.framework.TestCase;
package com.graph; public class CycleTest extends TestCase { private Graph graph; public void setUp() { Scanner scn = null; try { URL url = this.getClass().getClassLoader().getResource("tinyCyclicGraph.txt"); scn = new Scanner(new File(url.getFile())); } catch (Exception e) { e.printStackTrace(); } this.graph = new Graph(scn); } public void testBasicCycleDetection() {
// Path: src/main/java/com/graphs/Cycle.java // public class Cycle { // // private boolean marked[]; // list of vertices marked true if visited. // private boolean hasCycle; // flag to record if cycle exists. // private Graph graph; // the graph under consideration // // // /** // * creates a Cycle object which processes the // * given graph from the given source vertex s. // * @param graph The Graph under processing. // * @param sourceVertex source vertex // */ // public Cycle(Graph graph, int sourceVertex) { // this.graph = graph; // this.marked = new boolean[graph.V()]; // this.hasCycle = false; // dfs(sourceVertex); // } // // /* // * runs DFS on a given graph and identifies cycle. // * If any vertex which has already been marked/visited, // * is seen again, then cycle exists. // * // */ // private void dfs(int s) { // marked[s] = true; // for (int w: graph.adj(s)) { // if (!marked[w]) // dfs(w); // else { // hasCycle = true; // break; // } // } // } // // /** // * determines if the given Graph graph has cycle. // * @return true if cycle exists, false otherwise. // */ // public boolean hasCycle() { // return hasCycle; // } // } // // Path: src/main/java/com/graphs/Graph.java // public class Graph { // private int V; // private int E; // private List<Bag<Integer>> adj; // adjacency list of vertices // // /** // * creates an empty graph with zero edges with // * given number of vertices as input. // * @param totalVertices Total number of vertices in the graph. // */ // public Graph(int totalVertices) { // if (totalVertices <= 0) // throw new IllegalArgumentException("No. of vertices is zero or negative."); // this.V = totalVertices; // this.E = 0; // adj = new ArrayList<Bag<Integer>>(); // for (int i = 0; i < V; i++) { // adj.add(new Bag<Integer>()); // } // } // // /** // * creates a graph by reading input from // * the input stream. // * <pre> // * The input format is like: // * 5 // number of vertices // * 6 // number of edges // * 0 3 // edge wise pair in E lines // * 2 4 // * 3 4 // * 1 2 // * </pre> // * @param s // */ // public Graph(Scanner s) { // this(s.nextInt()); // int noOfEdges = s.nextInt(); // for (int i = 0; i < noOfEdges; i++) { // addEdge(s.nextInt(), s.nextInt()); // } // } // // /** // * adds an edge v-w in the graph. // * @param v one vertex // * @param w other vertex // */ // public void addEdge(int v, int w) { // adj.get(v).add(w); // adj.get(w).add(v); // E++; // } // // /** // * gets the total number of vertices in the graph. // * @return // */ // public int V() { // return V; // } // // /** // * gets the total number of edges in the graph. // * @return // */ // public int E() { // return E; // } // // /** // * returns a list of adjacent vertices of a // * given vertex in the graph. // * @param v the vertex whose adjacency list is required. // * @return // */ // public Iterable<Integer> adj(int v) { // return adj.get(v); // } // // /** // * checks to see if there is an edge v-w in the graph. // * @param v one vertex // * @param w other vertex // * @return // */ // public boolean hasEdge(int v, int w) { // for (int k: adj(v)) { // if (w == k) return true; // } // return false; // } // // /** // * returns a String representation of the graph. // */ // public String toString() { // StringBuilder sb = new StringBuilder(); // sb.append("Graph with V = " + V + " and E = " + E + "\n"); // for (int v = 0; v < V; v++) { // sb.append(v + ": "); // for (int w: adj(v)) { // sb.append(w + " "); // } // sb.append("\n"); // } // return sb.toString(); // } // } // Path: src/test/java/com/graph/CycleTest.java import java.io.File; import java.net.URL; import java.util.Scanner; import com.graphs.Cycle; import com.graphs.Graph; import junit.framework.TestCase; package com.graph; public class CycleTest extends TestCase { private Graph graph; public void setUp() { Scanner scn = null; try { URL url = this.getClass().getClassLoader().getResource("tinyCyclicGraph.txt"); scn = new Scanner(new File(url.getFile())); } catch (Exception e) { e.printStackTrace(); } this.graph = new Graph(scn); } public void testBasicCycleDetection() {
Cycle cycle = new Cycle(graph, 0);
ashish-chopra/Structures
src/main/java/com/applications/Subset.java
// Path: src/main/java/com/queues/RandomizedQueue.java // public class RandomizedQueue<Item> implements Iterable<Item> { // // private int N; // private Item[] items; // private Random randomGenerator; // // /** // * constructs the RandomizedQueue object. // */ // public RandomizedQueue() { // items = (Item[]) new Object[1]; // randomGenerator = new Random(); // N = 0; // } // // /** // * inserts an item into the queue. // * @param item Item to be inserted in the queue. // */ // public void enqueue(Item item) { // if (item == null) // throw new NullPointerException("null elements cannot be added."); // // if (N == items.length) resize(N * 2); // items[N++] = item; // } // // /** // * checks to see if queue is empty. // * @return <code>true</code> if empty, <code>false</code> otherwise. // */ // public boolean isEmpty() { // return N == 0; // } // // /** // * returns the size of the queue. // * @return size as Integer. // */ // public int size() { // return N; // } // // /** // * removes a randomly chosen item from the queue. If queue is empty, // * throws NoSuchElementException. // * @return a randomly chosen item from queue. // */ // public Item dequeue() { // if (isEmpty()) // throw new NoSuchElementException("Queue is empty, by the way!!"); // // int index = randomGenerator.nextInt(N); // Item item = items[index]; // items[index] = items[N-1]; // items[N-1] = null; // N--; // if (N > 0 && N == items.length / 4) resize(items.length / 2); // return item; // } // // /** // * returns a randomly chosen item from the queue without removing it. // * Throws NoSuchElementException when queue is empty. // * @return an item from the queue. // */ // public Item sample() { // if (isEmpty()) // throw new NoSuchElementException("Queue is empty, by the way!!"); // // int index = randomGenerator.nextInt(N); // Item item = items[index]; // return item; // } // // /** // * returns an iterator of this random queue object. // */ // public Iterator<Item> iterator() { // return new RandomQueueIterator(); // } // // // private void resize(int size) { // Item[] list = (Item[]) new Object[size]; // for (int i = 0; i < N; i++) { // list[i] = items[i]; // } // items = list; // } // // private class RandomQueueIterator implements Iterator<Item> { // // private int current; // private Item[] data; // // public RandomQueueIterator() { // current = 0; // data = (Item[]) new Object[N]; // for (int i = 0; i < N; i++) { // data[i] = items[i]; // } // } // // public boolean hasNext() { // return current != 0; // } // // public Item next() { // if (!hasNext()) // throw new NoSuchElementException("no elements on the list by the way :("); // int index = randomGenerator.nextInt(current); // Item item = data[index]; // data[index] = data[current - 1]; // data[current - 1] = item; // current--; // return item; // } // // public void remove() { // throw new UnsupportedOperationException("Remove not supported :("); // } // } // }
import java.util.Iterator; import com.queues.RandomizedQueue;
/* * File: Subset.java * Date: 17 Feb, 2013 * Author: Ashish Chopra * --------------------------------------------- * Deque is an abstract data structure and an adaptation * of queue, such that the elements can be inserted and removed from * the front as well as from the last. * It is implemented for generic types of data using doublly linked list * implementation. * It also implements iterable interface to provide an iterator over the * elements from front to end. * */ package com.applications; /** * This class tests the RandomizedQueue implementation by * accepting N number of input strings and printing back * random k strings back to the output. * @author Ashish Chopra * */ public class Subset { public static void main(String[] args) { int k = Integer.parseInt(args[0]);
// Path: src/main/java/com/queues/RandomizedQueue.java // public class RandomizedQueue<Item> implements Iterable<Item> { // // private int N; // private Item[] items; // private Random randomGenerator; // // /** // * constructs the RandomizedQueue object. // */ // public RandomizedQueue() { // items = (Item[]) new Object[1]; // randomGenerator = new Random(); // N = 0; // } // // /** // * inserts an item into the queue. // * @param item Item to be inserted in the queue. // */ // public void enqueue(Item item) { // if (item == null) // throw new NullPointerException("null elements cannot be added."); // // if (N == items.length) resize(N * 2); // items[N++] = item; // } // // /** // * checks to see if queue is empty. // * @return <code>true</code> if empty, <code>false</code> otherwise. // */ // public boolean isEmpty() { // return N == 0; // } // // /** // * returns the size of the queue. // * @return size as Integer. // */ // public int size() { // return N; // } // // /** // * removes a randomly chosen item from the queue. If queue is empty, // * throws NoSuchElementException. // * @return a randomly chosen item from queue. // */ // public Item dequeue() { // if (isEmpty()) // throw new NoSuchElementException("Queue is empty, by the way!!"); // // int index = randomGenerator.nextInt(N); // Item item = items[index]; // items[index] = items[N-1]; // items[N-1] = null; // N--; // if (N > 0 && N == items.length / 4) resize(items.length / 2); // return item; // } // // /** // * returns a randomly chosen item from the queue without removing it. // * Throws NoSuchElementException when queue is empty. // * @return an item from the queue. // */ // public Item sample() { // if (isEmpty()) // throw new NoSuchElementException("Queue is empty, by the way!!"); // // int index = randomGenerator.nextInt(N); // Item item = items[index]; // return item; // } // // /** // * returns an iterator of this random queue object. // */ // public Iterator<Item> iterator() { // return new RandomQueueIterator(); // } // // // private void resize(int size) { // Item[] list = (Item[]) new Object[size]; // for (int i = 0; i < N; i++) { // list[i] = items[i]; // } // items = list; // } // // private class RandomQueueIterator implements Iterator<Item> { // // private int current; // private Item[] data; // // public RandomQueueIterator() { // current = 0; // data = (Item[]) new Object[N]; // for (int i = 0; i < N; i++) { // data[i] = items[i]; // } // } // // public boolean hasNext() { // return current != 0; // } // // public Item next() { // if (!hasNext()) // throw new NoSuchElementException("no elements on the list by the way :("); // int index = randomGenerator.nextInt(current); // Item item = data[index]; // data[index] = data[current - 1]; // data[current - 1] = item; // current--; // return item; // } // // public void remove() { // throw new UnsupportedOperationException("Remove not supported :("); // } // } // } // Path: src/main/java/com/applications/Subset.java import java.util.Iterator; import com.queues.RandomizedQueue; /* * File: Subset.java * Date: 17 Feb, 2013 * Author: Ashish Chopra * --------------------------------------------- * Deque is an abstract data structure and an adaptation * of queue, such that the elements can be inserted and removed from * the front as well as from the last. * It is implemented for generic types of data using doublly linked list * implementation. * It also implements iterable interface to provide an iterator over the * elements from front to end. * */ package com.applications; /** * This class tests the RandomizedQueue implementation by * accepting N number of input strings and printing back * random k strings back to the output. * @author Ashish Chopra * */ public class Subset { public static void main(String[] args) { int k = Integer.parseInt(args[0]);
RandomizedQueue<String> list = new RandomizedQueue<String>();
ashish-chopra/Structures
src/main/java/com/graphs/Graph.java
// Path: src/main/java/com/bags/Bag.java // public class Bag<Item> implements Iterable<Item> { // // // private Item[] contents; // private int N; // // // /** // * creates a new empty Bag. // */ // public Bag() { // contents = (Item[]) new Object[1]; // N = 0; // } // // /** // * // * checks to see if Bag is empty. // * @return <code>true</code> if empty, <code>false</code> otherwise. // */ // public boolean isEmpty() { // return N == 0; // } // // // /** // * adds an item into the bag. // * @param item An item need to be added. // */ // public void add(Item item) { // if (item == null) // throw new NullPointerException("You cannot fool us with null insertion :)"); // if (N == contents.length) // resize(contents.length * 2); // contents[N++] = item; // } // // // /** // * returns an iterator over the elements of the bag. // * // */ // public Iterator<Item> iterator() { // return new BagIterator(); // } // // public int size() { // return N; // } // // private void resize(int size) { // Item[] items = (Item[]) new Object[size]; // for (int i = 0; i < N; i++) { // items[i] = contents[i]; // } // contents = items; // } // // // private class BagIterator implements Iterator<Item> { // // private int current; // // public BagIterator() { // current = 0; // } // // public boolean hasNext() { // return current != N; // } // // public Item next() { // return contents[current++]; // } // // public void remove() { // throw new UnsupportedOperationException("Boo! Operation not supported :("); // } // // } // // // }
import java.util.ArrayList; import java.util.List; import java.util.Scanner; import com.bags.Bag;
/* * File: Graph.java * Author: Ashish Chopra * Date: 4 jul, 2015 * ---------------------------------------------- * Graph is an abstract Data type that represents the collection * of vertices and edges as provided by input. * * The Graph will be studied and developed in four flavors: * 1. Undriected Graph * 2. Directed Graph * 3. Weighted Undirected Graph * 4. Weighted Digraph * * The Graph is implemented using adjacency list, which allows self loops * and parallel edges as well. Every edge will be stored twice in this * representation. However this representation is the most efficient among * others like Adjacency matrix, array of edges etc. * * Various operations that are performed on graph like search, finding path, * minimum path and other queries will be developed as their own class which * utilize Graph G as input. * * * Graph provides following API * ---------------------------------------------- * Graph (int v) // constructs a graph with given no. of vertices * Graph (Stream s) // constructs a graph from input stream data * int V() // returns the number of vertices * int E() // returns the number of edges * Iterable<Integer> adj(int v) // returns the adjacent vertices list of a given vertex v. * void addEdge(int v, int w) // adds an edge between vertex v and w. * */ package com.graphs; /** * Graph is an ADT that represents a collection of vertices V and the connection amongst them * called edges E. Every Graph G is defined as function of G = f(V, E). A graph is created by * calling one of the two constructors. One creates a graph with given number of vertices. * Other takes a stream input and initializes the graph from stream data. * * Note: This graph is an undirected graph, i.e. if a vertex v is reachable from vertex w, * then it implies that w is reachable from v * * @author Ashish Chopra * */ public class Graph { private int V; private int E;
// Path: src/main/java/com/bags/Bag.java // public class Bag<Item> implements Iterable<Item> { // // // private Item[] contents; // private int N; // // // /** // * creates a new empty Bag. // */ // public Bag() { // contents = (Item[]) new Object[1]; // N = 0; // } // // /** // * // * checks to see if Bag is empty. // * @return <code>true</code> if empty, <code>false</code> otherwise. // */ // public boolean isEmpty() { // return N == 0; // } // // // /** // * adds an item into the bag. // * @param item An item need to be added. // */ // public void add(Item item) { // if (item == null) // throw new NullPointerException("You cannot fool us with null insertion :)"); // if (N == contents.length) // resize(contents.length * 2); // contents[N++] = item; // } // // // /** // * returns an iterator over the elements of the bag. // * // */ // public Iterator<Item> iterator() { // return new BagIterator(); // } // // public int size() { // return N; // } // // private void resize(int size) { // Item[] items = (Item[]) new Object[size]; // for (int i = 0; i < N; i++) { // items[i] = contents[i]; // } // contents = items; // } // // // private class BagIterator implements Iterator<Item> { // // private int current; // // public BagIterator() { // current = 0; // } // // public boolean hasNext() { // return current != N; // } // // public Item next() { // return contents[current++]; // } // // public void remove() { // throw new UnsupportedOperationException("Boo! Operation not supported :("); // } // // } // // // } // Path: src/main/java/com/graphs/Graph.java import java.util.ArrayList; import java.util.List; import java.util.Scanner; import com.bags.Bag; /* * File: Graph.java * Author: Ashish Chopra * Date: 4 jul, 2015 * ---------------------------------------------- * Graph is an abstract Data type that represents the collection * of vertices and edges as provided by input. * * The Graph will be studied and developed in four flavors: * 1. Undriected Graph * 2. Directed Graph * 3. Weighted Undirected Graph * 4. Weighted Digraph * * The Graph is implemented using adjacency list, which allows self loops * and parallel edges as well. Every edge will be stored twice in this * representation. However this representation is the most efficient among * others like Adjacency matrix, array of edges etc. * * Various operations that are performed on graph like search, finding path, * minimum path and other queries will be developed as their own class which * utilize Graph G as input. * * * Graph provides following API * ---------------------------------------------- * Graph (int v) // constructs a graph with given no. of vertices * Graph (Stream s) // constructs a graph from input stream data * int V() // returns the number of vertices * int E() // returns the number of edges * Iterable<Integer> adj(int v) // returns the adjacent vertices list of a given vertex v. * void addEdge(int v, int w) // adds an edge between vertex v and w. * */ package com.graphs; /** * Graph is an ADT that represents a collection of vertices V and the connection amongst them * called edges E. Every Graph G is defined as function of G = f(V, E). A graph is created by * calling one of the two constructors. One creates a graph with given number of vertices. * Other takes a stream input and initializes the graph from stream data. * * Note: This graph is an undirected graph, i.e. if a vertex v is reachable from vertex w, * then it implies that w is reachable from v * * @author Ashish Chopra * */ public class Graph { private int V; private int E;
private List<Bag<Integer>> adj; // adjacency list of vertices
ashish-chopra/Structures
src/test/java/com/graph/FlightsGraphTest.java
// Path: src/main/java/com/graphs/SymbolGraph.java // public class SymbolGraph { // // private ST<String, Integer> st; // stores keys and their index // private String[] keys; // stores inverted index of keys // private Graph G; // Graph representation of SymbolGraph // // public SymbolGraph(String name, String delimiter) { // Scanner scn = null; // try { // scn = new Scanner(new File(name)); // st = new ST<String, Integer>(); // // // reading the distinct vertices in ST // while (scn.hasNextLine()) { // String line = scn.nextLine(); // String[] words = line.split(delimiter); // for(String w: words) { // if(!st.contains(w)) // st.put(w, st.size()); // } // } // scn.close(); // // // creating inverted index // keys = new String[st.size()]; // for (String k: st.keys()) { // keys[st.get(k)] = k; // } // // //second pass to create a graph // scn = new Scanner(new File(name)); // G = new Graph(st.size()); // while (scn.hasNextLine()) { // String line = scn.nextLine(); // String[] words = line.split(delimiter); // int v = st.get(words[0]); // for (int i = 0; i < words.length; i++) { // G.addEdge(v, st.get(words[i])); // } // } // // } catch (Exception e) { // e.printStackTrace(); // } // } // // public Graph G() { // return G; // } // // public boolean contains(String key) { // return st.contains(key); // } // // public int index(String key) { // return st.get(key); // } // // public String name(int v) { // return keys[v]; // } // }
import com.graphs.SymbolGraph; import junit.framework.TestCase;
package com.graph; public class FlightsGraphTest { private static String FLIGHT_ROUTES = "src/test/resources/routes.txt"; private static String DELIMITER = " "; public void testQueriesOnFlightsGraph() {
// Path: src/main/java/com/graphs/SymbolGraph.java // public class SymbolGraph { // // private ST<String, Integer> st; // stores keys and their index // private String[] keys; // stores inverted index of keys // private Graph G; // Graph representation of SymbolGraph // // public SymbolGraph(String name, String delimiter) { // Scanner scn = null; // try { // scn = new Scanner(new File(name)); // st = new ST<String, Integer>(); // // // reading the distinct vertices in ST // while (scn.hasNextLine()) { // String line = scn.nextLine(); // String[] words = line.split(delimiter); // for(String w: words) { // if(!st.contains(w)) // st.put(w, st.size()); // } // } // scn.close(); // // // creating inverted index // keys = new String[st.size()]; // for (String k: st.keys()) { // keys[st.get(k)] = k; // } // // //second pass to create a graph // scn = new Scanner(new File(name)); // G = new Graph(st.size()); // while (scn.hasNextLine()) { // String line = scn.nextLine(); // String[] words = line.split(delimiter); // int v = st.get(words[0]); // for (int i = 0; i < words.length; i++) { // G.addEdge(v, st.get(words[i])); // } // } // // } catch (Exception e) { // e.printStackTrace(); // } // } // // public Graph G() { // return G; // } // // public boolean contains(String key) { // return st.contains(key); // } // // public int index(String key) { // return st.get(key); // } // // public String name(int v) { // return keys[v]; // } // } // Path: src/test/java/com/graph/FlightsGraphTest.java import com.graphs.SymbolGraph; import junit.framework.TestCase; package com.graph; public class FlightsGraphTest { private static String FLIGHT_ROUTES = "src/test/resources/routes.txt"; private static String DELIMITER = " "; public void testQueriesOnFlightsGraph() {
SymbolGraph flights = new SymbolGraph(FLIGHT_ROUTES, DELIMITER);
ashish-chopra/Structures
src/main/java/com/tables/ST.java
// Path: src/main/java/com/queues/Queue.java // public class Queue<Item> implements Iterable<Item> { // // private Node first, last; // // /** // * creates a new empty // * Queue object. // */ // public Queue() { // first = null; // last = null; // } // // /** // * inserts the given item into the queue. // * @param item Item to be stored. // */ // public void enqueue(Item item) { // Node oldLast = last; // last = new Node(); // last.item = item; // last.next = null; // if (isEmpty()) // first = last; // else // oldLast.next = last; // } // // /** // * removes the least recent item from the queue. // * @return an item from the queue. // */ // public Item dequeue() { // if (isEmpty()) // throw new NoSuchElementException("Queue is empty"); // Item item = first.item; // first = first.next; // return item; // } // // /** // * checks to see if queue is empty. // * @return <code>true</code> if queue is empty, <code>false</code> otherwise. // */ // public boolean isEmpty() { // return first == null; // } // // /** // * returns an iterator over the elements of the queue. // */ // public Iterator<Item> iterator() { // return new QueueIterator(); // } // // // private class Node { // Item item; // Node next; // } // // private class QueueIterator implements Iterator<Item> { // // Node current = first; // public boolean hasNext() { // return current != null; // } // // public Item next() { // Item item = current.item; // current = current.next; // return item; // } // // public void remove() { // throw new UnsupportedOperationException("Operation is not supported"); // } // // } // }
import com.queues.Queue;
int mid = lo + (hi- lo) / 2; int cmp = key.compareTo(keys[mid]); if (cmp == 0) return mid; else if (cmp > 0) { lo = mid + 1; } else if (cmp < 0) { hi = mid - 1; } } return lo; } /** * returns the key at the given rank in the table. * @param rank an Integer * @return Key */ public Key select(int rank) { if (rank >= N) return null; return keys[rank]; } /** * iterates the keys in the symbol table * @return an iterator on the keys in the data structure */ public Iterable<Key> keys() {
// Path: src/main/java/com/queues/Queue.java // public class Queue<Item> implements Iterable<Item> { // // private Node first, last; // // /** // * creates a new empty // * Queue object. // */ // public Queue() { // first = null; // last = null; // } // // /** // * inserts the given item into the queue. // * @param item Item to be stored. // */ // public void enqueue(Item item) { // Node oldLast = last; // last = new Node(); // last.item = item; // last.next = null; // if (isEmpty()) // first = last; // else // oldLast.next = last; // } // // /** // * removes the least recent item from the queue. // * @return an item from the queue. // */ // public Item dequeue() { // if (isEmpty()) // throw new NoSuchElementException("Queue is empty"); // Item item = first.item; // first = first.next; // return item; // } // // /** // * checks to see if queue is empty. // * @return <code>true</code> if queue is empty, <code>false</code> otherwise. // */ // public boolean isEmpty() { // return first == null; // } // // /** // * returns an iterator over the elements of the queue. // */ // public Iterator<Item> iterator() { // return new QueueIterator(); // } // // // private class Node { // Item item; // Node next; // } // // private class QueueIterator implements Iterator<Item> { // // Node current = first; // public boolean hasNext() { // return current != null; // } // // public Item next() { // Item item = current.item; // current = current.next; // return item; // } // // public void remove() { // throw new UnsupportedOperationException("Operation is not supported"); // } // // } // } // Path: src/main/java/com/tables/ST.java import com.queues.Queue; int mid = lo + (hi- lo) / 2; int cmp = key.compareTo(keys[mid]); if (cmp == 0) return mid; else if (cmp > 0) { lo = mid + 1; } else if (cmp < 0) { hi = mid - 1; } } return lo; } /** * returns the key at the given rank in the table. * @param rank an Integer * @return Key */ public Key select(int rank) { if (rank >= N) return null; return keys[rank]; } /** * iterates the keys in the symbol table * @return an iterator on the keys in the data structure */ public Iterable<Key> keys() {
Queue<Key> queue = new Queue<Key>();
HayDar-Android/FileScanner
filescannercore/src/main/java/io/haydar/filescanner/db/DBManager.java
// Path: filescannercore/src/main/java/io/haydar/filescanner/util/LogUtil.java // public class LogUtil { // private static final boolean isDebug = BuildConfig.DEBUG; // // public static void i(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void d(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void v(String tag, String... args) { // // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void w(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void e(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // private static String getLog(String tag, String... args) { // StringBuilder builder = new StringBuilder(); // for (String arg : args) { // if (TextUtils.isEmpty(arg)) continue; // // builder.append(arg); // } // // return builder.toString(); // } // // // }
import android.content.Context; import android.database.sqlite.SQLiteDatabase; import io.haydar.filescanner.util.LogUtil;
package io.haydar.filescanner.db; /** * 管理数据库类 * 打开和关闭数据库 * * @author Haydar * @Package io.haydar.aotumusic.db * @DATE 2017-03-28 */ public class DBManager { public static final String TAG = "DBManager"; private static SQLiteDatabase mWriteDB; private static SQLiteDatabase mReadDB; private static DBHelper mDbHelper; private Context context; /** * 关闭数据库 */ public static void close() { if (mWriteDB != null) { mWriteDB.close(); mWriteDB = null;
// Path: filescannercore/src/main/java/io/haydar/filescanner/util/LogUtil.java // public class LogUtil { // private static final boolean isDebug = BuildConfig.DEBUG; // // public static void i(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void d(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void v(String tag, String... args) { // // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void w(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void e(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // private static String getLog(String tag, String... args) { // StringBuilder builder = new StringBuilder(); // for (String arg : args) { // if (TextUtils.isEmpty(arg)) continue; // // builder.append(arg); // } // // return builder.toString(); // } // // // } // Path: filescannercore/src/main/java/io/haydar/filescanner/db/DBManager.java import android.content.Context; import android.database.sqlite.SQLiteDatabase; import io.haydar.filescanner.util.LogUtil; package io.haydar.filescanner.db; /** * 管理数据库类 * 打开和关闭数据库 * * @author Haydar * @Package io.haydar.aotumusic.db * @DATE 2017-03-28 */ public class DBManager { public static final String TAG = "DBManager"; private static SQLiteDatabase mWriteDB; private static SQLiteDatabase mReadDB; private static DBHelper mDbHelper; private Context context; /** * 关闭数据库 */ public static void close() { if (mWriteDB != null) { mWriteDB.close(); mWriteDB = null;
LogUtil.i(TAG, "close: writeDB-close");
HayDar-Android/FileScanner
filescannercore/src/main/java/io/haydar/filescanner/db/DBFilesHelper.java
// Path: filescannercore/src/main/java/io/haydar/filescanner/FileInfo.java // public class FileInfo { // private int count; // private String filePath; // private long fileSize; // private long lastModifyTime; // private int type;//1文件夹 2 mp3 // // public FileInfo(){ // // } // // public int getCount() { // ArrayList list = new ArrayList(); // return count; // } // // public void setCount(int count) { // this.count = count; // } // // public String getFilePath() { // return filePath; // } // // public void setFilePath(String filePath) { // this.filePath = filePath; // } // // public long getFileSize() { // return fileSize; // } // // public void setFileSize(long fileSize) { // this.fileSize = fileSize; // } // // public Long getLastModifyTime() { // return lastModifyTime; // } // // public void setLastModifyTime(long lastModifyTime) { // this.lastModifyTime = lastModifyTime; // } // // public int getType() { // return type; // } // // public void setType(int type) { // this.type = type; // } // // @Override // public String toString() { // return "FileInfo{" + // "count=" + count + // ", filePath='" + filePath + '\'' + // ", fileSize=" + fileSize + // ", lastModifyTime=" + lastModifyTime + // ", type=" + type + // '}'; // } // } // // Path: filescannercore/src/main/java/io/haydar/filescanner/FileScanner.java // public class FileScanner { // public static final String TAG = "FileScanner"; // private Context mContext; // private static FileScanner instance; // private static String type; // public static final int SCANNER_TYPE_ADD=1; // public static final int SCANNER_TYPE_DEL=2; // // public static FileScanner getInstance(Context paramContext) { // if (instance == null) { // instance = new FileScanner(paramContext); // } // return instance; // } // // private FileScanner(Context context) { // this.mContext = context; // // } // // public FileScanner setType(String s) { // type = s; // return instance; // } // // public static String getType() { // return type; // } // // /** // * 开始扫描 // */ // public void start(ScannerListener mCommonListener) { // if (TextUtils.isEmpty(type)) { // LogUtil.i(TAG, "start: 需要查找的类型为空"); // return; // } // LogUtil.i(TAG, "start: -----start scan-----"); // setCommonListener(mCommonListener); // //判断是否全盘扫描 // boolean bool = isNeedToScannerAll(); // if (bool) { // //全盘扫描 // LogUtil.i(TAG, "start: 全盘扫描"); // ScannerUtil.scanAllDirAsync(mContext); // } else { // //增量扫描 // LogUtil.i(TAG, "start: 增量扫描"); // ScannerUtil.updateAllDirAsync(mContext); // } // // } // // private boolean isNeedToScannerAll() { // return ScannerUtil.isNeedToScannerAll(mContext); // } // // // private void setCommonListener(ScannerListener mCommonListener) { // LocalFileCacheManager.getInstance(mContext).setCommonListener(mCommonListener); // } // // public void clear() { // LocalFileCacheManager.getInstance(mContext).clear(); // } // // public ArrayList<FileInfo> getAllFiles() { // return LocalFileCacheManager.getInstance(mContext).getAllFiles(); // } // // public interface ScannerListener { // // /** // * 扫描开始 // */ // void onScanBegin(); // // /** // * 扫描结束 // */ // void onScanEnd(); // // /** // * 扫描进行中 // * @param paramString 文件夹地址 // * @param progress 扫描进度 // */ // void onScanning(String paramString, int progress); // // /** // * 扫描进行中,文件的更新 // * @param info // * @param type SCANNER_TYPE_ADD:添加;SCANNER_TYPE_DEL:删除 // */ // void onScanningFiles(FileInfo info,int type); // } // }
import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.text.TextUtils; import java.util.ArrayList; import java.util.List; import io.haydar.filescanner.FileInfo; import io.haydar.filescanner.FileScanner;
package io.haydar.filescanner.db; /** * @author Haydar * @Package io.haydar.filescannercore.db * @DATE 2017-04-13 */ public class DBFilesHelper { private Context mContext; public DBFilesHelper(Context context) { this.mContext = context; } public static String deleteTableSql() { return "DROP TABLE IF EXISTS " + FilesDBContract.TABLE_NAME; } public static String createTableSql() { return "CREATE TABLE " + FilesDBContract.TABLE_NAME + "(" + FilesDBContract.COLUMN_NAME_DATA + " TEXT NOT NULL PRIMARY KEY," + FilesDBContract.COLUMN_NAME_FOLDER_ID + " TEXT," + FilesDBContract.COLUMN_NAME_SIZE + " INTEGER," + FilesDBContract.COLUMN_NAME_MODIFIED_TIME + " INTEGER)"; }
// Path: filescannercore/src/main/java/io/haydar/filescanner/FileInfo.java // public class FileInfo { // private int count; // private String filePath; // private long fileSize; // private long lastModifyTime; // private int type;//1文件夹 2 mp3 // // public FileInfo(){ // // } // // public int getCount() { // ArrayList list = new ArrayList(); // return count; // } // // public void setCount(int count) { // this.count = count; // } // // public String getFilePath() { // return filePath; // } // // public void setFilePath(String filePath) { // this.filePath = filePath; // } // // public long getFileSize() { // return fileSize; // } // // public void setFileSize(long fileSize) { // this.fileSize = fileSize; // } // // public Long getLastModifyTime() { // return lastModifyTime; // } // // public void setLastModifyTime(long lastModifyTime) { // this.lastModifyTime = lastModifyTime; // } // // public int getType() { // return type; // } // // public void setType(int type) { // this.type = type; // } // // @Override // public String toString() { // return "FileInfo{" + // "count=" + count + // ", filePath='" + filePath + '\'' + // ", fileSize=" + fileSize + // ", lastModifyTime=" + lastModifyTime + // ", type=" + type + // '}'; // } // } // // Path: filescannercore/src/main/java/io/haydar/filescanner/FileScanner.java // public class FileScanner { // public static final String TAG = "FileScanner"; // private Context mContext; // private static FileScanner instance; // private static String type; // public static final int SCANNER_TYPE_ADD=1; // public static final int SCANNER_TYPE_DEL=2; // // public static FileScanner getInstance(Context paramContext) { // if (instance == null) { // instance = new FileScanner(paramContext); // } // return instance; // } // // private FileScanner(Context context) { // this.mContext = context; // // } // // public FileScanner setType(String s) { // type = s; // return instance; // } // // public static String getType() { // return type; // } // // /** // * 开始扫描 // */ // public void start(ScannerListener mCommonListener) { // if (TextUtils.isEmpty(type)) { // LogUtil.i(TAG, "start: 需要查找的类型为空"); // return; // } // LogUtil.i(TAG, "start: -----start scan-----"); // setCommonListener(mCommonListener); // //判断是否全盘扫描 // boolean bool = isNeedToScannerAll(); // if (bool) { // //全盘扫描 // LogUtil.i(TAG, "start: 全盘扫描"); // ScannerUtil.scanAllDirAsync(mContext); // } else { // //增量扫描 // LogUtil.i(TAG, "start: 增量扫描"); // ScannerUtil.updateAllDirAsync(mContext); // } // // } // // private boolean isNeedToScannerAll() { // return ScannerUtil.isNeedToScannerAll(mContext); // } // // // private void setCommonListener(ScannerListener mCommonListener) { // LocalFileCacheManager.getInstance(mContext).setCommonListener(mCommonListener); // } // // public void clear() { // LocalFileCacheManager.getInstance(mContext).clear(); // } // // public ArrayList<FileInfo> getAllFiles() { // return LocalFileCacheManager.getInstance(mContext).getAllFiles(); // } // // public interface ScannerListener { // // /** // * 扫描开始 // */ // void onScanBegin(); // // /** // * 扫描结束 // */ // void onScanEnd(); // // /** // * 扫描进行中 // * @param paramString 文件夹地址 // * @param progress 扫描进度 // */ // void onScanning(String paramString, int progress); // // /** // * 扫描进行中,文件的更新 // * @param info // * @param type SCANNER_TYPE_ADD:添加;SCANNER_TYPE_DEL:删除 // */ // void onScanningFiles(FileInfo info,int type); // } // } // Path: filescannercore/src/main/java/io/haydar/filescanner/db/DBFilesHelper.java import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.text.TextUtils; import java.util.ArrayList; import java.util.List; import io.haydar.filescanner.FileInfo; import io.haydar.filescanner.FileScanner; package io.haydar.filescanner.db; /** * @author Haydar * @Package io.haydar.filescannercore.db * @DATE 2017-04-13 */ public class DBFilesHelper { private Context mContext; public DBFilesHelper(Context context) { this.mContext = context; } public static String deleteTableSql() { return "DROP TABLE IF EXISTS " + FilesDBContract.TABLE_NAME; } public static String createTableSql() { return "CREATE TABLE " + FilesDBContract.TABLE_NAME + "(" + FilesDBContract.COLUMN_NAME_DATA + " TEXT NOT NULL PRIMARY KEY," + FilesDBContract.COLUMN_NAME_FOLDER_ID + " TEXT," + FilesDBContract.COLUMN_NAME_SIZE + " INTEGER," + FilesDBContract.COLUMN_NAME_MODIFIED_TIME + " INTEGER)"; }
public void insertNewFiles(ArrayList<FileInfo> filesArrayList, String folder_id, FileScanner.ScannerListener mCommonListener) {
HayDar-Android/FileScanner
filescannercore/src/main/java/io/haydar/filescanner/db/DBFilesHelper.java
// Path: filescannercore/src/main/java/io/haydar/filescanner/FileInfo.java // public class FileInfo { // private int count; // private String filePath; // private long fileSize; // private long lastModifyTime; // private int type;//1文件夹 2 mp3 // // public FileInfo(){ // // } // // public int getCount() { // ArrayList list = new ArrayList(); // return count; // } // // public void setCount(int count) { // this.count = count; // } // // public String getFilePath() { // return filePath; // } // // public void setFilePath(String filePath) { // this.filePath = filePath; // } // // public long getFileSize() { // return fileSize; // } // // public void setFileSize(long fileSize) { // this.fileSize = fileSize; // } // // public Long getLastModifyTime() { // return lastModifyTime; // } // // public void setLastModifyTime(long lastModifyTime) { // this.lastModifyTime = lastModifyTime; // } // // public int getType() { // return type; // } // // public void setType(int type) { // this.type = type; // } // // @Override // public String toString() { // return "FileInfo{" + // "count=" + count + // ", filePath='" + filePath + '\'' + // ", fileSize=" + fileSize + // ", lastModifyTime=" + lastModifyTime + // ", type=" + type + // '}'; // } // } // // Path: filescannercore/src/main/java/io/haydar/filescanner/FileScanner.java // public class FileScanner { // public static final String TAG = "FileScanner"; // private Context mContext; // private static FileScanner instance; // private static String type; // public static final int SCANNER_TYPE_ADD=1; // public static final int SCANNER_TYPE_DEL=2; // // public static FileScanner getInstance(Context paramContext) { // if (instance == null) { // instance = new FileScanner(paramContext); // } // return instance; // } // // private FileScanner(Context context) { // this.mContext = context; // // } // // public FileScanner setType(String s) { // type = s; // return instance; // } // // public static String getType() { // return type; // } // // /** // * 开始扫描 // */ // public void start(ScannerListener mCommonListener) { // if (TextUtils.isEmpty(type)) { // LogUtil.i(TAG, "start: 需要查找的类型为空"); // return; // } // LogUtil.i(TAG, "start: -----start scan-----"); // setCommonListener(mCommonListener); // //判断是否全盘扫描 // boolean bool = isNeedToScannerAll(); // if (bool) { // //全盘扫描 // LogUtil.i(TAG, "start: 全盘扫描"); // ScannerUtil.scanAllDirAsync(mContext); // } else { // //增量扫描 // LogUtil.i(TAG, "start: 增量扫描"); // ScannerUtil.updateAllDirAsync(mContext); // } // // } // // private boolean isNeedToScannerAll() { // return ScannerUtil.isNeedToScannerAll(mContext); // } // // // private void setCommonListener(ScannerListener mCommonListener) { // LocalFileCacheManager.getInstance(mContext).setCommonListener(mCommonListener); // } // // public void clear() { // LocalFileCacheManager.getInstance(mContext).clear(); // } // // public ArrayList<FileInfo> getAllFiles() { // return LocalFileCacheManager.getInstance(mContext).getAllFiles(); // } // // public interface ScannerListener { // // /** // * 扫描开始 // */ // void onScanBegin(); // // /** // * 扫描结束 // */ // void onScanEnd(); // // /** // * 扫描进行中 // * @param paramString 文件夹地址 // * @param progress 扫描进度 // */ // void onScanning(String paramString, int progress); // // /** // * 扫描进行中,文件的更新 // * @param info // * @param type SCANNER_TYPE_ADD:添加;SCANNER_TYPE_DEL:删除 // */ // void onScanningFiles(FileInfo info,int type); // } // }
import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.text.TextUtils; import java.util.ArrayList; import java.util.List; import io.haydar.filescanner.FileInfo; import io.haydar.filescanner.FileScanner;
package io.haydar.filescanner.db; /** * @author Haydar * @Package io.haydar.filescannercore.db * @DATE 2017-04-13 */ public class DBFilesHelper { private Context mContext; public DBFilesHelper(Context context) { this.mContext = context; } public static String deleteTableSql() { return "DROP TABLE IF EXISTS " + FilesDBContract.TABLE_NAME; } public static String createTableSql() { return "CREATE TABLE " + FilesDBContract.TABLE_NAME + "(" + FilesDBContract.COLUMN_NAME_DATA + " TEXT NOT NULL PRIMARY KEY," + FilesDBContract.COLUMN_NAME_FOLDER_ID + " TEXT," + FilesDBContract.COLUMN_NAME_SIZE + " INTEGER," + FilesDBContract.COLUMN_NAME_MODIFIED_TIME + " INTEGER)"; }
// Path: filescannercore/src/main/java/io/haydar/filescanner/FileInfo.java // public class FileInfo { // private int count; // private String filePath; // private long fileSize; // private long lastModifyTime; // private int type;//1文件夹 2 mp3 // // public FileInfo(){ // // } // // public int getCount() { // ArrayList list = new ArrayList(); // return count; // } // // public void setCount(int count) { // this.count = count; // } // // public String getFilePath() { // return filePath; // } // // public void setFilePath(String filePath) { // this.filePath = filePath; // } // // public long getFileSize() { // return fileSize; // } // // public void setFileSize(long fileSize) { // this.fileSize = fileSize; // } // // public Long getLastModifyTime() { // return lastModifyTime; // } // // public void setLastModifyTime(long lastModifyTime) { // this.lastModifyTime = lastModifyTime; // } // // public int getType() { // return type; // } // // public void setType(int type) { // this.type = type; // } // // @Override // public String toString() { // return "FileInfo{" + // "count=" + count + // ", filePath='" + filePath + '\'' + // ", fileSize=" + fileSize + // ", lastModifyTime=" + lastModifyTime + // ", type=" + type + // '}'; // } // } // // Path: filescannercore/src/main/java/io/haydar/filescanner/FileScanner.java // public class FileScanner { // public static final String TAG = "FileScanner"; // private Context mContext; // private static FileScanner instance; // private static String type; // public static final int SCANNER_TYPE_ADD=1; // public static final int SCANNER_TYPE_DEL=2; // // public static FileScanner getInstance(Context paramContext) { // if (instance == null) { // instance = new FileScanner(paramContext); // } // return instance; // } // // private FileScanner(Context context) { // this.mContext = context; // // } // // public FileScanner setType(String s) { // type = s; // return instance; // } // // public static String getType() { // return type; // } // // /** // * 开始扫描 // */ // public void start(ScannerListener mCommonListener) { // if (TextUtils.isEmpty(type)) { // LogUtil.i(TAG, "start: 需要查找的类型为空"); // return; // } // LogUtil.i(TAG, "start: -----start scan-----"); // setCommonListener(mCommonListener); // //判断是否全盘扫描 // boolean bool = isNeedToScannerAll(); // if (bool) { // //全盘扫描 // LogUtil.i(TAG, "start: 全盘扫描"); // ScannerUtil.scanAllDirAsync(mContext); // } else { // //增量扫描 // LogUtil.i(TAG, "start: 增量扫描"); // ScannerUtil.updateAllDirAsync(mContext); // } // // } // // private boolean isNeedToScannerAll() { // return ScannerUtil.isNeedToScannerAll(mContext); // } // // // private void setCommonListener(ScannerListener mCommonListener) { // LocalFileCacheManager.getInstance(mContext).setCommonListener(mCommonListener); // } // // public void clear() { // LocalFileCacheManager.getInstance(mContext).clear(); // } // // public ArrayList<FileInfo> getAllFiles() { // return LocalFileCacheManager.getInstance(mContext).getAllFiles(); // } // // public interface ScannerListener { // // /** // * 扫描开始 // */ // void onScanBegin(); // // /** // * 扫描结束 // */ // void onScanEnd(); // // /** // * 扫描进行中 // * @param paramString 文件夹地址 // * @param progress 扫描进度 // */ // void onScanning(String paramString, int progress); // // /** // * 扫描进行中,文件的更新 // * @param info // * @param type SCANNER_TYPE_ADD:添加;SCANNER_TYPE_DEL:删除 // */ // void onScanningFiles(FileInfo info,int type); // } // } // Path: filescannercore/src/main/java/io/haydar/filescanner/db/DBFilesHelper.java import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.text.TextUtils; import java.util.ArrayList; import java.util.List; import io.haydar.filescanner.FileInfo; import io.haydar.filescanner.FileScanner; package io.haydar.filescanner.db; /** * @author Haydar * @Package io.haydar.filescannercore.db * @DATE 2017-04-13 */ public class DBFilesHelper { private Context mContext; public DBFilesHelper(Context context) { this.mContext = context; } public static String deleteTableSql() { return "DROP TABLE IF EXISTS " + FilesDBContract.TABLE_NAME; } public static String createTableSql() { return "CREATE TABLE " + FilesDBContract.TABLE_NAME + "(" + FilesDBContract.COLUMN_NAME_DATA + " TEXT NOT NULL PRIMARY KEY," + FilesDBContract.COLUMN_NAME_FOLDER_ID + " TEXT," + FilesDBContract.COLUMN_NAME_SIZE + " INTEGER," + FilesDBContract.COLUMN_NAME_MODIFIED_TIME + " INTEGER)"; }
public void insertNewFiles(ArrayList<FileInfo> filesArrayList, String folder_id, FileScanner.ScannerListener mCommonListener) {
HayDar-Android/FileScanner
filescannercore/src/main/java/io/haydar/filescanner/db/DBFolderHelper.java
// Path: filescannercore/src/main/java/io/haydar/filescanner/FileInfo.java // public class FileInfo { // private int count; // private String filePath; // private long fileSize; // private long lastModifyTime; // private int type;//1文件夹 2 mp3 // // public FileInfo(){ // // } // // public int getCount() { // ArrayList list = new ArrayList(); // return count; // } // // public void setCount(int count) { // this.count = count; // } // // public String getFilePath() { // return filePath; // } // // public void setFilePath(String filePath) { // this.filePath = filePath; // } // // public long getFileSize() { // return fileSize; // } // // public void setFileSize(long fileSize) { // this.fileSize = fileSize; // } // // public Long getLastModifyTime() { // return lastModifyTime; // } // // public void setLastModifyTime(long lastModifyTime) { // this.lastModifyTime = lastModifyTime; // } // // public int getType() { // return type; // } // // public void setType(int type) { // this.type = type; // } // // @Override // public String toString() { // return "FileInfo{" + // "count=" + count + // ", filePath='" + filePath + '\'' + // ", fileSize=" + fileSize + // ", lastModifyTime=" + lastModifyTime + // ", type=" + type + // '}'; // } // } // // Path: filescannercore/src/main/java/io/haydar/filescanner/util/LogUtil.java // public class LogUtil { // private static final boolean isDebug = BuildConfig.DEBUG; // // public static void i(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void d(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void v(String tag, String... args) { // // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void w(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void e(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // private static String getLog(String tag, String... args) { // StringBuilder builder = new StringBuilder(); // for (String arg : args) { // if (TextUtils.isEmpty(arg)) continue; // // builder.append(arg); // } // // return builder.toString(); // } // // // }
import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.text.TextUtils; import java.util.ArrayList; import io.haydar.filescanner.FileInfo; import io.haydar.filescanner.util.LogUtil;
package io.haydar.filescanner.db; /** * @author Haydar * @Package io.haydar.filescannercore.db * @DATE 2017-04-13 */ public class DBFolderHelper { public static final String TAG = "TableFolderHelper"; private Context mContext; public DBFolderHelper(Context context) { mContext = context; } public static String deleteTableSql() { return "DROP TABLE IF EXISTS " + FolderDBContract.TABLE_NAME; } public static String createTableSql() { return "CREATE TABLE " + FolderDBContract.TABLE_NAME + "(" + FolderDBContract.COLUMN_NAME_DIR_PATH + " TEXT NOT NULL PRIMARY KEY, " + FolderDBContract.COLUMN_NAME_MODIFIED_TIME + " INTEGER," + FolderDBContract.COLUMN_NAME_FILE_COUNT + " INTEGER)"; }
// Path: filescannercore/src/main/java/io/haydar/filescanner/FileInfo.java // public class FileInfo { // private int count; // private String filePath; // private long fileSize; // private long lastModifyTime; // private int type;//1文件夹 2 mp3 // // public FileInfo(){ // // } // // public int getCount() { // ArrayList list = new ArrayList(); // return count; // } // // public void setCount(int count) { // this.count = count; // } // // public String getFilePath() { // return filePath; // } // // public void setFilePath(String filePath) { // this.filePath = filePath; // } // // public long getFileSize() { // return fileSize; // } // // public void setFileSize(long fileSize) { // this.fileSize = fileSize; // } // // public Long getLastModifyTime() { // return lastModifyTime; // } // // public void setLastModifyTime(long lastModifyTime) { // this.lastModifyTime = lastModifyTime; // } // // public int getType() { // return type; // } // // public void setType(int type) { // this.type = type; // } // // @Override // public String toString() { // return "FileInfo{" + // "count=" + count + // ", filePath='" + filePath + '\'' + // ", fileSize=" + fileSize + // ", lastModifyTime=" + lastModifyTime + // ", type=" + type + // '}'; // } // } // // Path: filescannercore/src/main/java/io/haydar/filescanner/util/LogUtil.java // public class LogUtil { // private static final boolean isDebug = BuildConfig.DEBUG; // // public static void i(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void d(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void v(String tag, String... args) { // // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void w(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void e(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // private static String getLog(String tag, String... args) { // StringBuilder builder = new StringBuilder(); // for (String arg : args) { // if (TextUtils.isEmpty(arg)) continue; // // builder.append(arg); // } // // return builder.toString(); // } // // // } // Path: filescannercore/src/main/java/io/haydar/filescanner/db/DBFolderHelper.java import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.text.TextUtils; import java.util.ArrayList; import io.haydar.filescanner.FileInfo; import io.haydar.filescanner.util.LogUtil; package io.haydar.filescanner.db; /** * @author Haydar * @Package io.haydar.filescannercore.db * @DATE 2017-04-13 */ public class DBFolderHelper { public static final String TAG = "TableFolderHelper"; private Context mContext; public DBFolderHelper(Context context) { mContext = context; } public static String deleteTableSql() { return "DROP TABLE IF EXISTS " + FolderDBContract.TABLE_NAME; } public static String createTableSql() { return "CREATE TABLE " + FolderDBContract.TABLE_NAME + "(" + FolderDBContract.COLUMN_NAME_DIR_PATH + " TEXT NOT NULL PRIMARY KEY, " + FolderDBContract.COLUMN_NAME_MODIFIED_TIME + " INTEGER," + FolderDBContract.COLUMN_NAME_FILE_COUNT + " INTEGER)"; }
public void insertNewDirs(ArrayList<FileInfo> dirsList) {
HayDar-Android/FileScanner
filescannercore/src/main/java/io/haydar/filescanner/db/DBFolderHelper.java
// Path: filescannercore/src/main/java/io/haydar/filescanner/FileInfo.java // public class FileInfo { // private int count; // private String filePath; // private long fileSize; // private long lastModifyTime; // private int type;//1文件夹 2 mp3 // // public FileInfo(){ // // } // // public int getCount() { // ArrayList list = new ArrayList(); // return count; // } // // public void setCount(int count) { // this.count = count; // } // // public String getFilePath() { // return filePath; // } // // public void setFilePath(String filePath) { // this.filePath = filePath; // } // // public long getFileSize() { // return fileSize; // } // // public void setFileSize(long fileSize) { // this.fileSize = fileSize; // } // // public Long getLastModifyTime() { // return lastModifyTime; // } // // public void setLastModifyTime(long lastModifyTime) { // this.lastModifyTime = lastModifyTime; // } // // public int getType() { // return type; // } // // public void setType(int type) { // this.type = type; // } // // @Override // public String toString() { // return "FileInfo{" + // "count=" + count + // ", filePath='" + filePath + '\'' + // ", fileSize=" + fileSize + // ", lastModifyTime=" + lastModifyTime + // ", type=" + type + // '}'; // } // } // // Path: filescannercore/src/main/java/io/haydar/filescanner/util/LogUtil.java // public class LogUtil { // private static final boolean isDebug = BuildConfig.DEBUG; // // public static void i(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void d(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void v(String tag, String... args) { // // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void w(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void e(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // private static String getLog(String tag, String... args) { // StringBuilder builder = new StringBuilder(); // for (String arg : args) { // if (TextUtils.isEmpty(arg)) continue; // // builder.append(arg); // } // // return builder.toString(); // } // // // }
import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.text.TextUtils; import java.util.ArrayList; import io.haydar.filescanner.FileInfo; import io.haydar.filescanner.util.LogUtil;
ContentValues contentValues = new ContentValues(); if (TextUtils.isEmpty(fileInfo.getFilePath())) { continue; } contentValues.put(FolderDBContract.COLUMN_NAME_DIR_PATH, fileInfo.getFilePath()); contentValues.put(FolderDBContract.COLUMN_NAME_MODIFIED_TIME, fileInfo.getLastModifyTime()); contentValues.put(FolderDBContract.COLUMN_NAME_FILE_COUNT, fileInfo.getCount()); DBManager.getWriteDB(mContext).insert(FolderDBContract.TABLE_NAME, null, contentValues); } DBManager.getWriteDB(mContext).setTransactionSuccessful(); } catch (Exception e) { e.printStackTrace(); } finally { DBManager.getWriteDB(mContext).endTransaction(); } } public void clearTable() { DBManager.getWriteDB(mContext).delete(FolderDBContract.TABLE_NAME, null, null); } public int getFolderCount() { Cursor cursor = null; try { cursor = DBManager.getReadDB(mContext).rawQuery("SELECT COUNT(" + FolderDBContract.COLUMN_NAME_DIR_PATH + ") AS NUM FROM " + FolderDBContract.TABLE_NAME, null); if (cursor == null) { return 0; } if (cursor.moveToFirst()) { int num = cursor.getInt(cursor.getColumnIndexOrThrow("NUM"));
// Path: filescannercore/src/main/java/io/haydar/filescanner/FileInfo.java // public class FileInfo { // private int count; // private String filePath; // private long fileSize; // private long lastModifyTime; // private int type;//1文件夹 2 mp3 // // public FileInfo(){ // // } // // public int getCount() { // ArrayList list = new ArrayList(); // return count; // } // // public void setCount(int count) { // this.count = count; // } // // public String getFilePath() { // return filePath; // } // // public void setFilePath(String filePath) { // this.filePath = filePath; // } // // public long getFileSize() { // return fileSize; // } // // public void setFileSize(long fileSize) { // this.fileSize = fileSize; // } // // public Long getLastModifyTime() { // return lastModifyTime; // } // // public void setLastModifyTime(long lastModifyTime) { // this.lastModifyTime = lastModifyTime; // } // // public int getType() { // return type; // } // // public void setType(int type) { // this.type = type; // } // // @Override // public String toString() { // return "FileInfo{" + // "count=" + count + // ", filePath='" + filePath + '\'' + // ", fileSize=" + fileSize + // ", lastModifyTime=" + lastModifyTime + // ", type=" + type + // '}'; // } // } // // Path: filescannercore/src/main/java/io/haydar/filescanner/util/LogUtil.java // public class LogUtil { // private static final boolean isDebug = BuildConfig.DEBUG; // // public static void i(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void d(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void v(String tag, String... args) { // // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void w(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void e(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // private static String getLog(String tag, String... args) { // StringBuilder builder = new StringBuilder(); // for (String arg : args) { // if (TextUtils.isEmpty(arg)) continue; // // builder.append(arg); // } // // return builder.toString(); // } // // // } // Path: filescannercore/src/main/java/io/haydar/filescanner/db/DBFolderHelper.java import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.text.TextUtils; import java.util.ArrayList; import io.haydar.filescanner.FileInfo; import io.haydar.filescanner.util.LogUtil; ContentValues contentValues = new ContentValues(); if (TextUtils.isEmpty(fileInfo.getFilePath())) { continue; } contentValues.put(FolderDBContract.COLUMN_NAME_DIR_PATH, fileInfo.getFilePath()); contentValues.put(FolderDBContract.COLUMN_NAME_MODIFIED_TIME, fileInfo.getLastModifyTime()); contentValues.put(FolderDBContract.COLUMN_NAME_FILE_COUNT, fileInfo.getCount()); DBManager.getWriteDB(mContext).insert(FolderDBContract.TABLE_NAME, null, contentValues); } DBManager.getWriteDB(mContext).setTransactionSuccessful(); } catch (Exception e) { e.printStackTrace(); } finally { DBManager.getWriteDB(mContext).endTransaction(); } } public void clearTable() { DBManager.getWriteDB(mContext).delete(FolderDBContract.TABLE_NAME, null, null); } public int getFolderCount() { Cursor cursor = null; try { cursor = DBManager.getReadDB(mContext).rawQuery("SELECT COUNT(" + FolderDBContract.COLUMN_NAME_DIR_PATH + ") AS NUM FROM " + FolderDBContract.TABLE_NAME, null); if (cursor == null) { return 0; } if (cursor.moveToFirst()) { int num = cursor.getInt(cursor.getColumnIndexOrThrow("NUM"));
LogUtil.i(TAG, "getFolderCount: num=" + num);
HayDar-Android/FileScanner
filescannercore/src/main/java/io/haydar/filescanner/FileScanner.java
// Path: filescannercore/src/main/java/io/haydar/filescanner/util/LogUtil.java // public class LogUtil { // private static final boolean isDebug = BuildConfig.DEBUG; // // public static void i(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void d(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void v(String tag, String... args) { // // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void w(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void e(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // private static String getLog(String tag, String... args) { // StringBuilder builder = new StringBuilder(); // for (String arg : args) { // if (TextUtils.isEmpty(arg)) continue; // // builder.append(arg); // } // // return builder.toString(); // } // // // }
import android.content.Context; import android.text.TextUtils; import java.util.ArrayList; import io.haydar.filescanner.util.LogUtil;
package io.haydar.filescanner; /** * @author Haydar * @Package io.haydar.filescannercore * @DATE 2017-04-13 */ public class FileScanner { public static final String TAG = "FileScanner"; private Context mContext; private static FileScanner instance; private static String type; public static final int SCANNER_TYPE_ADD=1; public static final int SCANNER_TYPE_DEL=2; public static FileScanner getInstance(Context paramContext) { if (instance == null) { instance = new FileScanner(paramContext); } return instance; } private FileScanner(Context context) { this.mContext = context; } public FileScanner setType(String s) { type = s; return instance; } public static String getType() { return type; } /** * 开始扫描 */ public void start(ScannerListener mCommonListener) { if (TextUtils.isEmpty(type)) {
// Path: filescannercore/src/main/java/io/haydar/filescanner/util/LogUtil.java // public class LogUtil { // private static final boolean isDebug = BuildConfig.DEBUG; // // public static void i(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void d(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void v(String tag, String... args) { // // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void w(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void e(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // private static String getLog(String tag, String... args) { // StringBuilder builder = new StringBuilder(); // for (String arg : args) { // if (TextUtils.isEmpty(arg)) continue; // // builder.append(arg); // } // // return builder.toString(); // } // // // } // Path: filescannercore/src/main/java/io/haydar/filescanner/FileScanner.java import android.content.Context; import android.text.TextUtils; import java.util.ArrayList; import io.haydar.filescanner.util.LogUtil; package io.haydar.filescanner; /** * @author Haydar * @Package io.haydar.filescannercore * @DATE 2017-04-13 */ public class FileScanner { public static final String TAG = "FileScanner"; private Context mContext; private static FileScanner instance; private static String type; public static final int SCANNER_TYPE_ADD=1; public static final int SCANNER_TYPE_DEL=2; public static FileScanner getInstance(Context paramContext) { if (instance == null) { instance = new FileScanner(paramContext); } return instance; } private FileScanner(Context context) { this.mContext = context; } public FileScanner setType(String s) { type = s; return instance; } public static String getType() { return type; } /** * 开始扫描 */ public void start(ScannerListener mCommonListener) { if (TextUtils.isEmpty(type)) {
LogUtil.i(TAG, "start: 需要查找的类型为空");
HayDar-Android/FileScanner
filescannercore/src/main/java/io/haydar/filescanner/FileScannerHelper.java
// Path: filescannercore/src/main/java/io/haydar/filescanner/db/DBManager.java // public class DBManager { // public static final String TAG = "DBManager"; // private static SQLiteDatabase mWriteDB; // private static SQLiteDatabase mReadDB; // private static DBHelper mDbHelper; // private Context context; // /** // * 关闭数据库 // */ // public static void close() { // if (mWriteDB != null) { // mWriteDB.close(); // mWriteDB = null; // LogUtil.i(TAG, "close: writeDB-close"); // } // if (mReadDB != null) { // mReadDB.close(); // mReadDB = null; // LogUtil.i(TAG, "close: readDB-close"); // } // } // // /** // * 打开数据库 // * // * @param context // */ // public static void open(Context context) { // openWriteDB(context); // openReadDB(context); // // } // // /** // * 打开读数据库 // * // * @param context // */ // private static void openReadDB(Context context) { // if (mReadDB == null || !mReadDB.isOpen()) { // mReadDB = getDbHelper(context).getReadableDatabase(); // // } // } // // /** // * 打开写数据库 // * // * @param context // */ // private static void openWriteDB(Context context) { // if (mWriteDB == null || !mWriteDB.isOpen()) { // mWriteDB = getDbHelper(context).getWritableDatabase(); // mWriteDB.enableWriteAheadLogging(); // // } // // // } // // // /** // * 获得dbhelper // * // * @param context // * @return // */ // public static DBHelper getDbHelper(Context context) { // if (mDbHelper == null) { // //新建dbhelper // mDbHelper = new DBHelper(context); // // } // return mDbHelper; // } // // // public static SQLiteDatabase getReadDB(Context context) { // if(mReadDB==null||!mReadDB.isOpen()){ // openReadDB(context); // } // return mReadDB; // } // // public static SQLiteDatabase getWriteDB(Context context) { // if(mWriteDB==null||!mWriteDB.isOpen()){ // openWriteDB(context); // } // return mWriteDB; // } // } // // Path: filescannercore/src/main/java/io/haydar/filescanner/util/LogUtil.java // public class LogUtil { // private static final boolean isDebug = BuildConfig.DEBUG; // // public static void i(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void d(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void v(String tag, String... args) { // // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void w(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void e(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // private static String getLog(String tag, String... args) { // StringBuilder builder = new StringBuilder(); // for (String arg : args) { // if (TextUtils.isEmpty(arg)) continue; // // builder.append(arg); // } // // return builder.toString(); // } // // // }
import android.content.Context; import io.haydar.filescanner.db.DBManager; import io.haydar.filescanner.util.LogUtil;
package io.haydar.filescanner; /** * @author Haydar * @Package io.haydar.filescannercore * @DATE 2017-04-12 */ public class FileScannerHelper { public static final String TAG = "FileScannerHelper"; private static FileScannerHelper instance = null; private FileScannerHelper() { } public static FileScannerHelper getInstance() { if (instance == null) { instance = new FileScannerHelper(); } return instance; } /** * 初始化 * * @param context */ public void init(Context context) { //创建数据库
// Path: filescannercore/src/main/java/io/haydar/filescanner/db/DBManager.java // public class DBManager { // public static final String TAG = "DBManager"; // private static SQLiteDatabase mWriteDB; // private static SQLiteDatabase mReadDB; // private static DBHelper mDbHelper; // private Context context; // /** // * 关闭数据库 // */ // public static void close() { // if (mWriteDB != null) { // mWriteDB.close(); // mWriteDB = null; // LogUtil.i(TAG, "close: writeDB-close"); // } // if (mReadDB != null) { // mReadDB.close(); // mReadDB = null; // LogUtil.i(TAG, "close: readDB-close"); // } // } // // /** // * 打开数据库 // * // * @param context // */ // public static void open(Context context) { // openWriteDB(context); // openReadDB(context); // // } // // /** // * 打开读数据库 // * // * @param context // */ // private static void openReadDB(Context context) { // if (mReadDB == null || !mReadDB.isOpen()) { // mReadDB = getDbHelper(context).getReadableDatabase(); // // } // } // // /** // * 打开写数据库 // * // * @param context // */ // private static void openWriteDB(Context context) { // if (mWriteDB == null || !mWriteDB.isOpen()) { // mWriteDB = getDbHelper(context).getWritableDatabase(); // mWriteDB.enableWriteAheadLogging(); // // } // // // } // // // /** // * 获得dbhelper // * // * @param context // * @return // */ // public static DBHelper getDbHelper(Context context) { // if (mDbHelper == null) { // //新建dbhelper // mDbHelper = new DBHelper(context); // // } // return mDbHelper; // } // // // public static SQLiteDatabase getReadDB(Context context) { // if(mReadDB==null||!mReadDB.isOpen()){ // openReadDB(context); // } // return mReadDB; // } // // public static SQLiteDatabase getWriteDB(Context context) { // if(mWriteDB==null||!mWriteDB.isOpen()){ // openWriteDB(context); // } // return mWriteDB; // } // } // // Path: filescannercore/src/main/java/io/haydar/filescanner/util/LogUtil.java // public class LogUtil { // private static final boolean isDebug = BuildConfig.DEBUG; // // public static void i(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void d(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void v(String tag, String... args) { // // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void w(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void e(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // private static String getLog(String tag, String... args) { // StringBuilder builder = new StringBuilder(); // for (String arg : args) { // if (TextUtils.isEmpty(arg)) continue; // // builder.append(arg); // } // // return builder.toString(); // } // // // } // Path: filescannercore/src/main/java/io/haydar/filescanner/FileScannerHelper.java import android.content.Context; import io.haydar.filescanner.db.DBManager; import io.haydar.filescanner.util.LogUtil; package io.haydar.filescanner; /** * @author Haydar * @Package io.haydar.filescannercore * @DATE 2017-04-12 */ public class FileScannerHelper { public static final String TAG = "FileScannerHelper"; private static FileScannerHelper instance = null; private FileScannerHelper() { } public static FileScannerHelper getInstance() { if (instance == null) { instance = new FileScannerHelper(); } return instance; } /** * 初始化 * * @param context */ public void init(Context context) { //创建数据库
DBManager.open(context);
HayDar-Android/FileScanner
filescannercore/src/main/java/io/haydar/filescanner/FileScannerHelper.java
// Path: filescannercore/src/main/java/io/haydar/filescanner/db/DBManager.java // public class DBManager { // public static final String TAG = "DBManager"; // private static SQLiteDatabase mWriteDB; // private static SQLiteDatabase mReadDB; // private static DBHelper mDbHelper; // private Context context; // /** // * 关闭数据库 // */ // public static void close() { // if (mWriteDB != null) { // mWriteDB.close(); // mWriteDB = null; // LogUtil.i(TAG, "close: writeDB-close"); // } // if (mReadDB != null) { // mReadDB.close(); // mReadDB = null; // LogUtil.i(TAG, "close: readDB-close"); // } // } // // /** // * 打开数据库 // * // * @param context // */ // public static void open(Context context) { // openWriteDB(context); // openReadDB(context); // // } // // /** // * 打开读数据库 // * // * @param context // */ // private static void openReadDB(Context context) { // if (mReadDB == null || !mReadDB.isOpen()) { // mReadDB = getDbHelper(context).getReadableDatabase(); // // } // } // // /** // * 打开写数据库 // * // * @param context // */ // private static void openWriteDB(Context context) { // if (mWriteDB == null || !mWriteDB.isOpen()) { // mWriteDB = getDbHelper(context).getWritableDatabase(); // mWriteDB.enableWriteAheadLogging(); // // } // // // } // // // /** // * 获得dbhelper // * // * @param context // * @return // */ // public static DBHelper getDbHelper(Context context) { // if (mDbHelper == null) { // //新建dbhelper // mDbHelper = new DBHelper(context); // // } // return mDbHelper; // } // // // public static SQLiteDatabase getReadDB(Context context) { // if(mReadDB==null||!mReadDB.isOpen()){ // openReadDB(context); // } // return mReadDB; // } // // public static SQLiteDatabase getWriteDB(Context context) { // if(mWriteDB==null||!mWriteDB.isOpen()){ // openWriteDB(context); // } // return mWriteDB; // } // } // // Path: filescannercore/src/main/java/io/haydar/filescanner/util/LogUtil.java // public class LogUtil { // private static final boolean isDebug = BuildConfig.DEBUG; // // public static void i(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void d(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void v(String tag, String... args) { // // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void w(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void e(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // private static String getLog(String tag, String... args) { // StringBuilder builder = new StringBuilder(); // for (String arg : args) { // if (TextUtils.isEmpty(arg)) continue; // // builder.append(arg); // } // // return builder.toString(); // } // // // }
import android.content.Context; import io.haydar.filescanner.db.DBManager; import io.haydar.filescanner.util.LogUtil;
package io.haydar.filescanner; /** * @author Haydar * @Package io.haydar.filescannercore * @DATE 2017-04-12 */ public class FileScannerHelper { public static final String TAG = "FileScannerHelper"; private static FileScannerHelper instance = null; private FileScannerHelper() { } public static FileScannerHelper getInstance() { if (instance == null) { instance = new FileScannerHelper(); } return instance; } /** * 初始化 * * @param context */ public void init(Context context) { //创建数据库 DBManager.open(context); } public static void startScanner() {
// Path: filescannercore/src/main/java/io/haydar/filescanner/db/DBManager.java // public class DBManager { // public static final String TAG = "DBManager"; // private static SQLiteDatabase mWriteDB; // private static SQLiteDatabase mReadDB; // private static DBHelper mDbHelper; // private Context context; // /** // * 关闭数据库 // */ // public static void close() { // if (mWriteDB != null) { // mWriteDB.close(); // mWriteDB = null; // LogUtil.i(TAG, "close: writeDB-close"); // } // if (mReadDB != null) { // mReadDB.close(); // mReadDB = null; // LogUtil.i(TAG, "close: readDB-close"); // } // } // // /** // * 打开数据库 // * // * @param context // */ // public static void open(Context context) { // openWriteDB(context); // openReadDB(context); // // } // // /** // * 打开读数据库 // * // * @param context // */ // private static void openReadDB(Context context) { // if (mReadDB == null || !mReadDB.isOpen()) { // mReadDB = getDbHelper(context).getReadableDatabase(); // // } // } // // /** // * 打开写数据库 // * // * @param context // */ // private static void openWriteDB(Context context) { // if (mWriteDB == null || !mWriteDB.isOpen()) { // mWriteDB = getDbHelper(context).getWritableDatabase(); // mWriteDB.enableWriteAheadLogging(); // // } // // // } // // // /** // * 获得dbhelper // * // * @param context // * @return // */ // public static DBHelper getDbHelper(Context context) { // if (mDbHelper == null) { // //新建dbhelper // mDbHelper = new DBHelper(context); // // } // return mDbHelper; // } // // // public static SQLiteDatabase getReadDB(Context context) { // if(mReadDB==null||!mReadDB.isOpen()){ // openReadDB(context); // } // return mReadDB; // } // // public static SQLiteDatabase getWriteDB(Context context) { // if(mWriteDB==null||!mWriteDB.isOpen()){ // openWriteDB(context); // } // return mWriteDB; // } // } // // Path: filescannercore/src/main/java/io/haydar/filescanner/util/LogUtil.java // public class LogUtil { // private static final boolean isDebug = BuildConfig.DEBUG; // // public static void i(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void d(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void v(String tag, String... args) { // // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void w(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // public static void e(String tag, String... args) { // if (isDebug) { // Log.i(tag, getLog(tag, args)); // } // } // // private static String getLog(String tag, String... args) { // StringBuilder builder = new StringBuilder(); // for (String arg : args) { // if (TextUtils.isEmpty(arg)) continue; // // builder.append(arg); // } // // return builder.toString(); // } // // // } // Path: filescannercore/src/main/java/io/haydar/filescanner/FileScannerHelper.java import android.content.Context; import io.haydar.filescanner.db.DBManager; import io.haydar.filescanner.util.LogUtil; package io.haydar.filescanner; /** * @author Haydar * @Package io.haydar.filescannercore * @DATE 2017-04-12 */ public class FileScannerHelper { public static final String TAG = "FileScannerHelper"; private static FileScannerHelper instance = null; private FileScannerHelper() { } public static FileScannerHelper getInstance() { if (instance == null) { instance = new FileScannerHelper(); } return instance; } /** * 初始化 * * @param context */ public void init(Context context) { //创建数据库 DBManager.open(context); } public static void startScanner() {
LogUtil.i(TAG, "startScanner: 开始全盘扫描");
mthli/Type
app/src/main/java/io/github/mthli/type/event/DeleteEvent.java
// Path: app/src/main/java/io/github/mthli/type/widget/model/Type.java // public class Type { // public static final int TYPE_BLOCK = 0x100; // public static final int TYPE_DOTS = 0x101; // public static final int TYPE_IMAGE = 0x102; // public static final int TYPE_TITLE = 0x103; // // @IntDef({TYPE_BLOCK, TYPE_DOTS, TYPE_IMAGE, TYPE_TITLE}) // @Retention(RetentionPolicy.SOURCE) // public @interface TypeValue {} // // private int type; // // public Type(@TypeValue int type) { // this.type = type; // } // // @TypeValue // public final int getType() { // return type; // } // }
import io.github.mthli.type.widget.model.Type;
/* * Copyright 2016 Matthew Lee * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package io.github.mthli.type.event; public class DeleteEvent { private int type; private int position;
// Path: app/src/main/java/io/github/mthli/type/widget/model/Type.java // public class Type { // public static final int TYPE_BLOCK = 0x100; // public static final int TYPE_DOTS = 0x101; // public static final int TYPE_IMAGE = 0x102; // public static final int TYPE_TITLE = 0x103; // // @IntDef({TYPE_BLOCK, TYPE_DOTS, TYPE_IMAGE, TYPE_TITLE}) // @Retention(RetentionPolicy.SOURCE) // public @interface TypeValue {} // // private int type; // // public Type(@TypeValue int type) { // this.type = type; // } // // @TypeValue // public final int getType() { // return type; // } // } // Path: app/src/main/java/io/github/mthli/type/event/DeleteEvent.java import io.github.mthli.type.widget.model.Type; /* * Copyright 2016 Matthew Lee * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package io.github.mthli.type.event; public class DeleteEvent { private int type; private int position;
public DeleteEvent(@Type.TypeValue int type, int position) {
mthli/Type
app/src/main/java/io/github/mthli/type/widget/text/KnifeText.java
// Path: app/src/main/java/io/github/mthli/type/event/FormatEvent.java // public class FormatEvent { // private boolean isBold; // private boolean isItalic; // private boolean isUnderline; // private boolean isStrikethrough; // private boolean isLink; // // public FormatEvent() {} // // public FormatEvent(boolean isBold, boolean isItalic, boolean isUnderline, boolean isStrikethrough, boolean isLink) { // this.isBold = isBold; // this.isItalic = isItalic; // this.isUnderline = isUnderline; // this.isStrikethrough = isStrikethrough; // this.isLink = isLink; // } // // public boolean isBold() { // return isBold; // } // // public void setBold(boolean isBold) { // this.isBold = isBold; // } // // public boolean isItalic() { // return isItalic; // } // // public void setItalic(boolean isItalic) { // this.isItalic = isItalic; // } // // public boolean isUnderline() { // return isUnderline; // } // // public void setUnderline(boolean isUnderline) { // this.isUnderline = isUnderline; // } // // public boolean isStrikethrough() { // return isStrikethrough; // } // // public void setStrikethrough(boolean isStrikethrough) { // this.isStrikethrough = isStrikethrough; // } // // public boolean isLink() { // return isLink; // } // // public void setLink(boolean isLink) { // this.isLink = isLink; // } // } // // Path: app/src/main/java/io/github/mthli/type/util/RxBus.java // public class RxBus { // private static final RxBus sRxBus = new RxBus(); // // public static RxBus getInstance() { // return sRxBus; // } // // private Subject<Object, Object> mSubject = new SerializedSubject<>(PublishSubject.create()); // // private RxBus() {} // // public void post(Object object) { // mSubject.onNext(object); // } // // public <T> Observable<T> toObservable(Class<T> eventType) { // return mSubject.ofType(eventType); // } // // public boolean hasObservers() { // return mSubject.hasObservers(); // } // }
import io.github.mthli.type.util.RxBus; import android.content.Context; import android.graphics.Typeface; import android.support.annotation.IntDef; import android.support.v7.widget.AppCompatEditText; import android.text.Spanned; import android.text.style.StrikethroughSpan; import android.text.style.StyleSpan; import android.text.style.UnderlineSpan; import android.util.AttributeSet; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.List; import io.github.mthli.type.event.FormatEvent;
public boolean contains(@FormatValue int format) { switch (format) { case FORMAT_BOLD: return containStyle(Typeface.BOLD, getSelectionStart(), getSelectionEnd()); case FORMAT_ITALIC: return containStyle(Typeface.ITALIC, getSelectionStart(), getSelectionEnd()); case FORMAT_UNDERLINE: return containUnderline(getSelectionStart(), getSelectionEnd()); case FORMAT_STRIKETHROUGH: return containStrikethrough(getSelectionStart(), getSelectionEnd()); case FORMAT_LINK: // TODO return false; default: return false; } } public void clearFormats() { setText(getEditableText().toString()); setSelection(getEditableText().length()); } @Override protected void onSelectionChanged(int start, int end) { if (start >= end) { return; }
// Path: app/src/main/java/io/github/mthli/type/event/FormatEvent.java // public class FormatEvent { // private boolean isBold; // private boolean isItalic; // private boolean isUnderline; // private boolean isStrikethrough; // private boolean isLink; // // public FormatEvent() {} // // public FormatEvent(boolean isBold, boolean isItalic, boolean isUnderline, boolean isStrikethrough, boolean isLink) { // this.isBold = isBold; // this.isItalic = isItalic; // this.isUnderline = isUnderline; // this.isStrikethrough = isStrikethrough; // this.isLink = isLink; // } // // public boolean isBold() { // return isBold; // } // // public void setBold(boolean isBold) { // this.isBold = isBold; // } // // public boolean isItalic() { // return isItalic; // } // // public void setItalic(boolean isItalic) { // this.isItalic = isItalic; // } // // public boolean isUnderline() { // return isUnderline; // } // // public void setUnderline(boolean isUnderline) { // this.isUnderline = isUnderline; // } // // public boolean isStrikethrough() { // return isStrikethrough; // } // // public void setStrikethrough(boolean isStrikethrough) { // this.isStrikethrough = isStrikethrough; // } // // public boolean isLink() { // return isLink; // } // // public void setLink(boolean isLink) { // this.isLink = isLink; // } // } // // Path: app/src/main/java/io/github/mthli/type/util/RxBus.java // public class RxBus { // private static final RxBus sRxBus = new RxBus(); // // public static RxBus getInstance() { // return sRxBus; // } // // private Subject<Object, Object> mSubject = new SerializedSubject<>(PublishSubject.create()); // // private RxBus() {} // // public void post(Object object) { // mSubject.onNext(object); // } // // public <T> Observable<T> toObservable(Class<T> eventType) { // return mSubject.ofType(eventType); // } // // public boolean hasObservers() { // return mSubject.hasObservers(); // } // } // Path: app/src/main/java/io/github/mthli/type/widget/text/KnifeText.java import io.github.mthli.type.util.RxBus; import android.content.Context; import android.graphics.Typeface; import android.support.annotation.IntDef; import android.support.v7.widget.AppCompatEditText; import android.text.Spanned; import android.text.style.StrikethroughSpan; import android.text.style.StyleSpan; import android.text.style.UnderlineSpan; import android.util.AttributeSet; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.List; import io.github.mthli.type.event.FormatEvent; public boolean contains(@FormatValue int format) { switch (format) { case FORMAT_BOLD: return containStyle(Typeface.BOLD, getSelectionStart(), getSelectionEnd()); case FORMAT_ITALIC: return containStyle(Typeface.ITALIC, getSelectionStart(), getSelectionEnd()); case FORMAT_UNDERLINE: return containUnderline(getSelectionStart(), getSelectionEnd()); case FORMAT_STRIKETHROUGH: return containStrikethrough(getSelectionStart(), getSelectionEnd()); case FORMAT_LINK: // TODO return false; default: return false; } } public void clearFormats() { setText(getEditableText().toString()); setSelection(getEditableText().length()); } @Override protected void onSelectionChanged(int start, int end) { if (start >= end) { return; }
FormatEvent event = new FormatEvent();
mthli/Type
app/src/main/java/io/github/mthli/type/widget/text/KnifeText.java
// Path: app/src/main/java/io/github/mthli/type/event/FormatEvent.java // public class FormatEvent { // private boolean isBold; // private boolean isItalic; // private boolean isUnderline; // private boolean isStrikethrough; // private boolean isLink; // // public FormatEvent() {} // // public FormatEvent(boolean isBold, boolean isItalic, boolean isUnderline, boolean isStrikethrough, boolean isLink) { // this.isBold = isBold; // this.isItalic = isItalic; // this.isUnderline = isUnderline; // this.isStrikethrough = isStrikethrough; // this.isLink = isLink; // } // // public boolean isBold() { // return isBold; // } // // public void setBold(boolean isBold) { // this.isBold = isBold; // } // // public boolean isItalic() { // return isItalic; // } // // public void setItalic(boolean isItalic) { // this.isItalic = isItalic; // } // // public boolean isUnderline() { // return isUnderline; // } // // public void setUnderline(boolean isUnderline) { // this.isUnderline = isUnderline; // } // // public boolean isStrikethrough() { // return isStrikethrough; // } // // public void setStrikethrough(boolean isStrikethrough) { // this.isStrikethrough = isStrikethrough; // } // // public boolean isLink() { // return isLink; // } // // public void setLink(boolean isLink) { // this.isLink = isLink; // } // } // // Path: app/src/main/java/io/github/mthli/type/util/RxBus.java // public class RxBus { // private static final RxBus sRxBus = new RxBus(); // // public static RxBus getInstance() { // return sRxBus; // } // // private Subject<Object, Object> mSubject = new SerializedSubject<>(PublishSubject.create()); // // private RxBus() {} // // public void post(Object object) { // mSubject.onNext(object); // } // // public <T> Observable<T> toObservable(Class<T> eventType) { // return mSubject.ofType(eventType); // } // // public boolean hasObservers() { // return mSubject.hasObservers(); // } // }
import io.github.mthli.type.util.RxBus; import android.content.Context; import android.graphics.Typeface; import android.support.annotation.IntDef; import android.support.v7.widget.AppCompatEditText; import android.text.Spanned; import android.text.style.StrikethroughSpan; import android.text.style.StyleSpan; import android.text.style.UnderlineSpan; import android.util.AttributeSet; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.List; import io.github.mthli.type.event.FormatEvent;
return containStyle(Typeface.ITALIC, getSelectionStart(), getSelectionEnd()); case FORMAT_UNDERLINE: return containUnderline(getSelectionStart(), getSelectionEnd()); case FORMAT_STRIKETHROUGH: return containStrikethrough(getSelectionStart(), getSelectionEnd()); case FORMAT_LINK: // TODO return false; default: return false; } } public void clearFormats() { setText(getEditableText().toString()); setSelection(getEditableText().length()); } @Override protected void onSelectionChanged(int start, int end) { if (start >= end) { return; } FormatEvent event = new FormatEvent(); event.setBold(contains(FORMAT_BOLD)); event.setItalic(contains(FORMAT_ITALIC)); event.setUnderline(contains(FORMAT_UNDERLINE)); event.setStrikethrough(contains(FORMAT_STRIKETHROUGH)); event.setLink(contains(FORMAT_LINK));
// Path: app/src/main/java/io/github/mthli/type/event/FormatEvent.java // public class FormatEvent { // private boolean isBold; // private boolean isItalic; // private boolean isUnderline; // private boolean isStrikethrough; // private boolean isLink; // // public FormatEvent() {} // // public FormatEvent(boolean isBold, boolean isItalic, boolean isUnderline, boolean isStrikethrough, boolean isLink) { // this.isBold = isBold; // this.isItalic = isItalic; // this.isUnderline = isUnderline; // this.isStrikethrough = isStrikethrough; // this.isLink = isLink; // } // // public boolean isBold() { // return isBold; // } // // public void setBold(boolean isBold) { // this.isBold = isBold; // } // // public boolean isItalic() { // return isItalic; // } // // public void setItalic(boolean isItalic) { // this.isItalic = isItalic; // } // // public boolean isUnderline() { // return isUnderline; // } // // public void setUnderline(boolean isUnderline) { // this.isUnderline = isUnderline; // } // // public boolean isStrikethrough() { // return isStrikethrough; // } // // public void setStrikethrough(boolean isStrikethrough) { // this.isStrikethrough = isStrikethrough; // } // // public boolean isLink() { // return isLink; // } // // public void setLink(boolean isLink) { // this.isLink = isLink; // } // } // // Path: app/src/main/java/io/github/mthli/type/util/RxBus.java // public class RxBus { // private static final RxBus sRxBus = new RxBus(); // // public static RxBus getInstance() { // return sRxBus; // } // // private Subject<Object, Object> mSubject = new SerializedSubject<>(PublishSubject.create()); // // private RxBus() {} // // public void post(Object object) { // mSubject.onNext(object); // } // // public <T> Observable<T> toObservable(Class<T> eventType) { // return mSubject.ofType(eventType); // } // // public boolean hasObservers() { // return mSubject.hasObservers(); // } // } // Path: app/src/main/java/io/github/mthli/type/widget/text/KnifeText.java import io.github.mthli.type.util.RxBus; import android.content.Context; import android.graphics.Typeface; import android.support.annotation.IntDef; import android.support.v7.widget.AppCompatEditText; import android.text.Spanned; import android.text.style.StrikethroughSpan; import android.text.style.StyleSpan; import android.text.style.UnderlineSpan; import android.util.AttributeSet; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.List; import io.github.mthli.type.event.FormatEvent; return containStyle(Typeface.ITALIC, getSelectionStart(), getSelectionEnd()); case FORMAT_UNDERLINE: return containUnderline(getSelectionStart(), getSelectionEnd()); case FORMAT_STRIKETHROUGH: return containStrikethrough(getSelectionStart(), getSelectionEnd()); case FORMAT_LINK: // TODO return false; default: return false; } } public void clearFormats() { setText(getEditableText().toString()); setSelection(getEditableText().length()); } @Override protected void onSelectionChanged(int start, int end) { if (start >= end) { return; } FormatEvent event = new FormatEvent(); event.setBold(contains(FORMAT_BOLD)); event.setItalic(contains(FORMAT_ITALIC)); event.setUnderline(contains(FORMAT_UNDERLINE)); event.setStrikethrough(contains(FORMAT_STRIKETHROUGH)); event.setLink(contains(FORMAT_LINK));
RxBus.getInstance().post(event);
mthli/Type
app/src/main/java/io/github/mthli/type/widget/holder/TypeImageHolder.java
// Path: app/src/main/java/io/github/mthli/type/widget/model/TypeImage.java // public class TypeImage extends Type { // private Bitmap bitmap; // // public TypeImage(@NonNull Bitmap bitmap) { // super(TYPE_IMAGE); // this.bitmap = bitmap; // } // // public Bitmap getBitmap() { // return bitmap; // } // // public void setBitmap(@NonNull Bitmap bitmap) { // this.bitmap = bitmap; // } // }
import android.support.annotation.NonNull; import android.support.v7.widget.AppCompatImageView; import android.support.v7.widget.RecyclerView; import android.view.View; import io.github.mthli.type.R; import io.github.mthli.type.widget.model.TypeImage;
/* * Copyright 2016 Matthew Lee * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package io.github.mthli.type.widget.holder; public class TypeImageHolder extends RecyclerView.ViewHolder { private AppCompatImageView image; public TypeImageHolder(@NonNull View view) { super(view); image = (AppCompatImageView) view.findViewById(R.id.image); }
// Path: app/src/main/java/io/github/mthli/type/widget/model/TypeImage.java // public class TypeImage extends Type { // private Bitmap bitmap; // // public TypeImage(@NonNull Bitmap bitmap) { // super(TYPE_IMAGE); // this.bitmap = bitmap; // } // // public Bitmap getBitmap() { // return bitmap; // } // // public void setBitmap(@NonNull Bitmap bitmap) { // this.bitmap = bitmap; // } // } // Path: app/src/main/java/io/github/mthli/type/widget/holder/TypeImageHolder.java import android.support.annotation.NonNull; import android.support.v7.widget.AppCompatImageView; import android.support.v7.widget.RecyclerView; import android.view.View; import io.github.mthli.type.R; import io.github.mthli.type.widget.model.TypeImage; /* * Copyright 2016 Matthew Lee * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package io.github.mthli.type.widget.holder; public class TypeImageHolder extends RecyclerView.ViewHolder { private AppCompatImageView image; public TypeImageHolder(@NonNull View view) { super(view); image = (AppCompatImageView) view.findViewById(R.id.image); }
public void inject(TypeImage type) {
mthli/Type
app/src/main/java/io/github/mthli/type/widget/holder/TypeTitleHolder.java
// Path: app/src/main/java/io/github/mthli/type/widget/model/TypeTitle.java // public class TypeTitle extends Type { // private String title; // // public TypeTitle(@Nullable String title) { // super(TYPE_TITLE); // setTitle(title); // } // // @NonNull // public String getTitle() { // return title; // } // // public void setTitle(@Nullable String title) { // this.title = title != null ? title : ""; // } // }
import android.support.annotation.NonNull; import android.support.v7.widget.AppCompatEditText; import android.support.v7.widget.RecyclerView; import android.view.View; import com.jakewharton.rxbinding.widget.RxTextView; import com.jakewharton.rxbinding.widget.TextViewAfterTextChangeEvent; import io.github.mthli.type.R; import io.github.mthli.type.widget.model.TypeTitle; import rx.functions.Action1;
/* * Copyright 2016 Matthew Lee * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package io.github.mthli.type.widget.holder; public class TypeTitleHolder extends RecyclerView.ViewHolder { private AppCompatEditText title;
// Path: app/src/main/java/io/github/mthli/type/widget/model/TypeTitle.java // public class TypeTitle extends Type { // private String title; // // public TypeTitle(@Nullable String title) { // super(TYPE_TITLE); // setTitle(title); // } // // @NonNull // public String getTitle() { // return title; // } // // public void setTitle(@Nullable String title) { // this.title = title != null ? title : ""; // } // } // Path: app/src/main/java/io/github/mthli/type/widget/holder/TypeTitleHolder.java import android.support.annotation.NonNull; import android.support.v7.widget.AppCompatEditText; import android.support.v7.widget.RecyclerView; import android.view.View; import com.jakewharton.rxbinding.widget.RxTextView; import com.jakewharton.rxbinding.widget.TextViewAfterTextChangeEvent; import io.github.mthli.type.R; import io.github.mthli.type.widget.model.TypeTitle; import rx.functions.Action1; /* * Copyright 2016 Matthew Lee * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package io.github.mthli.type.widget.holder; public class TypeTitleHolder extends RecyclerView.ViewHolder { private AppCompatEditText title;
private TypeTitle type;
mthli/Type
app/src/main/java/io/github/mthli/type/event/InsertEvent.java
// Path: app/src/main/java/io/github/mthli/type/widget/model/Type.java // public class Type { // public static final int TYPE_BLOCK = 0x100; // public static final int TYPE_DOTS = 0x101; // public static final int TYPE_IMAGE = 0x102; // public static final int TYPE_TITLE = 0x103; // // @IntDef({TYPE_BLOCK, TYPE_DOTS, TYPE_IMAGE, TYPE_TITLE}) // @Retention(RetentionPolicy.SOURCE) // public @interface TypeValue {} // // private int type; // // public Type(@TypeValue int type) { // this.type = type; // } // // @TypeValue // public final int getType() { // return type; // } // }
import android.graphics.Bitmap; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.text.SpannableString; import android.text.Spanned; import io.github.mthli.type.widget.model.Type;
/* * Copyright 2016 Matthew Lee * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package io.github.mthli.type.event; public class InsertEvent { private int type; private int position; private Spanned prefix; private Spanned suffix; private Bitmap bitmap;
// Path: app/src/main/java/io/github/mthli/type/widget/model/Type.java // public class Type { // public static final int TYPE_BLOCK = 0x100; // public static final int TYPE_DOTS = 0x101; // public static final int TYPE_IMAGE = 0x102; // public static final int TYPE_TITLE = 0x103; // // @IntDef({TYPE_BLOCK, TYPE_DOTS, TYPE_IMAGE, TYPE_TITLE}) // @Retention(RetentionPolicy.SOURCE) // public @interface TypeValue {} // // private int type; // // public Type(@TypeValue int type) { // this.type = type; // } // // @TypeValue // public final int getType() { // return type; // } // } // Path: app/src/main/java/io/github/mthli/type/event/InsertEvent.java import android.graphics.Bitmap; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.text.SpannableString; import android.text.Spanned; import io.github.mthli.type.widget.model.Type; /* * Copyright 2016 Matthew Lee * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package io.github.mthli.type.event; public class InsertEvent { private int type; private int position; private Spanned prefix; private Spanned suffix; private Bitmap bitmap;
public InsertEvent(@Type.TypeValue int type, int position, @Nullable Spanned prefix, @Nullable Spanned suffix, @Nullable Bitmap bitmap) {
Glucosio/glucosio-android
app/src/test/java/org/glucosio/android/tools/ReadingToCSVTest.java
// Path: app/src/main/java/org/glucosio/android/Constants.java // public class Constants { // public class Units { // public static final String MG_DL = "mg/dL"; // public static final String MMOL_L = "mmol/L"; // // private Units() { // } // } // // private Constants() { // } // } // // Path: app/src/test/java/org/glucosio/android/RobolectricTest.java // @Ignore // @RunWith(RobolectricTestRunner.class) // @Config(sdk = 25) // public abstract class RobolectricTest { // protected Analytics getAnalytics() { // return getTestApplication().getAnalytics(); // } // // protected Backup getBackup() { // return getTestApplication().getBackup(); // } // // private TestGlucosioApplication getTestApplication() { // return (TestGlucosioApplication) RuntimeEnvironment.application; // } // // protected DatabaseHandler getDBHandler() { // return getTestApplication().getDBHandler(); // } // // protected HelloPresenter getHelloPresenter() { // //noinspection ConstantConditions // return getTestApplication().createHelloPresenter(null); // } // // protected LocaleHelper getLocaleHelper() { // //noinspection ConstantConditions // return getTestApplication().getLocaleHelper(); // } // } // // Path: app/src/main/java/org/glucosio/android/db/GlucoseReading.java // public class GlucoseReading extends RealmObject { // // @PrimaryKey // private long id; // // private double reading; // private String reading_type; // private String notes; // private int user_id; // private Date created; // // public GlucoseReading() { // } // // public GlucoseReading(double reading, String reading_type, Date created, String notes) { // this.reading = reading; // this.reading_type = reading_type; // this.created = created; // this.notes = notes; // } // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public double getReading() { // return reading; // } // // public void setReading(double reading) { // this.reading = reading; // } // // public String getReading_type() { // return reading_type; // } // // public void setReading_type(String reading_type) { // this.reading_type = reading_type; // } // // public String getNotes() { // return notes; // } // // public void setNotes(String notes) { // this.notes = notes; // } // // public int getUser_id() { // return user_id; // } // // public void setUser_id(int user_id) { // this.user_id = user_id; // } // // public Date getCreated() { // return created; // } // // public void setCreated(Date created) { // this.created = created; // } // }
import org.glucosio.android.Constants; import org.glucosio.android.R; import org.glucosio.android.RobolectricTest; import org.glucosio.android.db.GlucoseReading; import org.junit.Assert; import org.junit.Test; import org.robolectric.RuntimeEnvironment; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.text.NumberFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; import static org.assertj.core.api.Assertions.assertThat;
package org.glucosio.android.tools; /** * Created by david on 30/10/16. */ public class ReadingToCSVTest extends RobolectricTest { private final FormatDateTime dateTool = new FormatDateTime(RuntimeEnvironment.application); private final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); private final OutputStreamWriter osw = new OutputStreamWriter(outputStream); private final NumberFormat numberFormat = NumberFormatUtils.createDefaultNumberFormat(); @Test public void GeneratesEmptyCSVWithHeader_WhenNoData() throws IOException {
// Path: app/src/main/java/org/glucosio/android/Constants.java // public class Constants { // public class Units { // public static final String MG_DL = "mg/dL"; // public static final String MMOL_L = "mmol/L"; // // private Units() { // } // } // // private Constants() { // } // } // // Path: app/src/test/java/org/glucosio/android/RobolectricTest.java // @Ignore // @RunWith(RobolectricTestRunner.class) // @Config(sdk = 25) // public abstract class RobolectricTest { // protected Analytics getAnalytics() { // return getTestApplication().getAnalytics(); // } // // protected Backup getBackup() { // return getTestApplication().getBackup(); // } // // private TestGlucosioApplication getTestApplication() { // return (TestGlucosioApplication) RuntimeEnvironment.application; // } // // protected DatabaseHandler getDBHandler() { // return getTestApplication().getDBHandler(); // } // // protected HelloPresenter getHelloPresenter() { // //noinspection ConstantConditions // return getTestApplication().createHelloPresenter(null); // } // // protected LocaleHelper getLocaleHelper() { // //noinspection ConstantConditions // return getTestApplication().getLocaleHelper(); // } // } // // Path: app/src/main/java/org/glucosio/android/db/GlucoseReading.java // public class GlucoseReading extends RealmObject { // // @PrimaryKey // private long id; // // private double reading; // private String reading_type; // private String notes; // private int user_id; // private Date created; // // public GlucoseReading() { // } // // public GlucoseReading(double reading, String reading_type, Date created, String notes) { // this.reading = reading; // this.reading_type = reading_type; // this.created = created; // this.notes = notes; // } // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public double getReading() { // return reading; // } // // public void setReading(double reading) { // this.reading = reading; // } // // public String getReading_type() { // return reading_type; // } // // public void setReading_type(String reading_type) { // this.reading_type = reading_type; // } // // public String getNotes() { // return notes; // } // // public void setNotes(String notes) { // this.notes = notes; // } // // public int getUser_id() { // return user_id; // } // // public void setUser_id(int user_id) { // this.user_id = user_id; // } // // public Date getCreated() { // return created; // } // // public void setCreated(Date created) { // this.created = created; // } // } // Path: app/src/test/java/org/glucosio/android/tools/ReadingToCSVTest.java import org.glucosio.android.Constants; import org.glucosio.android.R; import org.glucosio.android.RobolectricTest; import org.glucosio.android.db.GlucoseReading; import org.junit.Assert; import org.junit.Test; import org.robolectric.RuntimeEnvironment; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.text.NumberFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; import static org.assertj.core.api.Assertions.assertThat; package org.glucosio.android.tools; /** * Created by david on 30/10/16. */ public class ReadingToCSVTest extends RobolectricTest { private final FormatDateTime dateTool = new FormatDateTime(RuntimeEnvironment.application); private final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); private final OutputStreamWriter osw = new OutputStreamWriter(outputStream); private final NumberFormat numberFormat = NumberFormatUtils.createDefaultNumberFormat(); @Test public void GeneratesEmptyCSVWithHeader_WhenNoData() throws IOException {
ReadingToCSV r = new ReadingToCSV(RuntimeEnvironment.application, Constants.Units.MG_DL);
Glucosio/glucosio-android
app/src/test/java/org/glucosio/android/tools/ReadingToCSVTest.java
// Path: app/src/main/java/org/glucosio/android/Constants.java // public class Constants { // public class Units { // public static final String MG_DL = "mg/dL"; // public static final String MMOL_L = "mmol/L"; // // private Units() { // } // } // // private Constants() { // } // } // // Path: app/src/test/java/org/glucosio/android/RobolectricTest.java // @Ignore // @RunWith(RobolectricTestRunner.class) // @Config(sdk = 25) // public abstract class RobolectricTest { // protected Analytics getAnalytics() { // return getTestApplication().getAnalytics(); // } // // protected Backup getBackup() { // return getTestApplication().getBackup(); // } // // private TestGlucosioApplication getTestApplication() { // return (TestGlucosioApplication) RuntimeEnvironment.application; // } // // protected DatabaseHandler getDBHandler() { // return getTestApplication().getDBHandler(); // } // // protected HelloPresenter getHelloPresenter() { // //noinspection ConstantConditions // return getTestApplication().createHelloPresenter(null); // } // // protected LocaleHelper getLocaleHelper() { // //noinspection ConstantConditions // return getTestApplication().getLocaleHelper(); // } // } // // Path: app/src/main/java/org/glucosio/android/db/GlucoseReading.java // public class GlucoseReading extends RealmObject { // // @PrimaryKey // private long id; // // private double reading; // private String reading_type; // private String notes; // private int user_id; // private Date created; // // public GlucoseReading() { // } // // public GlucoseReading(double reading, String reading_type, Date created, String notes) { // this.reading = reading; // this.reading_type = reading_type; // this.created = created; // this.notes = notes; // } // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public double getReading() { // return reading; // } // // public void setReading(double reading) { // this.reading = reading; // } // // public String getReading_type() { // return reading_type; // } // // public void setReading_type(String reading_type) { // this.reading_type = reading_type; // } // // public String getNotes() { // return notes; // } // // public void setNotes(String notes) { // this.notes = notes; // } // // public int getUser_id() { // return user_id; // } // // public void setUser_id(int user_id) { // this.user_id = user_id; // } // // public Date getCreated() { // return created; // } // // public void setCreated(Date created) { // this.created = created; // } // }
import org.glucosio.android.Constants; import org.glucosio.android.R; import org.glucosio.android.RobolectricTest; import org.glucosio.android.db.GlucoseReading; import org.junit.Assert; import org.junit.Test; import org.robolectric.RuntimeEnvironment; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.text.NumberFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; import static org.assertj.core.api.Assertions.assertThat;
package org.glucosio.android.tools; /** * Created by david on 30/10/16. */ public class ReadingToCSVTest extends RobolectricTest { private final FormatDateTime dateTool = new FormatDateTime(RuntimeEnvironment.application); private final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); private final OutputStreamWriter osw = new OutputStreamWriter(outputStream); private final NumberFormat numberFormat = NumberFormatUtils.createDefaultNumberFormat(); @Test public void GeneratesEmptyCSVWithHeader_WhenNoData() throws IOException { ReadingToCSV r = new ReadingToCSV(RuntimeEnvironment.application, Constants.Units.MG_DL);
// Path: app/src/main/java/org/glucosio/android/Constants.java // public class Constants { // public class Units { // public static final String MG_DL = "mg/dL"; // public static final String MMOL_L = "mmol/L"; // // private Units() { // } // } // // private Constants() { // } // } // // Path: app/src/test/java/org/glucosio/android/RobolectricTest.java // @Ignore // @RunWith(RobolectricTestRunner.class) // @Config(sdk = 25) // public abstract class RobolectricTest { // protected Analytics getAnalytics() { // return getTestApplication().getAnalytics(); // } // // protected Backup getBackup() { // return getTestApplication().getBackup(); // } // // private TestGlucosioApplication getTestApplication() { // return (TestGlucosioApplication) RuntimeEnvironment.application; // } // // protected DatabaseHandler getDBHandler() { // return getTestApplication().getDBHandler(); // } // // protected HelloPresenter getHelloPresenter() { // //noinspection ConstantConditions // return getTestApplication().createHelloPresenter(null); // } // // protected LocaleHelper getLocaleHelper() { // //noinspection ConstantConditions // return getTestApplication().getLocaleHelper(); // } // } // // Path: app/src/main/java/org/glucosio/android/db/GlucoseReading.java // public class GlucoseReading extends RealmObject { // // @PrimaryKey // private long id; // // private double reading; // private String reading_type; // private String notes; // private int user_id; // private Date created; // // public GlucoseReading() { // } // // public GlucoseReading(double reading, String reading_type, Date created, String notes) { // this.reading = reading; // this.reading_type = reading_type; // this.created = created; // this.notes = notes; // } // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public double getReading() { // return reading; // } // // public void setReading(double reading) { // this.reading = reading; // } // // public String getReading_type() { // return reading_type; // } // // public void setReading_type(String reading_type) { // this.reading_type = reading_type; // } // // public String getNotes() { // return notes; // } // // public void setNotes(String notes) { // this.notes = notes; // } // // public int getUser_id() { // return user_id; // } // // public void setUser_id(int user_id) { // this.user_id = user_id; // } // // public Date getCreated() { // return created; // } // // public void setCreated(Date created) { // this.created = created; // } // } // Path: app/src/test/java/org/glucosio/android/tools/ReadingToCSVTest.java import org.glucosio.android.Constants; import org.glucosio.android.R; import org.glucosio.android.RobolectricTest; import org.glucosio.android.db.GlucoseReading; import org.junit.Assert; import org.junit.Test; import org.robolectric.RuntimeEnvironment; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.text.NumberFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; import static org.assertj.core.api.Assertions.assertThat; package org.glucosio.android.tools; /** * Created by david on 30/10/16. */ public class ReadingToCSVTest extends RobolectricTest { private final FormatDateTime dateTool = new FormatDateTime(RuntimeEnvironment.application); private final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); private final OutputStreamWriter osw = new OutputStreamWriter(outputStream); private final NumberFormat numberFormat = NumberFormatUtils.createDefaultNumberFormat(); @Test public void GeneratesEmptyCSVWithHeader_WhenNoData() throws IOException { ReadingToCSV r = new ReadingToCSV(RuntimeEnvironment.application, Constants.Units.MG_DL);
r.createCSVFile(new ArrayList<GlucoseReading>(), osw);
Glucosio/glucosio-android
app/src/test/java/org/glucosio/android/activity/PreferencesActivityTest.java
// Path: app/src/main/java/org/glucosio/android/Constants.java // public class Constants { // public class Units { // public static final String MG_DL = "mg/dL"; // public static final String MMOL_L = "mmol/L"; // // private Units() { // } // } // // private Constants() { // } // } // // Path: app/src/test/java/org/glucosio/android/RobolectricTest.java // @Ignore // @RunWith(RobolectricTestRunner.class) // @Config(sdk = 25) // public abstract class RobolectricTest { // protected Analytics getAnalytics() { // return getTestApplication().getAnalytics(); // } // // protected Backup getBackup() { // return getTestApplication().getBackup(); // } // // private TestGlucosioApplication getTestApplication() { // return (TestGlucosioApplication) RuntimeEnvironment.application; // } // // protected DatabaseHandler getDBHandler() { // return getTestApplication().getDBHandler(); // } // // protected HelloPresenter getHelloPresenter() { // //noinspection ConstantConditions // return getTestApplication().createHelloPresenter(null); // } // // protected LocaleHelper getLocaleHelper() { // //noinspection ConstantConditions // return getTestApplication().getLocaleHelper(); // } // }
import org.glucosio.android.Constants; import org.glucosio.android.RobolectricTest; import org.glucosio.android.db.User; import org.glucosio.android.db.UserBuilder; import org.junit.Before; import org.junit.Test; import org.robolectric.Robolectric; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when;
package org.glucosio.android.activity; public class PreferencesActivityTest extends RobolectricTest { private PreferencesActivity activity; private final User user = new UserBuilder() .setId(1) .setName("test") .setPreferredLanguage("en") .setCountry("en") .setAge(23) .setGender("M") .setDiabetesType(1)
// Path: app/src/main/java/org/glucosio/android/Constants.java // public class Constants { // public class Units { // public static final String MG_DL = "mg/dL"; // public static final String MMOL_L = "mmol/L"; // // private Units() { // } // } // // private Constants() { // } // } // // Path: app/src/test/java/org/glucosio/android/RobolectricTest.java // @Ignore // @RunWith(RobolectricTestRunner.class) // @Config(sdk = 25) // public abstract class RobolectricTest { // protected Analytics getAnalytics() { // return getTestApplication().getAnalytics(); // } // // protected Backup getBackup() { // return getTestApplication().getBackup(); // } // // private TestGlucosioApplication getTestApplication() { // return (TestGlucosioApplication) RuntimeEnvironment.application; // } // // protected DatabaseHandler getDBHandler() { // return getTestApplication().getDBHandler(); // } // // protected HelloPresenter getHelloPresenter() { // //noinspection ConstantConditions // return getTestApplication().createHelloPresenter(null); // } // // protected LocaleHelper getLocaleHelper() { // //noinspection ConstantConditions // return getTestApplication().getLocaleHelper(); // } // } // Path: app/src/test/java/org/glucosio/android/activity/PreferencesActivityTest.java import org.glucosio.android.Constants; import org.glucosio.android.RobolectricTest; import org.glucosio.android.db.User; import org.glucosio.android.db.UserBuilder; import org.junit.Before; import org.junit.Test; import org.robolectric.Robolectric; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; package org.glucosio.android.activity; public class PreferencesActivityTest extends RobolectricTest { private PreferencesActivity activity; private final User user = new UserBuilder() .setId(1) .setName("test") .setPreferredLanguage("en") .setCountry("en") .setAge(23) .setGender("M") .setDiabetesType(1)
.setPreferredUnit(Constants.Units.MG_DL)
linkedin/play-parseq
src/trace/java/app/com/linkedin/playparseq/trace/j/renderers/ParSeqTraceRendererImpl.java
// Path: src/core/java/app/com/linkedin/playparseq/j/stores/ParSeqTaskStore.java // public interface ParSeqTaskStore { // // /** // * The method put puts ParSeq Task into store. // * // * @param context The HTTP Context // * @param task The ParSeq Task // */ // void put(final Http.Context context, final Task<?> task); // // /** // * The method get gets all Tasks from one request out of store as an unmodifiable Set. // * // * @param context The HTTP Context // * @return A set of Tasks // */ // Set<Task<?>> get(final Http.Context context); // // /** // * The method initialize sets up the store properly for put/get APIs. // * // * @param context The origin HTTP Context // * @return The HTTP Context with store set up properly // */ // Http.Context initialize(final Http.Context context); // // }
import com.linkedin.parseq.trace.ShallowTrace; import com.linkedin.parseq.trace.Trace; import com.linkedin.parseq.trace.TraceRelationship; import com.linkedin.playparseq.j.stores.ParSeqTaskStore; import com.linkedin.playparseq.trace.utils.ParSeqTraceBaseVisualizer; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; import javax.inject.Inject; import javax.inject.Singleton; import play.api.http.HttpConfiguration; import play.Environment; import play.libs.concurrent.HttpExecutionContext; import play.mvc.Http; import play.mvc.Result; import play.mvc.Results;
/* * Copyright 2015 LinkedIn Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ package com.linkedin.playparseq.trace.j.renderers; /** * The class ParSeqTraceRendererImpl is an implementation of the interface {@link ParSeqTraceRenderer} with the * help from the class {@link ParSeqTraceBaseVisualizer}. * * @author Yinan Ding (yding@linkedin.com) */ @Singleton public class ParSeqTraceRendererImpl extends ParSeqTraceBaseVisualizer implements ParSeqTraceRenderer { /** * The field _environment is the injected Environment. */ private final Environment _environment; /** * The field _httpConfiguration is the injected HttpConfiguration. */ private final HttpConfiguration _httpConfiguration; /** * The field _httpExecutionContext is a {@link HttpExecutionContext} for setting Java async task's executor. */ private final HttpExecutionContext _httpExecutionContext; /** * The constructor injects the Environment and the HttpConfiguration. * * @param environment The injected Environment component * @param httpConfiguration The injected HttpConfiguration component * @param httpExecutionContext The injected HttpExecutionContext component */ @Inject public ParSeqTraceRendererImpl(final Environment environment, final HttpConfiguration httpConfiguration, final HttpExecutionContext httpExecutionContext) { _environment = environment; _httpConfiguration = httpConfiguration; _httpExecutionContext = httpExecutionContext; } /** * {@inheritDoc} */ @Override
// Path: src/core/java/app/com/linkedin/playparseq/j/stores/ParSeqTaskStore.java // public interface ParSeqTaskStore { // // /** // * The method put puts ParSeq Task into store. // * // * @param context The HTTP Context // * @param task The ParSeq Task // */ // void put(final Http.Context context, final Task<?> task); // // /** // * The method get gets all Tasks from one request out of store as an unmodifiable Set. // * // * @param context The HTTP Context // * @return A set of Tasks // */ // Set<Task<?>> get(final Http.Context context); // // /** // * The method initialize sets up the store properly for put/get APIs. // * // * @param context The origin HTTP Context // * @return The HTTP Context with store set up properly // */ // Http.Context initialize(final Http.Context context); // // } // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/renderers/ParSeqTraceRendererImpl.java import com.linkedin.parseq.trace.ShallowTrace; import com.linkedin.parseq.trace.Trace; import com.linkedin.parseq.trace.TraceRelationship; import com.linkedin.playparseq.j.stores.ParSeqTaskStore; import com.linkedin.playparseq.trace.utils.ParSeqTraceBaseVisualizer; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; import javax.inject.Inject; import javax.inject.Singleton; import play.api.http.HttpConfiguration; import play.Environment; import play.libs.concurrent.HttpExecutionContext; import play.mvc.Http; import play.mvc.Result; import play.mvc.Results; /* * Copyright 2015 LinkedIn Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ package com.linkedin.playparseq.trace.j.renderers; /** * The class ParSeqTraceRendererImpl is an implementation of the interface {@link ParSeqTraceRenderer} with the * help from the class {@link ParSeqTraceBaseVisualizer}. * * @author Yinan Ding (yding@linkedin.com) */ @Singleton public class ParSeqTraceRendererImpl extends ParSeqTraceBaseVisualizer implements ParSeqTraceRenderer { /** * The field _environment is the injected Environment. */ private final Environment _environment; /** * The field _httpConfiguration is the injected HttpConfiguration. */ private final HttpConfiguration _httpConfiguration; /** * The field _httpExecutionContext is a {@link HttpExecutionContext} for setting Java async task's executor. */ private final HttpExecutionContext _httpExecutionContext; /** * The constructor injects the Environment and the HttpConfiguration. * * @param environment The injected Environment component * @param httpConfiguration The injected HttpConfiguration component * @param httpExecutionContext The injected HttpExecutionContext component */ @Inject public ParSeqTraceRendererImpl(final Environment environment, final HttpConfiguration httpConfiguration, final HttpExecutionContext httpExecutionContext) { _environment = environment; _httpConfiguration = httpConfiguration; _httpExecutionContext = httpExecutionContext; } /** * {@inheritDoc} */ @Override
public CompletionStage<Result> render(final Http.Context context, final ParSeqTaskStore parSeqTaskStore) {
linkedin/play-parseq
src/core/java/app/com/linkedin/playparseq/j/PlayParSeqImpl.java
// Path: src/core/java/app/com/linkedin/playparseq/j/stores/ParSeqTaskStore.java // public interface ParSeqTaskStore { // // /** // * The method put puts ParSeq Task into store. // * // * @param context The HTTP Context // * @param task The ParSeq Task // */ // void put(final Http.Context context, final Task<?> task); // // /** // * The method get gets all Tasks from one request out of store as an unmodifiable Set. // * // * @param context The HTTP Context // * @return A set of Tasks // */ // Set<Task<?>> get(final Http.Context context); // // /** // * The method initialize sets up the store properly for put/get APIs. // * // * @param context The origin HTTP Context // * @return The HTTP Context with store set up properly // */ // Http.Context initialize(final Http.Context context); // // }
import com.linkedin.parseq.Engine; import com.linkedin.parseq.Task; import com.linkedin.parseq.promise.Promises; import com.linkedin.parseq.promise.SettablePromise; import com.linkedin.playparseq.j.stores.ParSeqTaskStore; import com.linkedin.playparseq.utils.PlayParSeqHelper; import java.util.concurrent.Callable; import java.util.concurrent.CompletionStage; import javax.inject.Inject; import javax.inject.Singleton; import play.libs.concurrent.HttpExecutionContext; import play.mvc.Http;
/* * Copyright 2015 LinkedIn Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ package com.linkedin.playparseq.j; /** * The class PlayParSeqImpl is an implementation of the interface {@link PlayParSeq} with the help from the class * {@link PlayParSeqHelper}. * * @author Yinan Ding (yding@linkedin.com) */ @Singleton public class PlayParSeqImpl extends PlayParSeqHelper implements PlayParSeq { /** * The field DEFAULT_TASK_NAME is the default name of ParSeq Task. */ public final static String DEFAULT_TASK_NAME = "fromPlayCompletionStage"; /** * The field _engine is a ParSeq Engine for running ParSeq Task. */ private final Engine _engine; /** * The field _parSeqTaskStore is a {@link ParSeqTaskStore} for storing ParSeq Tasks. */
// Path: src/core/java/app/com/linkedin/playparseq/j/stores/ParSeqTaskStore.java // public interface ParSeqTaskStore { // // /** // * The method put puts ParSeq Task into store. // * // * @param context The HTTP Context // * @param task The ParSeq Task // */ // void put(final Http.Context context, final Task<?> task); // // /** // * The method get gets all Tasks from one request out of store as an unmodifiable Set. // * // * @param context The HTTP Context // * @return A set of Tasks // */ // Set<Task<?>> get(final Http.Context context); // // /** // * The method initialize sets up the store properly for put/get APIs. // * // * @param context The origin HTTP Context // * @return The HTTP Context with store set up properly // */ // Http.Context initialize(final Http.Context context); // // } // Path: src/core/java/app/com/linkedin/playparseq/j/PlayParSeqImpl.java import com.linkedin.parseq.Engine; import com.linkedin.parseq.Task; import com.linkedin.parseq.promise.Promises; import com.linkedin.parseq.promise.SettablePromise; import com.linkedin.playparseq.j.stores.ParSeqTaskStore; import com.linkedin.playparseq.utils.PlayParSeqHelper; import java.util.concurrent.Callable; import java.util.concurrent.CompletionStage; import javax.inject.Inject; import javax.inject.Singleton; import play.libs.concurrent.HttpExecutionContext; import play.mvc.Http; /* * Copyright 2015 LinkedIn Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ package com.linkedin.playparseq.j; /** * The class PlayParSeqImpl is an implementation of the interface {@link PlayParSeq} with the help from the class * {@link PlayParSeqHelper}. * * @author Yinan Ding (yding@linkedin.com) */ @Singleton public class PlayParSeqImpl extends PlayParSeqHelper implements PlayParSeq { /** * The field DEFAULT_TASK_NAME is the default name of ParSeq Task. */ public final static String DEFAULT_TASK_NAME = "fromPlayCompletionStage"; /** * The field _engine is a ParSeq Engine for running ParSeq Task. */ private final Engine _engine; /** * The field _parSeqTaskStore is a {@link ParSeqTaskStore} for storing ParSeq Tasks. */
private final ParSeqTaskStore _parSeqTaskStore;
linkedin/play-parseq
src/trace/java/app/com/linkedin/playparseq/trace/j/ParSeqTraceBuilderImpl.java
// Path: src/core/java/app/com/linkedin/playparseq/j/stores/ParSeqTaskStore.java // public interface ParSeqTaskStore { // // /** // * The method put puts ParSeq Task into store. // * // * @param context The HTTP Context // * @param task The ParSeq Task // */ // void put(final Http.Context context, final Task<?> task); // // /** // * The method get gets all Tasks from one request out of store as an unmodifiable Set. // * // * @param context The HTTP Context // * @return A set of Tasks // */ // Set<Task<?>> get(final Http.Context context); // // /** // * The method initialize sets up the store properly for put/get APIs. // * // * @param context The origin HTTP Context // * @return The HTTP Context with store set up properly // */ // Http.Context initialize(final Http.Context context); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/renderers/ParSeqTraceRenderer.java // public interface ParSeqTraceRenderer { // // /** // * The method render generates a {@code CompletionStage<Result>} from {@link ParSeqTaskStore}. // * // * @param context The HTTP Context // * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks // * @return The CompletionStage of Result // */ // CompletionStage<Result> render(final Http.Context context, final ParSeqTaskStore parSeqTaskStore); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/sensors/ParSeqTraceSensor.java // public interface ParSeqTraceSensor { // // /** // * The method isEnabled decides whether ParSeq Trace is enabled or not from {@link Http.Context} and // * {@link ParSeqTaskStore}. // * // * @param context The HTTP Context // * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks // * @return The decision // */ // boolean isEnabled(final Http.Context context, final ParSeqTaskStore parSeqTaskStore); // // }
import akka.stream.Materializer; import com.linkedin.parseq.Task; import com.linkedin.playparseq.j.stores.ParSeqTaskStore; import com.linkedin.playparseq.trace.j.renderers.ParSeqTraceRenderer; import com.linkedin.playparseq.trace.j.sensors.ParSeqTraceSensor; import com.linkedin.playparseq.trace.utils.PlayParSeqTraceHelper; import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; import java.util.stream.Collectors; import javax.inject.Inject; import javax.inject.Singleton; import play.libs.concurrent.HttpExecutionContext; import play.mvc.Http; import play.mvc.Result;
/* * Copyright 2015 LinkedIn Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ package com.linkedin.playparseq.trace.j; /** * The class ParSeqTraceBuilderImpl is an implementation of {@link ParSeqTraceBuilder} with the help from the class * {@link PlayParSeqTraceHelper}. * * @author Yinan Ding (yding@linkedin.com) */ @Singleton public class ParSeqTraceBuilderImpl extends PlayParSeqTraceHelper implements ParSeqTraceBuilder { /** * The field _materializer is an Akka Materializer for consuming result body stream. */ private final Materializer _materializer; /** * The field _httpExecutionContext is a {@link HttpExecutionContext} for setting Java async task's executor. */ private final HttpExecutionContext _httpExecutionContext; /** * The constructor injects the Materializer. * * @param materializer The injected Materializer component * @param httpExecutionContext The injected HttpExecutionContext component */ @Inject public ParSeqTraceBuilderImpl(final Materializer materializer, final HttpExecutionContext httpExecutionContext) { _materializer = materializer; _httpExecutionContext = httpExecutionContext; } /** * {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public CompletionStage<Result> build(final Http.Context context, final CompletionStage<Result> origin,
// Path: src/core/java/app/com/linkedin/playparseq/j/stores/ParSeqTaskStore.java // public interface ParSeqTaskStore { // // /** // * The method put puts ParSeq Task into store. // * // * @param context The HTTP Context // * @param task The ParSeq Task // */ // void put(final Http.Context context, final Task<?> task); // // /** // * The method get gets all Tasks from one request out of store as an unmodifiable Set. // * // * @param context The HTTP Context // * @return A set of Tasks // */ // Set<Task<?>> get(final Http.Context context); // // /** // * The method initialize sets up the store properly for put/get APIs. // * // * @param context The origin HTTP Context // * @return The HTTP Context with store set up properly // */ // Http.Context initialize(final Http.Context context); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/renderers/ParSeqTraceRenderer.java // public interface ParSeqTraceRenderer { // // /** // * The method render generates a {@code CompletionStage<Result>} from {@link ParSeqTaskStore}. // * // * @param context The HTTP Context // * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks // * @return The CompletionStage of Result // */ // CompletionStage<Result> render(final Http.Context context, final ParSeqTaskStore parSeqTaskStore); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/sensors/ParSeqTraceSensor.java // public interface ParSeqTraceSensor { // // /** // * The method isEnabled decides whether ParSeq Trace is enabled or not from {@link Http.Context} and // * {@link ParSeqTaskStore}. // * // * @param context The HTTP Context // * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks // * @return The decision // */ // boolean isEnabled(final Http.Context context, final ParSeqTaskStore parSeqTaskStore); // // } // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/ParSeqTraceBuilderImpl.java import akka.stream.Materializer; import com.linkedin.parseq.Task; import com.linkedin.playparseq.j.stores.ParSeqTaskStore; import com.linkedin.playparseq.trace.j.renderers.ParSeqTraceRenderer; import com.linkedin.playparseq.trace.j.sensors.ParSeqTraceSensor; import com.linkedin.playparseq.trace.utils.PlayParSeqTraceHelper; import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; import java.util.stream.Collectors; import javax.inject.Inject; import javax.inject.Singleton; import play.libs.concurrent.HttpExecutionContext; import play.mvc.Http; import play.mvc.Result; /* * Copyright 2015 LinkedIn Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ package com.linkedin.playparseq.trace.j; /** * The class ParSeqTraceBuilderImpl is an implementation of {@link ParSeqTraceBuilder} with the help from the class * {@link PlayParSeqTraceHelper}. * * @author Yinan Ding (yding@linkedin.com) */ @Singleton public class ParSeqTraceBuilderImpl extends PlayParSeqTraceHelper implements ParSeqTraceBuilder { /** * The field _materializer is an Akka Materializer for consuming result body stream. */ private final Materializer _materializer; /** * The field _httpExecutionContext is a {@link HttpExecutionContext} for setting Java async task's executor. */ private final HttpExecutionContext _httpExecutionContext; /** * The constructor injects the Materializer. * * @param materializer The injected Materializer component * @param httpExecutionContext The injected HttpExecutionContext component */ @Inject public ParSeqTraceBuilderImpl(final Materializer materializer, final HttpExecutionContext httpExecutionContext) { _materializer = materializer; _httpExecutionContext = httpExecutionContext; } /** * {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public CompletionStage<Result> build(final Http.Context context, final CompletionStage<Result> origin,
final ParSeqTaskStore parSeqTaskStore, final ParSeqTraceSensor parSeqTraceSensor,
linkedin/play-parseq
src/trace/java/app/com/linkedin/playparseq/trace/j/ParSeqTraceBuilderImpl.java
// Path: src/core/java/app/com/linkedin/playparseq/j/stores/ParSeqTaskStore.java // public interface ParSeqTaskStore { // // /** // * The method put puts ParSeq Task into store. // * // * @param context The HTTP Context // * @param task The ParSeq Task // */ // void put(final Http.Context context, final Task<?> task); // // /** // * The method get gets all Tasks from one request out of store as an unmodifiable Set. // * // * @param context The HTTP Context // * @return A set of Tasks // */ // Set<Task<?>> get(final Http.Context context); // // /** // * The method initialize sets up the store properly for put/get APIs. // * // * @param context The origin HTTP Context // * @return The HTTP Context with store set up properly // */ // Http.Context initialize(final Http.Context context); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/renderers/ParSeqTraceRenderer.java // public interface ParSeqTraceRenderer { // // /** // * The method render generates a {@code CompletionStage<Result>} from {@link ParSeqTaskStore}. // * // * @param context The HTTP Context // * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks // * @return The CompletionStage of Result // */ // CompletionStage<Result> render(final Http.Context context, final ParSeqTaskStore parSeqTaskStore); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/sensors/ParSeqTraceSensor.java // public interface ParSeqTraceSensor { // // /** // * The method isEnabled decides whether ParSeq Trace is enabled or not from {@link Http.Context} and // * {@link ParSeqTaskStore}. // * // * @param context The HTTP Context // * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks // * @return The decision // */ // boolean isEnabled(final Http.Context context, final ParSeqTaskStore parSeqTaskStore); // // }
import akka.stream.Materializer; import com.linkedin.parseq.Task; import com.linkedin.playparseq.j.stores.ParSeqTaskStore; import com.linkedin.playparseq.trace.j.renderers.ParSeqTraceRenderer; import com.linkedin.playparseq.trace.j.sensors.ParSeqTraceSensor; import com.linkedin.playparseq.trace.utils.PlayParSeqTraceHelper; import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; import java.util.stream.Collectors; import javax.inject.Inject; import javax.inject.Singleton; import play.libs.concurrent.HttpExecutionContext; import play.mvc.Http; import play.mvc.Result;
/* * Copyright 2015 LinkedIn Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ package com.linkedin.playparseq.trace.j; /** * The class ParSeqTraceBuilderImpl is an implementation of {@link ParSeqTraceBuilder} with the help from the class * {@link PlayParSeqTraceHelper}. * * @author Yinan Ding (yding@linkedin.com) */ @Singleton public class ParSeqTraceBuilderImpl extends PlayParSeqTraceHelper implements ParSeqTraceBuilder { /** * The field _materializer is an Akka Materializer for consuming result body stream. */ private final Materializer _materializer; /** * The field _httpExecutionContext is a {@link HttpExecutionContext} for setting Java async task's executor. */ private final HttpExecutionContext _httpExecutionContext; /** * The constructor injects the Materializer. * * @param materializer The injected Materializer component * @param httpExecutionContext The injected HttpExecutionContext component */ @Inject public ParSeqTraceBuilderImpl(final Materializer materializer, final HttpExecutionContext httpExecutionContext) { _materializer = materializer; _httpExecutionContext = httpExecutionContext; } /** * {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public CompletionStage<Result> build(final Http.Context context, final CompletionStage<Result> origin,
// Path: src/core/java/app/com/linkedin/playparseq/j/stores/ParSeqTaskStore.java // public interface ParSeqTaskStore { // // /** // * The method put puts ParSeq Task into store. // * // * @param context The HTTP Context // * @param task The ParSeq Task // */ // void put(final Http.Context context, final Task<?> task); // // /** // * The method get gets all Tasks from one request out of store as an unmodifiable Set. // * // * @param context The HTTP Context // * @return A set of Tasks // */ // Set<Task<?>> get(final Http.Context context); // // /** // * The method initialize sets up the store properly for put/get APIs. // * // * @param context The origin HTTP Context // * @return The HTTP Context with store set up properly // */ // Http.Context initialize(final Http.Context context); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/renderers/ParSeqTraceRenderer.java // public interface ParSeqTraceRenderer { // // /** // * The method render generates a {@code CompletionStage<Result>} from {@link ParSeqTaskStore}. // * // * @param context The HTTP Context // * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks // * @return The CompletionStage of Result // */ // CompletionStage<Result> render(final Http.Context context, final ParSeqTaskStore parSeqTaskStore); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/sensors/ParSeqTraceSensor.java // public interface ParSeqTraceSensor { // // /** // * The method isEnabled decides whether ParSeq Trace is enabled or not from {@link Http.Context} and // * {@link ParSeqTaskStore}. // * // * @param context The HTTP Context // * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks // * @return The decision // */ // boolean isEnabled(final Http.Context context, final ParSeqTaskStore parSeqTaskStore); // // } // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/ParSeqTraceBuilderImpl.java import akka.stream.Materializer; import com.linkedin.parseq.Task; import com.linkedin.playparseq.j.stores.ParSeqTaskStore; import com.linkedin.playparseq.trace.j.renderers.ParSeqTraceRenderer; import com.linkedin.playparseq.trace.j.sensors.ParSeqTraceSensor; import com.linkedin.playparseq.trace.utils.PlayParSeqTraceHelper; import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; import java.util.stream.Collectors; import javax.inject.Inject; import javax.inject.Singleton; import play.libs.concurrent.HttpExecutionContext; import play.mvc.Http; import play.mvc.Result; /* * Copyright 2015 LinkedIn Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ package com.linkedin.playparseq.trace.j; /** * The class ParSeqTraceBuilderImpl is an implementation of {@link ParSeqTraceBuilder} with the help from the class * {@link PlayParSeqTraceHelper}. * * @author Yinan Ding (yding@linkedin.com) */ @Singleton public class ParSeqTraceBuilderImpl extends PlayParSeqTraceHelper implements ParSeqTraceBuilder { /** * The field _materializer is an Akka Materializer for consuming result body stream. */ private final Materializer _materializer; /** * The field _httpExecutionContext is a {@link HttpExecutionContext} for setting Java async task's executor. */ private final HttpExecutionContext _httpExecutionContext; /** * The constructor injects the Materializer. * * @param materializer The injected Materializer component * @param httpExecutionContext The injected HttpExecutionContext component */ @Inject public ParSeqTraceBuilderImpl(final Materializer materializer, final HttpExecutionContext httpExecutionContext) { _materializer = materializer; _httpExecutionContext = httpExecutionContext; } /** * {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public CompletionStage<Result> build(final Http.Context context, final CompletionStage<Result> origin,
final ParSeqTaskStore parSeqTaskStore, final ParSeqTraceSensor parSeqTraceSensor,
linkedin/play-parseq
src/trace/java/app/com/linkedin/playparseq/trace/j/ParSeqTraceBuilderImpl.java
// Path: src/core/java/app/com/linkedin/playparseq/j/stores/ParSeqTaskStore.java // public interface ParSeqTaskStore { // // /** // * The method put puts ParSeq Task into store. // * // * @param context The HTTP Context // * @param task The ParSeq Task // */ // void put(final Http.Context context, final Task<?> task); // // /** // * The method get gets all Tasks from one request out of store as an unmodifiable Set. // * // * @param context The HTTP Context // * @return A set of Tasks // */ // Set<Task<?>> get(final Http.Context context); // // /** // * The method initialize sets up the store properly for put/get APIs. // * // * @param context The origin HTTP Context // * @return The HTTP Context with store set up properly // */ // Http.Context initialize(final Http.Context context); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/renderers/ParSeqTraceRenderer.java // public interface ParSeqTraceRenderer { // // /** // * The method render generates a {@code CompletionStage<Result>} from {@link ParSeqTaskStore}. // * // * @param context The HTTP Context // * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks // * @return The CompletionStage of Result // */ // CompletionStage<Result> render(final Http.Context context, final ParSeqTaskStore parSeqTaskStore); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/sensors/ParSeqTraceSensor.java // public interface ParSeqTraceSensor { // // /** // * The method isEnabled decides whether ParSeq Trace is enabled or not from {@link Http.Context} and // * {@link ParSeqTaskStore}. // * // * @param context The HTTP Context // * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks // * @return The decision // */ // boolean isEnabled(final Http.Context context, final ParSeqTaskStore parSeqTaskStore); // // }
import akka.stream.Materializer; import com.linkedin.parseq.Task; import com.linkedin.playparseq.j.stores.ParSeqTaskStore; import com.linkedin.playparseq.trace.j.renderers.ParSeqTraceRenderer; import com.linkedin.playparseq.trace.j.sensors.ParSeqTraceSensor; import com.linkedin.playparseq.trace.utils.PlayParSeqTraceHelper; import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; import java.util.stream.Collectors; import javax.inject.Inject; import javax.inject.Singleton; import play.libs.concurrent.HttpExecutionContext; import play.mvc.Http; import play.mvc.Result;
/* * Copyright 2015 LinkedIn Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ package com.linkedin.playparseq.trace.j; /** * The class ParSeqTraceBuilderImpl is an implementation of {@link ParSeqTraceBuilder} with the help from the class * {@link PlayParSeqTraceHelper}. * * @author Yinan Ding (yding@linkedin.com) */ @Singleton public class ParSeqTraceBuilderImpl extends PlayParSeqTraceHelper implements ParSeqTraceBuilder { /** * The field _materializer is an Akka Materializer for consuming result body stream. */ private final Materializer _materializer; /** * The field _httpExecutionContext is a {@link HttpExecutionContext} for setting Java async task's executor. */ private final HttpExecutionContext _httpExecutionContext; /** * The constructor injects the Materializer. * * @param materializer The injected Materializer component * @param httpExecutionContext The injected HttpExecutionContext component */ @Inject public ParSeqTraceBuilderImpl(final Materializer materializer, final HttpExecutionContext httpExecutionContext) { _materializer = materializer; _httpExecutionContext = httpExecutionContext; } /** * {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public CompletionStage<Result> build(final Http.Context context, final CompletionStage<Result> origin, final ParSeqTaskStore parSeqTaskStore, final ParSeqTraceSensor parSeqTraceSensor,
// Path: src/core/java/app/com/linkedin/playparseq/j/stores/ParSeqTaskStore.java // public interface ParSeqTaskStore { // // /** // * The method put puts ParSeq Task into store. // * // * @param context The HTTP Context // * @param task The ParSeq Task // */ // void put(final Http.Context context, final Task<?> task); // // /** // * The method get gets all Tasks from one request out of store as an unmodifiable Set. // * // * @param context The HTTP Context // * @return A set of Tasks // */ // Set<Task<?>> get(final Http.Context context); // // /** // * The method initialize sets up the store properly for put/get APIs. // * // * @param context The origin HTTP Context // * @return The HTTP Context with store set up properly // */ // Http.Context initialize(final Http.Context context); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/renderers/ParSeqTraceRenderer.java // public interface ParSeqTraceRenderer { // // /** // * The method render generates a {@code CompletionStage<Result>} from {@link ParSeqTaskStore}. // * // * @param context The HTTP Context // * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks // * @return The CompletionStage of Result // */ // CompletionStage<Result> render(final Http.Context context, final ParSeqTaskStore parSeqTaskStore); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/sensors/ParSeqTraceSensor.java // public interface ParSeqTraceSensor { // // /** // * The method isEnabled decides whether ParSeq Trace is enabled or not from {@link Http.Context} and // * {@link ParSeqTaskStore}. // * // * @param context The HTTP Context // * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks // * @return The decision // */ // boolean isEnabled(final Http.Context context, final ParSeqTaskStore parSeqTaskStore); // // } // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/ParSeqTraceBuilderImpl.java import akka.stream.Materializer; import com.linkedin.parseq.Task; import com.linkedin.playparseq.j.stores.ParSeqTaskStore; import com.linkedin.playparseq.trace.j.renderers.ParSeqTraceRenderer; import com.linkedin.playparseq.trace.j.sensors.ParSeqTraceSensor; import com.linkedin.playparseq.trace.utils.PlayParSeqTraceHelper; import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; import java.util.stream.Collectors; import javax.inject.Inject; import javax.inject.Singleton; import play.libs.concurrent.HttpExecutionContext; import play.mvc.Http; import play.mvc.Result; /* * Copyright 2015 LinkedIn Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ package com.linkedin.playparseq.trace.j; /** * The class ParSeqTraceBuilderImpl is an implementation of {@link ParSeqTraceBuilder} with the help from the class * {@link PlayParSeqTraceHelper}. * * @author Yinan Ding (yding@linkedin.com) */ @Singleton public class ParSeqTraceBuilderImpl extends PlayParSeqTraceHelper implements ParSeqTraceBuilder { /** * The field _materializer is an Akka Materializer for consuming result body stream. */ private final Materializer _materializer; /** * The field _httpExecutionContext is a {@link HttpExecutionContext} for setting Java async task's executor. */ private final HttpExecutionContext _httpExecutionContext; /** * The constructor injects the Materializer. * * @param materializer The injected Materializer component * @param httpExecutionContext The injected HttpExecutionContext component */ @Inject public ParSeqTraceBuilderImpl(final Materializer materializer, final HttpExecutionContext httpExecutionContext) { _materializer = materializer; _httpExecutionContext = httpExecutionContext; } /** * {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public CompletionStage<Result> build(final Http.Context context, final CompletionStage<Result> origin, final ParSeqTaskStore parSeqTaskStore, final ParSeqTraceSensor parSeqTraceSensor,
final ParSeqTraceRenderer parSeqTraceRenderer) {
linkedin/play-parseq
src/trace/java/app/com/linkedin/playparseq/trace/j/ParSeqTraceAction.java
// Path: src/core/java/app/com/linkedin/playparseq/j/stores/ParSeqTaskStore.java // public interface ParSeqTaskStore { // // /** // * The method put puts ParSeq Task into store. // * // * @param context The HTTP Context // * @param task The ParSeq Task // */ // void put(final Http.Context context, final Task<?> task); // // /** // * The method get gets all Tasks from one request out of store as an unmodifiable Set. // * // * @param context The HTTP Context // * @return A set of Tasks // */ // Set<Task<?>> get(final Http.Context context); // // /** // * The method initialize sets up the store properly for put/get APIs. // * // * @param context The origin HTTP Context // * @return The HTTP Context with store set up properly // */ // Http.Context initialize(final Http.Context context); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/renderers/ParSeqTraceRenderer.java // public interface ParSeqTraceRenderer { // // /** // * The method render generates a {@code CompletionStage<Result>} from {@link ParSeqTaskStore}. // * // * @param context The HTTP Context // * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks // * @return The CompletionStage of Result // */ // CompletionStage<Result> render(final Http.Context context, final ParSeqTaskStore parSeqTaskStore); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/sensors/ParSeqTraceSensor.java // public interface ParSeqTraceSensor { // // /** // * The method isEnabled decides whether ParSeq Trace is enabled or not from {@link Http.Context} and // * {@link ParSeqTaskStore}. // * // * @param context The HTTP Context // * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks // * @return The decision // */ // boolean isEnabled(final Http.Context context, final ParSeqTaskStore parSeqTaskStore); // // }
import com.linkedin.playparseq.j.stores.ParSeqTaskStore; import com.linkedin.playparseq.trace.j.renderers.ParSeqTraceRenderer; import com.linkedin.playparseq.trace.j.sensors.ParSeqTraceSensor; import java.util.concurrent.CompletionStage; import javax.inject.Inject; import play.mvc.Action.Simple; import play.mvc.Http; import play.mvc.Result;
/* * Copyright 2015 LinkedIn Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ package com.linkedin.playparseq.trace.j; /** * The class ParSeqTraceAction is an Action composition which sets up a normal HTTP Context with {@link ParSeqTaskStore} * in order to put ParSeq Task into store for retrieving all Tasks within the scope of one request when building ParSeq * Trace. * And it also composes with {@link ParSeqTraceBuilder} to hand origin Result off in order to determine whether to show * ParSeq Trace data or the origin Result, if so generate the ParSeq Trace Result. * * @author Yinan Ding (yding@linkedin.com) */ public class ParSeqTraceAction extends Simple { /** * The field _parSeqTaskStore is a {@link ParSeqTaskStore} for getting ParSeq Tasks. */ private final ParSeqTaskStore _parSeqTaskStore; /** * The field _parSeqTraceBuilder is a {@link ParSeqTraceBuilder} for building ParSeq Trace. */ private final ParSeqTraceBuilder _parSeqTraceBuilder; /** * The field _parSeqTraceSensor is a {@link ParSeqTraceSensor} for deciding whether ParSeq Trace is enabled or not. */
// Path: src/core/java/app/com/linkedin/playparseq/j/stores/ParSeqTaskStore.java // public interface ParSeqTaskStore { // // /** // * The method put puts ParSeq Task into store. // * // * @param context The HTTP Context // * @param task The ParSeq Task // */ // void put(final Http.Context context, final Task<?> task); // // /** // * The method get gets all Tasks from one request out of store as an unmodifiable Set. // * // * @param context The HTTP Context // * @return A set of Tasks // */ // Set<Task<?>> get(final Http.Context context); // // /** // * The method initialize sets up the store properly for put/get APIs. // * // * @param context The origin HTTP Context // * @return The HTTP Context with store set up properly // */ // Http.Context initialize(final Http.Context context); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/renderers/ParSeqTraceRenderer.java // public interface ParSeqTraceRenderer { // // /** // * The method render generates a {@code CompletionStage<Result>} from {@link ParSeqTaskStore}. // * // * @param context The HTTP Context // * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks // * @return The CompletionStage of Result // */ // CompletionStage<Result> render(final Http.Context context, final ParSeqTaskStore parSeqTaskStore); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/sensors/ParSeqTraceSensor.java // public interface ParSeqTraceSensor { // // /** // * The method isEnabled decides whether ParSeq Trace is enabled or not from {@link Http.Context} and // * {@link ParSeqTaskStore}. // * // * @param context The HTTP Context // * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks // * @return The decision // */ // boolean isEnabled(final Http.Context context, final ParSeqTaskStore parSeqTaskStore); // // } // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/ParSeqTraceAction.java import com.linkedin.playparseq.j.stores.ParSeqTaskStore; import com.linkedin.playparseq.trace.j.renderers.ParSeqTraceRenderer; import com.linkedin.playparseq.trace.j.sensors.ParSeqTraceSensor; import java.util.concurrent.CompletionStage; import javax.inject.Inject; import play.mvc.Action.Simple; import play.mvc.Http; import play.mvc.Result; /* * Copyright 2015 LinkedIn Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ package com.linkedin.playparseq.trace.j; /** * The class ParSeqTraceAction is an Action composition which sets up a normal HTTP Context with {@link ParSeqTaskStore} * in order to put ParSeq Task into store for retrieving all Tasks within the scope of one request when building ParSeq * Trace. * And it also composes with {@link ParSeqTraceBuilder} to hand origin Result off in order to determine whether to show * ParSeq Trace data or the origin Result, if so generate the ParSeq Trace Result. * * @author Yinan Ding (yding@linkedin.com) */ public class ParSeqTraceAction extends Simple { /** * The field _parSeqTaskStore is a {@link ParSeqTaskStore} for getting ParSeq Tasks. */ private final ParSeqTaskStore _parSeqTaskStore; /** * The field _parSeqTraceBuilder is a {@link ParSeqTraceBuilder} for building ParSeq Trace. */ private final ParSeqTraceBuilder _parSeqTraceBuilder; /** * The field _parSeqTraceSensor is a {@link ParSeqTraceSensor} for deciding whether ParSeq Trace is enabled or not. */
private final ParSeqTraceSensor _parSeqTraceSensor;
linkedin/play-parseq
src/trace/java/app/com/linkedin/playparseq/trace/j/ParSeqTraceAction.java
// Path: src/core/java/app/com/linkedin/playparseq/j/stores/ParSeqTaskStore.java // public interface ParSeqTaskStore { // // /** // * The method put puts ParSeq Task into store. // * // * @param context The HTTP Context // * @param task The ParSeq Task // */ // void put(final Http.Context context, final Task<?> task); // // /** // * The method get gets all Tasks from one request out of store as an unmodifiable Set. // * // * @param context The HTTP Context // * @return A set of Tasks // */ // Set<Task<?>> get(final Http.Context context); // // /** // * The method initialize sets up the store properly for put/get APIs. // * // * @param context The origin HTTP Context // * @return The HTTP Context with store set up properly // */ // Http.Context initialize(final Http.Context context); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/renderers/ParSeqTraceRenderer.java // public interface ParSeqTraceRenderer { // // /** // * The method render generates a {@code CompletionStage<Result>} from {@link ParSeqTaskStore}. // * // * @param context The HTTP Context // * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks // * @return The CompletionStage of Result // */ // CompletionStage<Result> render(final Http.Context context, final ParSeqTaskStore parSeqTaskStore); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/sensors/ParSeqTraceSensor.java // public interface ParSeqTraceSensor { // // /** // * The method isEnabled decides whether ParSeq Trace is enabled or not from {@link Http.Context} and // * {@link ParSeqTaskStore}. // * // * @param context The HTTP Context // * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks // * @return The decision // */ // boolean isEnabled(final Http.Context context, final ParSeqTaskStore parSeqTaskStore); // // }
import com.linkedin.playparseq.j.stores.ParSeqTaskStore; import com.linkedin.playparseq.trace.j.renderers.ParSeqTraceRenderer; import com.linkedin.playparseq.trace.j.sensors.ParSeqTraceSensor; import java.util.concurrent.CompletionStage; import javax.inject.Inject; import play.mvc.Action.Simple; import play.mvc.Http; import play.mvc.Result;
/* * Copyright 2015 LinkedIn Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ package com.linkedin.playparseq.trace.j; /** * The class ParSeqTraceAction is an Action composition which sets up a normal HTTP Context with {@link ParSeqTaskStore} * in order to put ParSeq Task into store for retrieving all Tasks within the scope of one request when building ParSeq * Trace. * And it also composes with {@link ParSeqTraceBuilder} to hand origin Result off in order to determine whether to show * ParSeq Trace data or the origin Result, if so generate the ParSeq Trace Result. * * @author Yinan Ding (yding@linkedin.com) */ public class ParSeqTraceAction extends Simple { /** * The field _parSeqTaskStore is a {@link ParSeqTaskStore} for getting ParSeq Tasks. */ private final ParSeqTaskStore _parSeqTaskStore; /** * The field _parSeqTraceBuilder is a {@link ParSeqTraceBuilder} for building ParSeq Trace. */ private final ParSeqTraceBuilder _parSeqTraceBuilder; /** * The field _parSeqTraceSensor is a {@link ParSeqTraceSensor} for deciding whether ParSeq Trace is enabled or not. */ private final ParSeqTraceSensor _parSeqTraceSensor; /** * The field _parSeqTraceRenderer is a {@link ParSeqTraceRenderer} for generating ParSeq Trace. */
// Path: src/core/java/app/com/linkedin/playparseq/j/stores/ParSeqTaskStore.java // public interface ParSeqTaskStore { // // /** // * The method put puts ParSeq Task into store. // * // * @param context The HTTP Context // * @param task The ParSeq Task // */ // void put(final Http.Context context, final Task<?> task); // // /** // * The method get gets all Tasks from one request out of store as an unmodifiable Set. // * // * @param context The HTTP Context // * @return A set of Tasks // */ // Set<Task<?>> get(final Http.Context context); // // /** // * The method initialize sets up the store properly for put/get APIs. // * // * @param context The origin HTTP Context // * @return The HTTP Context with store set up properly // */ // Http.Context initialize(final Http.Context context); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/renderers/ParSeqTraceRenderer.java // public interface ParSeqTraceRenderer { // // /** // * The method render generates a {@code CompletionStage<Result>} from {@link ParSeqTaskStore}. // * // * @param context The HTTP Context // * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks // * @return The CompletionStage of Result // */ // CompletionStage<Result> render(final Http.Context context, final ParSeqTaskStore parSeqTaskStore); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/sensors/ParSeqTraceSensor.java // public interface ParSeqTraceSensor { // // /** // * The method isEnabled decides whether ParSeq Trace is enabled or not from {@link Http.Context} and // * {@link ParSeqTaskStore}. // * // * @param context The HTTP Context // * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks // * @return The decision // */ // boolean isEnabled(final Http.Context context, final ParSeqTaskStore parSeqTaskStore); // // } // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/ParSeqTraceAction.java import com.linkedin.playparseq.j.stores.ParSeqTaskStore; import com.linkedin.playparseq.trace.j.renderers.ParSeqTraceRenderer; import com.linkedin.playparseq.trace.j.sensors.ParSeqTraceSensor; import java.util.concurrent.CompletionStage; import javax.inject.Inject; import play.mvc.Action.Simple; import play.mvc.Http; import play.mvc.Result; /* * Copyright 2015 LinkedIn Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ package com.linkedin.playparseq.trace.j; /** * The class ParSeqTraceAction is an Action composition which sets up a normal HTTP Context with {@link ParSeqTaskStore} * in order to put ParSeq Task into store for retrieving all Tasks within the scope of one request when building ParSeq * Trace. * And it also composes with {@link ParSeqTraceBuilder} to hand origin Result off in order to determine whether to show * ParSeq Trace data or the origin Result, if so generate the ParSeq Trace Result. * * @author Yinan Ding (yding@linkedin.com) */ public class ParSeqTraceAction extends Simple { /** * The field _parSeqTaskStore is a {@link ParSeqTaskStore} for getting ParSeq Tasks. */ private final ParSeqTaskStore _parSeqTaskStore; /** * The field _parSeqTraceBuilder is a {@link ParSeqTraceBuilder} for building ParSeq Trace. */ private final ParSeqTraceBuilder _parSeqTraceBuilder; /** * The field _parSeqTraceSensor is a {@link ParSeqTraceSensor} for deciding whether ParSeq Trace is enabled or not. */ private final ParSeqTraceSensor _parSeqTraceSensor; /** * The field _parSeqTraceRenderer is a {@link ParSeqTraceRenderer} for generating ParSeq Trace. */
private final ParSeqTraceRenderer _parSeqTraceRenderer;
linkedin/play-parseq
sample/app/controllers/j/MultipleTasksSample.java
// Path: src/core/java/app/com/linkedin/playparseq/j/PlayParSeq.java // public interface PlayParSeq { // // /** // * The method toTask converts a {@code Callable<CompletionStage<T>>} to a ParSeq {@code Task<T>}. // * // * @param name The String which describes the Task and shows up in a trace // * @param f The Callable which returns a CompletionStage // * @param <T> The type parameter of the CompletionStage and the ParSeq Task // * @return The ParSeq Task // */ // <T> Task<T> toTask(final String name, final Callable<CompletionStage<T>> f); // // /** // * The method toTask converts a {@code Callable<CompletionStage<T>>} to a ParSeq {@code Task<T>}, which binds with a // * default name. // * // * @param f The Callable which returns a CompletionStage // * @param <T> The type parameter of the CompletionStage and the ParSeq Task // * @return The ParSeq Task // */ // <T> Task<T> toTask(final Callable<CompletionStage<T>> f); // // /** // * The method runTask executes a ParSeq {@code Task<T>} then generates a {@code CompletionStage<T>}, and puts into the // * store. // * // * @param context The HTTP Context // * @param task The ParSeq Task // * @param <T> The type parameter of the ParSeq Task and the CompletionStage // * @return The CompletionStage // */ // <T> CompletionStage<T> runTask(final Http.Context context, final Task<T> task); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/ParSeqTraceAction.java // public class ParSeqTraceAction extends Simple { // // /** // * The field _parSeqTaskStore is a {@link ParSeqTaskStore} for getting ParSeq Tasks. // */ // private final ParSeqTaskStore _parSeqTaskStore; // // /** // * The field _parSeqTraceBuilder is a {@link ParSeqTraceBuilder} for building ParSeq Trace. // */ // private final ParSeqTraceBuilder _parSeqTraceBuilder; // // /** // * The field _parSeqTraceSensor is a {@link ParSeqTraceSensor} for deciding whether ParSeq Trace is enabled or not. // */ // private final ParSeqTraceSensor _parSeqTraceSensor; // // /** // * The field _parSeqTraceRenderer is a {@link ParSeqTraceRenderer} for generating ParSeq Trace. // */ // private final ParSeqTraceRenderer _parSeqTraceRenderer; // // /** // * The constructor injects the {@link ParSeqTaskStore}, the {@link ParSeqTraceBuilder}, the {@link ParSeqTraceSensor} // * and the {@link ParSeqTraceRenderer}. // * // * @param parSeqTaskStore The injected {@link ParSeqTaskStore} component // * @param parSeqTraceBuilder The injected {@link ParSeqTraceBuilder} component // * @param parSeqTraceSensor The injected {@link ParSeqTraceSensor} component // * @param parSeqTraceRenderer The injected {@link ParSeqTraceRenderer} component // */ // @Inject // public ParSeqTraceAction(final ParSeqTaskStore parSeqTaskStore, final ParSeqTraceBuilder parSeqTraceBuilder, // final ParSeqTraceSensor parSeqTraceSensor, final ParSeqTraceRenderer parSeqTraceRenderer) { // super(); // _parSeqTaskStore = parSeqTaskStore; // _parSeqTraceBuilder = parSeqTraceBuilder; // _parSeqTraceSensor = parSeqTraceSensor; // _parSeqTraceRenderer = parSeqTraceRenderer; // } // // /** // * The method call sets up a normal HTTP Context with {@link ParSeqTaskStore} and composes with // * {@link ParSeqTraceBuilder} to build ParSeq Trace for the request. // * // * @param context The HTTP Context // * @return The CompletionStage of Result // */ // @Override // public CompletionStage<Result> call(final Http.Context context) { // Http.Context newContext = _parSeqTaskStore.initialize(context); // return _parSeqTraceBuilder.build(newContext, delegate.call(newContext), _parSeqTaskStore, _parSeqTraceSensor, // _parSeqTraceRenderer); // } // // }
import com.linkedin.parseq.Task; import com.linkedin.parseq.httpclient.HttpClient; import com.linkedin.playparseq.j.PlayParSeq; import com.linkedin.playparseq.trace.j.ParSeqTraceAction; import java.util.concurrent.CompletionStage; import javax.inject.Inject; import play.libs.ws.WSClient; import play.mvc.Controller; import play.mvc.Http; import play.mvc.Result; import play.mvc.With;
/* * Copyright 2015 LinkedIn Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ package controllers.j; /** * The class MultipleTasksSample is a Controller to show how to use {@link ParSeqTraceAction} for generating ParSeq * Trace of multiple ParSeq Tasks. * * @author Yinan Ding (yding@linkedin.com) */ public class MultipleTasksSample extends Controller { /** * The field _ws is the WSClient for making HTTP calls. */ private final WSClient _ws; /** * The field _playParSeq is a {@link PlayParSeq} for conversion and execution of ParSeq Tasks. */
// Path: src/core/java/app/com/linkedin/playparseq/j/PlayParSeq.java // public interface PlayParSeq { // // /** // * The method toTask converts a {@code Callable<CompletionStage<T>>} to a ParSeq {@code Task<T>}. // * // * @param name The String which describes the Task and shows up in a trace // * @param f The Callable which returns a CompletionStage // * @param <T> The type parameter of the CompletionStage and the ParSeq Task // * @return The ParSeq Task // */ // <T> Task<T> toTask(final String name, final Callable<CompletionStage<T>> f); // // /** // * The method toTask converts a {@code Callable<CompletionStage<T>>} to a ParSeq {@code Task<T>}, which binds with a // * default name. // * // * @param f The Callable which returns a CompletionStage // * @param <T> The type parameter of the CompletionStage and the ParSeq Task // * @return The ParSeq Task // */ // <T> Task<T> toTask(final Callable<CompletionStage<T>> f); // // /** // * The method runTask executes a ParSeq {@code Task<T>} then generates a {@code CompletionStage<T>}, and puts into the // * store. // * // * @param context The HTTP Context // * @param task The ParSeq Task // * @param <T> The type parameter of the ParSeq Task and the CompletionStage // * @return The CompletionStage // */ // <T> CompletionStage<T> runTask(final Http.Context context, final Task<T> task); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/ParSeqTraceAction.java // public class ParSeqTraceAction extends Simple { // // /** // * The field _parSeqTaskStore is a {@link ParSeqTaskStore} for getting ParSeq Tasks. // */ // private final ParSeqTaskStore _parSeqTaskStore; // // /** // * The field _parSeqTraceBuilder is a {@link ParSeqTraceBuilder} for building ParSeq Trace. // */ // private final ParSeqTraceBuilder _parSeqTraceBuilder; // // /** // * The field _parSeqTraceSensor is a {@link ParSeqTraceSensor} for deciding whether ParSeq Trace is enabled or not. // */ // private final ParSeqTraceSensor _parSeqTraceSensor; // // /** // * The field _parSeqTraceRenderer is a {@link ParSeqTraceRenderer} for generating ParSeq Trace. // */ // private final ParSeqTraceRenderer _parSeqTraceRenderer; // // /** // * The constructor injects the {@link ParSeqTaskStore}, the {@link ParSeqTraceBuilder}, the {@link ParSeqTraceSensor} // * and the {@link ParSeqTraceRenderer}. // * // * @param parSeqTaskStore The injected {@link ParSeqTaskStore} component // * @param parSeqTraceBuilder The injected {@link ParSeqTraceBuilder} component // * @param parSeqTraceSensor The injected {@link ParSeqTraceSensor} component // * @param parSeqTraceRenderer The injected {@link ParSeqTraceRenderer} component // */ // @Inject // public ParSeqTraceAction(final ParSeqTaskStore parSeqTaskStore, final ParSeqTraceBuilder parSeqTraceBuilder, // final ParSeqTraceSensor parSeqTraceSensor, final ParSeqTraceRenderer parSeqTraceRenderer) { // super(); // _parSeqTaskStore = parSeqTaskStore; // _parSeqTraceBuilder = parSeqTraceBuilder; // _parSeqTraceSensor = parSeqTraceSensor; // _parSeqTraceRenderer = parSeqTraceRenderer; // } // // /** // * The method call sets up a normal HTTP Context with {@link ParSeqTaskStore} and composes with // * {@link ParSeqTraceBuilder} to build ParSeq Trace for the request. // * // * @param context The HTTP Context // * @return The CompletionStage of Result // */ // @Override // public CompletionStage<Result> call(final Http.Context context) { // Http.Context newContext = _parSeqTaskStore.initialize(context); // return _parSeqTraceBuilder.build(newContext, delegate.call(newContext), _parSeqTaskStore, _parSeqTraceSensor, // _parSeqTraceRenderer); // } // // } // Path: sample/app/controllers/j/MultipleTasksSample.java import com.linkedin.parseq.Task; import com.linkedin.parseq.httpclient.HttpClient; import com.linkedin.playparseq.j.PlayParSeq; import com.linkedin.playparseq.trace.j.ParSeqTraceAction; import java.util.concurrent.CompletionStage; import javax.inject.Inject; import play.libs.ws.WSClient; import play.mvc.Controller; import play.mvc.Http; import play.mvc.Result; import play.mvc.With; /* * Copyright 2015 LinkedIn Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ package controllers.j; /** * The class MultipleTasksSample is a Controller to show how to use {@link ParSeqTraceAction} for generating ParSeq * Trace of multiple ParSeq Tasks. * * @author Yinan Ding (yding@linkedin.com) */ public class MultipleTasksSample extends Controller { /** * The field _ws is the WSClient for making HTTP calls. */ private final WSClient _ws; /** * The field _playParSeq is a {@link PlayParSeq} for conversion and execution of ParSeq Tasks. */
private final PlayParSeq _playParSeq;
linkedin/play-parseq
src/core/java/test/com/linkedin/playparseq/j/PlayParSeqImplTest.java
// Path: src/core/java/app/com/linkedin/playparseq/j/stores/ParSeqTaskStore.java // public interface ParSeqTaskStore { // // /** // * The method put puts ParSeq Task into store. // * // * @param context The HTTP Context // * @param task The ParSeq Task // */ // void put(final Http.Context context, final Task<?> task); // // /** // * The method get gets all Tasks from one request out of store as an unmodifiable Set. // * // * @param context The HTTP Context // * @return A set of Tasks // */ // Set<Task<?>> get(final Http.Context context); // // /** // * The method initialize sets up the store properly for put/get APIs. // * // * @param context The origin HTTP Context // * @return The HTTP Context with store set up properly // */ // Http.Context initialize(final Http.Context context); // // }
import com.linkedin.parseq.Engine; import com.linkedin.parseq.EngineBuilder; import com.linkedin.parseq.Task; import com.linkedin.playparseq.j.stores.ParSeqTaskStore; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; import java.util.concurrent.Executors; import java.util.concurrent.ExecutorService; import java.util.concurrent.ForkJoinPool; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import org.junit.After; import org.junit.Before; import org.junit.Test; import play.libs.concurrent.HttpExecutionContext; import play.mvc.Http; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when;
/* * Copyright 2015 LinkedIn Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ package com.linkedin.playparseq.j; /** * The class PlayParSeqImplTest is a test class for {@link PlayParSeqImpl}. * * @author Yinan Ding (yding@linkedin.com) */ public class PlayParSeqImplTest { /** * The field _playParSeqImpl is the {@link PlayParSeqImpl} to be tested. */ private PlayParSeqImpl _playParSeqImpl; /** * The field _engine is a ParSeq Engine for running ParSeq Task. */ private Engine _engine; /** * The field _taskScheduler is a task scheduler for ParSeq Engine. */ private ExecutorService _taskScheduler; /** * The field _timerScheduler is a timer scheduler for ParSeq Engine. */ private ScheduledExecutorService _timerScheduler; /** * The filed _mockContext is mocking Http.Context. */ private Http.Context _mockContext; /** * The field DEFAULT_TIME_OUT is the default time out value for retrieving data from a CompletionStage in the unit of * ms. */ public final static int DEFAULT_TIME_OUT = 5000; /** * The method setUp sets the ParSeq Engine and the {@link PlayParSeqImpl}. * * @see <a href="https://github.com/linkedin/parseq/wiki/User's-Guide#creating-an-engine">ParSeq Wiki</a> */ @Before public void setUp() { _taskScheduler = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() + 1); _timerScheduler = Executors.newSingleThreadScheduledExecutor(); _engine = new EngineBuilder().setTaskExecutor(_taskScheduler).setTimerScheduler(_timerScheduler).build();
// Path: src/core/java/app/com/linkedin/playparseq/j/stores/ParSeqTaskStore.java // public interface ParSeqTaskStore { // // /** // * The method put puts ParSeq Task into store. // * // * @param context The HTTP Context // * @param task The ParSeq Task // */ // void put(final Http.Context context, final Task<?> task); // // /** // * The method get gets all Tasks from one request out of store as an unmodifiable Set. // * // * @param context The HTTP Context // * @return A set of Tasks // */ // Set<Task<?>> get(final Http.Context context); // // /** // * The method initialize sets up the store properly for put/get APIs. // * // * @param context The origin HTTP Context // * @return The HTTP Context with store set up properly // */ // Http.Context initialize(final Http.Context context); // // } // Path: src/core/java/test/com/linkedin/playparseq/j/PlayParSeqImplTest.java import com.linkedin.parseq.Engine; import com.linkedin.parseq.EngineBuilder; import com.linkedin.parseq.Task; import com.linkedin.playparseq.j.stores.ParSeqTaskStore; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; import java.util.concurrent.Executors; import java.util.concurrent.ExecutorService; import java.util.concurrent.ForkJoinPool; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import org.junit.After; import org.junit.Before; import org.junit.Test; import play.libs.concurrent.HttpExecutionContext; import play.mvc.Http; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; /* * Copyright 2015 LinkedIn Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ package com.linkedin.playparseq.j; /** * The class PlayParSeqImplTest is a test class for {@link PlayParSeqImpl}. * * @author Yinan Ding (yding@linkedin.com) */ public class PlayParSeqImplTest { /** * The field _playParSeqImpl is the {@link PlayParSeqImpl} to be tested. */ private PlayParSeqImpl _playParSeqImpl; /** * The field _engine is a ParSeq Engine for running ParSeq Task. */ private Engine _engine; /** * The field _taskScheduler is a task scheduler for ParSeq Engine. */ private ExecutorService _taskScheduler; /** * The field _timerScheduler is a timer scheduler for ParSeq Engine. */ private ScheduledExecutorService _timerScheduler; /** * The filed _mockContext is mocking Http.Context. */ private Http.Context _mockContext; /** * The field DEFAULT_TIME_OUT is the default time out value for retrieving data from a CompletionStage in the unit of * ms. */ public final static int DEFAULT_TIME_OUT = 5000; /** * The method setUp sets the ParSeq Engine and the {@link PlayParSeqImpl}. * * @see <a href="https://github.com/linkedin/parseq/wiki/User's-Guide#creating-an-engine">ParSeq Wiki</a> */ @Before public void setUp() { _taskScheduler = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() + 1); _timerScheduler = Executors.newSingleThreadScheduledExecutor(); _engine = new EngineBuilder().setTaskExecutor(_taskScheduler).setTimerScheduler(_timerScheduler).build();
_playParSeqImpl = new PlayParSeqImpl(_engine, mock(ParSeqTaskStore.class), when(mock(HttpExecutionContext.class).current()).thenReturn(ForkJoinPool.commonPool()).getMock());
linkedin/play-parseq
src/trace/java/app/com/linkedin/playparseq/trace/j/sensors/ParSeqTraceSensorImpl.java
// Path: src/core/java/app/com/linkedin/playparseq/j/stores/ParSeqTaskStore.java // public interface ParSeqTaskStore { // // /** // * The method put puts ParSeq Task into store. // * // * @param context The HTTP Context // * @param task The ParSeq Task // */ // void put(final Http.Context context, final Task<?> task); // // /** // * The method get gets all Tasks from one request out of store as an unmodifiable Set. // * // * @param context The HTTP Context // * @return A set of Tasks // */ // Set<Task<?>> get(final Http.Context context); // // /** // * The method initialize sets up the store properly for put/get APIs. // * // * @param context The origin HTTP Context // * @return The HTTP Context with store set up properly // */ // Http.Context initialize(final Http.Context context); // // }
import com.linkedin.playparseq.j.stores.ParSeqTaskStore; import java.util.Optional; import javax.inject.Inject; import javax.inject.Singleton; import play.Environment; import play.mvc.Http;
/* * Copyright 2015 LinkedIn Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ package com.linkedin.playparseq.trace.j.sensors; /** * The class ParSeqTraceSensorImpl is an implementation of the interface {@link ParSeqTraceSensor}. * It determines based on whether the application is under dev mode, whether the query param is present, and whether the * data from the {@link ParSeqTaskStore} is available. * * @author Yinan Ding (yding@linkedin.com) */ @Singleton public class ParSeqTraceSensorImpl implements ParSeqTraceSensor { /** * The field QUERY_KEY is the key of query for ParSeq Trace. */ public final static String QUERY_KEY = "parseq-trace"; /** * The field _environment is a Play Environment for checking dev mode. */ private final Environment _environment; /** * The constructor injects the Environment. * * @param environment The injected Environment component */ @Inject public ParSeqTraceSensorImpl(final Environment environment) { _environment = environment; } /** * {@inheritDoc} */ @Override
// Path: src/core/java/app/com/linkedin/playparseq/j/stores/ParSeqTaskStore.java // public interface ParSeqTaskStore { // // /** // * The method put puts ParSeq Task into store. // * // * @param context The HTTP Context // * @param task The ParSeq Task // */ // void put(final Http.Context context, final Task<?> task); // // /** // * The method get gets all Tasks from one request out of store as an unmodifiable Set. // * // * @param context The HTTP Context // * @return A set of Tasks // */ // Set<Task<?>> get(final Http.Context context); // // /** // * The method initialize sets up the store properly for put/get APIs. // * // * @param context The origin HTTP Context // * @return The HTTP Context with store set up properly // */ // Http.Context initialize(final Http.Context context); // // } // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/sensors/ParSeqTraceSensorImpl.java import com.linkedin.playparseq.j.stores.ParSeqTaskStore; import java.util.Optional; import javax.inject.Inject; import javax.inject.Singleton; import play.Environment; import play.mvc.Http; /* * Copyright 2015 LinkedIn Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ package com.linkedin.playparseq.trace.j.sensors; /** * The class ParSeqTraceSensorImpl is an implementation of the interface {@link ParSeqTraceSensor}. * It determines based on whether the application is under dev mode, whether the query param is present, and whether the * data from the {@link ParSeqTaskStore} is available. * * @author Yinan Ding (yding@linkedin.com) */ @Singleton public class ParSeqTraceSensorImpl implements ParSeqTraceSensor { /** * The field QUERY_KEY is the key of query for ParSeq Trace. */ public final static String QUERY_KEY = "parseq-trace"; /** * The field _environment is a Play Environment for checking dev mode. */ private final Environment _environment; /** * The constructor injects the Environment. * * @param environment The injected Environment component */ @Inject public ParSeqTraceSensorImpl(final Environment environment) { _environment = environment; } /** * {@inheritDoc} */ @Override
public boolean isEnabled(final Http.Context context, final ParSeqTaskStore parSeqTaskStore) {
linkedin/play-parseq
src/trace/java/app/com/linkedin/playparseq/trace/j/ParSeqTraceBuilder.java
// Path: src/core/java/app/com/linkedin/playparseq/j/stores/ParSeqTaskStore.java // public interface ParSeqTaskStore { // // /** // * The method put puts ParSeq Task into store. // * // * @param context The HTTP Context // * @param task The ParSeq Task // */ // void put(final Http.Context context, final Task<?> task); // // /** // * The method get gets all Tasks from one request out of store as an unmodifiable Set. // * // * @param context The HTTP Context // * @return A set of Tasks // */ // Set<Task<?>> get(final Http.Context context); // // /** // * The method initialize sets up the store properly for put/get APIs. // * // * @param context The origin HTTP Context // * @return The HTTP Context with store set up properly // */ // Http.Context initialize(final Http.Context context); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/renderers/ParSeqTraceRenderer.java // public interface ParSeqTraceRenderer { // // /** // * The method render generates a {@code CompletionStage<Result>} from {@link ParSeqTaskStore}. // * // * @param context The HTTP Context // * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks // * @return The CompletionStage of Result // */ // CompletionStage<Result> render(final Http.Context context, final ParSeqTaskStore parSeqTaskStore); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/sensors/ParSeqTraceSensor.java // public interface ParSeqTraceSensor { // // /** // * The method isEnabled decides whether ParSeq Trace is enabled or not from {@link Http.Context} and // * {@link ParSeqTaskStore}. // * // * @param context The HTTP Context // * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks // * @return The decision // */ // boolean isEnabled(final Http.Context context, final ParSeqTaskStore parSeqTaskStore); // // }
import com.linkedin.playparseq.j.stores.ParSeqTaskStore; import com.linkedin.playparseq.trace.j.renderers.ParSeqTraceRenderer; import com.linkedin.playparseq.trace.j.sensors.ParSeqTraceSensor; import java.util.concurrent.CompletionStage; import play.mvc.Http; import play.mvc.Result;
/* * Copyright 2015 LinkedIn Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ package com.linkedin.playparseq.trace.j; /** * The interface ParSeqTraceBuilder defines building a ParSeq Trace Result using the {@link ParSeqTraceRenderer} if the * {@link ParSeqTraceSensor} determines ParSeq Trace is enabled. * * @author Yinan Ding (yding@linkedin.com) */ public interface ParSeqTraceBuilder { /** * The method show returns the trace Result. * * @param context The HTTP Context * @param origin The origin CompletionStage of Result * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks * @param parSeqTraceSensor The {@link ParSeqTraceSensor} for deciding whether ParSeq Trace is enabled or not * @param parSeqTraceRenderer The {@link ParSeqTraceRenderer} for generating the ParSeq Trace page * @return The CompletionStage of Result */ CompletionStage<Result> build(final Http.Context context, final CompletionStage<Result> origin,
// Path: src/core/java/app/com/linkedin/playparseq/j/stores/ParSeqTaskStore.java // public interface ParSeqTaskStore { // // /** // * The method put puts ParSeq Task into store. // * // * @param context The HTTP Context // * @param task The ParSeq Task // */ // void put(final Http.Context context, final Task<?> task); // // /** // * The method get gets all Tasks from one request out of store as an unmodifiable Set. // * // * @param context The HTTP Context // * @return A set of Tasks // */ // Set<Task<?>> get(final Http.Context context); // // /** // * The method initialize sets up the store properly for put/get APIs. // * // * @param context The origin HTTP Context // * @return The HTTP Context with store set up properly // */ // Http.Context initialize(final Http.Context context); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/renderers/ParSeqTraceRenderer.java // public interface ParSeqTraceRenderer { // // /** // * The method render generates a {@code CompletionStage<Result>} from {@link ParSeqTaskStore}. // * // * @param context The HTTP Context // * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks // * @return The CompletionStage of Result // */ // CompletionStage<Result> render(final Http.Context context, final ParSeqTaskStore parSeqTaskStore); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/sensors/ParSeqTraceSensor.java // public interface ParSeqTraceSensor { // // /** // * The method isEnabled decides whether ParSeq Trace is enabled or not from {@link Http.Context} and // * {@link ParSeqTaskStore}. // * // * @param context The HTTP Context // * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks // * @return The decision // */ // boolean isEnabled(final Http.Context context, final ParSeqTaskStore parSeqTaskStore); // // } // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/ParSeqTraceBuilder.java import com.linkedin.playparseq.j.stores.ParSeqTaskStore; import com.linkedin.playparseq.trace.j.renderers.ParSeqTraceRenderer; import com.linkedin.playparseq.trace.j.sensors.ParSeqTraceSensor; import java.util.concurrent.CompletionStage; import play.mvc.Http; import play.mvc.Result; /* * Copyright 2015 LinkedIn Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ package com.linkedin.playparseq.trace.j; /** * The interface ParSeqTraceBuilder defines building a ParSeq Trace Result using the {@link ParSeqTraceRenderer} if the * {@link ParSeqTraceSensor} determines ParSeq Trace is enabled. * * @author Yinan Ding (yding@linkedin.com) */ public interface ParSeqTraceBuilder { /** * The method show returns the trace Result. * * @param context The HTTP Context * @param origin The origin CompletionStage of Result * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks * @param parSeqTraceSensor The {@link ParSeqTraceSensor} for deciding whether ParSeq Trace is enabled or not * @param parSeqTraceRenderer The {@link ParSeqTraceRenderer} for generating the ParSeq Trace page * @return The CompletionStage of Result */ CompletionStage<Result> build(final Http.Context context, final CompletionStage<Result> origin,
final ParSeqTaskStore parSeqTaskStore, final ParSeqTraceSensor parSeqTraceSensor,
linkedin/play-parseq
src/trace/java/app/com/linkedin/playparseq/trace/j/ParSeqTraceBuilder.java
// Path: src/core/java/app/com/linkedin/playparseq/j/stores/ParSeqTaskStore.java // public interface ParSeqTaskStore { // // /** // * The method put puts ParSeq Task into store. // * // * @param context The HTTP Context // * @param task The ParSeq Task // */ // void put(final Http.Context context, final Task<?> task); // // /** // * The method get gets all Tasks from one request out of store as an unmodifiable Set. // * // * @param context The HTTP Context // * @return A set of Tasks // */ // Set<Task<?>> get(final Http.Context context); // // /** // * The method initialize sets up the store properly for put/get APIs. // * // * @param context The origin HTTP Context // * @return The HTTP Context with store set up properly // */ // Http.Context initialize(final Http.Context context); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/renderers/ParSeqTraceRenderer.java // public interface ParSeqTraceRenderer { // // /** // * The method render generates a {@code CompletionStage<Result>} from {@link ParSeqTaskStore}. // * // * @param context The HTTP Context // * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks // * @return The CompletionStage of Result // */ // CompletionStage<Result> render(final Http.Context context, final ParSeqTaskStore parSeqTaskStore); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/sensors/ParSeqTraceSensor.java // public interface ParSeqTraceSensor { // // /** // * The method isEnabled decides whether ParSeq Trace is enabled or not from {@link Http.Context} and // * {@link ParSeqTaskStore}. // * // * @param context The HTTP Context // * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks // * @return The decision // */ // boolean isEnabled(final Http.Context context, final ParSeqTaskStore parSeqTaskStore); // // }
import com.linkedin.playparseq.j.stores.ParSeqTaskStore; import com.linkedin.playparseq.trace.j.renderers.ParSeqTraceRenderer; import com.linkedin.playparseq.trace.j.sensors.ParSeqTraceSensor; import java.util.concurrent.CompletionStage; import play.mvc.Http; import play.mvc.Result;
/* * Copyright 2015 LinkedIn Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ package com.linkedin.playparseq.trace.j; /** * The interface ParSeqTraceBuilder defines building a ParSeq Trace Result using the {@link ParSeqTraceRenderer} if the * {@link ParSeqTraceSensor} determines ParSeq Trace is enabled. * * @author Yinan Ding (yding@linkedin.com) */ public interface ParSeqTraceBuilder { /** * The method show returns the trace Result. * * @param context The HTTP Context * @param origin The origin CompletionStage of Result * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks * @param parSeqTraceSensor The {@link ParSeqTraceSensor} for deciding whether ParSeq Trace is enabled or not * @param parSeqTraceRenderer The {@link ParSeqTraceRenderer} for generating the ParSeq Trace page * @return The CompletionStage of Result */ CompletionStage<Result> build(final Http.Context context, final CompletionStage<Result> origin,
// Path: src/core/java/app/com/linkedin/playparseq/j/stores/ParSeqTaskStore.java // public interface ParSeqTaskStore { // // /** // * The method put puts ParSeq Task into store. // * // * @param context The HTTP Context // * @param task The ParSeq Task // */ // void put(final Http.Context context, final Task<?> task); // // /** // * The method get gets all Tasks from one request out of store as an unmodifiable Set. // * // * @param context The HTTP Context // * @return A set of Tasks // */ // Set<Task<?>> get(final Http.Context context); // // /** // * The method initialize sets up the store properly for put/get APIs. // * // * @param context The origin HTTP Context // * @return The HTTP Context with store set up properly // */ // Http.Context initialize(final Http.Context context); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/renderers/ParSeqTraceRenderer.java // public interface ParSeqTraceRenderer { // // /** // * The method render generates a {@code CompletionStage<Result>} from {@link ParSeqTaskStore}. // * // * @param context The HTTP Context // * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks // * @return The CompletionStage of Result // */ // CompletionStage<Result> render(final Http.Context context, final ParSeqTaskStore parSeqTaskStore); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/sensors/ParSeqTraceSensor.java // public interface ParSeqTraceSensor { // // /** // * The method isEnabled decides whether ParSeq Trace is enabled or not from {@link Http.Context} and // * {@link ParSeqTaskStore}. // * // * @param context The HTTP Context // * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks // * @return The decision // */ // boolean isEnabled(final Http.Context context, final ParSeqTaskStore parSeqTaskStore); // // } // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/ParSeqTraceBuilder.java import com.linkedin.playparseq.j.stores.ParSeqTaskStore; import com.linkedin.playparseq.trace.j.renderers.ParSeqTraceRenderer; import com.linkedin.playparseq.trace.j.sensors.ParSeqTraceSensor; import java.util.concurrent.CompletionStage; import play.mvc.Http; import play.mvc.Result; /* * Copyright 2015 LinkedIn Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ package com.linkedin.playparseq.trace.j; /** * The interface ParSeqTraceBuilder defines building a ParSeq Trace Result using the {@link ParSeqTraceRenderer} if the * {@link ParSeqTraceSensor} determines ParSeq Trace is enabled. * * @author Yinan Ding (yding@linkedin.com) */ public interface ParSeqTraceBuilder { /** * The method show returns the trace Result. * * @param context The HTTP Context * @param origin The origin CompletionStage of Result * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks * @param parSeqTraceSensor The {@link ParSeqTraceSensor} for deciding whether ParSeq Trace is enabled or not * @param parSeqTraceRenderer The {@link ParSeqTraceRenderer} for generating the ParSeq Trace page * @return The CompletionStage of Result */ CompletionStage<Result> build(final Http.Context context, final CompletionStage<Result> origin,
final ParSeqTaskStore parSeqTaskStore, final ParSeqTraceSensor parSeqTraceSensor,
linkedin/play-parseq
src/trace/java/app/com/linkedin/playparseq/trace/j/ParSeqTraceBuilder.java
// Path: src/core/java/app/com/linkedin/playparseq/j/stores/ParSeqTaskStore.java // public interface ParSeqTaskStore { // // /** // * The method put puts ParSeq Task into store. // * // * @param context The HTTP Context // * @param task The ParSeq Task // */ // void put(final Http.Context context, final Task<?> task); // // /** // * The method get gets all Tasks from one request out of store as an unmodifiable Set. // * // * @param context The HTTP Context // * @return A set of Tasks // */ // Set<Task<?>> get(final Http.Context context); // // /** // * The method initialize sets up the store properly for put/get APIs. // * // * @param context The origin HTTP Context // * @return The HTTP Context with store set up properly // */ // Http.Context initialize(final Http.Context context); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/renderers/ParSeqTraceRenderer.java // public interface ParSeqTraceRenderer { // // /** // * The method render generates a {@code CompletionStage<Result>} from {@link ParSeqTaskStore}. // * // * @param context The HTTP Context // * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks // * @return The CompletionStage of Result // */ // CompletionStage<Result> render(final Http.Context context, final ParSeqTaskStore parSeqTaskStore); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/sensors/ParSeqTraceSensor.java // public interface ParSeqTraceSensor { // // /** // * The method isEnabled decides whether ParSeq Trace is enabled or not from {@link Http.Context} and // * {@link ParSeqTaskStore}. // * // * @param context The HTTP Context // * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks // * @return The decision // */ // boolean isEnabled(final Http.Context context, final ParSeqTaskStore parSeqTaskStore); // // }
import com.linkedin.playparseq.j.stores.ParSeqTaskStore; import com.linkedin.playparseq.trace.j.renderers.ParSeqTraceRenderer; import com.linkedin.playparseq.trace.j.sensors.ParSeqTraceSensor; import java.util.concurrent.CompletionStage; import play.mvc.Http; import play.mvc.Result;
/* * Copyright 2015 LinkedIn Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ package com.linkedin.playparseq.trace.j; /** * The interface ParSeqTraceBuilder defines building a ParSeq Trace Result using the {@link ParSeqTraceRenderer} if the * {@link ParSeqTraceSensor} determines ParSeq Trace is enabled. * * @author Yinan Ding (yding@linkedin.com) */ public interface ParSeqTraceBuilder { /** * The method show returns the trace Result. * * @param context The HTTP Context * @param origin The origin CompletionStage of Result * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks * @param parSeqTraceSensor The {@link ParSeqTraceSensor} for deciding whether ParSeq Trace is enabled or not * @param parSeqTraceRenderer The {@link ParSeqTraceRenderer} for generating the ParSeq Trace page * @return The CompletionStage of Result */ CompletionStage<Result> build(final Http.Context context, final CompletionStage<Result> origin, final ParSeqTaskStore parSeqTaskStore, final ParSeqTraceSensor parSeqTraceSensor,
// Path: src/core/java/app/com/linkedin/playparseq/j/stores/ParSeqTaskStore.java // public interface ParSeqTaskStore { // // /** // * The method put puts ParSeq Task into store. // * // * @param context The HTTP Context // * @param task The ParSeq Task // */ // void put(final Http.Context context, final Task<?> task); // // /** // * The method get gets all Tasks from one request out of store as an unmodifiable Set. // * // * @param context The HTTP Context // * @return A set of Tasks // */ // Set<Task<?>> get(final Http.Context context); // // /** // * The method initialize sets up the store properly for put/get APIs. // * // * @param context The origin HTTP Context // * @return The HTTP Context with store set up properly // */ // Http.Context initialize(final Http.Context context); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/renderers/ParSeqTraceRenderer.java // public interface ParSeqTraceRenderer { // // /** // * The method render generates a {@code CompletionStage<Result>} from {@link ParSeqTaskStore}. // * // * @param context The HTTP Context // * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks // * @return The CompletionStage of Result // */ // CompletionStage<Result> render(final Http.Context context, final ParSeqTaskStore parSeqTaskStore); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/sensors/ParSeqTraceSensor.java // public interface ParSeqTraceSensor { // // /** // * The method isEnabled decides whether ParSeq Trace is enabled or not from {@link Http.Context} and // * {@link ParSeqTaskStore}. // * // * @param context The HTTP Context // * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks // * @return The decision // */ // boolean isEnabled(final Http.Context context, final ParSeqTaskStore parSeqTaskStore); // // } // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/ParSeqTraceBuilder.java import com.linkedin.playparseq.j.stores.ParSeqTaskStore; import com.linkedin.playparseq.trace.j.renderers.ParSeqTraceRenderer; import com.linkedin.playparseq.trace.j.sensors.ParSeqTraceSensor; import java.util.concurrent.CompletionStage; import play.mvc.Http; import play.mvc.Result; /* * Copyright 2015 LinkedIn Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ package com.linkedin.playparseq.trace.j; /** * The interface ParSeqTraceBuilder defines building a ParSeq Trace Result using the {@link ParSeqTraceRenderer} if the * {@link ParSeqTraceSensor} determines ParSeq Trace is enabled. * * @author Yinan Ding (yding@linkedin.com) */ public interface ParSeqTraceBuilder { /** * The method show returns the trace Result. * * @param context The HTTP Context * @param origin The origin CompletionStage of Result * @param parSeqTaskStore The {@link ParSeqTaskStore} for getting ParSeq Tasks * @param parSeqTraceSensor The {@link ParSeqTraceSensor} for deciding whether ParSeq Trace is enabled or not * @param parSeqTraceRenderer The {@link ParSeqTraceRenderer} for generating the ParSeq Trace page * @return The CompletionStage of Result */ CompletionStage<Result> build(final Http.Context context, final CompletionStage<Result> origin, final ParSeqTaskStore parSeqTaskStore, final ParSeqTraceSensor parSeqTraceSensor,
final ParSeqTraceRenderer parSeqTraceRenderer);
linkedin/play-parseq
sample/app/controllers/j/SingleTaskSample.java
// Path: src/core/java/app/com/linkedin/playparseq/j/PlayParSeq.java // public interface PlayParSeq { // // /** // * The method toTask converts a {@code Callable<CompletionStage<T>>} to a ParSeq {@code Task<T>}. // * // * @param name The String which describes the Task and shows up in a trace // * @param f The Callable which returns a CompletionStage // * @param <T> The type parameter of the CompletionStage and the ParSeq Task // * @return The ParSeq Task // */ // <T> Task<T> toTask(final String name, final Callable<CompletionStage<T>> f); // // /** // * The method toTask converts a {@code Callable<CompletionStage<T>>} to a ParSeq {@code Task<T>}, which binds with a // * default name. // * // * @param f The Callable which returns a CompletionStage // * @param <T> The type parameter of the CompletionStage and the ParSeq Task // * @return The ParSeq Task // */ // <T> Task<T> toTask(final Callable<CompletionStage<T>> f); // // /** // * The method runTask executes a ParSeq {@code Task<T>} then generates a {@code CompletionStage<T>}, and puts into the // * store. // * // * @param context The HTTP Context // * @param task The ParSeq Task // * @param <T> The type parameter of the ParSeq Task and the CompletionStage // * @return The CompletionStage // */ // <T> CompletionStage<T> runTask(final Http.Context context, final Task<T> task); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/ParSeqTraceAction.java // public class ParSeqTraceAction extends Simple { // // /** // * The field _parSeqTaskStore is a {@link ParSeqTaskStore} for getting ParSeq Tasks. // */ // private final ParSeqTaskStore _parSeqTaskStore; // // /** // * The field _parSeqTraceBuilder is a {@link ParSeqTraceBuilder} for building ParSeq Trace. // */ // private final ParSeqTraceBuilder _parSeqTraceBuilder; // // /** // * The field _parSeqTraceSensor is a {@link ParSeqTraceSensor} for deciding whether ParSeq Trace is enabled or not. // */ // private final ParSeqTraceSensor _parSeqTraceSensor; // // /** // * The field _parSeqTraceRenderer is a {@link ParSeqTraceRenderer} for generating ParSeq Trace. // */ // private final ParSeqTraceRenderer _parSeqTraceRenderer; // // /** // * The constructor injects the {@link ParSeqTaskStore}, the {@link ParSeqTraceBuilder}, the {@link ParSeqTraceSensor} // * and the {@link ParSeqTraceRenderer}. // * // * @param parSeqTaskStore The injected {@link ParSeqTaskStore} component // * @param parSeqTraceBuilder The injected {@link ParSeqTraceBuilder} component // * @param parSeqTraceSensor The injected {@link ParSeqTraceSensor} component // * @param parSeqTraceRenderer The injected {@link ParSeqTraceRenderer} component // */ // @Inject // public ParSeqTraceAction(final ParSeqTaskStore parSeqTaskStore, final ParSeqTraceBuilder parSeqTraceBuilder, // final ParSeqTraceSensor parSeqTraceSensor, final ParSeqTraceRenderer parSeqTraceRenderer) { // super(); // _parSeqTaskStore = parSeqTaskStore; // _parSeqTraceBuilder = parSeqTraceBuilder; // _parSeqTraceSensor = parSeqTraceSensor; // _parSeqTraceRenderer = parSeqTraceRenderer; // } // // /** // * The method call sets up a normal HTTP Context with {@link ParSeqTaskStore} and composes with // * {@link ParSeqTraceBuilder} to build ParSeq Trace for the request. // * // * @param context The HTTP Context // * @return The CompletionStage of Result // */ // @Override // public CompletionStage<Result> call(final Http.Context context) { // Http.Context newContext = _parSeqTaskStore.initialize(context); // return _parSeqTraceBuilder.build(newContext, delegate.call(newContext), _parSeqTaskStore, _parSeqTraceSensor, // _parSeqTraceRenderer); // } // // }
import com.linkedin.parseq.Task; import com.linkedin.playparseq.j.PlayParSeq; import com.linkedin.playparseq.trace.j.ParSeqTraceAction; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; import javax.inject.Inject; import play.mvc.Controller; import play.mvc.Http; import play.mvc.Result; import play.mvc.With;
/* * Copyright 2015 LinkedIn Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ package controllers.j; /** * The class SingleTaskSample is a Controller to show how to use {@link ParSeqTraceAction} for generating ParSeq Trace * of one ParSeq Task. * * @author Yinan Ding (yding@linkedin.com) */ public class SingleTaskSample extends Controller { /** * The field _playParSeq is a {@link PlayParSeq} for conversion and execution of ParSeq Tasks. */ private final PlayParSeq _playParSeq; /** * The constructor injects the {@link PlayParSeq}. * * @param playParSeq The injected {@link PlayParSeq} component */ @Inject public SingleTaskSample(final PlayParSeq playParSeq) { _playParSeq = playParSeq; } /** * The method demo runs one Task, and is able to show the ParSeq Trace if the request has `parseq-trace=true`. * Note that, in general you shouldn't be running multiple ParSeq Tasks, otherwise the order of execution is not * accurate, which minimizes the benefits of ParSeq. * * @return The CompletionStage of Action Result */
// Path: src/core/java/app/com/linkedin/playparseq/j/PlayParSeq.java // public interface PlayParSeq { // // /** // * The method toTask converts a {@code Callable<CompletionStage<T>>} to a ParSeq {@code Task<T>}. // * // * @param name The String which describes the Task and shows up in a trace // * @param f The Callable which returns a CompletionStage // * @param <T> The type parameter of the CompletionStage and the ParSeq Task // * @return The ParSeq Task // */ // <T> Task<T> toTask(final String name, final Callable<CompletionStage<T>> f); // // /** // * The method toTask converts a {@code Callable<CompletionStage<T>>} to a ParSeq {@code Task<T>}, which binds with a // * default name. // * // * @param f The Callable which returns a CompletionStage // * @param <T> The type parameter of the CompletionStage and the ParSeq Task // * @return The ParSeq Task // */ // <T> Task<T> toTask(final Callable<CompletionStage<T>> f); // // /** // * The method runTask executes a ParSeq {@code Task<T>} then generates a {@code CompletionStage<T>}, and puts into the // * store. // * // * @param context The HTTP Context // * @param task The ParSeq Task // * @param <T> The type parameter of the ParSeq Task and the CompletionStage // * @return The CompletionStage // */ // <T> CompletionStage<T> runTask(final Http.Context context, final Task<T> task); // // } // // Path: src/trace/java/app/com/linkedin/playparseq/trace/j/ParSeqTraceAction.java // public class ParSeqTraceAction extends Simple { // // /** // * The field _parSeqTaskStore is a {@link ParSeqTaskStore} for getting ParSeq Tasks. // */ // private final ParSeqTaskStore _parSeqTaskStore; // // /** // * The field _parSeqTraceBuilder is a {@link ParSeqTraceBuilder} for building ParSeq Trace. // */ // private final ParSeqTraceBuilder _parSeqTraceBuilder; // // /** // * The field _parSeqTraceSensor is a {@link ParSeqTraceSensor} for deciding whether ParSeq Trace is enabled or not. // */ // private final ParSeqTraceSensor _parSeqTraceSensor; // // /** // * The field _parSeqTraceRenderer is a {@link ParSeqTraceRenderer} for generating ParSeq Trace. // */ // private final ParSeqTraceRenderer _parSeqTraceRenderer; // // /** // * The constructor injects the {@link ParSeqTaskStore}, the {@link ParSeqTraceBuilder}, the {@link ParSeqTraceSensor} // * and the {@link ParSeqTraceRenderer}. // * // * @param parSeqTaskStore The injected {@link ParSeqTaskStore} component // * @param parSeqTraceBuilder The injected {@link ParSeqTraceBuilder} component // * @param parSeqTraceSensor The injected {@link ParSeqTraceSensor} component // * @param parSeqTraceRenderer The injected {@link ParSeqTraceRenderer} component // */ // @Inject // public ParSeqTraceAction(final ParSeqTaskStore parSeqTaskStore, final ParSeqTraceBuilder parSeqTraceBuilder, // final ParSeqTraceSensor parSeqTraceSensor, final ParSeqTraceRenderer parSeqTraceRenderer) { // super(); // _parSeqTaskStore = parSeqTaskStore; // _parSeqTraceBuilder = parSeqTraceBuilder; // _parSeqTraceSensor = parSeqTraceSensor; // _parSeqTraceRenderer = parSeqTraceRenderer; // } // // /** // * The method call sets up a normal HTTP Context with {@link ParSeqTaskStore} and composes with // * {@link ParSeqTraceBuilder} to build ParSeq Trace for the request. // * // * @param context The HTTP Context // * @return The CompletionStage of Result // */ // @Override // public CompletionStage<Result> call(final Http.Context context) { // Http.Context newContext = _parSeqTaskStore.initialize(context); // return _parSeqTraceBuilder.build(newContext, delegate.call(newContext), _parSeqTaskStore, _parSeqTraceSensor, // _parSeqTraceRenderer); // } // // } // Path: sample/app/controllers/j/SingleTaskSample.java import com.linkedin.parseq.Task; import com.linkedin.playparseq.j.PlayParSeq; import com.linkedin.playparseq.trace.j.ParSeqTraceAction; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; import javax.inject.Inject; import play.mvc.Controller; import play.mvc.Http; import play.mvc.Result; import play.mvc.With; /* * Copyright 2015 LinkedIn Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ package controllers.j; /** * The class SingleTaskSample is a Controller to show how to use {@link ParSeqTraceAction} for generating ParSeq Trace * of one ParSeq Task. * * @author Yinan Ding (yding@linkedin.com) */ public class SingleTaskSample extends Controller { /** * The field _playParSeq is a {@link PlayParSeq} for conversion and execution of ParSeq Tasks. */ private final PlayParSeq _playParSeq; /** * The constructor injects the {@link PlayParSeq}. * * @param playParSeq The injected {@link PlayParSeq} component */ @Inject public SingleTaskSample(final PlayParSeq playParSeq) { _playParSeq = playParSeq; } /** * The method demo runs one Task, and is able to show the ParSeq Trace if the request has `parseq-trace=true`. * Note that, in general you shouldn't be running multiple ParSeq Tasks, otherwise the order of execution is not * accurate, which minimizes the benefits of ParSeq. * * @return The CompletionStage of Action Result */
@With(ParSeqTraceAction.class)
nikku/silent-disco
server/src/main/java/de/nixis/web/disco/dto/MoveTrack.java
// Path: server/src/main/java/de/nixis/web/disco/db/entity/Position.java // public class Position { // // public enum Status { // PLAYING, // STOPPED // } // // private String trackId; // // private Date date; // // private Status status; // // private int position; // // public Position(String trackId, int position, Status status) { // this.trackId = trackId; // this.date = new Date(); // this.status = status; // this.position = position; // } // // public Position() { // } // // public String getTrackId() { // return trackId; // } // // public Status getStatus() { // return status; // } // // public void setStatus(Status status) { // this.status = status; // } // // public Date getDate() { // return date; // } // // public void setDate(Date date) { // this.date = date; // } // // public int getPosition() { // return position; // } // }
import de.nixis.web.disco.db.entity.Position;
package de.nixis.web.disco.dto; /** * * @author nico.rehwaldt */ public class MoveTrack extends TrackOperation implements PlaylistPositionSync { private TrackPosition from; private TrackPosition to;
// Path: server/src/main/java/de/nixis/web/disco/db/entity/Position.java // public class Position { // // public enum Status { // PLAYING, // STOPPED // } // // private String trackId; // // private Date date; // // private Status status; // // private int position; // // public Position(String trackId, int position, Status status) { // this.trackId = trackId; // this.date = new Date(); // this.status = status; // this.position = position; // } // // public Position() { // } // // public String getTrackId() { // return trackId; // } // // public Status getStatus() { // return status; // } // // public void setStatus(Status status) { // this.status = status; // } // // public Date getDate() { // return date; // } // // public void setDate(Date date) { // this.date = date; // } // // public int getPosition() { // return position; // } // } // Path: server/src/main/java/de/nixis/web/disco/dto/MoveTrack.java import de.nixis.web.disco.db.entity.Position; package de.nixis.web.disco.dto; /** * * @author nico.rehwaldt */ public class MoveTrack extends TrackOperation implements PlaylistPositionSync { private TrackPosition from; private TrackPosition to;
private Position playlistPosition;
nikku/silent-disco
server/src/test/java/de/nixis/web/disco/PojoDecoderTest.java
// Path: server/src/main/java/de/nixis/web/disco/json/DecodeHelper.java // public class DecodeHelper { // // public static <T> T decode(String text, Class<T> cls) { // // try { // Message message = parse(text); // // ObjectMapper mapper = new ObjectMapper(); // // mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss")); // mapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS, false); // // return (T) mapper.readValue(message.content, message.cls); // } catch (IOException e) { // throw new RuntimeException(e); // } // } // // private static final String ATTR_NAME_PATTERN_STR = "(?:\"(.*)\"|'(.*)')"; // // private static final String ATTR_PATTERN_STR = "\\s*([^:]+)\\s*:\\s*(.+)\\s*\\"; // // private static final String PAYLOAD_PATTERN_STR = "^\\s*\\{" + ATTR_PATTERN_STR + "}\\s*$"; // // public static final Pattern ATTR_NAME_PATTERN; // public static final Pattern PAYLOAD_PATTERN; // // static { // ATTR_NAME_PATTERN = Pattern.compile(ATTR_NAME_PATTERN_STR); // PAYLOAD_PATTERN = Pattern.compile(PAYLOAD_PATTERN_STR, Pattern.MULTILINE); // } // // private static Message parse(String text) throws IOException { // // Matcher matcher = PAYLOAD_PATTERN.matcher(text); // // if (!matcher.matches()) { // throw new IOException("Failed to parse message: Invalid json"); // } // // String name = matcher.group(1); // String content = matcher.group(2); // // Matcher nameMatcher = ATTR_NAME_PATTERN.matcher(name); // // if (!nameMatcher.matches()) { // throw new IOException("Failed to parse message: Invalid json"); // } // // if (nameMatcher.group(1) == null) { // name = nameMatcher.group(2); // } else { // name = nameMatcher.group(1); // } // // name = name.substring(0, 1).toUpperCase() + name.substring(1); // // try { // Class<?> cls = Class.forName(Base.class.getPackage().getName() + "." + name); // // return new Message(cls, content); // } catch (ClassNotFoundException e) { // throw new IOException("Failed to parse message: Unknown"); // } // } // // private static class Message { // // private final Class<?> cls; // private final String content; // // public Message(Class<?> cls, String content) { // this.cls = cls; // this.content = content; // } // } // }
import static org.fest.assertions.Assertions.assertThat; import java.util.regex.MatchResult; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.junit.Test; import de.nixis.web.disco.json.DecodeHelper;
package de.nixis.web.disco; /** * * @author nico.rehwaldt */ public class PojoDecoderTest { @Test public void testAttrNamePattern0() {
// Path: server/src/main/java/de/nixis/web/disco/json/DecodeHelper.java // public class DecodeHelper { // // public static <T> T decode(String text, Class<T> cls) { // // try { // Message message = parse(text); // // ObjectMapper mapper = new ObjectMapper(); // // mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss")); // mapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS, false); // // return (T) mapper.readValue(message.content, message.cls); // } catch (IOException e) { // throw new RuntimeException(e); // } // } // // private static final String ATTR_NAME_PATTERN_STR = "(?:\"(.*)\"|'(.*)')"; // // private static final String ATTR_PATTERN_STR = "\\s*([^:]+)\\s*:\\s*(.+)\\s*\\"; // // private static final String PAYLOAD_PATTERN_STR = "^\\s*\\{" + ATTR_PATTERN_STR + "}\\s*$"; // // public static final Pattern ATTR_NAME_PATTERN; // public static final Pattern PAYLOAD_PATTERN; // // static { // ATTR_NAME_PATTERN = Pattern.compile(ATTR_NAME_PATTERN_STR); // PAYLOAD_PATTERN = Pattern.compile(PAYLOAD_PATTERN_STR, Pattern.MULTILINE); // } // // private static Message parse(String text) throws IOException { // // Matcher matcher = PAYLOAD_PATTERN.matcher(text); // // if (!matcher.matches()) { // throw new IOException("Failed to parse message: Invalid json"); // } // // String name = matcher.group(1); // String content = matcher.group(2); // // Matcher nameMatcher = ATTR_NAME_PATTERN.matcher(name); // // if (!nameMatcher.matches()) { // throw new IOException("Failed to parse message: Invalid json"); // } // // if (nameMatcher.group(1) == null) { // name = nameMatcher.group(2); // } else { // name = nameMatcher.group(1); // } // // name = name.substring(0, 1).toUpperCase() + name.substring(1); // // try { // Class<?> cls = Class.forName(Base.class.getPackage().getName() + "." + name); // // return new Message(cls, content); // } catch (ClassNotFoundException e) { // throw new IOException("Failed to parse message: Unknown"); // } // } // // private static class Message { // // private final Class<?> cls; // private final String content; // // public Message(Class<?> cls, String content) { // this.cls = cls; // this.content = content; // } // } // } // Path: server/src/test/java/de/nixis/web/disco/PojoDecoderTest.java import static org.fest.assertions.Assertions.assertThat; import java.util.regex.MatchResult; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.junit.Test; import de.nixis.web.disco.json.DecodeHelper; package de.nixis.web.disco; /** * * @author nico.rehwaldt */ public class PojoDecoderTest { @Test public void testAttrNamePattern0() {
Pattern p = DecodeHelper.ATTR_NAME_PATTERN;
nikku/silent-disco
server/src/main/java/de/nixis/web/disco/json/DecodeHelper.java
// Path: server/src/main/java/de/nixis/web/disco/dto/Base.java // public class Base { // // }
import java.io.IOException; import java.text.SimpleDateFormat; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.SerializationConfig; import de.nixis.web.disco.dto.Base;
ATTR_NAME_PATTERN = Pattern.compile(ATTR_NAME_PATTERN_STR); PAYLOAD_PATTERN = Pattern.compile(PAYLOAD_PATTERN_STR, Pattern.MULTILINE); } private static Message parse(String text) throws IOException { Matcher matcher = PAYLOAD_PATTERN.matcher(text); if (!matcher.matches()) { throw new IOException("Failed to parse message: Invalid json"); } String name = matcher.group(1); String content = matcher.group(2); Matcher nameMatcher = ATTR_NAME_PATTERN.matcher(name); if (!nameMatcher.matches()) { throw new IOException("Failed to parse message: Invalid json"); } if (nameMatcher.group(1) == null) { name = nameMatcher.group(2); } else { name = nameMatcher.group(1); } name = name.substring(0, 1).toUpperCase() + name.substring(1); try {
// Path: server/src/main/java/de/nixis/web/disco/dto/Base.java // public class Base { // // } // Path: server/src/main/java/de/nixis/web/disco/json/DecodeHelper.java import java.io.IOException; import java.text.SimpleDateFormat; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.SerializationConfig; import de.nixis.web.disco.dto.Base; ATTR_NAME_PATTERN = Pattern.compile(ATTR_NAME_PATTERN_STR); PAYLOAD_PATTERN = Pattern.compile(PAYLOAD_PATTERN_STR, Pattern.MULTILINE); } private static Message parse(String text) throws IOException { Matcher matcher = PAYLOAD_PATTERN.matcher(text); if (!matcher.matches()) { throw new IOException("Failed to parse message: Invalid json"); } String name = matcher.group(1); String content = matcher.group(2); Matcher nameMatcher = ATTR_NAME_PATTERN.matcher(name); if (!nameMatcher.matches()) { throw new IOException("Failed to parse message: Invalid json"); } if (nameMatcher.group(1) == null) { name = nameMatcher.group(2); } else { name = nameMatcher.group(1); } name = name.substring(0, 1).toUpperCase() + name.substring(1); try {
Class<?> cls = Class.forName(Base.class.getPackage().getName() + "." + name);
nikku/silent-disco
server/src/main/java/de/nixis/web/disco/dto/ChannelJoined.java
// Path: server/src/main/java/de/nixis/web/disco/db/entity/Room.java // @Entity // public class Room { // // @Id // private ObjectId id; // // private String name; // // @Embedded // private Position position; // // public Room() { // } // // public Room(String name) { // this.name = name; // } // // public String getName() { // return name; // } // // public void setPosition(Position position) { // this.position = position; // } // // public Position getPosition() { // return position; // } // // public String getId() { // return id.toString(); // } // // public Set<Channel> channels() { // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. // } // // public Map<Channel, String> channelMap() { // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. // } // // public Collection<String> participantIds() { // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. // } // } // // Path: server/src/main/java/de/nixis/web/disco/db/entity/Track.java // @Entity // public class Track { // // @Id // private ObjectId trackId; // // /** // * The soundcloud id of the track // */ // private String id; // // private String artwork_url; // // private Date added; // // private String permalink_url; // // private String title; // // @Embedded // private SoundCloudUser user; // // private long duration; // // private String roomName; // // @JsonIgnore // private boolean deleted = false; // // /** // * The position of the track in the track list // */ // @JsonIgnore // private long position = 0; // // public Track() { // // } // // public Track(String id, String artwork_url, String permalink_url, String title, SoundCloudUser user, long duration, String roomName) { // this.artwork_url = artwork_url; // this.permalink_url = permalink_url; // this.title = title; // this.user = user; // this.duration = duration; // this.roomName = roomName; // // this.added = new Date(); // // this.id = id; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public boolean isDeleted() { // return deleted; // } // // public void setDeleted(boolean deleted) { // this.deleted = deleted; // } // // public long getPosition() { // return position; // } // // public void setPosition(long position) { // this.position = position; // } // // public String getArtwork_url() { // return artwork_url; // } // // public void setArtwork_url(String artwork_url) { // this.artwork_url = artwork_url; // } // // public Date getAdded() { // return added; // } // // public void setAdded(Date added) { // this.added = added; // } // // public String getPermalink_url() { // return permalink_url; // } // // public void setPermalink_url(String permalink_url) { // this.permalink_url = permalink_url; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public SoundCloudUser getUser() { // return user; // } // // public void setUser(SoundCloudUser user) { // this.user = user; // } // // public long getDuration() { // return duration; // } // // public void setDuration(long duration) { // this.duration = duration; // } // // public String getRoomName() { // return roomName; // } // // public void setRoomName(String roomName) { // this.roomName = roomName; // } // // public String getTrackId() { // return trackId.toString(); // } // // @Override // public String toString() { // return "Track(id=" + getTrackId() + ")"; // } // }
import java.util.Date; import java.util.List; import de.nixis.web.disco.db.entity.Room; import de.nixis.web.disco.db.entity.Track;
package de.nixis.web.disco.dto; /** * * @author nico.rehwaldt */ public class ChannelJoined extends ParticipantJoined { private List<Participant> participants;
// Path: server/src/main/java/de/nixis/web/disco/db/entity/Room.java // @Entity // public class Room { // // @Id // private ObjectId id; // // private String name; // // @Embedded // private Position position; // // public Room() { // } // // public Room(String name) { // this.name = name; // } // // public String getName() { // return name; // } // // public void setPosition(Position position) { // this.position = position; // } // // public Position getPosition() { // return position; // } // // public String getId() { // return id.toString(); // } // // public Set<Channel> channels() { // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. // } // // public Map<Channel, String> channelMap() { // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. // } // // public Collection<String> participantIds() { // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. // } // } // // Path: server/src/main/java/de/nixis/web/disco/db/entity/Track.java // @Entity // public class Track { // // @Id // private ObjectId trackId; // // /** // * The soundcloud id of the track // */ // private String id; // // private String artwork_url; // // private Date added; // // private String permalink_url; // // private String title; // // @Embedded // private SoundCloudUser user; // // private long duration; // // private String roomName; // // @JsonIgnore // private boolean deleted = false; // // /** // * The position of the track in the track list // */ // @JsonIgnore // private long position = 0; // // public Track() { // // } // // public Track(String id, String artwork_url, String permalink_url, String title, SoundCloudUser user, long duration, String roomName) { // this.artwork_url = artwork_url; // this.permalink_url = permalink_url; // this.title = title; // this.user = user; // this.duration = duration; // this.roomName = roomName; // // this.added = new Date(); // // this.id = id; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public boolean isDeleted() { // return deleted; // } // // public void setDeleted(boolean deleted) { // this.deleted = deleted; // } // // public long getPosition() { // return position; // } // // public void setPosition(long position) { // this.position = position; // } // // public String getArtwork_url() { // return artwork_url; // } // // public void setArtwork_url(String artwork_url) { // this.artwork_url = artwork_url; // } // // public Date getAdded() { // return added; // } // // public void setAdded(Date added) { // this.added = added; // } // // public String getPermalink_url() { // return permalink_url; // } // // public void setPermalink_url(String permalink_url) { // this.permalink_url = permalink_url; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public SoundCloudUser getUser() { // return user; // } // // public void setUser(SoundCloudUser user) { // this.user = user; // } // // public long getDuration() { // return duration; // } // // public void setDuration(long duration) { // this.duration = duration; // } // // public String getRoomName() { // return roomName; // } // // public void setRoomName(String roomName) { // this.roomName = roomName; // } // // public String getTrackId() { // return trackId.toString(); // } // // @Override // public String toString() { // return "Track(id=" + getTrackId() + ")"; // } // } // Path: server/src/main/java/de/nixis/web/disco/dto/ChannelJoined.java import java.util.Date; import java.util.List; import de.nixis.web.disco.db.entity.Room; import de.nixis.web.disco.db.entity.Track; package de.nixis.web.disco.dto; /** * * @author nico.rehwaldt */ public class ChannelJoined extends ParticipantJoined { private List<Participant> participants;
private List<Track> tracks;
nikku/silent-disco
server/src/main/java/de/nixis/web/disco/dto/ChannelJoined.java
// Path: server/src/main/java/de/nixis/web/disco/db/entity/Room.java // @Entity // public class Room { // // @Id // private ObjectId id; // // private String name; // // @Embedded // private Position position; // // public Room() { // } // // public Room(String name) { // this.name = name; // } // // public String getName() { // return name; // } // // public void setPosition(Position position) { // this.position = position; // } // // public Position getPosition() { // return position; // } // // public String getId() { // return id.toString(); // } // // public Set<Channel> channels() { // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. // } // // public Map<Channel, String> channelMap() { // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. // } // // public Collection<String> participantIds() { // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. // } // } // // Path: server/src/main/java/de/nixis/web/disco/db/entity/Track.java // @Entity // public class Track { // // @Id // private ObjectId trackId; // // /** // * The soundcloud id of the track // */ // private String id; // // private String artwork_url; // // private Date added; // // private String permalink_url; // // private String title; // // @Embedded // private SoundCloudUser user; // // private long duration; // // private String roomName; // // @JsonIgnore // private boolean deleted = false; // // /** // * The position of the track in the track list // */ // @JsonIgnore // private long position = 0; // // public Track() { // // } // // public Track(String id, String artwork_url, String permalink_url, String title, SoundCloudUser user, long duration, String roomName) { // this.artwork_url = artwork_url; // this.permalink_url = permalink_url; // this.title = title; // this.user = user; // this.duration = duration; // this.roomName = roomName; // // this.added = new Date(); // // this.id = id; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public boolean isDeleted() { // return deleted; // } // // public void setDeleted(boolean deleted) { // this.deleted = deleted; // } // // public long getPosition() { // return position; // } // // public void setPosition(long position) { // this.position = position; // } // // public String getArtwork_url() { // return artwork_url; // } // // public void setArtwork_url(String artwork_url) { // this.artwork_url = artwork_url; // } // // public Date getAdded() { // return added; // } // // public void setAdded(Date added) { // this.added = added; // } // // public String getPermalink_url() { // return permalink_url; // } // // public void setPermalink_url(String permalink_url) { // this.permalink_url = permalink_url; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public SoundCloudUser getUser() { // return user; // } // // public void setUser(SoundCloudUser user) { // this.user = user; // } // // public long getDuration() { // return duration; // } // // public void setDuration(long duration) { // this.duration = duration; // } // // public String getRoomName() { // return roomName; // } // // public void setRoomName(String roomName) { // this.roomName = roomName; // } // // public String getTrackId() { // return trackId.toString(); // } // // @Override // public String toString() { // return "Track(id=" + getTrackId() + ")"; // } // }
import java.util.Date; import java.util.List; import de.nixis.web.disco.db.entity.Room; import de.nixis.web.disco.db.entity.Track;
package de.nixis.web.disco.dto; /** * * @author nico.rehwaldt */ public class ChannelJoined extends ParticipantJoined { private List<Participant> participants; private List<Track> tracks;
// Path: server/src/main/java/de/nixis/web/disco/db/entity/Room.java // @Entity // public class Room { // // @Id // private ObjectId id; // // private String name; // // @Embedded // private Position position; // // public Room() { // } // // public Room(String name) { // this.name = name; // } // // public String getName() { // return name; // } // // public void setPosition(Position position) { // this.position = position; // } // // public Position getPosition() { // return position; // } // // public String getId() { // return id.toString(); // } // // public Set<Channel> channels() { // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. // } // // public Map<Channel, String> channelMap() { // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. // } // // public Collection<String> participantIds() { // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. // } // } // // Path: server/src/main/java/de/nixis/web/disco/db/entity/Track.java // @Entity // public class Track { // // @Id // private ObjectId trackId; // // /** // * The soundcloud id of the track // */ // private String id; // // private String artwork_url; // // private Date added; // // private String permalink_url; // // private String title; // // @Embedded // private SoundCloudUser user; // // private long duration; // // private String roomName; // // @JsonIgnore // private boolean deleted = false; // // /** // * The position of the track in the track list // */ // @JsonIgnore // private long position = 0; // // public Track() { // // } // // public Track(String id, String artwork_url, String permalink_url, String title, SoundCloudUser user, long duration, String roomName) { // this.artwork_url = artwork_url; // this.permalink_url = permalink_url; // this.title = title; // this.user = user; // this.duration = duration; // this.roomName = roomName; // // this.added = new Date(); // // this.id = id; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public boolean isDeleted() { // return deleted; // } // // public void setDeleted(boolean deleted) { // this.deleted = deleted; // } // // public long getPosition() { // return position; // } // // public void setPosition(long position) { // this.position = position; // } // // public String getArtwork_url() { // return artwork_url; // } // // public void setArtwork_url(String artwork_url) { // this.artwork_url = artwork_url; // } // // public Date getAdded() { // return added; // } // // public void setAdded(Date added) { // this.added = added; // } // // public String getPermalink_url() { // return permalink_url; // } // // public void setPermalink_url(String permalink_url) { // this.permalink_url = permalink_url; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public SoundCloudUser getUser() { // return user; // } // // public void setUser(SoundCloudUser user) { // this.user = user; // } // // public long getDuration() { // return duration; // } // // public void setDuration(long duration) { // this.duration = duration; // } // // public String getRoomName() { // return roomName; // } // // public void setRoomName(String roomName) { // this.roomName = roomName; // } // // public String getTrackId() { // return trackId.toString(); // } // // @Override // public String toString() { // return "Track(id=" + getTrackId() + ")"; // } // } // Path: server/src/main/java/de/nixis/web/disco/dto/ChannelJoined.java import java.util.Date; import java.util.List; import de.nixis.web.disco.db.entity.Room; import de.nixis.web.disco.db.entity.Track; package de.nixis.web.disco.dto; /** * * @author nico.rehwaldt */ public class ChannelJoined extends ParticipantJoined { private List<Participant> participants; private List<Track> tracks;
private Room room;
nikku/silent-disco
server/src/main/java/de/nixis/web/disco/room/impl/RoomContextImpl.java
// Path: server/src/main/java/de/nixis/web/disco/dto/Participant.java // public class Participant implements Comparable<Participant> { // // private ObjectId id; // // private String name; // // public Participant(String name) { // this.name = name; // // this.id = new ObjectId(); // } // // public Participant() { // } // // public String getId() { // return id.toString(); // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int compareTo(Participant o) { // return o.id.compareTo(id); // } // } // // Path: server/src/main/java/de/nixis/web/disco/room/Room.java // public interface Room { // // public String id(); // // public Map<Channel, String> channelMap(); // // public Set<Channel> channels(); // // public <T> Attribute<T> attr(AttributeKey<T> key); // // Map<String, Participant> participantsMap(); // } // // Path: server/src/main/java/de/nixis/web/disco/room/RoomContext.java // public interface RoomContext { // // public Executor executor(); // // /** // * Returns the current channel. // * // * @return // */ // public Channel channel(); // // /** // * Returns all channels. // * // * @return // */ // public Set<Channel> channels(); // // public Map<Channel, String> channelMap(); // // public <T> Attribute<T> attr(AttributeKey<T> key); // // public Room room(); // // public RoomContext forChannel(Channel channel); // }
import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentSkipListMap; import java.util.concurrent.Executor; import de.nixis.web.disco.dto.Participant; import de.nixis.web.disco.room.Room; import de.nixis.web.disco.room.RoomContext; import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; import io.netty.util.Attribute; import io.netty.util.AttributeKey;
package de.nixis.web.disco.room.impl; /** * * @author nico.rehwaldt */ public class RoomContextImpl implements RoomContext { private final Executor executor;
// Path: server/src/main/java/de/nixis/web/disco/dto/Participant.java // public class Participant implements Comparable<Participant> { // // private ObjectId id; // // private String name; // // public Participant(String name) { // this.name = name; // // this.id = new ObjectId(); // } // // public Participant() { // } // // public String getId() { // return id.toString(); // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int compareTo(Participant o) { // return o.id.compareTo(id); // } // } // // Path: server/src/main/java/de/nixis/web/disco/room/Room.java // public interface Room { // // public String id(); // // public Map<Channel, String> channelMap(); // // public Set<Channel> channels(); // // public <T> Attribute<T> attr(AttributeKey<T> key); // // Map<String, Participant> participantsMap(); // } // // Path: server/src/main/java/de/nixis/web/disco/room/RoomContext.java // public interface RoomContext { // // public Executor executor(); // // /** // * Returns the current channel. // * // * @return // */ // public Channel channel(); // // /** // * Returns all channels. // * // * @return // */ // public Set<Channel> channels(); // // public Map<Channel, String> channelMap(); // // public <T> Attribute<T> attr(AttributeKey<T> key); // // public Room room(); // // public RoomContext forChannel(Channel channel); // } // Path: server/src/main/java/de/nixis/web/disco/room/impl/RoomContextImpl.java import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentSkipListMap; import java.util.concurrent.Executor; import de.nixis.web.disco.dto.Participant; import de.nixis.web.disco.room.Room; import de.nixis.web.disco.room.RoomContext; import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; import io.netty.util.Attribute; import io.netty.util.AttributeKey; package de.nixis.web.disco.room.impl; /** * * @author nico.rehwaldt */ public class RoomContextImpl implements RoomContext { private final Executor executor;
private final Room room;
nikku/silent-disco
server/src/main/java/de/nixis/web/disco/json/PojoDecoder.java
// Path: server/src/main/java/de/nixis/web/disco/dto/Base.java // public class Base { // // }
import java.util.List; import de.nixis.web.disco.dto.Base; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToMessageDecoder; import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
package de.nixis.web.disco.json; /** * * @author nico.rehwaldt */ public class PojoDecoder extends MessageToMessageDecoder<TextWebSocketFrame> { @Override protected void decode(ChannelHandlerContext ctx, TextWebSocketFrame frame, List<Object> out) throws Exception { String msg = frame.text();
// Path: server/src/main/java/de/nixis/web/disco/dto/Base.java // public class Base { // // } // Path: server/src/main/java/de/nixis/web/disco/json/PojoDecoder.java import java.util.List; import de.nixis.web.disco.dto.Base; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToMessageDecoder; import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; package de.nixis.web.disco.json; /** * * @author nico.rehwaldt */ public class PojoDecoder extends MessageToMessageDecoder<TextWebSocketFrame> { @Override protected void decode(ChannelHandlerContext ctx, TextWebSocketFrame frame, List<Object> out) throws Exception { String msg = frame.text();
Base base = DecodeHelper.decode(msg, Base.class);
nikku/silent-disco
server/src/main/java/de/nixis/web/disco/ws/RoomAwareHandler.java
// Path: server/src/main/java/de/nixis/web/disco/dto/Base.java // public class Base { // // } // // Path: server/src/main/java/de/nixis/web/disco/dto/ChannelLeave.java // public class ChannelLeave extends Base { // // private String reason; // // public ChannelLeave() { // } // // public ChannelLeave(String reason) { // this.reason = reason; // } // // public String getReason() { // return reason; // } // } // // Path: server/src/main/java/de/nixis/web/disco/dto/ChannelOpen.java // public class ChannelOpen extends Base { // // } // // Path: server/src/main/java/de/nixis/web/disco/dto/Participant.java // public class Participant implements Comparable<Participant> { // // private ObjectId id; // // private String name; // // public Participant(String name) { // this.name = name; // // this.id = new ObjectId(); // } // // public Participant() { // } // // public String getId() { // return id.toString(); // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int compareTo(Participant o) { // return o.id.compareTo(id); // } // } // // Path: server/src/main/java/de/nixis/web/disco/room/Room.java // public interface Room { // // public String id(); // // public Map<Channel, String> channelMap(); // // public Set<Channel> channels(); // // public <T> Attribute<T> attr(AttributeKey<T> key); // // Map<String, Participant> participantsMap(); // } // // Path: server/src/main/java/de/nixis/web/disco/room/RoomHandler.java // public interface RoomHandler<T> { // // public void handleMessage(RoomContext ctx, T message); // // } // // Path: server/src/main/java/de/nixis/web/disco/room/impl/RoomContextImpl.java // public class RoomContextImpl implements RoomContext { // // private final Executor executor; // // private final Room room; // private final Channel channel; // // public RoomContextImpl(ChannelHandlerContext channelCtx, Room room) { // this(room, channelCtx.channel(), channelCtx.executor()); // } // // public RoomContextImpl(Room room, Channel channel, Executor executor) { // this.room = room; // this.executor = executor; // this.channel = channel; // } // // public Executor executor() { // return executor; // } // // public Channel channel() { // return channel; // } // // public Set<Channel> channels() { // return room.channels(); // } // // public Map<Channel, String> channelMap() { // return room.channelMap(); // } // // public Room room() { // return room; // } // // public <T> Attribute<T> attr(AttributeKey<T> key) { // return room.attr(key); // } // // public RoomContext forChannel(Channel newChannel) { // return new RoomContextImpl(room, newChannel, executor); // } // } // // Path: server/src/main/java/de/nixis/web/disco/ws/RoomAwareWebSocketHandler.java // public static enum ChannelEvent { // OPEN, CLOSE // }
import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentSkipListMap; import java.util.regex.Matcher; import java.util.regex.Pattern; import de.nixis.web.disco.dto.Base; import de.nixis.web.disco.dto.ChannelLeave; import de.nixis.web.disco.dto.ChannelOpen; import de.nixis.web.disco.dto.Participant; import de.nixis.web.disco.room.Room; import de.nixis.web.disco.room.RoomHandler; import de.nixis.web.disco.room.impl.RoomContextImpl; import de.nixis.web.disco.ws.RoomAwareWebSocketHandler.ChannelEvent; import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; import io.netty.handler.codec.http.DefaultFullHttpResponse; import io.netty.handler.codec.http.FullHttpRequest; import io.netty.handler.codec.http.FullHttpResponse; import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.util.Attribute; import io.netty.util.AttributeKey; import io.netty.util.AttributeMap; import io.netty.util.DefaultAttributeMap;
package de.nixis.web.disco.ws; /** * * @author nico.rehwaldt */ public class RoomAwareHandler extends SimpleChannelInboundHandler<Base> { public static final AttributeKey<String> ROOM_ID = new AttributeKey<String>("roomId"); private static final Rooms rooms = new RoomsImpl();
// Path: server/src/main/java/de/nixis/web/disco/dto/Base.java // public class Base { // // } // // Path: server/src/main/java/de/nixis/web/disco/dto/ChannelLeave.java // public class ChannelLeave extends Base { // // private String reason; // // public ChannelLeave() { // } // // public ChannelLeave(String reason) { // this.reason = reason; // } // // public String getReason() { // return reason; // } // } // // Path: server/src/main/java/de/nixis/web/disco/dto/ChannelOpen.java // public class ChannelOpen extends Base { // // } // // Path: server/src/main/java/de/nixis/web/disco/dto/Participant.java // public class Participant implements Comparable<Participant> { // // private ObjectId id; // // private String name; // // public Participant(String name) { // this.name = name; // // this.id = new ObjectId(); // } // // public Participant() { // } // // public String getId() { // return id.toString(); // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int compareTo(Participant o) { // return o.id.compareTo(id); // } // } // // Path: server/src/main/java/de/nixis/web/disco/room/Room.java // public interface Room { // // public String id(); // // public Map<Channel, String> channelMap(); // // public Set<Channel> channels(); // // public <T> Attribute<T> attr(AttributeKey<T> key); // // Map<String, Participant> participantsMap(); // } // // Path: server/src/main/java/de/nixis/web/disco/room/RoomHandler.java // public interface RoomHandler<T> { // // public void handleMessage(RoomContext ctx, T message); // // } // // Path: server/src/main/java/de/nixis/web/disco/room/impl/RoomContextImpl.java // public class RoomContextImpl implements RoomContext { // // private final Executor executor; // // private final Room room; // private final Channel channel; // // public RoomContextImpl(ChannelHandlerContext channelCtx, Room room) { // this(room, channelCtx.channel(), channelCtx.executor()); // } // // public RoomContextImpl(Room room, Channel channel, Executor executor) { // this.room = room; // this.executor = executor; // this.channel = channel; // } // // public Executor executor() { // return executor; // } // // public Channel channel() { // return channel; // } // // public Set<Channel> channels() { // return room.channels(); // } // // public Map<Channel, String> channelMap() { // return room.channelMap(); // } // // public Room room() { // return room; // } // // public <T> Attribute<T> attr(AttributeKey<T> key) { // return room.attr(key); // } // // public RoomContext forChannel(Channel newChannel) { // return new RoomContextImpl(room, newChannel, executor); // } // } // // Path: server/src/main/java/de/nixis/web/disco/ws/RoomAwareWebSocketHandler.java // public static enum ChannelEvent { // OPEN, CLOSE // } // Path: server/src/main/java/de/nixis/web/disco/ws/RoomAwareHandler.java import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentSkipListMap; import java.util.regex.Matcher; import java.util.regex.Pattern; import de.nixis.web.disco.dto.Base; import de.nixis.web.disco.dto.ChannelLeave; import de.nixis.web.disco.dto.ChannelOpen; import de.nixis.web.disco.dto.Participant; import de.nixis.web.disco.room.Room; import de.nixis.web.disco.room.RoomHandler; import de.nixis.web.disco.room.impl.RoomContextImpl; import de.nixis.web.disco.ws.RoomAwareWebSocketHandler.ChannelEvent; import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; import io.netty.handler.codec.http.DefaultFullHttpResponse; import io.netty.handler.codec.http.FullHttpRequest; import io.netty.handler.codec.http.FullHttpResponse; import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.util.Attribute; import io.netty.util.AttributeKey; import io.netty.util.AttributeMap; import io.netty.util.DefaultAttributeMap; package de.nixis.web.disco.ws; /** * * @author nico.rehwaldt */ public class RoomAwareHandler extends SimpleChannelInboundHandler<Base> { public static final AttributeKey<String> ROOM_ID = new AttributeKey<String>("roomId"); private static final Rooms rooms = new RoomsImpl();
private final RoomHandler roomHandler;
nikku/silent-disco
server/src/main/java/de/nixis/web/disco/ws/RoomAwareHandler.java
// Path: server/src/main/java/de/nixis/web/disco/dto/Base.java // public class Base { // // } // // Path: server/src/main/java/de/nixis/web/disco/dto/ChannelLeave.java // public class ChannelLeave extends Base { // // private String reason; // // public ChannelLeave() { // } // // public ChannelLeave(String reason) { // this.reason = reason; // } // // public String getReason() { // return reason; // } // } // // Path: server/src/main/java/de/nixis/web/disco/dto/ChannelOpen.java // public class ChannelOpen extends Base { // // } // // Path: server/src/main/java/de/nixis/web/disco/dto/Participant.java // public class Participant implements Comparable<Participant> { // // private ObjectId id; // // private String name; // // public Participant(String name) { // this.name = name; // // this.id = new ObjectId(); // } // // public Participant() { // } // // public String getId() { // return id.toString(); // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int compareTo(Participant o) { // return o.id.compareTo(id); // } // } // // Path: server/src/main/java/de/nixis/web/disco/room/Room.java // public interface Room { // // public String id(); // // public Map<Channel, String> channelMap(); // // public Set<Channel> channels(); // // public <T> Attribute<T> attr(AttributeKey<T> key); // // Map<String, Participant> participantsMap(); // } // // Path: server/src/main/java/de/nixis/web/disco/room/RoomHandler.java // public interface RoomHandler<T> { // // public void handleMessage(RoomContext ctx, T message); // // } // // Path: server/src/main/java/de/nixis/web/disco/room/impl/RoomContextImpl.java // public class RoomContextImpl implements RoomContext { // // private final Executor executor; // // private final Room room; // private final Channel channel; // // public RoomContextImpl(ChannelHandlerContext channelCtx, Room room) { // this(room, channelCtx.channel(), channelCtx.executor()); // } // // public RoomContextImpl(Room room, Channel channel, Executor executor) { // this.room = room; // this.executor = executor; // this.channel = channel; // } // // public Executor executor() { // return executor; // } // // public Channel channel() { // return channel; // } // // public Set<Channel> channels() { // return room.channels(); // } // // public Map<Channel, String> channelMap() { // return room.channelMap(); // } // // public Room room() { // return room; // } // // public <T> Attribute<T> attr(AttributeKey<T> key) { // return room.attr(key); // } // // public RoomContext forChannel(Channel newChannel) { // return new RoomContextImpl(room, newChannel, executor); // } // } // // Path: server/src/main/java/de/nixis/web/disco/ws/RoomAwareWebSocketHandler.java // public static enum ChannelEvent { // OPEN, CLOSE // }
import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentSkipListMap; import java.util.regex.Matcher; import java.util.regex.Pattern; import de.nixis.web.disco.dto.Base; import de.nixis.web.disco.dto.ChannelLeave; import de.nixis.web.disco.dto.ChannelOpen; import de.nixis.web.disco.dto.Participant; import de.nixis.web.disco.room.Room; import de.nixis.web.disco.room.RoomHandler; import de.nixis.web.disco.room.impl.RoomContextImpl; import de.nixis.web.disco.ws.RoomAwareWebSocketHandler.ChannelEvent; import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; import io.netty.handler.codec.http.DefaultFullHttpResponse; import io.netty.handler.codec.http.FullHttpRequest; import io.netty.handler.codec.http.FullHttpResponse; import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.util.Attribute; import io.netty.util.AttributeKey; import io.netty.util.AttributeMap; import io.netty.util.DefaultAttributeMap;
package de.nixis.web.disco.ws; /** * * @author nico.rehwaldt */ public class RoomAwareHandler extends SimpleChannelInboundHandler<Base> { public static final AttributeKey<String> ROOM_ID = new AttributeKey<String>("roomId"); private static final Rooms rooms = new RoomsImpl(); private final RoomHandler roomHandler; public RoomAwareHandler(RoomHandler roomHandler) { this.roomHandler = roomHandler; } @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
// Path: server/src/main/java/de/nixis/web/disco/dto/Base.java // public class Base { // // } // // Path: server/src/main/java/de/nixis/web/disco/dto/ChannelLeave.java // public class ChannelLeave extends Base { // // private String reason; // // public ChannelLeave() { // } // // public ChannelLeave(String reason) { // this.reason = reason; // } // // public String getReason() { // return reason; // } // } // // Path: server/src/main/java/de/nixis/web/disco/dto/ChannelOpen.java // public class ChannelOpen extends Base { // // } // // Path: server/src/main/java/de/nixis/web/disco/dto/Participant.java // public class Participant implements Comparable<Participant> { // // private ObjectId id; // // private String name; // // public Participant(String name) { // this.name = name; // // this.id = new ObjectId(); // } // // public Participant() { // } // // public String getId() { // return id.toString(); // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int compareTo(Participant o) { // return o.id.compareTo(id); // } // } // // Path: server/src/main/java/de/nixis/web/disco/room/Room.java // public interface Room { // // public String id(); // // public Map<Channel, String> channelMap(); // // public Set<Channel> channels(); // // public <T> Attribute<T> attr(AttributeKey<T> key); // // Map<String, Participant> participantsMap(); // } // // Path: server/src/main/java/de/nixis/web/disco/room/RoomHandler.java // public interface RoomHandler<T> { // // public void handleMessage(RoomContext ctx, T message); // // } // // Path: server/src/main/java/de/nixis/web/disco/room/impl/RoomContextImpl.java // public class RoomContextImpl implements RoomContext { // // private final Executor executor; // // private final Room room; // private final Channel channel; // // public RoomContextImpl(ChannelHandlerContext channelCtx, Room room) { // this(room, channelCtx.channel(), channelCtx.executor()); // } // // public RoomContextImpl(Room room, Channel channel, Executor executor) { // this.room = room; // this.executor = executor; // this.channel = channel; // } // // public Executor executor() { // return executor; // } // // public Channel channel() { // return channel; // } // // public Set<Channel> channels() { // return room.channels(); // } // // public Map<Channel, String> channelMap() { // return room.channelMap(); // } // // public Room room() { // return room; // } // // public <T> Attribute<T> attr(AttributeKey<T> key) { // return room.attr(key); // } // // public RoomContext forChannel(Channel newChannel) { // return new RoomContextImpl(room, newChannel, executor); // } // } // // Path: server/src/main/java/de/nixis/web/disco/ws/RoomAwareWebSocketHandler.java // public static enum ChannelEvent { // OPEN, CLOSE // } // Path: server/src/main/java/de/nixis/web/disco/ws/RoomAwareHandler.java import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentSkipListMap; import java.util.regex.Matcher; import java.util.regex.Pattern; import de.nixis.web.disco.dto.Base; import de.nixis.web.disco.dto.ChannelLeave; import de.nixis.web.disco.dto.ChannelOpen; import de.nixis.web.disco.dto.Participant; import de.nixis.web.disco.room.Room; import de.nixis.web.disco.room.RoomHandler; import de.nixis.web.disco.room.impl.RoomContextImpl; import de.nixis.web.disco.ws.RoomAwareWebSocketHandler.ChannelEvent; import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; import io.netty.handler.codec.http.DefaultFullHttpResponse; import io.netty.handler.codec.http.FullHttpRequest; import io.netty.handler.codec.http.FullHttpResponse; import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.util.Attribute; import io.netty.util.AttributeKey; import io.netty.util.AttributeMap; import io.netty.util.DefaultAttributeMap; package de.nixis.web.disco.ws; /** * * @author nico.rehwaldt */ public class RoomAwareHandler extends SimpleChannelInboundHandler<Base> { public static final AttributeKey<String> ROOM_ID = new AttributeKey<String>("roomId"); private static final Rooms rooms = new RoomsImpl(); private final RoomHandler roomHandler; public RoomAwareHandler(RoomHandler roomHandler) { this.roomHandler = roomHandler; } @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
if (evt == ChannelEvent.OPEN) {
nikku/silent-disco
server/src/main/java/de/nixis/web/disco/ws/RoomAwareHandler.java
// Path: server/src/main/java/de/nixis/web/disco/dto/Base.java // public class Base { // // } // // Path: server/src/main/java/de/nixis/web/disco/dto/ChannelLeave.java // public class ChannelLeave extends Base { // // private String reason; // // public ChannelLeave() { // } // // public ChannelLeave(String reason) { // this.reason = reason; // } // // public String getReason() { // return reason; // } // } // // Path: server/src/main/java/de/nixis/web/disco/dto/ChannelOpen.java // public class ChannelOpen extends Base { // // } // // Path: server/src/main/java/de/nixis/web/disco/dto/Participant.java // public class Participant implements Comparable<Participant> { // // private ObjectId id; // // private String name; // // public Participant(String name) { // this.name = name; // // this.id = new ObjectId(); // } // // public Participant() { // } // // public String getId() { // return id.toString(); // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int compareTo(Participant o) { // return o.id.compareTo(id); // } // } // // Path: server/src/main/java/de/nixis/web/disco/room/Room.java // public interface Room { // // public String id(); // // public Map<Channel, String> channelMap(); // // public Set<Channel> channels(); // // public <T> Attribute<T> attr(AttributeKey<T> key); // // Map<String, Participant> participantsMap(); // } // // Path: server/src/main/java/de/nixis/web/disco/room/RoomHandler.java // public interface RoomHandler<T> { // // public void handleMessage(RoomContext ctx, T message); // // } // // Path: server/src/main/java/de/nixis/web/disco/room/impl/RoomContextImpl.java // public class RoomContextImpl implements RoomContext { // // private final Executor executor; // // private final Room room; // private final Channel channel; // // public RoomContextImpl(ChannelHandlerContext channelCtx, Room room) { // this(room, channelCtx.channel(), channelCtx.executor()); // } // // public RoomContextImpl(Room room, Channel channel, Executor executor) { // this.room = room; // this.executor = executor; // this.channel = channel; // } // // public Executor executor() { // return executor; // } // // public Channel channel() { // return channel; // } // // public Set<Channel> channels() { // return room.channels(); // } // // public Map<Channel, String> channelMap() { // return room.channelMap(); // } // // public Room room() { // return room; // } // // public <T> Attribute<T> attr(AttributeKey<T> key) { // return room.attr(key); // } // // public RoomContext forChannel(Channel newChannel) { // return new RoomContextImpl(room, newChannel, executor); // } // } // // Path: server/src/main/java/de/nixis/web/disco/ws/RoomAwareWebSocketHandler.java // public static enum ChannelEvent { // OPEN, CLOSE // }
import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentSkipListMap; import java.util.regex.Matcher; import java.util.regex.Pattern; import de.nixis.web.disco.dto.Base; import de.nixis.web.disco.dto.ChannelLeave; import de.nixis.web.disco.dto.ChannelOpen; import de.nixis.web.disco.dto.Participant; import de.nixis.web.disco.room.Room; import de.nixis.web.disco.room.RoomHandler; import de.nixis.web.disco.room.impl.RoomContextImpl; import de.nixis.web.disco.ws.RoomAwareWebSocketHandler.ChannelEvent; import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; import io.netty.handler.codec.http.DefaultFullHttpResponse; import io.netty.handler.codec.http.FullHttpRequest; import io.netty.handler.codec.http.FullHttpResponse; import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.util.Attribute; import io.netty.util.AttributeKey; import io.netty.util.AttributeMap; import io.netty.util.DefaultAttributeMap;
package de.nixis.web.disco.ws; /** * * @author nico.rehwaldt */ public class RoomAwareHandler extends SimpleChannelInboundHandler<Base> { public static final AttributeKey<String> ROOM_ID = new AttributeKey<String>("roomId"); private static final Rooms rooms = new RoomsImpl(); private final RoomHandler roomHandler; public RoomAwareHandler(RoomHandler roomHandler) { this.roomHandler = roomHandler; } @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt == ChannelEvent.OPEN) {
// Path: server/src/main/java/de/nixis/web/disco/dto/Base.java // public class Base { // // } // // Path: server/src/main/java/de/nixis/web/disco/dto/ChannelLeave.java // public class ChannelLeave extends Base { // // private String reason; // // public ChannelLeave() { // } // // public ChannelLeave(String reason) { // this.reason = reason; // } // // public String getReason() { // return reason; // } // } // // Path: server/src/main/java/de/nixis/web/disco/dto/ChannelOpen.java // public class ChannelOpen extends Base { // // } // // Path: server/src/main/java/de/nixis/web/disco/dto/Participant.java // public class Participant implements Comparable<Participant> { // // private ObjectId id; // // private String name; // // public Participant(String name) { // this.name = name; // // this.id = new ObjectId(); // } // // public Participant() { // } // // public String getId() { // return id.toString(); // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int compareTo(Participant o) { // return o.id.compareTo(id); // } // } // // Path: server/src/main/java/de/nixis/web/disco/room/Room.java // public interface Room { // // public String id(); // // public Map<Channel, String> channelMap(); // // public Set<Channel> channels(); // // public <T> Attribute<T> attr(AttributeKey<T> key); // // Map<String, Participant> participantsMap(); // } // // Path: server/src/main/java/de/nixis/web/disco/room/RoomHandler.java // public interface RoomHandler<T> { // // public void handleMessage(RoomContext ctx, T message); // // } // // Path: server/src/main/java/de/nixis/web/disco/room/impl/RoomContextImpl.java // public class RoomContextImpl implements RoomContext { // // private final Executor executor; // // private final Room room; // private final Channel channel; // // public RoomContextImpl(ChannelHandlerContext channelCtx, Room room) { // this(room, channelCtx.channel(), channelCtx.executor()); // } // // public RoomContextImpl(Room room, Channel channel, Executor executor) { // this.room = room; // this.executor = executor; // this.channel = channel; // } // // public Executor executor() { // return executor; // } // // public Channel channel() { // return channel; // } // // public Set<Channel> channels() { // return room.channels(); // } // // public Map<Channel, String> channelMap() { // return room.channelMap(); // } // // public Room room() { // return room; // } // // public <T> Attribute<T> attr(AttributeKey<T> key) { // return room.attr(key); // } // // public RoomContext forChannel(Channel newChannel) { // return new RoomContextImpl(room, newChannel, executor); // } // } // // Path: server/src/main/java/de/nixis/web/disco/ws/RoomAwareWebSocketHandler.java // public static enum ChannelEvent { // OPEN, CLOSE // } // Path: server/src/main/java/de/nixis/web/disco/ws/RoomAwareHandler.java import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentSkipListMap; import java.util.regex.Matcher; import java.util.regex.Pattern; import de.nixis.web.disco.dto.Base; import de.nixis.web.disco.dto.ChannelLeave; import de.nixis.web.disco.dto.ChannelOpen; import de.nixis.web.disco.dto.Participant; import de.nixis.web.disco.room.Room; import de.nixis.web.disco.room.RoomHandler; import de.nixis.web.disco.room.impl.RoomContextImpl; import de.nixis.web.disco.ws.RoomAwareWebSocketHandler.ChannelEvent; import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; import io.netty.handler.codec.http.DefaultFullHttpResponse; import io.netty.handler.codec.http.FullHttpRequest; import io.netty.handler.codec.http.FullHttpResponse; import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.util.Attribute; import io.netty.util.AttributeKey; import io.netty.util.AttributeMap; import io.netty.util.DefaultAttributeMap; package de.nixis.web.disco.ws; /** * * @author nico.rehwaldt */ public class RoomAwareHandler extends SimpleChannelInboundHandler<Base> { public static final AttributeKey<String> ROOM_ID = new AttributeKey<String>("roomId"); private static final Rooms rooms = new RoomsImpl(); private final RoomHandler roomHandler; public RoomAwareHandler(RoomHandler roomHandler) { this.roomHandler = roomHandler; } @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt == ChannelEvent.OPEN) {
handleMessage(ctx, new ChannelOpen());
nikku/silent-disco
server/src/main/java/de/nixis/web/disco/ws/RoomAwareHandler.java
// Path: server/src/main/java/de/nixis/web/disco/dto/Base.java // public class Base { // // } // // Path: server/src/main/java/de/nixis/web/disco/dto/ChannelLeave.java // public class ChannelLeave extends Base { // // private String reason; // // public ChannelLeave() { // } // // public ChannelLeave(String reason) { // this.reason = reason; // } // // public String getReason() { // return reason; // } // } // // Path: server/src/main/java/de/nixis/web/disco/dto/ChannelOpen.java // public class ChannelOpen extends Base { // // } // // Path: server/src/main/java/de/nixis/web/disco/dto/Participant.java // public class Participant implements Comparable<Participant> { // // private ObjectId id; // // private String name; // // public Participant(String name) { // this.name = name; // // this.id = new ObjectId(); // } // // public Participant() { // } // // public String getId() { // return id.toString(); // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int compareTo(Participant o) { // return o.id.compareTo(id); // } // } // // Path: server/src/main/java/de/nixis/web/disco/room/Room.java // public interface Room { // // public String id(); // // public Map<Channel, String> channelMap(); // // public Set<Channel> channels(); // // public <T> Attribute<T> attr(AttributeKey<T> key); // // Map<String, Participant> participantsMap(); // } // // Path: server/src/main/java/de/nixis/web/disco/room/RoomHandler.java // public interface RoomHandler<T> { // // public void handleMessage(RoomContext ctx, T message); // // } // // Path: server/src/main/java/de/nixis/web/disco/room/impl/RoomContextImpl.java // public class RoomContextImpl implements RoomContext { // // private final Executor executor; // // private final Room room; // private final Channel channel; // // public RoomContextImpl(ChannelHandlerContext channelCtx, Room room) { // this(room, channelCtx.channel(), channelCtx.executor()); // } // // public RoomContextImpl(Room room, Channel channel, Executor executor) { // this.room = room; // this.executor = executor; // this.channel = channel; // } // // public Executor executor() { // return executor; // } // // public Channel channel() { // return channel; // } // // public Set<Channel> channels() { // return room.channels(); // } // // public Map<Channel, String> channelMap() { // return room.channelMap(); // } // // public Room room() { // return room; // } // // public <T> Attribute<T> attr(AttributeKey<T> key) { // return room.attr(key); // } // // public RoomContext forChannel(Channel newChannel) { // return new RoomContextImpl(room, newChannel, executor); // } // } // // Path: server/src/main/java/de/nixis/web/disco/ws/RoomAwareWebSocketHandler.java // public static enum ChannelEvent { // OPEN, CLOSE // }
import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentSkipListMap; import java.util.regex.Matcher; import java.util.regex.Pattern; import de.nixis.web.disco.dto.Base; import de.nixis.web.disco.dto.ChannelLeave; import de.nixis.web.disco.dto.ChannelOpen; import de.nixis.web.disco.dto.Participant; import de.nixis.web.disco.room.Room; import de.nixis.web.disco.room.RoomHandler; import de.nixis.web.disco.room.impl.RoomContextImpl; import de.nixis.web.disco.ws.RoomAwareWebSocketHandler.ChannelEvent; import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; import io.netty.handler.codec.http.DefaultFullHttpResponse; import io.netty.handler.codec.http.FullHttpRequest; import io.netty.handler.codec.http.FullHttpResponse; import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.util.Attribute; import io.netty.util.AttributeKey; import io.netty.util.AttributeMap; import io.netty.util.DefaultAttributeMap;
package de.nixis.web.disco.ws; /** * * @author nico.rehwaldt */ public class RoomAwareHandler extends SimpleChannelInboundHandler<Base> { public static final AttributeKey<String> ROOM_ID = new AttributeKey<String>("roomId"); private static final Rooms rooms = new RoomsImpl(); private final RoomHandler roomHandler; public RoomAwareHandler(RoomHandler roomHandler) { this.roomHandler = roomHandler; } @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt == ChannelEvent.OPEN) { handleMessage(ctx, new ChannelOpen()); } if (evt == ChannelEvent.CLOSE) {
// Path: server/src/main/java/de/nixis/web/disco/dto/Base.java // public class Base { // // } // // Path: server/src/main/java/de/nixis/web/disco/dto/ChannelLeave.java // public class ChannelLeave extends Base { // // private String reason; // // public ChannelLeave() { // } // // public ChannelLeave(String reason) { // this.reason = reason; // } // // public String getReason() { // return reason; // } // } // // Path: server/src/main/java/de/nixis/web/disco/dto/ChannelOpen.java // public class ChannelOpen extends Base { // // } // // Path: server/src/main/java/de/nixis/web/disco/dto/Participant.java // public class Participant implements Comparable<Participant> { // // private ObjectId id; // // private String name; // // public Participant(String name) { // this.name = name; // // this.id = new ObjectId(); // } // // public Participant() { // } // // public String getId() { // return id.toString(); // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int compareTo(Participant o) { // return o.id.compareTo(id); // } // } // // Path: server/src/main/java/de/nixis/web/disco/room/Room.java // public interface Room { // // public String id(); // // public Map<Channel, String> channelMap(); // // public Set<Channel> channels(); // // public <T> Attribute<T> attr(AttributeKey<T> key); // // Map<String, Participant> participantsMap(); // } // // Path: server/src/main/java/de/nixis/web/disco/room/RoomHandler.java // public interface RoomHandler<T> { // // public void handleMessage(RoomContext ctx, T message); // // } // // Path: server/src/main/java/de/nixis/web/disco/room/impl/RoomContextImpl.java // public class RoomContextImpl implements RoomContext { // // private final Executor executor; // // private final Room room; // private final Channel channel; // // public RoomContextImpl(ChannelHandlerContext channelCtx, Room room) { // this(room, channelCtx.channel(), channelCtx.executor()); // } // // public RoomContextImpl(Room room, Channel channel, Executor executor) { // this.room = room; // this.executor = executor; // this.channel = channel; // } // // public Executor executor() { // return executor; // } // // public Channel channel() { // return channel; // } // // public Set<Channel> channels() { // return room.channels(); // } // // public Map<Channel, String> channelMap() { // return room.channelMap(); // } // // public Room room() { // return room; // } // // public <T> Attribute<T> attr(AttributeKey<T> key) { // return room.attr(key); // } // // public RoomContext forChannel(Channel newChannel) { // return new RoomContextImpl(room, newChannel, executor); // } // } // // Path: server/src/main/java/de/nixis/web/disco/ws/RoomAwareWebSocketHandler.java // public static enum ChannelEvent { // OPEN, CLOSE // } // Path: server/src/main/java/de/nixis/web/disco/ws/RoomAwareHandler.java import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentSkipListMap; import java.util.regex.Matcher; import java.util.regex.Pattern; import de.nixis.web.disco.dto.Base; import de.nixis.web.disco.dto.ChannelLeave; import de.nixis.web.disco.dto.ChannelOpen; import de.nixis.web.disco.dto.Participant; import de.nixis.web.disco.room.Room; import de.nixis.web.disco.room.RoomHandler; import de.nixis.web.disco.room.impl.RoomContextImpl; import de.nixis.web.disco.ws.RoomAwareWebSocketHandler.ChannelEvent; import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; import io.netty.handler.codec.http.DefaultFullHttpResponse; import io.netty.handler.codec.http.FullHttpRequest; import io.netty.handler.codec.http.FullHttpResponse; import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.util.Attribute; import io.netty.util.AttributeKey; import io.netty.util.AttributeMap; import io.netty.util.DefaultAttributeMap; package de.nixis.web.disco.ws; /** * * @author nico.rehwaldt */ public class RoomAwareHandler extends SimpleChannelInboundHandler<Base> { public static final AttributeKey<String> ROOM_ID = new AttributeKey<String>("roomId"); private static final Rooms rooms = new RoomsImpl(); private final RoomHandler roomHandler; public RoomAwareHandler(RoomHandler roomHandler) { this.roomHandler = roomHandler; } @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt == ChannelEvent.OPEN) { handleMessage(ctx, new ChannelOpen()); } if (evt == ChannelEvent.CLOSE) {
handleMessage(ctx, new ChannelLeave());
nikku/silent-disco
server/src/main/java/de/nixis/web/disco/ws/RoomAwareHandler.java
// Path: server/src/main/java/de/nixis/web/disco/dto/Base.java // public class Base { // // } // // Path: server/src/main/java/de/nixis/web/disco/dto/ChannelLeave.java // public class ChannelLeave extends Base { // // private String reason; // // public ChannelLeave() { // } // // public ChannelLeave(String reason) { // this.reason = reason; // } // // public String getReason() { // return reason; // } // } // // Path: server/src/main/java/de/nixis/web/disco/dto/ChannelOpen.java // public class ChannelOpen extends Base { // // } // // Path: server/src/main/java/de/nixis/web/disco/dto/Participant.java // public class Participant implements Comparable<Participant> { // // private ObjectId id; // // private String name; // // public Participant(String name) { // this.name = name; // // this.id = new ObjectId(); // } // // public Participant() { // } // // public String getId() { // return id.toString(); // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int compareTo(Participant o) { // return o.id.compareTo(id); // } // } // // Path: server/src/main/java/de/nixis/web/disco/room/Room.java // public interface Room { // // public String id(); // // public Map<Channel, String> channelMap(); // // public Set<Channel> channels(); // // public <T> Attribute<T> attr(AttributeKey<T> key); // // Map<String, Participant> participantsMap(); // } // // Path: server/src/main/java/de/nixis/web/disco/room/RoomHandler.java // public interface RoomHandler<T> { // // public void handleMessage(RoomContext ctx, T message); // // } // // Path: server/src/main/java/de/nixis/web/disco/room/impl/RoomContextImpl.java // public class RoomContextImpl implements RoomContext { // // private final Executor executor; // // private final Room room; // private final Channel channel; // // public RoomContextImpl(ChannelHandlerContext channelCtx, Room room) { // this(room, channelCtx.channel(), channelCtx.executor()); // } // // public RoomContextImpl(Room room, Channel channel, Executor executor) { // this.room = room; // this.executor = executor; // this.channel = channel; // } // // public Executor executor() { // return executor; // } // // public Channel channel() { // return channel; // } // // public Set<Channel> channels() { // return room.channels(); // } // // public Map<Channel, String> channelMap() { // return room.channelMap(); // } // // public Room room() { // return room; // } // // public <T> Attribute<T> attr(AttributeKey<T> key) { // return room.attr(key); // } // // public RoomContext forChannel(Channel newChannel) { // return new RoomContextImpl(room, newChannel, executor); // } // } // // Path: server/src/main/java/de/nixis/web/disco/ws/RoomAwareWebSocketHandler.java // public static enum ChannelEvent { // OPEN, CLOSE // }
import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentSkipListMap; import java.util.regex.Matcher; import java.util.regex.Pattern; import de.nixis.web.disco.dto.Base; import de.nixis.web.disco.dto.ChannelLeave; import de.nixis.web.disco.dto.ChannelOpen; import de.nixis.web.disco.dto.Participant; import de.nixis.web.disco.room.Room; import de.nixis.web.disco.room.RoomHandler; import de.nixis.web.disco.room.impl.RoomContextImpl; import de.nixis.web.disco.ws.RoomAwareWebSocketHandler.ChannelEvent; import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; import io.netty.handler.codec.http.DefaultFullHttpResponse; import io.netty.handler.codec.http.FullHttpRequest; import io.netty.handler.codec.http.FullHttpResponse; import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.util.Attribute; import io.netty.util.AttributeKey; import io.netty.util.AttributeMap; import io.netty.util.DefaultAttributeMap;
handleMessage(ctx, msg); } /** * Handle a message in a generic way. * * @param ctx * @param message */ public void handleMessage(ChannelHandlerContext ctx, Base message) { String roomId = ctx.channel().attr(ROOM_ID).get(); if (roomId == null) { // channel leave may be sent out of order // (e.g. when a timeout occurs) if (message instanceof ChannelLeave) { handleOutOfOrderChannelLeave(ctx, (ChannelLeave) message); } else { throw new RuntimeException("No room id set"); } // nothing to do return; } handleRoomMessage(roomId, ctx, message); } protected void handleOutOfOrderChannelLeave(ChannelHandlerContext ctx, ChannelLeave message) {
// Path: server/src/main/java/de/nixis/web/disco/dto/Base.java // public class Base { // // } // // Path: server/src/main/java/de/nixis/web/disco/dto/ChannelLeave.java // public class ChannelLeave extends Base { // // private String reason; // // public ChannelLeave() { // } // // public ChannelLeave(String reason) { // this.reason = reason; // } // // public String getReason() { // return reason; // } // } // // Path: server/src/main/java/de/nixis/web/disco/dto/ChannelOpen.java // public class ChannelOpen extends Base { // // } // // Path: server/src/main/java/de/nixis/web/disco/dto/Participant.java // public class Participant implements Comparable<Participant> { // // private ObjectId id; // // private String name; // // public Participant(String name) { // this.name = name; // // this.id = new ObjectId(); // } // // public Participant() { // } // // public String getId() { // return id.toString(); // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int compareTo(Participant o) { // return o.id.compareTo(id); // } // } // // Path: server/src/main/java/de/nixis/web/disco/room/Room.java // public interface Room { // // public String id(); // // public Map<Channel, String> channelMap(); // // public Set<Channel> channels(); // // public <T> Attribute<T> attr(AttributeKey<T> key); // // Map<String, Participant> participantsMap(); // } // // Path: server/src/main/java/de/nixis/web/disco/room/RoomHandler.java // public interface RoomHandler<T> { // // public void handleMessage(RoomContext ctx, T message); // // } // // Path: server/src/main/java/de/nixis/web/disco/room/impl/RoomContextImpl.java // public class RoomContextImpl implements RoomContext { // // private final Executor executor; // // private final Room room; // private final Channel channel; // // public RoomContextImpl(ChannelHandlerContext channelCtx, Room room) { // this(room, channelCtx.channel(), channelCtx.executor()); // } // // public RoomContextImpl(Room room, Channel channel, Executor executor) { // this.room = room; // this.executor = executor; // this.channel = channel; // } // // public Executor executor() { // return executor; // } // // public Channel channel() { // return channel; // } // // public Set<Channel> channels() { // return room.channels(); // } // // public Map<Channel, String> channelMap() { // return room.channelMap(); // } // // public Room room() { // return room; // } // // public <T> Attribute<T> attr(AttributeKey<T> key) { // return room.attr(key); // } // // public RoomContext forChannel(Channel newChannel) { // return new RoomContextImpl(room, newChannel, executor); // } // } // // Path: server/src/main/java/de/nixis/web/disco/ws/RoomAwareWebSocketHandler.java // public static enum ChannelEvent { // OPEN, CLOSE // } // Path: server/src/main/java/de/nixis/web/disco/ws/RoomAwareHandler.java import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentSkipListMap; import java.util.regex.Matcher; import java.util.regex.Pattern; import de.nixis.web.disco.dto.Base; import de.nixis.web.disco.dto.ChannelLeave; import de.nixis.web.disco.dto.ChannelOpen; import de.nixis.web.disco.dto.Participant; import de.nixis.web.disco.room.Room; import de.nixis.web.disco.room.RoomHandler; import de.nixis.web.disco.room.impl.RoomContextImpl; import de.nixis.web.disco.ws.RoomAwareWebSocketHandler.ChannelEvent; import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; import io.netty.handler.codec.http.DefaultFullHttpResponse; import io.netty.handler.codec.http.FullHttpRequest; import io.netty.handler.codec.http.FullHttpResponse; import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.util.Attribute; import io.netty.util.AttributeKey; import io.netty.util.AttributeMap; import io.netty.util.DefaultAttributeMap; handleMessage(ctx, msg); } /** * Handle a message in a generic way. * * @param ctx * @param message */ public void handleMessage(ChannelHandlerContext ctx, Base message) { String roomId = ctx.channel().attr(ROOM_ID).get(); if (roomId == null) { // channel leave may be sent out of order // (e.g. when a timeout occurs) if (message instanceof ChannelLeave) { handleOutOfOrderChannelLeave(ctx, (ChannelLeave) message); } else { throw new RuntimeException("No room id set"); } // nothing to do return; } handleRoomMessage(roomId, ctx, message); } protected void handleOutOfOrderChannelLeave(ChannelHandlerContext ctx, ChannelLeave message) {
Set<Room> connectedRooms = rooms.getByChannel(ctx.channel());
nikku/silent-disco
server/src/main/java/de/nixis/web/disco/ws/RoomAwareHandler.java
// Path: server/src/main/java/de/nixis/web/disco/dto/Base.java // public class Base { // // } // // Path: server/src/main/java/de/nixis/web/disco/dto/ChannelLeave.java // public class ChannelLeave extends Base { // // private String reason; // // public ChannelLeave() { // } // // public ChannelLeave(String reason) { // this.reason = reason; // } // // public String getReason() { // return reason; // } // } // // Path: server/src/main/java/de/nixis/web/disco/dto/ChannelOpen.java // public class ChannelOpen extends Base { // // } // // Path: server/src/main/java/de/nixis/web/disco/dto/Participant.java // public class Participant implements Comparable<Participant> { // // private ObjectId id; // // private String name; // // public Participant(String name) { // this.name = name; // // this.id = new ObjectId(); // } // // public Participant() { // } // // public String getId() { // return id.toString(); // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int compareTo(Participant o) { // return o.id.compareTo(id); // } // } // // Path: server/src/main/java/de/nixis/web/disco/room/Room.java // public interface Room { // // public String id(); // // public Map<Channel, String> channelMap(); // // public Set<Channel> channels(); // // public <T> Attribute<T> attr(AttributeKey<T> key); // // Map<String, Participant> participantsMap(); // } // // Path: server/src/main/java/de/nixis/web/disco/room/RoomHandler.java // public interface RoomHandler<T> { // // public void handleMessage(RoomContext ctx, T message); // // } // // Path: server/src/main/java/de/nixis/web/disco/room/impl/RoomContextImpl.java // public class RoomContextImpl implements RoomContext { // // private final Executor executor; // // private final Room room; // private final Channel channel; // // public RoomContextImpl(ChannelHandlerContext channelCtx, Room room) { // this(room, channelCtx.channel(), channelCtx.executor()); // } // // public RoomContextImpl(Room room, Channel channel, Executor executor) { // this.room = room; // this.executor = executor; // this.channel = channel; // } // // public Executor executor() { // return executor; // } // // public Channel channel() { // return channel; // } // // public Set<Channel> channels() { // return room.channels(); // } // // public Map<Channel, String> channelMap() { // return room.channelMap(); // } // // public Room room() { // return room; // } // // public <T> Attribute<T> attr(AttributeKey<T> key) { // return room.attr(key); // } // // public RoomContext forChannel(Channel newChannel) { // return new RoomContextImpl(room, newChannel, executor); // } // } // // Path: server/src/main/java/de/nixis/web/disco/ws/RoomAwareWebSocketHandler.java // public static enum ChannelEvent { // OPEN, CLOSE // }
import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentSkipListMap; import java.util.regex.Matcher; import java.util.regex.Pattern; import de.nixis.web.disco.dto.Base; import de.nixis.web.disco.dto.ChannelLeave; import de.nixis.web.disco.dto.ChannelOpen; import de.nixis.web.disco.dto.Participant; import de.nixis.web.disco.room.Room; import de.nixis.web.disco.room.RoomHandler; import de.nixis.web.disco.room.impl.RoomContextImpl; import de.nixis.web.disco.ws.RoomAwareWebSocketHandler.ChannelEvent; import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; import io.netty.handler.codec.http.DefaultFullHttpResponse; import io.netty.handler.codec.http.FullHttpRequest; import io.netty.handler.codec.http.FullHttpResponse; import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.util.Attribute; import io.netty.util.AttributeKey; import io.netty.util.AttributeMap; import io.netty.util.DefaultAttributeMap;
/** * Handle a message in a generic way. * * @param ctx * @param message */ public void handleMessage(ChannelHandlerContext ctx, Base message) { String roomId = ctx.channel().attr(ROOM_ID).get(); if (roomId == null) { // channel leave may be sent out of order // (e.g. when a timeout occurs) if (message instanceof ChannelLeave) { handleOutOfOrderChannelLeave(ctx, (ChannelLeave) message); } else { throw new RuntimeException("No room id set"); } // nothing to do return; } handleRoomMessage(roomId, ctx, message); } protected void handleOutOfOrderChannelLeave(ChannelHandlerContext ctx, ChannelLeave message) { Set<Room> connectedRooms = rooms.getByChannel(ctx.channel()); for (Room connectedRoom: connectedRooms) {
// Path: server/src/main/java/de/nixis/web/disco/dto/Base.java // public class Base { // // } // // Path: server/src/main/java/de/nixis/web/disco/dto/ChannelLeave.java // public class ChannelLeave extends Base { // // private String reason; // // public ChannelLeave() { // } // // public ChannelLeave(String reason) { // this.reason = reason; // } // // public String getReason() { // return reason; // } // } // // Path: server/src/main/java/de/nixis/web/disco/dto/ChannelOpen.java // public class ChannelOpen extends Base { // // } // // Path: server/src/main/java/de/nixis/web/disco/dto/Participant.java // public class Participant implements Comparable<Participant> { // // private ObjectId id; // // private String name; // // public Participant(String name) { // this.name = name; // // this.id = new ObjectId(); // } // // public Participant() { // } // // public String getId() { // return id.toString(); // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int compareTo(Participant o) { // return o.id.compareTo(id); // } // } // // Path: server/src/main/java/de/nixis/web/disco/room/Room.java // public interface Room { // // public String id(); // // public Map<Channel, String> channelMap(); // // public Set<Channel> channels(); // // public <T> Attribute<T> attr(AttributeKey<T> key); // // Map<String, Participant> participantsMap(); // } // // Path: server/src/main/java/de/nixis/web/disco/room/RoomHandler.java // public interface RoomHandler<T> { // // public void handleMessage(RoomContext ctx, T message); // // } // // Path: server/src/main/java/de/nixis/web/disco/room/impl/RoomContextImpl.java // public class RoomContextImpl implements RoomContext { // // private final Executor executor; // // private final Room room; // private final Channel channel; // // public RoomContextImpl(ChannelHandlerContext channelCtx, Room room) { // this(room, channelCtx.channel(), channelCtx.executor()); // } // // public RoomContextImpl(Room room, Channel channel, Executor executor) { // this.room = room; // this.executor = executor; // this.channel = channel; // } // // public Executor executor() { // return executor; // } // // public Channel channel() { // return channel; // } // // public Set<Channel> channels() { // return room.channels(); // } // // public Map<Channel, String> channelMap() { // return room.channelMap(); // } // // public Room room() { // return room; // } // // public <T> Attribute<T> attr(AttributeKey<T> key) { // return room.attr(key); // } // // public RoomContext forChannel(Channel newChannel) { // return new RoomContextImpl(room, newChannel, executor); // } // } // // Path: server/src/main/java/de/nixis/web/disco/ws/RoomAwareWebSocketHandler.java // public static enum ChannelEvent { // OPEN, CLOSE // } // Path: server/src/main/java/de/nixis/web/disco/ws/RoomAwareHandler.java import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentSkipListMap; import java.util.regex.Matcher; import java.util.regex.Pattern; import de.nixis.web.disco.dto.Base; import de.nixis.web.disco.dto.ChannelLeave; import de.nixis.web.disco.dto.ChannelOpen; import de.nixis.web.disco.dto.Participant; import de.nixis.web.disco.room.Room; import de.nixis.web.disco.room.RoomHandler; import de.nixis.web.disco.room.impl.RoomContextImpl; import de.nixis.web.disco.ws.RoomAwareWebSocketHandler.ChannelEvent; import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; import io.netty.handler.codec.http.DefaultFullHttpResponse; import io.netty.handler.codec.http.FullHttpRequest; import io.netty.handler.codec.http.FullHttpResponse; import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.util.Attribute; import io.netty.util.AttributeKey; import io.netty.util.AttributeMap; import io.netty.util.DefaultAttributeMap; /** * Handle a message in a generic way. * * @param ctx * @param message */ public void handleMessage(ChannelHandlerContext ctx, Base message) { String roomId = ctx.channel().attr(ROOM_ID).get(); if (roomId == null) { // channel leave may be sent out of order // (e.g. when a timeout occurs) if (message instanceof ChannelLeave) { handleOutOfOrderChannelLeave(ctx, (ChannelLeave) message); } else { throw new RuntimeException("No room id set"); } // nothing to do return; } handleRoomMessage(roomId, ctx, message); } protected void handleOutOfOrderChannelLeave(ChannelHandlerContext ctx, ChannelLeave message) { Set<Room> connectedRooms = rooms.getByChannel(ctx.channel()); for (Room connectedRoom: connectedRooms) {
RoomContextImpl roomContext = new RoomContextImpl(ctx, connectedRoom);
nikku/silent-disco
server/src/main/java/de/nixis/web/disco/ws/RoomAwareHandler.java
// Path: server/src/main/java/de/nixis/web/disco/dto/Base.java // public class Base { // // } // // Path: server/src/main/java/de/nixis/web/disco/dto/ChannelLeave.java // public class ChannelLeave extends Base { // // private String reason; // // public ChannelLeave() { // } // // public ChannelLeave(String reason) { // this.reason = reason; // } // // public String getReason() { // return reason; // } // } // // Path: server/src/main/java/de/nixis/web/disco/dto/ChannelOpen.java // public class ChannelOpen extends Base { // // } // // Path: server/src/main/java/de/nixis/web/disco/dto/Participant.java // public class Participant implements Comparable<Participant> { // // private ObjectId id; // // private String name; // // public Participant(String name) { // this.name = name; // // this.id = new ObjectId(); // } // // public Participant() { // } // // public String getId() { // return id.toString(); // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int compareTo(Participant o) { // return o.id.compareTo(id); // } // } // // Path: server/src/main/java/de/nixis/web/disco/room/Room.java // public interface Room { // // public String id(); // // public Map<Channel, String> channelMap(); // // public Set<Channel> channels(); // // public <T> Attribute<T> attr(AttributeKey<T> key); // // Map<String, Participant> participantsMap(); // } // // Path: server/src/main/java/de/nixis/web/disco/room/RoomHandler.java // public interface RoomHandler<T> { // // public void handleMessage(RoomContext ctx, T message); // // } // // Path: server/src/main/java/de/nixis/web/disco/room/impl/RoomContextImpl.java // public class RoomContextImpl implements RoomContext { // // private final Executor executor; // // private final Room room; // private final Channel channel; // // public RoomContextImpl(ChannelHandlerContext channelCtx, Room room) { // this(room, channelCtx.channel(), channelCtx.executor()); // } // // public RoomContextImpl(Room room, Channel channel, Executor executor) { // this.room = room; // this.executor = executor; // this.channel = channel; // } // // public Executor executor() { // return executor; // } // // public Channel channel() { // return channel; // } // // public Set<Channel> channels() { // return room.channels(); // } // // public Map<Channel, String> channelMap() { // return room.channelMap(); // } // // public Room room() { // return room; // } // // public <T> Attribute<T> attr(AttributeKey<T> key) { // return room.attr(key); // } // // public RoomContext forChannel(Channel newChannel) { // return new RoomContextImpl(room, newChannel, executor); // } // } // // Path: server/src/main/java/de/nixis/web/disco/ws/RoomAwareWebSocketHandler.java // public static enum ChannelEvent { // OPEN, CLOSE // }
import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentSkipListMap; import java.util.regex.Matcher; import java.util.regex.Pattern; import de.nixis.web.disco.dto.Base; import de.nixis.web.disco.dto.ChannelLeave; import de.nixis.web.disco.dto.ChannelOpen; import de.nixis.web.disco.dto.Participant; import de.nixis.web.disco.room.Room; import de.nixis.web.disco.room.RoomHandler; import de.nixis.web.disco.room.impl.RoomContextImpl; import de.nixis.web.disco.ws.RoomAwareWebSocketHandler.ChannelEvent; import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; import io.netty.handler.codec.http.DefaultFullHttpResponse; import io.netty.handler.codec.http.FullHttpRequest; import io.netty.handler.codec.http.FullHttpResponse; import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.util.Attribute; import io.netty.util.AttributeKey; import io.netty.util.AttributeMap; import io.netty.util.DefaultAttributeMap;
private final AttributeMap attributes = new DefaultAttributeMap(); private final Map channelMap = new ConcurrentSkipListMap<Channel, String>(); private final String id; public RoomImpl(String id) { this.id = id; } public String id() { return id; } public Map<Channel, String> channelMap() { return channelMap; } public Set<String> participantIds() { return new HashSet<String>(channelMap.values()); } public Set<Channel> channels() { return channelMap.keySet(); } public <T> Attribute<T> attr(AttributeKey<T> key) { return attributes.attr(key); }
// Path: server/src/main/java/de/nixis/web/disco/dto/Base.java // public class Base { // // } // // Path: server/src/main/java/de/nixis/web/disco/dto/ChannelLeave.java // public class ChannelLeave extends Base { // // private String reason; // // public ChannelLeave() { // } // // public ChannelLeave(String reason) { // this.reason = reason; // } // // public String getReason() { // return reason; // } // } // // Path: server/src/main/java/de/nixis/web/disco/dto/ChannelOpen.java // public class ChannelOpen extends Base { // // } // // Path: server/src/main/java/de/nixis/web/disco/dto/Participant.java // public class Participant implements Comparable<Participant> { // // private ObjectId id; // // private String name; // // public Participant(String name) { // this.name = name; // // this.id = new ObjectId(); // } // // public Participant() { // } // // public String getId() { // return id.toString(); // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int compareTo(Participant o) { // return o.id.compareTo(id); // } // } // // Path: server/src/main/java/de/nixis/web/disco/room/Room.java // public interface Room { // // public String id(); // // public Map<Channel, String> channelMap(); // // public Set<Channel> channels(); // // public <T> Attribute<T> attr(AttributeKey<T> key); // // Map<String, Participant> participantsMap(); // } // // Path: server/src/main/java/de/nixis/web/disco/room/RoomHandler.java // public interface RoomHandler<T> { // // public void handleMessage(RoomContext ctx, T message); // // } // // Path: server/src/main/java/de/nixis/web/disco/room/impl/RoomContextImpl.java // public class RoomContextImpl implements RoomContext { // // private final Executor executor; // // private final Room room; // private final Channel channel; // // public RoomContextImpl(ChannelHandlerContext channelCtx, Room room) { // this(room, channelCtx.channel(), channelCtx.executor()); // } // // public RoomContextImpl(Room room, Channel channel, Executor executor) { // this.room = room; // this.executor = executor; // this.channel = channel; // } // // public Executor executor() { // return executor; // } // // public Channel channel() { // return channel; // } // // public Set<Channel> channels() { // return room.channels(); // } // // public Map<Channel, String> channelMap() { // return room.channelMap(); // } // // public Room room() { // return room; // } // // public <T> Attribute<T> attr(AttributeKey<T> key) { // return room.attr(key); // } // // public RoomContext forChannel(Channel newChannel) { // return new RoomContextImpl(room, newChannel, executor); // } // } // // Path: server/src/main/java/de/nixis/web/disco/ws/RoomAwareWebSocketHandler.java // public static enum ChannelEvent { // OPEN, CLOSE // } // Path: server/src/main/java/de/nixis/web/disco/ws/RoomAwareHandler.java import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentSkipListMap; import java.util.regex.Matcher; import java.util.regex.Pattern; import de.nixis.web.disco.dto.Base; import de.nixis.web.disco.dto.ChannelLeave; import de.nixis.web.disco.dto.ChannelOpen; import de.nixis.web.disco.dto.Participant; import de.nixis.web.disco.room.Room; import de.nixis.web.disco.room.RoomHandler; import de.nixis.web.disco.room.impl.RoomContextImpl; import de.nixis.web.disco.ws.RoomAwareWebSocketHandler.ChannelEvent; import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; import io.netty.handler.codec.http.DefaultFullHttpResponse; import io.netty.handler.codec.http.FullHttpRequest; import io.netty.handler.codec.http.FullHttpResponse; import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.util.Attribute; import io.netty.util.AttributeKey; import io.netty.util.AttributeMap; import io.netty.util.DefaultAttributeMap; private final AttributeMap attributes = new DefaultAttributeMap(); private final Map channelMap = new ConcurrentSkipListMap<Channel, String>(); private final String id; public RoomImpl(String id) { this.id = id; } public String id() { return id; } public Map<Channel, String> channelMap() { return channelMap; } public Set<String> participantIds() { return new HashSet<String>(channelMap.values()); } public Set<Channel> channels() { return channelMap.keySet(); } public <T> Attribute<T> attr(AttributeKey<T> key) { return attributes.attr(key); }
private static final AttributeKey<Map<String, Participant>> PARTICIPANTS = new AttributeKey<Map<String, Participant>>("Participants");
nikku/silent-disco
server/src/main/java/de/nixis/web/disco/room/Room.java
// Path: server/src/main/java/de/nixis/web/disco/dto/Participant.java // public class Participant implements Comparable<Participant> { // // private ObjectId id; // // private String name; // // public Participant(String name) { // this.name = name; // // this.id = new ObjectId(); // } // // public Participant() { // } // // public String getId() { // return id.toString(); // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int compareTo(Participant o) { // return o.id.compareTo(id); // } // }
import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentSkipListMap; import de.nixis.web.disco.dto.Participant; import io.netty.channel.Channel; import io.netty.util.Attribute; import io.netty.util.AttributeKey;
package de.nixis.web.disco.room; /** * * @author nico.rehwaldt */ public interface Room { public String id(); public Map<Channel, String> channelMap(); public Set<Channel> channels(); public <T> Attribute<T> attr(AttributeKey<T> key);
// Path: server/src/main/java/de/nixis/web/disco/dto/Participant.java // public class Participant implements Comparable<Participant> { // // private ObjectId id; // // private String name; // // public Participant(String name) { // this.name = name; // // this.id = new ObjectId(); // } // // public Participant() { // } // // public String getId() { // return id.toString(); // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int compareTo(Participant o) { // return o.id.compareTo(id); // } // } // Path: server/src/main/java/de/nixis/web/disco/room/Room.java import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentSkipListMap; import de.nixis.web.disco.dto.Participant; import io.netty.channel.Channel; import io.netty.util.Attribute; import io.netty.util.AttributeKey; package de.nixis.web.disco.room; /** * * @author nico.rehwaldt */ public interface Room { public String id(); public Map<Channel, String> channelMap(); public Set<Channel> channels(); public <T> Attribute<T> attr(AttributeKey<T> key);
Map<String, Participant> participantsMap();
nikku/silent-disco
server/src/test/java/de/nixis/web/disco/json/DecodeHelperTest.java
// Path: server/src/test/java/de/nixis/web/disco/dto/Foo.java // public class Foo extends Base { // // private String bar; // // public void setBar(String bar) { // this.bar = bar; // } // // public String getBar() { // return bar; // } // }
import static org.fest.assertions.Assertions.assertThat; import org.junit.Test; import de.nixis.web.disco.dto.Foo;
package de.nixis.web.disco.json; /** * * @author nico.rehwaldt */ public class DecodeHelperTest { @Test public void testDecode() { String msg = "{\"foo\":{ \"bar\": \"asdf\" }}";
// Path: server/src/test/java/de/nixis/web/disco/dto/Foo.java // public class Foo extends Base { // // private String bar; // // public void setBar(String bar) { // this.bar = bar; // } // // public String getBar() { // return bar; // } // } // Path: server/src/test/java/de/nixis/web/disco/json/DecodeHelperTest.java import static org.fest.assertions.Assertions.assertThat; import org.junit.Test; import de.nixis.web.disco.dto.Foo; package de.nixis.web.disco.json; /** * * @author nico.rehwaldt */ public class DecodeHelperTest { @Test public void testDecode() { String msg = "{\"foo\":{ \"bar\": \"asdf\" }}";
Foo decodedFoo = DecodeHelper.decode(msg, Foo.class);
mingzuozhibi/mzzb-server
src/main/java/mingzuozhibi/action/UserController.java
// Path: src/main/java/mingzuozhibi/persist/user/AutoLogin.java // @Entity // public class AutoLogin extends BaseModel implements Serializable { // // private User user; // private String token; // private LocalDateTime expired; // // public AutoLogin() { // } // // public AutoLogin(User user, String token, LocalDateTime expired) { // this.user = user; // this.token = token; // this.expired = expired; // } // // @ManyToOne(optional = false) // public User getUser() { // return user; // } // // public void setUser(User user) { // this.user = user; // } // // @Column(length = 36, nullable = false) // public String getToken() { // return token; // } // // public void setToken(String token) { // this.token = token; // } // // @Column(nullable = false) // public LocalDateTime getExpired() { // return expired; // } // // public void setExpired(LocalDateTime expired) { // this.expired = expired; // } // // } // // Path: src/main/java/mingzuozhibi/persist/user/User.java // @Entity // public class User extends BaseModel implements Serializable { // // private String username; // private String password; // private boolean enabled; // private Set<String> roles = new HashSet<>(); // // private LocalDateTime registerDate; // private LocalDateTime lastLoggedIn; // // public User() { // } // // public User(String username, String password, boolean enabled) { // this.username = username; // this.password = password; // this.enabled = enabled; // this.registerDate = LocalDateTime.now().withNano(0); // this.roles.add("ROLE_BASIC"); // } // // @Column(length = 32, nullable = false) // public String getPassword() { // return password; // } // // public void setPassword(String password) { // this.password = password; // } // // @Column(length = 32, unique = true, nullable = false) // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // @Column(nullable = false) // public boolean isEnabled() { // return enabled; // } // // public void setEnabled(boolean enabled) { // this.enabled = enabled; // } // // @ElementCollection // @CollectionTable(name = "user_roles", joinColumns = @JoinColumn(name = "user_id")) // public Set<String> getRoles() { // return roles; // } // // public void setRoles(Set<String> roles) { // this.roles = roles; // } // // @Column(nullable = false) // public LocalDateTime getRegisterDate() { // return registerDate; // } // // public void setRegisterDate(LocalDateTime registerDate) { // this.registerDate = registerDate; // } // // @Column // public LocalDateTime getLastLoggedIn() { // return lastLoggedIn; // } // // public void setLastLoggedIn(LocalDateTime lastLoggedIn) { // this.lastLoggedIn = lastLoggedIn; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // User user = (User) o; // return Objects.equals(username, user.username); // } // // @Override // public int hashCode() { // return Objects.hash(username); // } // // private static final DateTimeFormatter formatterTime = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"); // // public JSONObject toJSON() { // JSONObject object = new JSONObject(); // object.put("id", getId()); // object.put("username", getUsername()); // object.put("enabled", isEnabled()); // object.put("registerDate", getRegisterDate().format(formatterTime)); // Optional.ofNullable(getLastLoggedIn()).ifPresent(lastLoggedIn -> { // object.put("lastLoggedIn", lastLoggedIn.format(formatterTime)); // }); // return object; // } // // }
import mingzuozhibi.persist.user.AutoLogin; import mingzuozhibi.persist.user.User; import mingzuozhibi.support.JsonArg; import org.apache.commons.lang3.StringUtils; import org.json.JSONArray; import org.json.JSONObject; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import java.util.List;
package mingzuozhibi.action; @RestController public class UserController extends BaseController { @Transactional @PreAuthorize("hasRole('ADMIN')") @GetMapping(value = "/api/users", produces = MEDIA_TYPE) public String findAll() { JSONArray result = new JSONArray();
// Path: src/main/java/mingzuozhibi/persist/user/AutoLogin.java // @Entity // public class AutoLogin extends BaseModel implements Serializable { // // private User user; // private String token; // private LocalDateTime expired; // // public AutoLogin() { // } // // public AutoLogin(User user, String token, LocalDateTime expired) { // this.user = user; // this.token = token; // this.expired = expired; // } // // @ManyToOne(optional = false) // public User getUser() { // return user; // } // // public void setUser(User user) { // this.user = user; // } // // @Column(length = 36, nullable = false) // public String getToken() { // return token; // } // // public void setToken(String token) { // this.token = token; // } // // @Column(nullable = false) // public LocalDateTime getExpired() { // return expired; // } // // public void setExpired(LocalDateTime expired) { // this.expired = expired; // } // // } // // Path: src/main/java/mingzuozhibi/persist/user/User.java // @Entity // public class User extends BaseModel implements Serializable { // // private String username; // private String password; // private boolean enabled; // private Set<String> roles = new HashSet<>(); // // private LocalDateTime registerDate; // private LocalDateTime lastLoggedIn; // // public User() { // } // // public User(String username, String password, boolean enabled) { // this.username = username; // this.password = password; // this.enabled = enabled; // this.registerDate = LocalDateTime.now().withNano(0); // this.roles.add("ROLE_BASIC"); // } // // @Column(length = 32, nullable = false) // public String getPassword() { // return password; // } // // public void setPassword(String password) { // this.password = password; // } // // @Column(length = 32, unique = true, nullable = false) // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // @Column(nullable = false) // public boolean isEnabled() { // return enabled; // } // // public void setEnabled(boolean enabled) { // this.enabled = enabled; // } // // @ElementCollection // @CollectionTable(name = "user_roles", joinColumns = @JoinColumn(name = "user_id")) // public Set<String> getRoles() { // return roles; // } // // public void setRoles(Set<String> roles) { // this.roles = roles; // } // // @Column(nullable = false) // public LocalDateTime getRegisterDate() { // return registerDate; // } // // public void setRegisterDate(LocalDateTime registerDate) { // this.registerDate = registerDate; // } // // @Column // public LocalDateTime getLastLoggedIn() { // return lastLoggedIn; // } // // public void setLastLoggedIn(LocalDateTime lastLoggedIn) { // this.lastLoggedIn = lastLoggedIn; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // User user = (User) o; // return Objects.equals(username, user.username); // } // // @Override // public int hashCode() { // return Objects.hash(username); // } // // private static final DateTimeFormatter formatterTime = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"); // // public JSONObject toJSON() { // JSONObject object = new JSONObject(); // object.put("id", getId()); // object.put("username", getUsername()); // object.put("enabled", isEnabled()); // object.put("registerDate", getRegisterDate().format(formatterTime)); // Optional.ofNullable(getLastLoggedIn()).ifPresent(lastLoggedIn -> { // object.put("lastLoggedIn", lastLoggedIn.format(formatterTime)); // }); // return object; // } // // } // Path: src/main/java/mingzuozhibi/action/UserController.java import mingzuozhibi.persist.user.AutoLogin; import mingzuozhibi.persist.user.User; import mingzuozhibi.support.JsonArg; import org.apache.commons.lang3.StringUtils; import org.json.JSONArray; import org.json.JSONObject; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import java.util.List; package mingzuozhibi.action; @RestController public class UserController extends BaseController { @Transactional @PreAuthorize("hasRole('ADMIN')") @GetMapping(value = "/api/users", produces = MEDIA_TYPE) public String findAll() { JSONArray result = new JSONArray();
dao.findAll(User.class).forEach(user -> {
mingzuozhibi/mzzb-server
src/main/java/mingzuozhibi/action/UserController.java
// Path: src/main/java/mingzuozhibi/persist/user/AutoLogin.java // @Entity // public class AutoLogin extends BaseModel implements Serializable { // // private User user; // private String token; // private LocalDateTime expired; // // public AutoLogin() { // } // // public AutoLogin(User user, String token, LocalDateTime expired) { // this.user = user; // this.token = token; // this.expired = expired; // } // // @ManyToOne(optional = false) // public User getUser() { // return user; // } // // public void setUser(User user) { // this.user = user; // } // // @Column(length = 36, nullable = false) // public String getToken() { // return token; // } // // public void setToken(String token) { // this.token = token; // } // // @Column(nullable = false) // public LocalDateTime getExpired() { // return expired; // } // // public void setExpired(LocalDateTime expired) { // this.expired = expired; // } // // } // // Path: src/main/java/mingzuozhibi/persist/user/User.java // @Entity // public class User extends BaseModel implements Serializable { // // private String username; // private String password; // private boolean enabled; // private Set<String> roles = new HashSet<>(); // // private LocalDateTime registerDate; // private LocalDateTime lastLoggedIn; // // public User() { // } // // public User(String username, String password, boolean enabled) { // this.username = username; // this.password = password; // this.enabled = enabled; // this.registerDate = LocalDateTime.now().withNano(0); // this.roles.add("ROLE_BASIC"); // } // // @Column(length = 32, nullable = false) // public String getPassword() { // return password; // } // // public void setPassword(String password) { // this.password = password; // } // // @Column(length = 32, unique = true, nullable = false) // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // @Column(nullable = false) // public boolean isEnabled() { // return enabled; // } // // public void setEnabled(boolean enabled) { // this.enabled = enabled; // } // // @ElementCollection // @CollectionTable(name = "user_roles", joinColumns = @JoinColumn(name = "user_id")) // public Set<String> getRoles() { // return roles; // } // // public void setRoles(Set<String> roles) { // this.roles = roles; // } // // @Column(nullable = false) // public LocalDateTime getRegisterDate() { // return registerDate; // } // // public void setRegisterDate(LocalDateTime registerDate) { // this.registerDate = registerDate; // } // // @Column // public LocalDateTime getLastLoggedIn() { // return lastLoggedIn; // } // // public void setLastLoggedIn(LocalDateTime lastLoggedIn) { // this.lastLoggedIn = lastLoggedIn; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // User user = (User) o; // return Objects.equals(username, user.username); // } // // @Override // public int hashCode() { // return Objects.hash(username); // } // // private static final DateTimeFormatter formatterTime = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"); // // public JSONObject toJSON() { // JSONObject object = new JSONObject(); // object.put("id", getId()); // object.put("username", getUsername()); // object.put("enabled", isEnabled()); // object.put("registerDate", getRegisterDate().format(formatterTime)); // Optional.ofNullable(getLastLoggedIn()).ifPresent(lastLoggedIn -> { // object.put("lastLoggedIn", lastLoggedIn.format(formatterTime)); // }); // return object; // } // // }
import mingzuozhibi.persist.user.AutoLogin; import mingzuozhibi.persist.user.User; import mingzuozhibi.support.JsonArg; import org.apache.commons.lang3.StringUtils; import org.json.JSONArray; import org.json.JSONObject; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import java.util.List;
@JsonArg boolean enabled) { User user = dao.get(User.class, id); if (user == null) { if (LOGGER.isWarnEnabled()) { warnRequest("[编辑用户失败][指定的用户Id不存在][Id={}]", id); } return errorMessage("指定的用户Id不存在"); } if (LOGGER.isInfoEnabled()) { JSONObject before = user.toJSON(); infoRequest("[编辑用户开始][修改前={}]", before); } user.setUsername(username); user.setEnabled(enabled); if (StringUtils.isNotEmpty(password)) { user.setPassword(password); cleanAutoLogin(user); } JSONObject result = user.toJSON(); if (LOGGER.isInfoEnabled()) { infoRequest("[编辑用户成功][修改后={}]", result); } return objectResult(result); } private void cleanAutoLogin(User user) {
// Path: src/main/java/mingzuozhibi/persist/user/AutoLogin.java // @Entity // public class AutoLogin extends BaseModel implements Serializable { // // private User user; // private String token; // private LocalDateTime expired; // // public AutoLogin() { // } // // public AutoLogin(User user, String token, LocalDateTime expired) { // this.user = user; // this.token = token; // this.expired = expired; // } // // @ManyToOne(optional = false) // public User getUser() { // return user; // } // // public void setUser(User user) { // this.user = user; // } // // @Column(length = 36, nullable = false) // public String getToken() { // return token; // } // // public void setToken(String token) { // this.token = token; // } // // @Column(nullable = false) // public LocalDateTime getExpired() { // return expired; // } // // public void setExpired(LocalDateTime expired) { // this.expired = expired; // } // // } // // Path: src/main/java/mingzuozhibi/persist/user/User.java // @Entity // public class User extends BaseModel implements Serializable { // // private String username; // private String password; // private boolean enabled; // private Set<String> roles = new HashSet<>(); // // private LocalDateTime registerDate; // private LocalDateTime lastLoggedIn; // // public User() { // } // // public User(String username, String password, boolean enabled) { // this.username = username; // this.password = password; // this.enabled = enabled; // this.registerDate = LocalDateTime.now().withNano(0); // this.roles.add("ROLE_BASIC"); // } // // @Column(length = 32, nullable = false) // public String getPassword() { // return password; // } // // public void setPassword(String password) { // this.password = password; // } // // @Column(length = 32, unique = true, nullable = false) // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // @Column(nullable = false) // public boolean isEnabled() { // return enabled; // } // // public void setEnabled(boolean enabled) { // this.enabled = enabled; // } // // @ElementCollection // @CollectionTable(name = "user_roles", joinColumns = @JoinColumn(name = "user_id")) // public Set<String> getRoles() { // return roles; // } // // public void setRoles(Set<String> roles) { // this.roles = roles; // } // // @Column(nullable = false) // public LocalDateTime getRegisterDate() { // return registerDate; // } // // public void setRegisterDate(LocalDateTime registerDate) { // this.registerDate = registerDate; // } // // @Column // public LocalDateTime getLastLoggedIn() { // return lastLoggedIn; // } // // public void setLastLoggedIn(LocalDateTime lastLoggedIn) { // this.lastLoggedIn = lastLoggedIn; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // User user = (User) o; // return Objects.equals(username, user.username); // } // // @Override // public int hashCode() { // return Objects.hash(username); // } // // private static final DateTimeFormatter formatterTime = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"); // // public JSONObject toJSON() { // JSONObject object = new JSONObject(); // object.put("id", getId()); // object.put("username", getUsername()); // object.put("enabled", isEnabled()); // object.put("registerDate", getRegisterDate().format(formatterTime)); // Optional.ofNullable(getLastLoggedIn()).ifPresent(lastLoggedIn -> { // object.put("lastLoggedIn", lastLoggedIn.format(formatterTime)); // }); // return object; // } // // } // Path: src/main/java/mingzuozhibi/action/UserController.java import mingzuozhibi.persist.user.AutoLogin; import mingzuozhibi.persist.user.User; import mingzuozhibi.support.JsonArg; import org.apache.commons.lang3.StringUtils; import org.json.JSONArray; import org.json.JSONObject; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import java.util.List; @JsonArg boolean enabled) { User user = dao.get(User.class, id); if (user == null) { if (LOGGER.isWarnEnabled()) { warnRequest("[编辑用户失败][指定的用户Id不存在][Id={}]", id); } return errorMessage("指定的用户Id不存在"); } if (LOGGER.isInfoEnabled()) { JSONObject before = user.toJSON(); infoRequest("[编辑用户开始][修改前={}]", before); } user.setUsername(username); user.setEnabled(enabled); if (StringUtils.isNotEmpty(password)) { user.setPassword(password); cleanAutoLogin(user); } JSONObject result = user.toJSON(); if (LOGGER.isInfoEnabled()) { infoRequest("[编辑用户成功][修改后={}]", result); } return objectResult(result); } private void cleanAutoLogin(User user) {
List<AutoLogin> autoLogins = dao.findBy(AutoLogin.class, "user", user);
mingzuozhibi/mzzb-server
src/main/java/mingzuozhibi/MzzbServerApplication.java
// Path: src/main/java/mingzuozhibi/config/AutoRunConfig.java // @Service // @RestController // public class AutoRunConfig { // // public static final Logger LOGGER = LoggerFactory.getLogger(AutoRunConfig.class); // // @Autowired // private ScheduleMission scheduleMission; // // /** // * call by MzzbServerApplication // */ // public void runOnStartupServer() { // new Thread(() -> { // LOGGER.info("开机任务开始"); // scheduleMission.removeExpiredAutoLoginData(); // scheduleMission.moveHourRecordToDateRecord(); // scheduleMission.recordDiscsRankAndComputePt(); // LOGGER.info("开机任务完成"); // }).start(); // } // // @Scheduled(cron = "0 0 * * * ?") // public void runOnEveryHour() { // new Thread(() -> { // LOGGER.info("每小时任务开始"); // scheduleMission.removeExpiredAutoLoginData(); // scheduleMission.moveHourRecordToDateRecord(); // scheduleMission.recordDiscsRankAndComputePt(); // LOGGER.info("每小时任务完成"); // }).start(); // } // // }
import mingzuozhibi.config.AutoRunConfig; import org.hibernate.SessionFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.session.jdbc.config.annotation.web.http.EnableJdbcHttpSession; import javax.persistence.EntityManagerFactory;
package mingzuozhibi; @EnableScheduling @EnableJdbcHttpSession @SpringBootApplication public class MzzbServerApplication { public static final Logger LOGGER = LoggerFactory.getLogger(MzzbServerApplication.class); public static void main(String[] args) { ApplicationContext context = SpringApplication.run(MzzbServerApplication.class, args); LOGGER.info("MzzbServer服务已启动");
// Path: src/main/java/mingzuozhibi/config/AutoRunConfig.java // @Service // @RestController // public class AutoRunConfig { // // public static final Logger LOGGER = LoggerFactory.getLogger(AutoRunConfig.class); // // @Autowired // private ScheduleMission scheduleMission; // // /** // * call by MzzbServerApplication // */ // public void runOnStartupServer() { // new Thread(() -> { // LOGGER.info("开机任务开始"); // scheduleMission.removeExpiredAutoLoginData(); // scheduleMission.moveHourRecordToDateRecord(); // scheduleMission.recordDiscsRankAndComputePt(); // LOGGER.info("开机任务完成"); // }).start(); // } // // @Scheduled(cron = "0 0 * * * ?") // public void runOnEveryHour() { // new Thread(() -> { // LOGGER.info("每小时任务开始"); // scheduleMission.removeExpiredAutoLoginData(); // scheduleMission.moveHourRecordToDateRecord(); // scheduleMission.recordDiscsRankAndComputePt(); // LOGGER.info("每小时任务完成"); // }).start(); // } // // } // Path: src/main/java/mingzuozhibi/MzzbServerApplication.java import mingzuozhibi.config.AutoRunConfig; import org.hibernate.SessionFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.session.jdbc.config.annotation.web.http.EnableJdbcHttpSession; import javax.persistence.EntityManagerFactory; package mingzuozhibi; @EnableScheduling @EnableJdbcHttpSession @SpringBootApplication public class MzzbServerApplication { public static final Logger LOGGER = LoggerFactory.getLogger(MzzbServerApplication.class); public static void main(String[] args) { ApplicationContext context = SpringApplication.run(MzzbServerApplication.class, args); LOGGER.info("MzzbServer服务已启动");
context.getBean(AutoRunConfig.class).runOnStartupServer();
mingzuozhibi/mzzb-server
src/main/java/mingzuozhibi/action/BaseController.java
// Path: src/main/java/mingzuozhibi/support/Dao.java // public interface Dao { // // Long save(Object object); // // <T> T get(Class<T> klass, Long id); // // void refresh(Object object); // // void update(Object object); // // void delete(Object object); // // <T> List<T> findAll(Class<T> klass); // // <T> List<T> findBy(Class<T> klass, String name, Object value); // // <T> T lookup(Class<T> klass, String name, Object value); // // <T> T jdbc(ReturningWork<T> work); // // <T> T query(HibernateCallback<T> action); // // void execute(Consumer<Session> action); // // Criteria create(Class<?> klass); // // Session session(); // // }
import mingzuozhibi.support.Dao; import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.Optional;
package mingzuozhibi.action; public class BaseController { protected static final String MEDIA_TYPE = MediaType.APPLICATION_JSON_UTF8_VALUE; protected Logger LOGGER; @Autowired
// Path: src/main/java/mingzuozhibi/support/Dao.java // public interface Dao { // // Long save(Object object); // // <T> T get(Class<T> klass, Long id); // // void refresh(Object object); // // void update(Object object); // // void delete(Object object); // // <T> List<T> findAll(Class<T> klass); // // <T> List<T> findBy(Class<T> klass, String name, Object value); // // <T> T lookup(Class<T> klass, String name, Object value); // // <T> T jdbc(ReturningWork<T> work); // // <T> T query(HibernateCallback<T> action); // // void execute(Consumer<Session> action); // // Criteria create(Class<?> klass); // // Session session(); // // } // Path: src/main/java/mingzuozhibi/action/BaseController.java import mingzuozhibi.support.Dao; import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.Optional; package mingzuozhibi.action; public class BaseController { protected static final String MEDIA_TYPE = MediaType.APPLICATION_JSON_UTF8_VALUE; protected Logger LOGGER; @Autowired
protected Dao dao;
mingzuozhibi/mzzb-server
src/main/java/mingzuozhibi/config/WebMvcConfig.java
// Path: src/main/java/mingzuozhibi/support/JsonArgumentResolver.java // public class JsonArgumentResolver implements HandlerMethodArgumentResolver { // // private static final String JSON_BODY_ATTRIBUTE = "JSON_REQUEST_BODY"; // // public boolean supportsParameter(MethodParameter parameter) { // return parameter.hasParameterAnnotation(JsonArg.class); // } // // public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, // NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception { // String body = getRequestBody(webRequest); // String arg = getParameterName(parameter); // String defaults = getDefaults(parameter); // return readObject(body, arg, defaults, parameter.getParameterType()); // } // // private <T> T readObject(String body, String name, String defaults, Class<T> requiredType) { // SimpleTypeConverter converter = new SimpleTypeConverter(); // try { // Class<?> readType = requiredType.isEnum() ? String.class : requiredType; // Object read = JsonPath.parse(body).read(name, readType); // return converter.convertIfNecessary(read, requiredType); // } catch (PathNotFoundException e) { // return converter.convertIfNecessary(defaults, requiredType); // } // } // // private String getParameterName(MethodParameter parameter) { // String name = parameter.getParameterAnnotation(JsonArg.class).value(); // if (StringUtils.isEmpty(name)) { // name = parameter.getParameterName(); // } // return name; // } // // private String getDefaults(MethodParameter parameter) { // return parameter.getParameterAnnotation(JsonArg.class).defaults(); // } // // private String getRequestBody(NativeWebRequest webRequest) { // HttpServletRequest servletRequest = webRequest.getNativeRequest(HttpServletRequest.class); // // String jsonBody = (String) webRequest.getAttribute(JSON_BODY_ATTRIBUTE, NativeWebRequest.SCOPE_REQUEST); // if (jsonBody == null) { // try { // jsonBody = IOUtils.toString(servletRequest.getInputStream(), "UTF-8"); // webRequest.setAttribute(JSON_BODY_ATTRIBUTE, jsonBody, NativeWebRequest.SCOPE_REQUEST); // } catch (IOException e) { // throw new RuntimeException(e); // } // } // return jsonBody; // } // // }
import mingzuozhibi.support.JsonArgumentResolver; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.orm.hibernate5.support.OpenSessionInViewFilter; import org.springframework.web.method.support.HandlerMethodArgumentResolver; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import java.util.Collections; import java.util.List;
package mingzuozhibi.config; @EnableWebMvc @Configuration public class WebMvcConfig extends WebMvcConfigurerAdapter { public static final Logger LOGGER = LoggerFactory.getLogger(WebMvcConfig.class); public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
// Path: src/main/java/mingzuozhibi/support/JsonArgumentResolver.java // public class JsonArgumentResolver implements HandlerMethodArgumentResolver { // // private static final String JSON_BODY_ATTRIBUTE = "JSON_REQUEST_BODY"; // // public boolean supportsParameter(MethodParameter parameter) { // return parameter.hasParameterAnnotation(JsonArg.class); // } // // public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, // NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception { // String body = getRequestBody(webRequest); // String arg = getParameterName(parameter); // String defaults = getDefaults(parameter); // return readObject(body, arg, defaults, parameter.getParameterType()); // } // // private <T> T readObject(String body, String name, String defaults, Class<T> requiredType) { // SimpleTypeConverter converter = new SimpleTypeConverter(); // try { // Class<?> readType = requiredType.isEnum() ? String.class : requiredType; // Object read = JsonPath.parse(body).read(name, readType); // return converter.convertIfNecessary(read, requiredType); // } catch (PathNotFoundException e) { // return converter.convertIfNecessary(defaults, requiredType); // } // } // // private String getParameterName(MethodParameter parameter) { // String name = parameter.getParameterAnnotation(JsonArg.class).value(); // if (StringUtils.isEmpty(name)) { // name = parameter.getParameterName(); // } // return name; // } // // private String getDefaults(MethodParameter parameter) { // return parameter.getParameterAnnotation(JsonArg.class).defaults(); // } // // private String getRequestBody(NativeWebRequest webRequest) { // HttpServletRequest servletRequest = webRequest.getNativeRequest(HttpServletRequest.class); // // String jsonBody = (String) webRequest.getAttribute(JSON_BODY_ATTRIBUTE, NativeWebRequest.SCOPE_REQUEST); // if (jsonBody == null) { // try { // jsonBody = IOUtils.toString(servletRequest.getInputStream(), "UTF-8"); // webRequest.setAttribute(JSON_BODY_ATTRIBUTE, jsonBody, NativeWebRequest.SCOPE_REQUEST); // } catch (IOException e) { // throw new RuntimeException(e); // } // } // return jsonBody; // } // // } // Path: src/main/java/mingzuozhibi/config/WebMvcConfig.java import mingzuozhibi.support.JsonArgumentResolver; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.orm.hibernate5.support.OpenSessionInViewFilter; import org.springframework.web.method.support.HandlerMethodArgumentResolver; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import java.util.Collections; import java.util.List; package mingzuozhibi.config; @EnableWebMvc @Configuration public class WebMvcConfig extends WebMvcConfigurerAdapter { public static final Logger LOGGER = LoggerFactory.getLogger(WebMvcConfig.class); public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
argumentResolvers.add(new JsonArgumentResolver());
mingzuozhibi/mzzb-server
src/main/java/mingzuozhibi/config/AutoRunConfig.java
// Path: src/main/java/mingzuozhibi/service/ScheduleMission.java // @Service // public class ScheduleMission { // // public static final Logger LOGGER = LoggerFactory.getLogger(ScheduleMission.class); // // @Autowired // private Dao dao; // // public void removeExpiredAutoLoginData() { // dao.execute(session -> { // @SuppressWarnings("unchecked") // List<AutoLogin> expired = session.createCriteria(AutoLogin.class) // .add(Restrictions.lt("expired", LocalDateTime.now())) // .list(); // expired.forEach(autoLogin -> dao.delete(autoLogin)); // LOGGER.info("[定时任务][清理自动登入][共{}个]", expired.size()); // }); // } // // public void moveHourRecordToDateRecord() { // dao.execute(session -> { // @SuppressWarnings("unchecked") // List<HourRecord> hourRecords = session.createCriteria(HourRecord.class) // .add(Restrictions.lt("date", LocalDate.now())) // .addOrder(Order.asc("date")) // .list(); // hourRecords.forEach(hourRecord -> { // DateRecord dateRecord = new DateRecord(hourRecord.getDisc(), hourRecord.getDate()); // hourRecord.getAverRank().ifPresent(dateRecord::setRank); // Optional.ofNullable(hourRecord.getTodayPt()).ifPresent(dateRecord::setTodayPt); // Optional.ofNullable(hourRecord.getTotalPt()).ifPresent(dateRecord::setTotalPt); // Optional.ofNullable(hourRecord.getGuessPt()).ifPresent(dateRecord::setGuessPt); // session.save(dateRecord); // session.delete(hourRecord); // }); // LOGGER.info("[定时任务][转录碟片排名][共{}个]", hourRecords.size()); // }); // } // // public void recordDiscsRankAndComputePt() { // // +9 timezone and prev hour, so +1h -1h = +0h // LocalDateTime recordTime = LocalDateTime.now(); // LocalDate date = recordTime.toLocalDate(); // int hour = recordTime.getHour(); // // dao.execute(session -> { // Set<Disc> discs = needRecordDiscs(session); // // discs.forEach(disc -> { // HourRecord hourRecord = findOrCreateHourRecord(dao, disc, date); // hourRecord.setRank(hour, disc.getThisRank()); // if (date.isBefore(disc.getReleaseDate())) { // computeTodayPt(hourRecord); // computeTotalPt(hourRecord, findDateRecord(dao, disc, date.minusDays(1))); // computeGuessPt(hourRecord, findDateRecord(dao, disc, date.minusDays(7))); // // disc.setTodayPt(safeIntValue(hourRecord.getTodayPt())); // disc.setTotalPt(safeIntValue(hourRecord.getTotalPt())); // disc.setGuessPt(safeIntValue(hourRecord.getGuessPt())); // } else { // DateRecord dateRecord = findDateRecord(dao, disc, date.minusDays(1)); // if (dateRecord == null) { // return; // } // // hourRecord.setTodayPt(null); // hourRecord.setTotalPt(dateRecord.getTotalPt()); // hourRecord.setGuessPt(dateRecord.getGuessPt()); // // disc.setTodayPt(null); // disc.setTotalPt(safeIntValue(dateRecord.getTotalPt())); // disc.setGuessPt(safeIntValue(dateRecord.getGuessPt())); // } // // }); // LOGGER.info("[定时任务][记录碟片排名][共{}个]", discs.size()); // }); // } // // // private void computeGuessPt(HourRecord hourRecord0, DateRecord dateRecord7) { // if (dateRecord7 == null) { // return; // } // if (hourRecord0.getTotalPt() != null && dateRecord7.getTotalPt() != null) { // double addPt = (hourRecord0.getTotalPt() - dateRecord7.getTotalPt()) / 7d; // LocalDate releaseDate = hourRecord0.getDisc().getReleaseDate(); // LocalDate currentDate = hourRecord0.getDate(); // long days = getDays(releaseDate, currentDate); // hourRecord0.setGuessPt(hourRecord0.getTotalPt() + addPt * days); // } // } // // private long getDays(LocalDate releaseDate, LocalDate currentDate) { // return releaseDate.toEpochDay() - currentDate.toEpochDay() - 1; // } // // private void computeTotalPt(HourRecord hourRecord, DateRecord dateRecord) { // if (dateRecord == null || dateRecord.getTotalPt() == null) { // hourRecord.setTotalPt(hourRecord.getTodayPt()); // } else if (hourRecord.getTodayPt() != null) { // hourRecord.setTotalPt(hourRecord.getTodayPt() + dateRecord.getTotalPt()); // } else { // hourRecord.setTotalPt(dateRecord.getTotalPt()); // } // } // // private void computeTodayPt(HourRecord hourRecord) { // hourRecord.getAverRank().ifPresent(rank -> { // hourRecord.setTodayPt(24 * computeHourPt(hourRecord.getDisc(), rank)); // }); // } // // }
import mingzuozhibi.service.ScheduleMission; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; import org.springframework.web.bind.annotation.RestController;
package mingzuozhibi.config; @Service @RestController public class AutoRunConfig { public static final Logger LOGGER = LoggerFactory.getLogger(AutoRunConfig.class); @Autowired
// Path: src/main/java/mingzuozhibi/service/ScheduleMission.java // @Service // public class ScheduleMission { // // public static final Logger LOGGER = LoggerFactory.getLogger(ScheduleMission.class); // // @Autowired // private Dao dao; // // public void removeExpiredAutoLoginData() { // dao.execute(session -> { // @SuppressWarnings("unchecked") // List<AutoLogin> expired = session.createCriteria(AutoLogin.class) // .add(Restrictions.lt("expired", LocalDateTime.now())) // .list(); // expired.forEach(autoLogin -> dao.delete(autoLogin)); // LOGGER.info("[定时任务][清理自动登入][共{}个]", expired.size()); // }); // } // // public void moveHourRecordToDateRecord() { // dao.execute(session -> { // @SuppressWarnings("unchecked") // List<HourRecord> hourRecords = session.createCriteria(HourRecord.class) // .add(Restrictions.lt("date", LocalDate.now())) // .addOrder(Order.asc("date")) // .list(); // hourRecords.forEach(hourRecord -> { // DateRecord dateRecord = new DateRecord(hourRecord.getDisc(), hourRecord.getDate()); // hourRecord.getAverRank().ifPresent(dateRecord::setRank); // Optional.ofNullable(hourRecord.getTodayPt()).ifPresent(dateRecord::setTodayPt); // Optional.ofNullable(hourRecord.getTotalPt()).ifPresent(dateRecord::setTotalPt); // Optional.ofNullable(hourRecord.getGuessPt()).ifPresent(dateRecord::setGuessPt); // session.save(dateRecord); // session.delete(hourRecord); // }); // LOGGER.info("[定时任务][转录碟片排名][共{}个]", hourRecords.size()); // }); // } // // public void recordDiscsRankAndComputePt() { // // +9 timezone and prev hour, so +1h -1h = +0h // LocalDateTime recordTime = LocalDateTime.now(); // LocalDate date = recordTime.toLocalDate(); // int hour = recordTime.getHour(); // // dao.execute(session -> { // Set<Disc> discs = needRecordDiscs(session); // // discs.forEach(disc -> { // HourRecord hourRecord = findOrCreateHourRecord(dao, disc, date); // hourRecord.setRank(hour, disc.getThisRank()); // if (date.isBefore(disc.getReleaseDate())) { // computeTodayPt(hourRecord); // computeTotalPt(hourRecord, findDateRecord(dao, disc, date.minusDays(1))); // computeGuessPt(hourRecord, findDateRecord(dao, disc, date.minusDays(7))); // // disc.setTodayPt(safeIntValue(hourRecord.getTodayPt())); // disc.setTotalPt(safeIntValue(hourRecord.getTotalPt())); // disc.setGuessPt(safeIntValue(hourRecord.getGuessPt())); // } else { // DateRecord dateRecord = findDateRecord(dao, disc, date.minusDays(1)); // if (dateRecord == null) { // return; // } // // hourRecord.setTodayPt(null); // hourRecord.setTotalPt(dateRecord.getTotalPt()); // hourRecord.setGuessPt(dateRecord.getGuessPt()); // // disc.setTodayPt(null); // disc.setTotalPt(safeIntValue(dateRecord.getTotalPt())); // disc.setGuessPt(safeIntValue(dateRecord.getGuessPt())); // } // // }); // LOGGER.info("[定时任务][记录碟片排名][共{}个]", discs.size()); // }); // } // // // private void computeGuessPt(HourRecord hourRecord0, DateRecord dateRecord7) { // if (dateRecord7 == null) { // return; // } // if (hourRecord0.getTotalPt() != null && dateRecord7.getTotalPt() != null) { // double addPt = (hourRecord0.getTotalPt() - dateRecord7.getTotalPt()) / 7d; // LocalDate releaseDate = hourRecord0.getDisc().getReleaseDate(); // LocalDate currentDate = hourRecord0.getDate(); // long days = getDays(releaseDate, currentDate); // hourRecord0.setGuessPt(hourRecord0.getTotalPt() + addPt * days); // } // } // // private long getDays(LocalDate releaseDate, LocalDate currentDate) { // return releaseDate.toEpochDay() - currentDate.toEpochDay() - 1; // } // // private void computeTotalPt(HourRecord hourRecord, DateRecord dateRecord) { // if (dateRecord == null || dateRecord.getTotalPt() == null) { // hourRecord.setTotalPt(hourRecord.getTodayPt()); // } else if (hourRecord.getTodayPt() != null) { // hourRecord.setTotalPt(hourRecord.getTodayPt() + dateRecord.getTotalPt()); // } else { // hourRecord.setTotalPt(dateRecord.getTotalPt()); // } // } // // private void computeTodayPt(HourRecord hourRecord) { // hourRecord.getAverRank().ifPresent(rank -> { // hourRecord.setTodayPt(24 * computeHourPt(hourRecord.getDisc(), rank)); // }); // } // // } // Path: src/main/java/mingzuozhibi/config/AutoRunConfig.java import mingzuozhibi.service.ScheduleMission; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; import org.springframework.web.bind.annotation.RestController; package mingzuozhibi.config; @Service @RestController public class AutoRunConfig { public static final Logger LOGGER = LoggerFactory.getLogger(AutoRunConfig.class); @Autowired
private ScheduleMission scheduleMission;
googlemaps/android-places-demos
demo-java/app/src/gms/java/com/example/placesdemo/AutocompleteAddressActivity.java
// Path: demo-java/app/src/gms/java/com/example/placesdemo/model/AutocompleteEditText.java // public class AutocompleteEditText extends androidx.appcompat.widget.AppCompatEditText { // public AutocompleteEditText(Context context) { // super(context); // } // // public AutocompleteEditText(Context context, AttributeSet attrs) { // super(context, attrs); // } // // @Override // public boolean onTouchEvent(MotionEvent event) { // super.onTouchEvent(event); // // switch (event.getAction()) { // case MotionEvent.ACTION_DOWN: // return true; // // case MotionEvent.ACTION_UP: // performClick(); // return true; // } // return false; // } // // // Because we call this from onTouchEvent, this code will be executed for both // // normal touch events and for when the system calls this using Accessibility // @Override // public boolean performClick() { // super.performClick(); // return true; // } // }
import android.annotation.SuppressLint; import android.app.Activity; import android.content.Intent; import android.content.pm.PackageManager; import android.content.res.Resources; import android.os.Bundle; import android.util.Log; import android.view.View; import android.view.ViewStub; import android.widget.Button; import android.widget.CheckBox; import android.widget.EditText; import android.widget.Toast; import androidx.activity.result.ActivityResult; import androidx.activity.result.ActivityResultCallback; import androidx.activity.result.ActivityResultLauncher; import androidx.activity.result.contract.ActivityResultContracts; import androidx.appcompat.app.AppCompatActivity; import androidx.core.content.ContextCompat; import com.example.placesdemo.model.AutocompleteEditText; import com.google.android.gms.location.FusedLocationProviderClient; import com.google.android.gms.location.LocationServices; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.GoogleMapOptions; import com.google.android.gms.maps.OnMapReadyCallback; import com.google.android.gms.maps.SupportMapFragment; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.MapStyleOptions; import com.google.android.gms.maps.model.Marker; import com.google.android.gms.maps.model.MarkerOptions; import com.google.android.libraries.places.api.Places; import com.google.android.libraries.places.api.model.AddressComponent; import com.google.android.libraries.places.api.model.AddressComponents; import com.google.android.libraries.places.api.model.Place; import com.google.android.libraries.places.api.model.TypeFilter; import com.google.android.libraries.places.api.net.PlacesClient; import com.google.android.libraries.places.widget.Autocomplete; import com.google.android.libraries.places.widget.model.AutocompleteActivityMode; import java.util.Arrays; import java.util.List; import static android.Manifest.permission.ACCESS_FINE_LOCATION; import static com.google.maps.android.SphericalUtil.computeDistanceBetween;
/* * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.example.placesdemo; /** * Activity for using Place Autocomplete to assist filling out an address form. */ @SuppressWarnings("FieldCanBeLocal") public class AutocompleteAddressActivity extends AppCompatActivity implements OnMapReadyCallback { private static final String TAG = "ADDRESS_AUTOCOMPLETE"; private static final String MAP_FRAGMENT_TAG = "MAP";
// Path: demo-java/app/src/gms/java/com/example/placesdemo/model/AutocompleteEditText.java // public class AutocompleteEditText extends androidx.appcompat.widget.AppCompatEditText { // public AutocompleteEditText(Context context) { // super(context); // } // // public AutocompleteEditText(Context context, AttributeSet attrs) { // super(context, attrs); // } // // @Override // public boolean onTouchEvent(MotionEvent event) { // super.onTouchEvent(event); // // switch (event.getAction()) { // case MotionEvent.ACTION_DOWN: // return true; // // case MotionEvent.ACTION_UP: // performClick(); // return true; // } // return false; // } // // // Because we call this from onTouchEvent, this code will be executed for both // // normal touch events and for when the system calls this using Accessibility // @Override // public boolean performClick() { // super.performClick(); // return true; // } // } // Path: demo-java/app/src/gms/java/com/example/placesdemo/AutocompleteAddressActivity.java import android.annotation.SuppressLint; import android.app.Activity; import android.content.Intent; import android.content.pm.PackageManager; import android.content.res.Resources; import android.os.Bundle; import android.util.Log; import android.view.View; import android.view.ViewStub; import android.widget.Button; import android.widget.CheckBox; import android.widget.EditText; import android.widget.Toast; import androidx.activity.result.ActivityResult; import androidx.activity.result.ActivityResultCallback; import androidx.activity.result.ActivityResultLauncher; import androidx.activity.result.contract.ActivityResultContracts; import androidx.appcompat.app.AppCompatActivity; import androidx.core.content.ContextCompat; import com.example.placesdemo.model.AutocompleteEditText; import com.google.android.gms.location.FusedLocationProviderClient; import com.google.android.gms.location.LocationServices; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.GoogleMapOptions; import com.google.android.gms.maps.OnMapReadyCallback; import com.google.android.gms.maps.SupportMapFragment; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.MapStyleOptions; import com.google.android.gms.maps.model.Marker; import com.google.android.gms.maps.model.MarkerOptions; import com.google.android.libraries.places.api.Places; import com.google.android.libraries.places.api.model.AddressComponent; import com.google.android.libraries.places.api.model.AddressComponents; import com.google.android.libraries.places.api.model.Place; import com.google.android.libraries.places.api.model.TypeFilter; import com.google.android.libraries.places.api.net.PlacesClient; import com.google.android.libraries.places.widget.Autocomplete; import com.google.android.libraries.places.widget.model.AutocompleteActivityMode; import java.util.Arrays; import java.util.List; import static android.Manifest.permission.ACCESS_FINE_LOCATION; import static com.google.maps.android.SphericalUtil.computeDistanceBetween; /* * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.example.placesdemo; /** * Activity for using Place Autocomplete to assist filling out an address form. */ @SuppressWarnings("FieldCanBeLocal") public class AutocompleteAddressActivity extends AppCompatActivity implements OnMapReadyCallback { private static final String TAG = "ADDRESS_AUTOCOMPLETE"; private static final String MAP_FRAGMENT_TAG = "MAP";
private AutocompleteEditText address1Field;