Commit 973688c4 authored by Francesco Chicchiricco's avatar Francesco Chicchiricco
Browse files

[CRV-17] Undeploying existing choreography now working with choremocks

parent 4a8f9484
......@@ -36,7 +36,7 @@ public class ChoreographyResource implements ChoreographyApi {
return Response.created(uriInfo.getAbsolutePathBuilder().path(choreographyId).build()).
entity(new TaskSummary(
UUID.randomUUID().toString(),
"Task for " + choreographyId,
"Create Task for " + choreographyId,
null,
choreographyId,
choreographyName,
......@@ -64,8 +64,30 @@ public class ChoreographyResource implements ChoreographyApi {
}
@Override
public Response stop(final String choreography_id) {
return null;
public Response stop(final String choreographyId) {
return Response.noContent().
entity(new TaskSummary(
UUID.randomUUID().toString(),
"Delete Task for " + choreographyId,
null,
choreographyId,
null,
null,
new Date().getTime(),
new Date().getTime(),
new Date().getTime(),
"SUBMITTED",
null,
false,
false,
null,
null,
null,
null,
null,
null,
null)).
build();
}
@Override
......
......@@ -34,9 +34,6 @@ limitations under the License.
<bean id="authenticationHandler" class="eu.chorevolution.idm.choremocks.AuthenticationHandler"/>
<bean id="jsonProvider" class="com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider"/>
<bean id="exceptionMapper" class="org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper">
<property name="addMessageToResponse" value="true"/>
</bean>
<jaxrs:server address="/"
basePackages="eu.chorevolution.idm.choremocks.ee,
......@@ -48,7 +45,6 @@ limitations under the License.
<jaxrs:providers>
<ref bean="authenticationHandler"/>
<ref bean="jsonProvider"/>
<ref bean="exceptionMapper"/>
</jaxrs:providers>
</jaxrs:server>
......
......@@ -24,7 +24,7 @@ limitations under the License.
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:/*Context.xml</param-value>
<param-value>classpath:/restMocks.xml</param-value>
</context-param>
<listener>
......
......@@ -37,6 +37,7 @@ import org.apache.syncope.common.lib.AbstractBaseBean;
import org.apache.syncope.common.lib.SyncopeConstants;
import org.apache.syncope.common.lib.to.AnyObjectTO;
import org.apache.syncope.common.lib.to.AttrTO;
import org.apache.syncope.common.lib.to.GroupTO;
import org.apache.syncope.core.persistence.api.dao.NotFoundException;
import org.apache.syncope.core.persistence.api.dao.PlainSchemaDAO;
import org.apache.syncope.core.persistence.api.entity.PlainSchema;
......@@ -56,6 +57,11 @@ public class ChoreographyLogic extends AbstractTransactionalLogic<AbstractBaseBe
private static final String ENACTMENT_ENGINE_PASSWORD = "enactmentEnginePassword";
private static final String CHOREOGRAPHY_ANYTYPE_CLASS = "Choreography";
@Autowired
private GroupLogic groupLogic;
@Autowired
private AnyObjectLogic anyObjectLogic;
......@@ -140,7 +146,7 @@ public class ChoreographyLogic extends AbstractTransactionalLogic<AbstractBaseBe
if (StringUtils.isEmpty(generatedChoreographyId)) {
throw new WebApplicationException("Could not extract the generated choreography id", response);
}
return generatedChoreographyId;
}
......@@ -150,6 +156,31 @@ public class ChoreographyLogic extends AbstractTransactionalLogic<AbstractBaseBe
@PreAuthorize("hasRole('" + ChorevolutionEntitlement.CHOREOGRAPHY_DELETE + "')")
public void delete(final String id, final String enactmentEngineKey) {
// checks that the given choreography exists
try {
GroupTO choreography = groupLogic.read(id);
if (!choreography.getAuxClasses().contains(CHOREOGRAPHY_ANYTYPE_CLASS)) {
throw new NotFoundException("Choreography " + id);
}
} catch (NotFoundException e) {
throw new NotFoundException("Choreography " + id);
}
try {
WebClient webClient = getWebClient(enactmentEngineKey, "/stop/" + id);
Response response = webClient.get();
if (response.getStatus() != Response.Status.NO_CONTENT.getStatusCode()) {
throw new WebApplicationException(response);
}
} catch (Exception e) {
LOG.error("While deleting {}", enactmentEngineKey, e);
if (e instanceof WebApplicationException) {
throw WebApplicationException.class.cast(e);
} else {
throw new WebApplicationException("While deleting " + enactmentEngineKey, e);
}
}
}
@PreAuthorize("hasRole('" + ChorevolutionEntitlement.NOTIFY_COMPLETION + "')")
......
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