Commit b56d1280 authored by Francesco Chicchiricco's avatar Francesco Chicchiricco
Browse files

[CRV-280] Small fixes and enhancements

parent 3d4e2bcf
......@@ -215,29 +215,6 @@ public class ChoreographyLogic extends AbstractLogic<AbstractBaseBean> {
accept(MediaType.APPLICATION_JSON_TYPE).type(MediaType.APPLICATION_JSON_TYPE);
}
private GroupTO choreographyExists(final SearchCond cond) {
AttributeCond isChoreographyCond = new AttributeCond(AttributeCond.Type.EQ);
isChoreographyCond.setSchema("isChoreography");
isChoreographyCond.setExpression("true");
List<GroupTO> candidates = groupLogic.search(SearchCond.getAndCond(
cond, SearchCond.getLeafCond(isChoreographyCond)),
1, 1, Collections.<OrderByClause>emptyList(), SyncopeConstants.ROOT_REALM, false);
if (candidates.isEmpty()) {
throw new NotFoundException("Choreography matching " + cond);
}
return candidates.get(0);
}
private GroupTO choreographyExists(final String id) {
AttributeCond idCond = new AttributeCond(AttributeCond.Type.EQ);
idCond.setSchema(CHOREOGRAPHY_ID_SCHEMA);
idCond.setExpression(id);
return choreographyExists(SearchCond.getLeafCond(idCond));
}
private AnyObjectTO serviceExists(final String id) {
AnyObjectTO serviceTO = anyObjectLogic.read(id);
if (!SERVICE_TYPE.equals(serviceTO.getType())) {
......@@ -355,7 +332,7 @@ public class ChoreographyLogic extends AbstractLogic<AbstractBaseBean> {
try {
WebClient webClient = getEEWebClient(enactmentEngine,
"/" + choreography.getPlainAttrMap().get("id").getValues().iterator().next());
"/" + choreography.getPlainAttrMap().get("id").getValues().get(0));
Response response = webClient.delete();
if (response.getStatus() != Response.Status.ACCEPTED.getStatusCode()) {
throw new WebApplicationException(response);
......@@ -368,6 +345,29 @@ public class ChoreographyLogic extends AbstractLogic<AbstractBaseBean> {
updateChoreographyStatus(choreography, "PENDING DELETE");
}
private GroupTO choreographyExists(final SearchCond cond) {
AttributeCond isChoreographyCond = new AttributeCond(AttributeCond.Type.EQ);
isChoreographyCond.setSchema("isChoreography");
isChoreographyCond.setExpression("true");
List<GroupTO> candidates = groupLogic.search(SearchCond.getAndCond(
cond, SearchCond.getLeafCond(isChoreographyCond)),
1, 1, Collections.<OrderByClause>emptyList(), SyncopeConstants.ROOT_REALM, false);
if (candidates.isEmpty()) {
throw new NotFoundException("Choreography matching " + cond);
}
return candidates.get(0);
}
private GroupTO choreographyExists(final String id) {
AttributeCond idCond = new AttributeCond(AttributeCond.Type.EQ);
idCond.setSchema(CHOREOGRAPHY_ID_SCHEMA);
idCond.setExpression(id);
return choreographyExists(SearchCond.getLeafCond(idCond));
}
@PreAuthorize("hasRole('" + ChorevolutionEntitlement.CHOREOGRAPHY_ENACT + "')")
public void enact(final String name) {
AnyCond nameCond = new AnyCond(AttributeCond.Type.EQ);
......@@ -676,6 +676,7 @@ public class ChoreographyLogic extends AbstractLogic<AbstractBaseBean> {
final Integer newSize) {
GroupTO choreography = groupLogic.read(key);
String choregraphyId = choreography.getPlainAttrMap().get("id").getValues().get(0);
AnyObjectTO enactmentEngine = enactmentEngineForChoreography(key);
String newStatus = null;
......@@ -684,27 +685,22 @@ public class ChoreographyLogic extends AbstractLogic<AbstractBaseBean> {
switch (action) {
case START:
case UNFREEZE:
webClient = getEEWebClient(enactmentEngine,
"/" + choreography.getPlainAttrMap().get("id").getValues().iterator().next() + "/start");
webClient = getEEWebClient(enactmentEngine, "/" + choregraphyId + "/start");
newStatus = "STARTED";
break;
case STOP:
webClient = getEEWebClient(enactmentEngine,
"/" + choreography.getPlainAttrMap().get("id").getValues().iterator().next() + "/stop");
webClient = getEEWebClient(enactmentEngine, "/" + choregraphyId + "/stop");
newStatus = "STOPPED";
break;
case FREEZE:
webClient = getEEWebClient(enactmentEngine,
"/" + choreography.getPlainAttrMap().get("id").getValues().iterator().next() + "/pause");
webClient = getEEWebClient(enactmentEngine, "/" + choregraphyId + "/pause");
newStatus = "FROZEN";
break;
case RESIZE:
webClient = getEEWebClient(enactmentEngine,
"/" + choreography.getPlainAttrMap().get("id").getValues().iterator().next()
+ "/resize?newSize=" + newSize);
webClient = getEEWebClient(enactmentEngine, "/" + choregraphyId + "/resize?newSize=" + newSize);
break;
default:
......@@ -760,7 +756,7 @@ public class ChoreographyLogic extends AbstractLogic<AbstractBaseBean> {
try {
WebClient webClient = getEEWebClient(enactmentEngine,
"/" + choreography.getPlainAttrMap().get("id").getValues().iterator().next()
"/" + choreography.getPlainAttrMap().get("id").getValues().get(0)
+ "/replaceService/" + newServiceRole.getName() + "/" + newService.getName()
+ "?serviceEndPoint=" + serviceLocation);
Response response = webClient.post(null);
......
......@@ -67,7 +67,7 @@ public interface ChoreographyService extends JAXRSService {
@Path("{key}")
@Consumes({ MediaType.APPLICATION_XML })
void update(
@NotNull @PathParam("id") String key,
@NotNull @PathParam("key") String key,
@NotNull @QueryParam("name") String name,
InputStream chorSpec);
......
Markdown is supported
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