Skip to content

Commit

Permalink
Fix formatting by running "mvn editorconfig:format" plus a few manual
Browse files Browse the repository at this point in the history
tweaks
  • Loading branch information
ppalaga committed Feb 28, 2018
1 parent 6f56a8e commit 71dde8a
Show file tree
Hide file tree
Showing 21 changed files with 271 additions and 271 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
OpenShift Tasks: JAX-RS, JPA quickstart
OpenShift Tasks: JAX-RS, JPA quickstart
==============================
[![CircleCI](https://circleci.com/gh/OpenShiftDemos/openshift-tasks.svg?&style=shield&circle-token=1462d2d99334a912b32f758616eb39f6390a200b)](https://circleci.com/gh/OpenShiftDemos/openshift-tasks)

Expand Down
78 changes: 39 additions & 39 deletions configuration/cicd-settings-nexus3.xml
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
<settings>
<servers>
<server>
<id>nexus</id>
<username>deployment</username>
<password>deployment123</password>
</server>
</servers>
<mirrors>
<mirror>
<servers>
<server>
<id>nexus</id>
<username>deployment</username>
<password>deployment123</password>
</server>
</servers>
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://nexus:8081/repository/maven-all-public/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://nexus:8081/repository/maven-all-public/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<!--Enable snapshots for the built in central repo to direct -->
<!--all requests to nexus via the mirror -->
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
2 changes: 1 addition & 1 deletion pipeline-bc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ spec:
type: GitHub
- generic:
secret: CzgPZAZ5m2
type: Generic
type: Generic
22 changes: 11 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,10 @@

<profiles>
<profile>
<!-- The default profile skips all tests, though you can tune it to run
just unit tests based on a custom pattern -->
<!-- Separate profiles are provided for running all tests, including Arquillian
tests that execute in the specified container -->
<!-- The default profile skips all tests, though you can tune it to run
just unit tests based on a custom pattern -->
<!-- Separate profiles are provided for running all tests, including Arquillian
tests that execute in the specified container -->
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
Expand Down Expand Up @@ -378,13 +378,13 @@
</dependencies>
</profile>
<profile>
<!-- When built in OpenShift the 'openshift' profile will be used when
invoking mvn. -->
<!-- Use this profile for any OpenShift specific customization your app
will need. -->
<!-- By default that is to put the resulting archive into the 'deployments'
folder. -->
<!-- http://maven.apache.org/guides/mini/guide-building-for-different-environments.html -->
<!-- When built in OpenShift the 'openshift' profile will be used when
invoking mvn. -->
<!-- Use this profile for any OpenShift specific customization your app
will need. -->
<!-- By default that is to put the resulting archive into the 'deployments'
folder. -->
<!-- http://maven.apache.org/guides/mini/guide-building-for-different-environments.html -->
<id>openshift</id>
<build>
<plugins>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/openshift/helpers/Load.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public BusyThread(String name, double load, long duration) {
this.duration = duration;
}


@Override
public void run() {
long startTime = System.currentTimeMillis();
Expand All @@ -36,4 +36,4 @@ public void run() {
}
}
}
}
}
54 changes: 27 additions & 27 deletions src/main/java/com/openshift/service/DemoResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
*/
@Path("demo")
public class DemoResource {
// application instance health
// 1 is healthy
private static Integer health = 1;

// application instance health
// 1 is healthy
private static Integer health = 1;

@GET
@Path("load/{seconds}")
Expand Down Expand Up @@ -68,44 +68,44 @@ public String logSevere(@Context SecurityContext context) {
@Path("togglehealth/")
@Produces({"application/json"})
public String togglehealth(@Context SecurityContext context) {
// check if currently healthy, otherwise "become" healthy
if (health == 1) {
// become unhealthy
health = 0;
Logger log = Logger.getLogger(DemoResource.class.getName());
// check if currently healthy, otherwise "become" healthy
if (health == 1) {
// become unhealthy
health = 0;
Logger log = Logger.getLogger(DemoResource.class.getName());
log.log(Level.SEVERE, "ERROR: I'm not feeling so well.");
return new String("{\"response\":\"The app is starting to look a little ill...\"}");
} else {
// become healthy
health = 1;
Logger log = Logger.getLogger(DemoResource.class.getName());
return new String("{\"response\":\"The app is starting to look a little ill...\"}");
} else {
// become healthy
health = 1;
Logger log = Logger.getLogger(DemoResource.class.getName());
log.log(Level.INFO, "INFO: I feel much better.");
return new String("{\"response\":\"The app is starting to look great!\"}");
}
}
}

@GET
@Path("killswitch/")
@Produces({"application/json"})
public void killSwitch(@Context SecurityContext context) throws IOException {
Logger log = Logger.getLogger(DemoResource.class.getName());
Logger log = Logger.getLogger(DemoResource.class.getName());
log.log(Level.SEVERE, "ERROR: Going down NOW!");
Runtime.getRuntime().halt(255);
}
Runtime.getRuntime().halt(255);
}

@GET
@Path("healthcheck/")
@Produces({"application/json"})
public Response checkHealth(@Context SecurityContext context) throws IOException {

String response = new String("{\"response\":\"Health Status: " + health + "\", \"health\": " + health + "}");

// if health is 1, return 200, otherwise 500
if (health == 1) {
return Response.status(Response.Status.OK).entity(response).build();
} else {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(response).build();
}

String response = new String("{\"response\":\"Health Status: " + health + "\", \"health\": " + health + "}");

// if health is 1, return 200, otherwise 500
if (health == 1) {
return Response.status(Response.Status.OK).entity(response).build();
} else {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(response).build();
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ public void deleteTask(Task task) {
private TypedQuery<Task> querySelectAllTasksFromUser(User user) {
return em.createQuery("SELECT t FROM Task t WHERE t.owner = ?1", Task.class).setParameter(1, user);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ public interface UserDao {
public User getForUsername(String username);

public void createUser(User user);

public List<User> getAll();
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ public User getForUsername(String username) {
}
return result.get(0);
}

public List<User> getAll() {
return em.createQuery("select u from User u", User.class).getResultList();
return em.createQuery("select u from User u", User.class).getResultList();
}

public void createUser(User user) {
em.persist(user);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ public class UserResource {
@Path("/")
@Produces({ "application/xml", "application/json" })
public List<User> getUsers() {
List<User> users = userDao.getAll();

// TODO: Uncomment to sort users based on number of tasks
List<User> users = userDao.getAll();

// Collections.sort(users, new Comparator<User>() {
// TODO: Uncomment to sort users based on number of tasks

// Collections.sort(users, new Comparator<User>() {
//
// @Override
// public int compare(User user1, User user2) {
// return Integer.compare(user2.getTasks().size(), user1.getTasks().size());
// }
// });
// @Override
// public int compare(User user1, User user2) {
// return Integer.compare(user2.getTasks().size(), user1.getTasks().size());
// }
// });

return users;
}
}
14 changes: 7 additions & 7 deletions src/main/resources/META-INF/persistence.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="primary">
<jta-data-source>java:jboss/datasources/TasksRsQuickstartDS</jta-data-source>
<properties>
<persistence-unit name="primary">
<jta-data-source>java:jboss/datasources/TasksRsQuickstartDS</jta-data-source>
<properties>
<!-- Properties for Hibernate -->
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="hibernate.show_sql" value="false" />
</properties>
</persistence-unit>
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="hibernate.show_sql" value="false" />
</properties>
</persistence-unit>
</persistence>
4 changes: 2 additions & 2 deletions src/main/webapp/WEB-INF/beans.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
-->
<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
</beans>
</beans>
16 changes: 8 additions & 8 deletions src/main/webapp/WEB-INF/tasks-rs-ds.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
xsi:schemaLocation="http://www.jboss.org/ironjacamar/schema http://docs.jboss.org/ironjacamar/schema/datasources_1_0.xsd">
<!-- The datasource is bound into JNDI at this location. We reference
this in META-INF/persistence.xml -->
<datasource jndi-name="java:jboss/datasources/TasksRsQuickstartDS"
<datasource jndi-name="java:jboss/datasources/TasksRsQuickstartDS"
pool-name="TasksRsQuickstartDS" enabled="true"
use-java-context="true">
<connection-url>jdbc:h2:mem:tasks-rs-xml-quickstart;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>
<connection-url>jdbc:h2:mem:tasks-rs-xml-quickstart;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>
</datasources>
30 changes: 15 additions & 15 deletions src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,27 @@
</login-config>

<context-param>
<param-name>resteasy.role.based.security</param-name>
<param-value>true</param-value>
<param-name>resteasy.role.based.security</param-name>
<param-value>true</param-value>
</context-param>

<security-constraint>
<web-resource-collection>
<web-resource-name>Tasks</web-resource-name>
<url-pattern>/ws/tasks/*</url-pattern>
</web-resource-collection>
<web-resource-collection>
<web-resource-name>Users</web-resource-name>
<url-pattern>/ws/users/*</url-pattern>
</web-resource-collection>

<auth-constraint>
<role-name>guest</role-name>
</auth-constraint>
<web-resource-collection>
<web-resource-name>Tasks</web-resource-name>
<url-pattern>/ws/tasks/*</url-pattern>
</web-resource-collection>
<web-resource-collection>
<web-resource-name>Users</web-resource-name>
<url-pattern>/ws/users/*</url-pattern>
</web-resource-collection>

<auth-constraint>
<role-name>guest</role-name>
</auth-constraint>
</security-constraint>

<security-role>
<role-name>guest</role-name>
<role-name>guest</role-name>
</security-role>

<distributable/>
Expand Down
Loading

0 comments on commit 71dde8a

Please sign in to comment.