Search in sources :

Example 31 with Artifacts

use of org.wso2.ei.dashboard.core.rest.model.Artifacts in project product-mi-tooling by wso2.

the class GroupsApi method getMessageStoresByNodeIds.

@GET
@Path("/{group-id}/message-stores")
@Produces({ "application/json" })
@Operation(summary = "Get message stores by node ids", description = "", tags = { "messageStores" })
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "List of message stores deployed in provided nodes", content = @Content(schema = @Schema(implementation = Artifacts.class))), @ApiResponse(responseCode = "200", description = "Unexpected error", content = @Content(schema = @Schema(implementation = Error.class))) })
public Response getMessageStoresByNodeIds(@PathParam("group-id") @Parameter(description = "Group ID of the node") String groupId, @NotNull @QueryParam("nodes") @Parameter(description = "ID/IDs of the nodes") List<String> nodes) {
    MessageStoresDelegate messageStoresDelegate = new MessageStoresDelegate();
    Artifacts messageStoresList = messageStoresDelegate.getArtifactsList(groupId, nodes);
    Response.ResponseBuilder responseBuilder = Response.ok().entity(messageStoresList);
    HttpUtils.setHeaders(responseBuilder);
    return responseBuilder.build();
}
Also used : Response(javax.ws.rs.core.Response) ApiResponse(io.swagger.v3.oas.annotations.responses.ApiResponse) CAppArtifacts(org.wso2.ei.dashboard.core.rest.model.CAppArtifacts) Artifacts(org.wso2.ei.dashboard.core.rest.model.Artifacts) MessageStoresDelegate(org.wso2.ei.dashboard.micro.integrator.delegates.MessageStoresDelegate) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 32 with Artifacts

use of org.wso2.ei.dashboard.core.rest.model.Artifacts in project product-mi-tooling by wso2.

the class GroupsApi method getEndpointsByNodeIds.

@GET
@Path("/{group-id}/endpoints")
@Produces({ "application/json" })
@Operation(summary = "Get endpoints by node ids", description = "", tags = { "endpoints" })
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "List of endpoints deployed in provided nodes", content = @Content(schema = @Schema(implementation = Artifacts.class))), @ApiResponse(responseCode = "200", description = "Unexpected error", content = @Content(schema = @Schema(implementation = Error.class))) })
public Response getEndpointsByNodeIds(@PathParam("group-id") @Parameter(description = "Group ID of the node") String groupId, @NotNull @QueryParam("nodes") @Parameter(description = "ID/IDs of the nodes") List<String> nodes) {
    EndpointsDelegate endpointsDelegate = new EndpointsDelegate();
    Artifacts endpointList = endpointsDelegate.getArtifactsList(groupId, nodes);
    Response.ResponseBuilder responseBuilder = Response.ok().entity(endpointList);
    HttpUtils.setHeaders(responseBuilder);
    return responseBuilder.build();
}
Also used : Response(javax.ws.rs.core.Response) ApiResponse(io.swagger.v3.oas.annotations.responses.ApiResponse) CAppArtifacts(org.wso2.ei.dashboard.core.rest.model.CAppArtifacts) Artifacts(org.wso2.ei.dashboard.core.rest.model.Artifacts) EndpointsDelegate(org.wso2.ei.dashboard.micro.integrator.delegates.EndpointsDelegate) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 33 with Artifacts

use of org.wso2.ei.dashboard.core.rest.model.Artifacts in project product-mi-tooling by wso2.

the class GroupsApi method getMessageProcessorsByNodeIds.

@GET
@Path("/{group-id}/message-processors")
@Produces({ "application/json" })
@Operation(summary = "Get message processors by node ids", description = "", tags = { "messageProcessors" })
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "List of message processorss deployed in provided nodes", content = @Content(schema = @Schema(implementation = Artifacts.class))), @ApiResponse(responseCode = "200", description = "Unexpected error", content = @Content(schema = @Schema(implementation = Error.class))) })
public Response getMessageProcessorsByNodeIds(@PathParam("group-id") @Parameter(description = "Group ID of the node") String groupId, @NotNull @QueryParam("nodes") @Parameter(description = "ID/IDs of the nodes") List<String> nodes) {
    MessageProcessorsDelegate messageProcessorsDelegate = new MessageProcessorsDelegate();
    Artifacts messageProcessorList = messageProcessorsDelegate.getArtifactsList(groupId, nodes);
    Response.ResponseBuilder responseBuilder = Response.ok().entity(messageProcessorList);
    HttpUtils.setHeaders(responseBuilder);
    return responseBuilder.build();
}
Also used : Response(javax.ws.rs.core.Response) ApiResponse(io.swagger.v3.oas.annotations.responses.ApiResponse) CAppArtifacts(org.wso2.ei.dashboard.core.rest.model.CAppArtifacts) Artifacts(org.wso2.ei.dashboard.core.rest.model.Artifacts) MessageProcessorsDelegate(org.wso2.ei.dashboard.micro.integrator.delegates.MessageProcessorsDelegate) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 34 with Artifacts

