Commit 463a3c82 authored by Gianluca Filippone's avatar Gianluca Filippone
Browse files

Updated enact REST method, now using choreography key instead of name

parent a615d272
......@@ -142,7 +142,7 @@ public class ChoreographyDirectoryPanel extends GroupDirectoryPanel {
@Override
public void onClick(final AjaxRequestTarget target) {
try {
choreographyRestClient.enactChoreography(model.getObject().getName());
choreographyRestClient.enactChoreography(model.getObject().getKey());
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
target.add(container);
} catch (SyncopeClientException e) {
......
......@@ -33,8 +33,8 @@ public class ChoreographyRestClient extends BaseRestClient {
getService(ChoreographyService.class).delete(choreographyKey);
}
public void enactChoreography(final String choregographyName) {
getService(ChoreographyService.class).enact(choregographyName);
public void enactChoreography(final String choregographyKey) {
getService(ChoreographyService.class).enact(choregographyKey);
}
public void startChoreography(final String choreographyKey) {
......
......@@ -73,7 +73,6 @@ import org.apache.syncope.common.lib.types.PatchOperation;
import org.apache.syncope.common.lib.types.SchemaType;
import org.apache.syncope.core.persistence.api.dao.ChoreographyInstanceDAO;
import org.apache.syncope.core.persistence.api.dao.NotFoundException;
import org.apache.syncope.core.persistence.api.dao.search.AnyCond;
import org.apache.syncope.core.persistence.api.dao.search.AnyTypeCond;
import org.apache.syncope.core.persistence.api.dao.search.AttributeCond;
import org.apache.syncope.core.persistence.api.dao.search.MembershipCond;
......@@ -380,12 +379,9 @@ public class ChoreographyLogic extends AbstractLogic<AbstractBaseBean> {
}
@PreAuthorize("hasRole('" + ChorevolutionEntitlement.CHOREOGRAPHY_ENACT + "')")
public void enact(final String name) {
AnyCond nameCond = new AnyCond(AttributeCond.Type.EQ);
nameCond.setSchema("name");
nameCond.setExpression(name);
public void enact(final String key) {
GroupTO choreography = groupLogic.read(key);
GroupTO choreography = choreographyExists(SearchCond.getLeafCond(nameCond));
AnyObjectTO enactmentEngine = enactmentEngineForChoreography(choreography.getKey());
Map<String, AttrTO> choreographyAttrs = choreography.getPlainAttrMap();
try {
......@@ -399,7 +395,8 @@ public class ChoreographyLogic extends AbstractLogic<AbstractBaseBean> {
String generatedChoreographyId = null;
Response response;
WebClient webClient = getEEWebClient(enactmentEngine.getKey(), "/?choreographyName=" + name);
WebClient webClient =
getEEWebClient(enactmentEngine.getKey(), "/?choreographyName=" + choreography.getName());
response = webClient.post(chorSpec);
if (response.getStatus() != Response.Status.CREATED.getStatusCode()) {
throw new WebApplicationException(response);
......@@ -430,7 +427,8 @@ public class ChoreographyLogic extends AbstractLogic<AbstractBaseBean> {
groupLogic.update(choreographyPatch, false);
} else {
String id = choreographyAttrs.get(CHOREOGRAPHY_ID_SCHEMA).getValues().get(0);
WebClient webClient = getEEWebClient(enactmentEngine, "/" + id + "?choreographyName=" + name);
WebClient webClient
= getEEWebClient(enactmentEngine, "/" + id + "?choreographyName=" + choreography.getName());
Response response = webClient.put(chorSpec);
if (response.getStatus() != Response.Status.ACCEPTED.getStatusCode()) {
throw new WebApplicationException(response);
......
......@@ -98,8 +98,8 @@ public interface ChoreographyService extends JAXRSService {
* @param name choreography name
*/
@POST
@Path("{name}/enact")
void enact(@NotNull @PathParam("name") String name);
@Path("{key}/enact")
void enact(@NotNull @PathParam("key") String name);
/**
* This operation will used to notify that an enactment operation was completed, providing the
......
......@@ -61,8 +61,8 @@ public class ChoreographyServiceImpl extends AbstractServiceImpl implements Chor
}
@Override
public void enact(final String name) {
logic.enact(name);
public void enact(final String key) {
logic.enact(key);
}
@Override
......
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