use of org.wso2.carbon.apimgt.persistence.dto.Mediation in project carbon-apimgt by wso2.
the class MediationMappingUtil method fromMediationInfoToDTO.
/**
* Converts an Mediation object into MediationInfoDTO
*
* @param mediation Mediation object
* @return MediationInfoDTO object corresponding to the given Mediation object
*/
public static MediationInfoDTO fromMediationInfoToDTO(Mediation mediation) {
MediationInfoDTO mediationInfoDTO = new MediationInfoDTO();
mediationInfoDTO.setId(mediation.getUuid());
mediationInfoDTO.setName(mediation.getName());
mediationInfoDTO.setType(MediationInfoDTO.TypeEnum.valueOf(mediation.getType().toUpperCase()));
return mediationInfoDTO;
}
use of org.wso2.carbon.apimgt.persistence.dto.Mediation in project carbon-apimgt by wso2.
the class MediationMappingUtil method fromMediationToDTO.
public static MediationDTO fromMediationToDTO(Mediation mediation) {
MediationDTO mediationDTO = new MediationDTO();
mediationDTO.setId(mediation.getUuid());
mediationDTO.setName(mediation.getName());
mediationDTO.setType(MediationDTO.TypeEnum.valueOf(mediation.getType().toUpperCase()));
mediationDTO.setConfig(mediation.getConfig());
return mediationDTO;
}
use of org.wso2.carbon.apimgt.persistence.dto.Mediation in project carbon-apimgt by wso2.
the class ExportUtils method writeSOAPToRESTSequencesToArchive.
/**
* Retrieve SOAP to REST mediation logic for the exporting API for a particular type (in/out) and store it
* in the archive directory.
*
* @param api API
* @param sequencePathInArchive Path to the SOAP to REST sequences in the archive
* @param type Seqeunce type
* @throws APIManagementException If an error occurs while reading/writing SOAP to REST sequences
* @throws APIImportExportException If an error occurs while creating the directory
*/
private static void writeSOAPToRESTSequencesToArchive(API api, String sequencePathInArchive, String type) throws APIManagementException, APIImportExportException {
String resourcePolicy = SequenceUtils.getRestToSoapConvertedSequence(api, type);
ResourcePolicyListDTO resourcePolicyInListDTO = APIMappingUtil.fromResourcePolicyStrToDTO(resourcePolicy);
String individualSequencePathInArchive = sequencePathInArchive + File.separator + type;
CommonUtil.createDirectory(individualSequencePathInArchive);
for (ResourcePolicyInfoDTO resourcePolicyInfoDTO : resourcePolicyInListDTO.getList()) {
String sequenceContent = resourcePolicyInfoDTO.getContent();
String sequenceName = resourcePolicyInfoDTO.getResourcePath() + "_" + resourcePolicyInfoDTO.getHttpVerb();
writeSequenceToArchive(sequenceContent, individualSequencePathInArchive, sequenceName);
}
}
use of org.wso2.carbon.apimgt.persistence.dto.Mediation in project carbon-apimgt by wso2.
the class MediationMappingUtil method fromMediationListToDTO.
/**
* Converts a List mediation objects into a DTO
*
* @param mediation a list of mediation objects
* @param limit max number of objects returned
* @param offset starting index
* @return MediationListDTO object containing MediationInfoDTO
*/
public static MediationListDTO fromMediationListToDTO(List<Mediation> mediation, int offset, int limit) {
MediationListDTO mediationListDTO = new MediationListDTO();
List<MediationInfoDTO> mediationDTOs = mediationListDTO.getList();
if (mediationDTOs == null) {
mediationDTOs = new ArrayList<>();
mediationListDTO.setList(mediationDTOs);
}
// identifying the proper start and end indexes
int size = mediation.size();
int start = offset < size && offset >= 0 ? offset : Integer.MAX_VALUE;
int end = offset + limit - 1 <= size - 1 ? offset + limit - 1 : size - 1;
for (int i = start; i <= end; i++) {
mediationDTOs.add(fromMediationInfoToDTO(mediation.get(i)));
}
mediationListDTO.setCount(mediationDTOs.size());
return mediationListDTO;
}
use of org.wso2.carbon.apimgt.persistence.dto.Mediation in project carbon-apimgt by wso2.
the class MediationMappingUtil method fromMediationToDTO.
/**
* Converts an Mediation object into MediationDTO
*
* @param mediation Mediation object
* @return MediationDTO object correspond to the given Mediation object
*/
public static MediationDTO fromMediationToDTO(Mediation mediation) {
MediationDTO mediationDTO = new MediationDTO();
mediationDTO.setId(mediation.getUuid());
mediationDTO.setName(mediation.getName());
mediationDTO.setType(MediationDTO.TypeEnum.valueOf(mediation.getType().toUpperCase()));
return mediationDTO;
}
Aggregations