use of org.wso2.ei.dashboard.core.rest.model.Artifacts in project product-mi-tooling by wso2.

the class GroupsApi method getConnectorsByNodeIds.

@GET
@Path("/{group-id}/connectors")
@Produces({ "application/json" })
@Operation(summary = "Get connectors by node ids", description = "", tags = { "connectors" })
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "List of connectors deployed in provided nodes", content = @Content(schema = @Schema(implementation = Artifacts.class))), @ApiResponse(responseCode = "200", description = "Unexpected error", content = @Content(schema = @Schema(implementation = Error.class))) })
public Response getConnectorsByNodeIds(@PathParam("group-id") @Parameter(description = "Group ID of the node") String groupId, @NotNull @QueryParam("nodes") @Parameter(description = "ID/IDs of the nodes") List<String> nodes) {
    ConnectorsDelegate connectorsDelegate = new ConnectorsDelegate();
    Artifacts connectorList = connectorsDelegate.getArtifactsList(groupId, nodes);
    Response.ResponseBuilder responseBuilder = Response.ok().entity(connectorList);
    HttpUtils.setHeaders(responseBuilder);
    return responseBuilder.build();
}
Also used : Response(javax.ws.rs.core.Response) ApiResponse(io.swagger.v3.oas.annotations.responses.ApiResponse) CAppArtifacts(org.wso2.ei.dashboard.core.rest.model.CAppArtifacts) Artifacts(org.wso2.ei.dashboard.core.rest.model.Artifacts) ConnectorsDelegate(org.wso2.ei.dashboard.micro.integrator.delegates.ConnectorsDelegate) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 35 with Artifacts

use of org.wso2.ei.dashboard.core.rest.model.Artifacts in project carbon-mediation by wso2.

the class SynapseAppDeployer method undeployArtifactType.

/**
 * Un deploy a given artifact type
 * @param carbonApplication
 * @param axisConfig
 * @param artifacts
 */
