Updates deliverable

* Removes dummy greeting provider
* Moves linux scripts to specific folder
* Add scripts to main release delivery
This commit is contained in:
Julien Lengrand-Lambert
2020-11-16 22:05:29 +01:00
parent 91c09961df
commit 0c6393e9e1
7 changed files with 37 additions and 181 deletions

View File

@@ -24,7 +24,7 @@ jobs:
- name: Build with Maven
run: |
mvn -B package;
mkdir cellar-dist; cp -r cellar-app/target/libs cellar-dist; cp cellar-app/target/cellar-app.jar cellar-dist
mkdir cellar-dist; cp -r cellar-app/target/libs cellar-dist; cp cellar-app/target/cellar-app.jar cellar-dist; cp scripts/cellar* cellar-dist
zip -r cellar.zip cellar-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -1,130 +0,0 @@
/*
* Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
*
* 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 nl.lengrand.cellar;
import java.util.Collections;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.json.Json;
import javax.json.JsonBuilderFactory;
import javax.json.JsonObject;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
/**
* A simple JAX-RS resource to greet you. Examples:
*
* Get default greeting message:
* curl -X GET http://localhost:8080/greet
*
* Get greeting message for Joe:
* curl -X GET http://localhost:8080/greet/Joe
*
* Change greeting
* curl -X PUT -H "Content-Type: application/json" -d '{"greeting" : "Howdy"}' http://localhost:8080/greet/greeting
*
* The message is returned as a JSON object.
*/
@Path("/greet")
@RequestScoped
public class GreetResource {
private static final JsonBuilderFactory JSON = Json.createBuilderFactory(Collections.emptyMap());
/**
* The greeting message provider.
*/
private final GreetingProvider greetingProvider;
/**
* Using constructor injection to get a configuration property.
* By default this gets the value from META-INF/microprofile-config
*
* @param greetingConfig the configured greeting message
*/
@Inject
public GreetResource(GreetingProvider greetingConfig) {
this.greetingProvider = greetingConfig;
}
/**
* Return a wordly greeting message.
*
* @return {@link JsonObject}
*/
@SuppressWarnings("checkstyle:designforextension")
@GET
@Produces(MediaType.APPLICATION_JSON)
public JsonObject getDefaultMessage() {
return createResponse("World");
}
/**
* Return a greeting message using the name that was provided.
*
* @param name the name to greet
* @return {@link JsonObject}
*/
@SuppressWarnings("checkstyle:designforextension")
@Path("/{name}")
@GET
@Produces(MediaType.APPLICATION_JSON)
public JsonObject getMessage(@PathParam("name") String name) {
return createResponse(name);
}
/**
* Set the greeting to use in future messages.
*
* @param jsonObject JSON containing the new greeting
* @return {@link Response}
*/
@SuppressWarnings("checkstyle:designforextension")
@Path("/greeting")
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response updateGreeting(JsonObject jsonObject) {
if (!jsonObject.containsKey("greeting")) {
JsonObject entity = JSON.createObjectBuilder()
.add("error", "No greeting provided")
.build();
return Response.status(Response.Status.BAD_REQUEST).entity(entity).build();
}
String newGreeting = jsonObject.getString("greeting");
greetingProvider.setMessage(newGreeting);
return Response.status(Response.Status.NO_CONTENT).build();
}
private JsonObject createResponse(String who) {
String msg = String.format("%s %s!", greetingProvider.getMessage(), who);
return JSON.createObjectBuilder()
.add("message", msg)
.build();
}
}

View File

@@ -1,49 +0,0 @@
/*
* Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
*
* 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 nl.lengrand.cellar;
import java.util.concurrent.atomic.AtomicReference;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import org.eclipse.microprofile.config.inject.ConfigProperty;
/**
* Provider for greeting message.
*/
@ApplicationScoped
public class GreetingProvider {
private final AtomicReference<String> message = new AtomicReference<>();
/**
* Create a new greeting provider, reading the message from configuration.
*
* @param message greeting to use
*/
@Inject
public GreetingProvider(@ConfigProperty(name = "app.greeting") String message) {
this.message.set(message);
}
String getMessage() {
return message.get();
}
void setMessage(String message) {
this.message.set(message);
}
}

View File

@@ -14,7 +14,6 @@
# limitations under the License.
#
app.greeting=Hello
monitoring.enabled=true
driver.type=dummy

View File

@@ -0,0 +1,36 @@
#
# Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
#
# 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.
#
monitoring.enabled=true
driver.type=dummy
sensor.api.type=influx
monitor.time.unit=SECONDS
monitor.time.span=5
sensor.api.fauna.key=dummy
#sensor.api.fauna.db=cellar
#sensor.api.fauna.collection=sensors
#sensor.api.influx.location=http://localhost:8086
sensor.api.influx.key=dummy
#sensor.api.influx.organization=cellar
#sensor.api.influx.bucket=cellar-data
#sensor.api.influx.precision=S
# Microprofile server properties
server.port=8080
server.host=0.0.0.0