Commit 23ebd1aa authored by Francesco Chicchiricco's avatar Francesco Chicchiricco
Browse files

[CRV-17] Adapting to latest changes in EE

parent eb4f59c7
......@@ -20,6 +20,7 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import java.io.InputStream;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
......@@ -33,34 +34,34 @@ import javax.ws.rs.core.Response;
public interface ChoreographyApi {
@GET
@Path("/start/{choreography_id}")
@Path("/start/{choreographyId}")
@ApiOperation(
value = "Start a running choreography."
)
Response start(
@ApiParam(name = "choreography_id", value = "The ID of the choregraphy to start", required = true)
@PathParam("choreography_id")
String choreography_id);
@ApiParam(name = "choreographyId", value = "The ID of the choregraphy to start", required = true)
@PathParam("choreographyId")
String choreographyId);
@GET
@Path("/stop/{choreography_id}")
@Path("/stop/{choreographyId}")
@ApiOperation(
value = "Stop a running choreography."
)
Response stop(
@ApiParam(name = "choreography_id", value = "The ID of the choregraphy to stop", required = true)
@PathParam("choreography_id")
String choreography_id);
@ApiParam(name = "choreographyId", value = "The ID of the choregraphy to stop", required = true)
@PathParam("choreographyId")
String choreographyId);
@GET
@Path("/pause/{choreography_id}")
@Path("/pause/{choreographyId}")
@ApiOperation(
value = "Pause a running choreography."
)
Response pause(
@ApiParam(name = "choreography_id", value = "The ID of the choregraphy to pause", required = true)
@PathParam("choreography_id")
String choreography_id);
@ApiParam(name = "choreographyId", value = "The ID of the choregraphy to pause", required = true)
@PathParam("choreographyId")
String choreographyId);
/*
......@@ -71,15 +72,14 @@ public interface ChoreographyApi {
@ApiError(code = 404, reason = "Choreography not existing")
})*/
@GET
@Path("/check_status/{choreography_id}")
@Path("/check_status/{choreographyId}")
Response check_status(
@ApiParam(name = "choreography_id", value = "The ID of the choregraphy to check", required = true)
@PathParam("choreography_id")
String choreography_id);
@ApiParam(name = "choreographyId", value = "The ID of the choregraphy to check", required = true)
@PathParam("choreographyId")
String choreographyId);
@POST
@Path("/deploy/{choreography_name}")
@Path("/deploy/{choreographyName}")
@Consumes(MediaType.APPLICATION_JSON)
@ApiOperation(
value = "Deploy a choreography onto a cloud environment.",
......@@ -90,13 +90,13 @@ public interface ChoreographyApi {
@ApiResponse(code = 412, message = "Choreography already registered")
})
Response deploy(
@ApiParam(name = "choreography_name", value = "Choreography ID or name", required = true)
@PathParam("choreography_name") String choreography_name,
@ApiParam(name = "choreography", value = "Choreography specifications", required = true)
String choreography);
@ApiParam(name = "choreographyName", value = "Choreography name", required = true)
@PathParam("choreographyName") String choreographyName,
@ApiParam(name = "chorSpec", value = "Choreography specifications", required = true)
InputStream chorSpec);
@POST
@Path("/resize/{choreography_name}")
@Path("/resize/{choreographyId}")
@Consumes(MediaType.APPLICATION_JSON)
@ApiOperation(
value = "Resize VM pool running a running choreography.",
......@@ -107,9 +107,8 @@ public interface ChoreographyApi {
@ApiResponse(code = 412, message = "Choreography already registered")
})
Response resize(
@ApiParam(name = "choreography_name", value = "Choreography ID or name", required = true)
@PathParam("choreography_name") String choreography_name,
@ApiParam(name = "choreographyId", value = "Choreography ID", required = true)
@PathParam("choreographyId") String choreographyId,
@ApiParam(name = "desired_pool_size", value = "Desired size of the VMs pool", required = true)
int desired_size);
}
......@@ -15,6 +15,7 @@
*/
package eu.chorevolution.idm.choremocks.ee;
import java.io.InputStream;
import java.util.Date;
import java.util.UUID;
import javax.ws.rs.core.Context;
......@@ -30,7 +31,7 @@ public class ChoreographyResource implements ChoreographyApi {
private UriInfo uriInfo;
@Override
public Response deploy(final String choreography_name, final String choreography) {
public Response deploy(final String choreographyName, final InputStream chorSpec) {
String choreographyId = UUID.randomUUID().toString();
return Response.created(uriInfo.getAbsolutePathBuilder().path(choreographyId).build()).
entity(new TaskSummary(
......@@ -38,7 +39,7 @@ public class ChoreographyResource implements ChoreographyApi {
"Task for " + choreographyId,
null,
choreographyId,
choreography_name,
choreographyName,
null,
new Date().getTime(),
new Date().getTime(),
......
......@@ -107,13 +107,13 @@ public class ChoreographyLogic extends AbstractTransactionalLogic<AbstractBaseBe
}
@PreAuthorize("hasRole('" + ChorevolutionEntitlement.CHOREOGRAPHY_CREATE + "')")
public String enact(final String enactmentEngineKey, final InputStream chorSpec) {
public String enact(final String name, final String enactmentEngineKey, final InputStream chorSpec) {
String generatedChoreographyId = null;
Response response;
try {
WebClient webClient = getWebClient(enactmentEngineKey, "/deploy/TMP");
response = webClient.post(IOUtils.toString(chorSpec, SyncopeConstants.DEFAULT_CHARSET));
WebClient webClient = getWebClient(enactmentEngineKey, "/deploy/" + name);
response = webClient.post(chorSpec);
if (response.getStatus() != Response.Status.CREATED.getStatusCode()) {
throw new WebApplicationException(response);
}
......@@ -145,7 +145,7 @@ public class ChoreographyLogic extends AbstractTransactionalLogic<AbstractBaseBe
}
@PreAuthorize("hasRole('" + ChorevolutionEntitlement.CHOREOGRAPHY_UPDATE + "')")
public void enact(final String id, final String enactmentEngineKey, final InputStream chorSpec) {
public void enact(final String id, final String name, final String enactmentEngineKey, final InputStream chorSpec) {
}
@PreAuthorize("hasRole('" + ChorevolutionEntitlement.CHOREOGRAPHY_DELETE + "')")
......
......@@ -39,25 +39,32 @@ public interface ChoreographyService extends JAXRSService {
/**
* Enact a new choreography.
*
* @param name choreography name
* @param enactmentEngineKey target enactment engine instance
* @param chorSpec ChorSpec XML representation
* @return the choreography deployment id as generateed by the enactment engine
*/
@POST
@Consumes({ MediaType.APPLICATION_XML })
Response enact(@NotNull @QueryParam("enactmentEngineKey") String enactmentEngineKey, InputStream chorSpec);
Response enact(
@NotNull @QueryParam("name") String name,
@NotNull @QueryParam("enactmentEngineKey") String enactmentEngineKey,
InputStream chorSpec);
/**
* Enact an existing choreography, with updated specification.
*
* @param id choreography id
* @param name choreography name
* @param enactmentEngineKey target enactment engine instance
* @param chorSpec ChorSpec XML representation
*/
@PUT
@Path("{id}")
@Consumes({ MediaType.APPLICATION_XML })
void enact(
@NotNull @PathParam("id") String id,
@NotNull @QueryParam("name") String name,
@NotNull @QueryParam("enactmentEngineKey") String enactmentEngineKey,
InputStream chorSpec);
......
......@@ -32,15 +32,15 @@ public class ChoreographyServiceImpl extends AbstractServiceImpl implements Chor
private ChoreographyLogic logic;
@Override
public Response enact(final String enactmentEngineKey, final InputStream chorSpec) {
public Response enact(final String name, final String enactmentEngineKey, final InputStream chorSpec) {
return Response.status(Response.Status.CREATED).
header("X-CHOReVOLUTION-ChoreographyId", logic.enact(enactmentEngineKey, chorSpec)).
header("X-CHOReVOLUTION-ChoreographyId", logic.enact(name, enactmentEngineKey, chorSpec)).
build();
}
@Override
public void enact(final String id, final String enactmentEngineKey, final InputStream chorSpec) {
logic.enact(id, enactmentEngineKey, chorSpec);
public void enact(final String id, final String name, final String enactmentEngineKey, final InputStream chorSpec) {
logic.enact(id, name, enactmentEngineKey, chorSpec);
}
@Override
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment