use of org.wso2.carbon.apimgt.api.model.ResourcePath in project carbon-business-process by wso2.
the class DeploymentService method getDeploymentResourceForDifferentUrl.
@GET
@Path("/{deploymentId}/resources/{resourcePath:.*}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getDeploymentResourceForDifferentUrl(@PathParam("deploymentId") String deploymentId, @PathParam("resourcePath") String resourcePath) {
if (log.isDebugEnabled()) {
log.debug("deploymentId:" + deploymentId + " resourcePath:" + resourcePath);
}
RepositoryService repositoryService = BPMNOSGIService.getRepositoryService();
// Check if deployment exists
Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
if (deployment == null) {
throw new ActivitiObjectNotFoundException("Could not find a deployment with id '" + deploymentId + "'.", Deployment.class);
}
List<String> resourceList = repositoryService.getDeploymentResourceNames(deploymentId);
if (resourceList.contains(resourcePath)) {
// Build resource representation
DeploymentResourceResponse deploymentResourceResponse = new RestResponseFactory().createDeploymentResourceResponse(deploymentId, resourcePath, Utils.resolveContentType(resourcePath), uriInfo.getBaseUri().toString());
return Response.ok().entity(deploymentResourceResponse).build();
} else {
// Resource not found in deployment
throw new ActivitiObjectNotFoundException("Could not find a resource with id '" + resourcePath + "' in deployment '" + deploymentId + "'.", Deployment.class);
}
}
use of org.wso2.carbon.apimgt.api.model.ResourcePath in project identity-test-integration by wso2-incubator.
the class SampleContextEventListener method contextInitialized.
public void contextInitialized(ServletContextEvent servletContextEvent) {
properties = new Properties();
try {
if (servletContextEvent.getServletContext().getContextPath().contains("travelocity.com")) {
properties.load(servletContextEvent.getServletContext().getResourceAsStream("/WEB-INF/classes/travelocity.properties"));
} else if (servletContextEvent.getServletContext().getContextPath().contains("avis.com")) {
properties.load(servletContextEvent.getServletContext().getResourceAsStream("/WEB-INF/classes/avis.properties"));
} else {
String resourcePath = "/WEB-INF/classes" + servletContextEvent.getServletContext().getContextPath() + ".properties";
InputStream resourceStream = servletContextEvent.getServletContext().getResourceAsStream(resourcePath);
if (resourceStream != null) {
properties.load(servletContextEvent.getServletContext().getResourceAsStream(resourcePath));
}
}
InputStream keyStoreInputStream = servletContextEvent.getServletContext().getResourceAsStream("/WEB-INF/classes/wso2carbon.jks");
SSOAgentX509Credential credential = new SSOAgentX509KeyStoreCredential(keyStoreInputStream, properties.getProperty("KeyStorePassword").toCharArray(), properties.getProperty("IdPPublicCertAlias"), properties.getProperty("PrivateKeyAlias"), properties.getProperty("PrivateKeyPassword").toCharArray());
SSOAgentConfig config = new SSOAgentConfig();
config.initConfig(properties);
config.getSAML2().setSSOAgentX509Credential(credential);
config.getOpenId().setAttributesRequestor(new SampleAttributesRequestor());
servletContextEvent.getServletContext().setAttribute(SSOAgentConstants.CONFIG_BEAN_NAME, config);
} catch (IOException e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
} catch (SSOAgentException e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
}
}
use of org.wso2.carbon.apimgt.api.model.ResourcePath in project carbon-apimgt by wso2.
the class AbstractAPIManager method getApiSpecificMediationResourceFromUuid.
/**
* Returns Registry resource matching given mediation policy identifier
*
* @param identifier API identifier
* @param uuid mediation policy identifier
* @param resourcePath registry path to the API resource
* @return Registry resource matches given identifier or null
* @throws APIManagementException If fails to get the resource matching given identifier
*/
@Override
public Resource getApiSpecificMediationResourceFromUuid(Identifier identifier, String uuid, String resourcePath) throws APIManagementException {
try {
Resource resource = registry.get(resourcePath);
if (resource instanceof Collection) {
Collection typeCollection = (Collection) resource;
String[] typeArray = typeCollection.getChildren();
for (String type : typeArray) {
// Check for mediation policy resource
if ((type.equalsIgnoreCase(resourcePath + RegistryConstants.PATH_SEPARATOR + APIConstants.API_CUSTOM_SEQUENCE_TYPE_IN)) || (type.equalsIgnoreCase(resourcePath + RegistryConstants.PATH_SEPARATOR + APIConstants.API_CUSTOM_SEQUENCE_TYPE_OUT)) || (type.equalsIgnoreCase(resourcePath + RegistryConstants.PATH_SEPARATOR + APIConstants.API_CUSTOM_SEQUENCE_TYPE_FAULT))) {
Resource sequenceType = registry.get(type);
// sequenceType eg: in / out /fault
if (sequenceType instanceof Collection) {
String[] mediationPolicyArr = ((Collection) sequenceType).getChildren();
for (String mediationPolicy : mediationPolicyArr) {
Resource mediationResource = registry.get(mediationPolicy);
String resourceId = mediationResource.getUUID();
if (resourceId.equalsIgnoreCase(uuid)) {
return mediationResource;
}
}
}
}
}
}
} catch (RegistryException e) {
String msg = "Error while obtaining registry objects";
throw new APIManagementException(msg, e);
}
return null;
}
use of org.wso2.carbon.apimgt.api.model.ResourcePath in project carbon-apimgt by wso2.
the class AbstractAPIManager method getWsdlResourceFromUuid.
/**
* Returns the wsdl registry resource correspond to the given identifier
*
* @param wsdlId uuid of the wsdl resource
* @return Registry resource of given identifier or null
* @throws APIManagementException If failed to get the registry resource of given uuid
*/
@Override
public Resource getWsdlResourceFromUuid(String wsdlId) throws APIManagementException {
String resourcePath = APIConstants.API_WSDL_RESOURCE;
try {
if (registry.resourceExists(resourcePath)) {
Resource resource = registry.get(resourcePath);
if (resource instanceof Collection) {
Collection wsdlCollection = (Collection) resource;
String[] wsdlArray = wsdlCollection.getChildren();
for (String wsdl : wsdlArray) {
Resource wsdlResource = registry.get(wsdl);
String resourceId = wsdlResource.getUUID();
if (resourceId.equals(wsdlId)) {
return wsdlResource;
}
}
}
}
} catch (RegistryException e) {
String msg = "Error while accessing registry objects";
throw new APIManagementException(msg, e);
}
return null;
}
use of org.wso2.carbon.apimgt.api.model.ResourcePath in project carbon-apimgt by wso2.
the class AbstractAPIManager method addResourceFile.
public String addResourceFile(Identifier identifier, String resourcePath, ResourceFile resourceFile) throws APIManagementException {
try {
Resource thumb = registry.newResource();
thumb.setContentStream(resourceFile.getContent());
thumb.setMediaType(resourceFile.getContentType());
registry.put(resourcePath, thumb);
if (MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equalsIgnoreCase(tenantDomain)) {
return RegistryConstants.PATH_SEPARATOR + "registry" + RegistryConstants.PATH_SEPARATOR + "resource" + RegistryConstants.PATH_SEPARATOR + "_system" + RegistryConstants.PATH_SEPARATOR + "governance" + resourcePath;
} else {
return "/t/" + tenantDomain + RegistryConstants.PATH_SEPARATOR + "registry" + RegistryConstants.PATH_SEPARATOR + "resource" + RegistryConstants.PATH_SEPARATOR + "_system" + RegistryConstants.PATH_SEPARATOR + "governance" + resourcePath;
}
} catch (RegistryException e) {
String msg = "Error while adding the resource to the registry";
throw new APIManagementException(msg, e);
}
}
Aggregations