Commit c4f1a57d authored by Gianluca Filippone's avatar Gianluca Filippone
Browse files

[CRV-302] Providing functions for choreography export

parent 22436d83
......@@ -33,6 +33,8 @@ public class ChoreographyTO extends AbstractBaseBean {
private String description;
private byte[] chorspec;
private byte[] diagram;
private byte[] messages;
......@@ -73,6 +75,14 @@ public class ChoreographyTO extends AbstractBaseBean {
this.description = description;
}
public byte[] getChorspec() {
return chorspec;
}
public void setChorspec(final byte[] chorspec) {
this.chorspec = chorspec;
}
public byte[] getDiagram() {
return diagram;
}
......
......@@ -36,6 +36,7 @@ import java.lang.reflect.Method;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
......@@ -71,6 +72,7 @@ import org.apache.syncope.common.lib.types.AttrSchemaType;
import org.apache.syncope.common.lib.types.CipherAlgorithm;
import org.apache.syncope.common.lib.types.PatchOperation;
import org.apache.syncope.common.lib.types.SchemaType;
import org.apache.syncope.core.persistence.api.dao.ChoreographyDAO;
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.AnyTypeCond;
......@@ -78,6 +80,8 @@ import org.apache.syncope.core.persistence.api.dao.search.AttributeCond;
import org.apache.syncope.core.persistence.api.dao.search.MembershipCond;
import org.apache.syncope.core.persistence.api.dao.search.OrderByClause;
import org.apache.syncope.core.persistence.api.dao.search.SearchCond;
import org.apache.syncope.core.persistence.api.entity.group.GPlainAttr;
import org.apache.syncope.core.persistence.api.entity.group.Group;
import org.apache.syncope.core.spring.security.Encryptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
......@@ -144,6 +148,9 @@ public class ChoreographyLogic extends AbstractLogic<AbstractBaseBean> {
@Autowired
private SchemaLogic schemaLogic;
@Autowired
private ChoreographyDAO choreographyDAO;
@Autowired
private ChoreographyInstanceDAO choreographyInstanceDAO;
......@@ -291,6 +298,24 @@ public class ChoreographyLogic extends AbstractLogic<AbstractBaseBean> {
return getChoreography(choreography, true);
}
@PreAuthorize("hasRole('" + ChorevolutionEntitlement.CHOREOGRAPHY_LIST + "')")
public List<ChoreographyTO> getChoreographyList() {
List<ChoreographyTO> result = new LinkedList<>();
for (Group choreography : choreographyDAO.findAll()) {
ChoreographyTO choreographyTO = new ChoreographyTO();
choreographyTO.setKey(choreography.getKey());
choreographyTO.setName(choreography.getName());
GPlainAttr description = choreography.getPlainAttr("description");
if (description != null && !description.getValues().isEmpty()) {
choreographyTO.setDescription(description.getValues().get(0).getStringValue());
}
result.add(choreographyTO);
}
return result;
}
@PreAuthorize("hasRole('" + ChorevolutionEntitlement.CHOREOGRAPHY_CREATE + "')")
public String create(final String name, final String synthesisProcessorKey, final InputStream chorSpec) {
AnyObjectTO synthesisProcessor = synthesisProcessorExists(synthesisProcessorKey);
......@@ -923,6 +948,11 @@ public class ChoreographyLogic extends AbstractLogic<AbstractBaseBean> {
}
if (details) {
AttrTO chorspec = choreography.getPlainAttrMap().get("chorSpec");
if (chorspec != null && !chorspec.getValues().isEmpty()) {
choreographyTO.setChorspec(DatatypeConverter.parseBase64Binary(chorspec.getValues().get(0)));
}
AttrTO messages = choreography.getPlainAttrMap().get("messages");
if (messages != null && !messages.getValues().isEmpty()) {
choreographyTO.setMessages(DatatypeConverter.parseBase64Binary(messages.getValues().get(0)));
......
......@@ -22,6 +22,7 @@ import eu.chorevolution.idm.common.types.SecurityFilterInfo;
import eu.chorevolution.idm.common.types.ServiceAction;
import java.io.InputStream;
import java.net.URL;
import java.util.List;
import javax.validation.constraints.NotNull;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
......@@ -53,6 +54,15 @@ public interface ChoreographyService extends JAXRSService {
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
ChoreographyTO read(@NotNull @PathParam("key") String choreographyKey);
/**
* Retrieves choreography list
*
* @return list of all choreographies, with only name, key and description
*/
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
List<ChoreographyTO> list();
/**
* Creates a choreography.
*
......
......@@ -23,6 +23,7 @@ import eu.chorevolution.idm.common.types.ServiceAction;
import org.apache.syncope.core.logic.ChoreographyLogic;
import java.io.InputStream;
import java.net.URL;
import java.util.List;
import javax.ws.rs.core.Response;
import org.apache.syncope.common.lib.to.AnyObjectTO;
import org.apache.syncope.common.rest.api.RESTHeaders;
......@@ -50,6 +51,11 @@ public class ChoreographyServiceImpl extends AbstractServiceImpl implements Chor
return logic.getChoreography(choreographyKey);
}
@Override
public List<ChoreographyTO> list() {
return logic.getChoreographyList();
}
@Override
public void update(final String key, final String name, final InputStream chorSpec) {
logic.update(key, name, 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