use of org.wso2.carbon.bpel.ui.bpel2svg.Link in project carbon-apimgt by wso2.
the class WSDL11ProcessorImpl method getHttpBindingOperations.
/**
* Retrieves all the operations defined in the provided WSDL definition.
*
* @param definition WSDL Definition
* @return a set of {@link WSDLOperation} defined in the provided WSDL definition
*/
private Set<WSDLOperation> getHttpBindingOperations(Definition definition) {
Set<WSDLOperation> allOperations = new HashSet<>();
for (Object bindingObj : definition.getAllBindings().values()) {
if (bindingObj instanceof Binding) {
Binding binding = (Binding) bindingObj;
Set<WSDLOperation> operations = getHttpBindingOperations(binding);
allOperations.addAll(operations);
}
}
return allOperations;
}
use of org.wso2.carbon.bpel.ui.bpel2svg.Link in project carbon-apimgt by wso2.
the class WSDL11ProcessorImpl method getParameters.
/**
* Returns parameters, given http binding operation, verb and content type
*
* @param bindingOperation {@link BindingOperation} object
* @param verb HTTP verb
* @param contentType Content type
* @return parameters, given http binding operation, verb and content type
*/
private List<WSDLOperationParam> getParameters(BindingOperation bindingOperation, String verb, String contentType) {
List<WSDLOperationParam> params = new ArrayList<>();
Operation operation = bindingOperation.getOperation();
// or content type is not provided
if (APIMWSDLUtils.canContainBody(verb) && !APIMWSDLUtils.hasFormDataParams(contentType)) {
WSDLOperationParam param = new WSDLOperationParam();
param.setName("Payload");
param.setParamType(WSDLOperationParam.ParamTypeEnum.BODY);
params.add(param);
if (log.isDebugEnabled()) {
log.debug("Adding default Param for operation:" + operation.getName() + ", contentType: " + contentType);
}
return params;
}
if (operation != null) {
Input input = operation.getInput();
if (input != null) {
Message message = input.getMessage();
if (message != null) {
Map map = message.getParts();
map.forEach((name, partObj) -> {
WSDLOperationParam param = new WSDLOperationParam();
param.setName(name.toString());
if (log.isDebugEnabled()) {
log.debug("Identified param for operation: " + operation.getName() + " param: " + name);
}
if (APIMWSDLUtils.canContainBody(verb)) {
if (log.isDebugEnabled()) {
log.debug("Operation " + operation.getName() + " can contain a body.");
}
// In POST, PUT operations, parameters always in body according to HTTP Binding spec
if (APIMWSDLUtils.hasFormDataParams(contentType)) {
param.setParamType(WSDLOperationParam.ParamTypeEnum.FORM_DATA);
if (log.isDebugEnabled()) {
log.debug("Param " + name + " type was set to formData.");
}
}
// no else block since if content type is not form-data related, there can be only one
// parameter which is payload body. This is handled in the first if block which is
// if (canContainBody(verb) && !hasFormDataParams(contentType)) { .. }
} else {
// In GET operations, parameters always query or path as per HTTP Binding spec
if (isUrlReplacement(bindingOperation)) {
param.setParamType(WSDLOperationParam.ParamTypeEnum.PATH);
if (log.isDebugEnabled()) {
log.debug("Param " + name + " type was set to Path.");
}
} else {
param.setParamType(WSDLOperationParam.ParamTypeEnum.QUERY);
if (log.isDebugEnabled()) {
log.debug("Param " + name + " type was set to Query.");
}
}
}
Part part = (Part) partObj;
param.setDataType(part.getTypeName().getLocalPart());
if (log.isDebugEnabled()) {
log.debug("Param " + name + " data type was set to " + param.getDataType());
}
params.add(param);
});
}
}
}
return params;
}
use of org.wso2.carbon.bpel.ui.bpel2svg.Link in project carbon-apimgt by wso2.
the class APIFileUtils method extractUploadedArchive.
/**
* Extracts the APIs to the file system by reading the incoming {@link InputStream} object
* uploadedApiArchiveInputStream
*
* @param uploadedApiArchiveInputStream Incoming {@link InputStream}
* @param importedDirectoryName directory to extract the archive
* @param apiArchiveLocation full path of the archive location
* @param extractLocation full path to the location to which the archive will be written
* @return location to which APIs were extracted
* @throws APIMgtDAOException if an error occurs while extracting the archive
*/
public static String extractUploadedArchive(InputStream uploadedApiArchiveInputStream, String importedDirectoryName, String apiArchiveLocation, String extractLocation) throws APIMgtDAOException {
String archiveExtractLocation;
try {
// create api import directory structure
APIFileUtils.createDirectory(extractLocation);
// create archive
createArchiveFromInputStream(uploadedApiArchiveInputStream, apiArchiveLocation);
// extract the archive
archiveExtractLocation = extractLocation + File.separator + importedDirectoryName;
extractArchive(apiArchiveLocation, archiveExtractLocation);
} catch (APIMgtDAOException e) {
APIFileUtils.deleteDirectory(extractLocation);
String errorMsg = "Error in accessing uploaded API archive";
log.error(errorMsg, e);
throw new APIMgtDAOException(errorMsg, e);
}
return archiveExtractLocation;
}
use of org.wso2.carbon.bpel.ui.bpel2svg.Link in project carbon-apimgt by wso2.
the class ETagUtils method getHash.
/**
* If some other hashing algorithm is needed use this method.
*
* @param updatedTime, the updated/created time of the resource in UNIX time
* @param algorithm the algorithm used for hashing
* @return String
* @throws NoSuchAlgorithmException if the given algorithm is invalid or not found in {@link MessageDigest}
* @throws ETagGenerationException if hash generation failed.
*/
private static String getHash(String updatedTime, String algorithm) throws ETagGenerationException, NoSuchAlgorithmException {
MessageDigest messageDigest = MessageDigest.getInstance(algorithm);
try {
messageDigest.update(updatedTime.getBytes("UTF-8"));
byte[] digest = messageDigest.digest();
// conversion to hexadecimal
StringBuilder sb = new StringBuilder();
for (byte b : digest) {
sb.append(String.format("%02x", b & 0xff));
}
String generatedHash = sb.toString();
if (log.isDebugEnabled()) {
log.debug("ETag generated in HEX '" + generatedHash + "' for '" + updatedTime + "'");
}
return sb.toString();
} catch (UnsupportedEncodingException e) {
String errorMessage = "Error while converting timestamp to String :" + updatedTime;
log.error(errorMessage, e);
throw new ETagGenerationException(errorMessage, e);
}
}
use of org.wso2.carbon.bpel.ui.bpel2svg.Link in project carbon-apimgt by wso2.
the class MappingUtil method toAPIInfo.
/**
* Converts {@link API} List to an {@link APIInfoDTO} List.
*
* @param apiSummaryList
* @return
*/
private static List<APIInfoDTO> toAPIInfo(List<API> apiSummaryList) {
List<APIInfoDTO> apiInfoList = new ArrayList<APIInfoDTO>();
for (API apiSummary : apiSummaryList) {
APIInfoDTO apiInfo = new APIInfoDTO();
apiInfo.setId(apiSummary.getId());
apiInfo.setContext(apiSummary.getContext());
apiInfo.setDescription(apiSummary.getDescription());
apiInfo.setName(apiSummary.getName());
apiInfo.setProvider(apiSummary.getProvider());
apiInfo.setLifeCycleStatus(apiSummary.getLifeCycleStatus());
apiInfo.setVersion(apiSummary.getVersion());
apiInfo.setWorkflowStatus(apiSummary.getWorkflowStatus());
apiInfo.setSecurityScheme(mapSecuritySchemeIntToList(apiSummary.getSecurityScheme()));
apiInfoList.add(apiInfo);
}
return apiInfoList;
}
Aggregations