private void undeployArtifactType(CarbonApplication carbonApplication, AxisConfiguration axisConfig, List<Artifact.Dependency> artifacts) {
    for (Artifact.Dependency dep : artifacts) {
        Artifact artifact = dep.getArtifact();
        if (!validateArtifact(artifact)) {
            continue;
        }
        Deployer deployer;
        String artifactDir = null;
        if (SynapseAppDeployerConstants.MEDIATOR_TYPE.endsWith(artifact.getType())) {
            deployer = getClassMediatorDeployer(axisConfig);
        } else if (SynapseAppDeployerConstants.SYNAPSE_LIBRARY_TYPE.equals(artifact.getType())) {
            deployer = getSynapseLibraryDeployer(axisConfig);
        } else {
            String artifactDirName = getArtifactDirName(artifact);
            if (artifactDirName == null) {
                continue;
            }
            deployer = getDeployer(axisConfig, artifactDirName);
            artifactDir = getArtifactDirPath(axisConfig, artifactDirName);
        }
        if (deployer != null && AppDeployerConstants.DEPLOYMENT_STATUS_DEPLOYED.equals(artifact.getDeploymentStatus())) {
            String fileName = artifact.getFiles().get(0).getName();
            String artifactName = artifact.getName();
            String artifactPath = artifact.getExtractedPath() + File.separator + fileName;
            File artifactInRepo = new File(artifactDir + File.separator + fileName);
            try {
                // version in its name in the synapse config (ex: MyAPI:v1 instead of MyAPI)
                if (SynapseAppDeployerConstants.API_TYPE.equals(artifact.getType())) {
                    Properties properties = new Properties();
                    SynapseArtifactDeploymentStore deploymentStore = getSynapseConfiguration(axisConfig).getArtifactDeploymentStore();
                    if (deploymentStore != null) {
                        properties.put(SynapseConstants.CLASS_MEDIATOR_LOADERS, deploymentStore.getClassMediatorClassLoaders());
                    }
                    artifactName = extractApiNameFromArtifact(artifact, fileName, properties);
                }
                if (SynapseAppDeployerConstants.MEDIATOR_TYPE.endsWith(artifact.getType())) {
                    if (deployer instanceof AbstractSynapseArtifactDeployer) {
                        ((AbstractSynapseArtifactDeployer) deployer).setCustomLog(carbonApplication.getAppName(), AppDeployerUtils.getTenantIdLogString(AppDeployerUtils.getTenantId()));
                    }
                    deployer.undeploy(artifactPath);
                } else if (SynapseAppDeployerConstants.SYNAPSE_LIBRARY_TYPE.equals(artifact.getType())) {
                    String libQName = getArtifactName(artifactPath, axisConfig);
                    deleteImport(libQName, axisConfig);
                    deployer.undeploy(artifactPath);
                } else if (SynapseAppDeployerConstants.SEQUENCE_TYPE.equals(artifact.getType()) && handleMainFaultSeqUndeployment(artifact, axisConfig)) {
                } else if (artifactInRepo.exists()) {
                    log.info("Deleting artifact at " + artifactInRepo.getAbsolutePath());
                    if (!artifactInRepo.delete()) {
                        log.error("Unable to delete " + artifactInRepo.getAbsolutePath());
                    }
                } else {
                    // use reflection to avoid having synapse as a dependency
                    Class[] paramString = new Class[1];
                    paramString[0] = String.class;
                    Method method = deployer.getClass().getDeclaredMethod("undeploySynapseArtifact", paramString);
                    method.invoke(deployer, artifactName);
                }
                artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_PENDING);
                File artifactFile = new File(artifactPath);
                if (artifactFile.exists() && !artifactFile.delete()) {
                    log.warn("Couldn't delete App artifact file : " + artifactPath);
                }
            } catch (Exception e) {
                artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_FAILED);
                log.error("Error occured while trying to un deploy : " + artifactName);
            }
        }
    }
}
Also used : SynapseArtifactDeploymentStore(org.apache.synapse.deployers.SynapseArtifactDeploymentStore) Method(java.lang.reflect.Method) Properties(java.util.Properties) CappFile(org.wso2.carbon.application.deployer.config.CappFile) File(java.io.File) AbstractSynapseArtifactDeployer(org.apache.synapse.deployers.AbstractSynapseArtifactDeployer) Artifact(org.wso2.carbon.application.deployer.config.Artifact) Deployer(org.apache.axis2.deployment.Deployer) AbstractSynapseArtifactDeployer(org.apache.synapse.deployers.AbstractSynapseArtifactDeployer) LibraryArtifactDeployer(org.apache.synapse.deployers.LibraryArtifactDeployer) XMLStreamException(javax.xml.stream.XMLStreamException) DeploymentException(org.apache.axis2.deployment.DeploymentException) SynapseException(org.apache.synapse.SynapseException) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) OMException(org.apache.axiom.om.OMException)

Aggregations

File (java.io.File)23 IOException (java.io.IOException)18 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)18 ArrayList (java.util.ArrayList)17 CAppArtifacts (org.wso2.ei.dashboard.core.rest.model.CAppArtifacts)16 Operation (io.swagger.v3.oas.annotations.Operation)15 ApiResponse (io.swagger.v3.oas.annotations.responses.ApiResponse)15 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)15 Response (javax.ws.rs.core.Response)15 Artifact (org.wso2.carbon.application.deployer.config.Artifact)15 Artifacts (org.wso2.ei.dashboard.core.rest.model.Artifacts)15 DeploymentException (org.apache.axis2.deployment.DeploymentException)11 CappFile (org.wso2.carbon.application.deployer.config.CappFile)11 Deployer (org.apache.axis2.deployment.Deployer)10 ArtifactSynchronizerException (org.wso2.carbon.apimgt.impl.gatewayartifactsynchronizer.exception.ArtifactSynchronizerException)10 Organization (org.wso2.carbon.apimgt.persistence.dto.Organization)10 InputStream (java.io.InputStream)9 FileInputStream (java.io.FileInputStream)7 APIRuntimeArtifactDto (org.wso2.carbon.apimgt.impl.dto.APIRuntimeArtifactDto)7 APIPersistenceException (org.wso2.carbon.apimgt.persistence.exceptions.APIPersistenceException)7