Search in sources :

Example 81 with Artifacts

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

the class GroupsApi method getSequencesByNodeIds.

@GET
@Path("/{group-id}/sequences")
@Produces({ "application/json" })
@Operation(summary = "Get sequences by node ids", description = "", tags = { "sequences" })
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "List of sequences 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 getSequencesByNodeIds(@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) {
    SequencesDelegate sequencesDelegate = new SequencesDelegate();
    Artifacts sequenceList = sequencesDelegate.getArtifactsList(groupId, nodes);
    Response.ResponseBuilder responseBuilder = Response.ok().entity(sequenceList);
    HttpUtils.setHeaders(responseBuilder);
    return responseBuilder.build();
}
Also used : Response(javax.ws.rs.core.Response) ApiResponse(io.swagger.v3.oas.annotations.responses.ApiResponse) SequencesDelegate(org.wso2.ei.dashboard.micro.integrator.delegates.SequencesDelegate) CAppArtifacts(org.wso2.ei.dashboard.core.rest.model.CAppArtifacts) Artifacts(org.wso2.ei.dashboard.core.rest.model.Artifacts) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 82 with Artifacts

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

the class GroupsApi method getTemplatesByNodeIds.

@GET
@Path("/{group-id}/templates")
@Produces({ "application/json" })
@Operation(summary = "Get templates by node ids", description = "", tags = { "templates" })
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "List of templates 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 getTemplatesByNodeIds(@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) {
    TemplatesDelegate templatesDelegate = new TemplatesDelegate();
    Artifacts templateList = templatesDelegate.getArtifactsList(groupId, nodes);
    Response.ResponseBuilder responseBuilder = Response.ok().entity(templateList);
    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) TemplatesDelegate(org.wso2.ei.dashboard.micro.integrator.delegates.TemplatesDelegate) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 83 with Artifacts

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

the class CarbonAppsDelegate method getCAppArtifactList.

public CAppArtifacts getCAppArtifactList(String groupId, String nodeId, String cAppName) throws ManagementApiException {
    log.debug("Fetching artifacts in carbon applications from management console");
    String mgtApiUrl = ManagementApiUtils.getMgtApiUrl(groupId, nodeId);
    String url = mgtApiUrl.concat("applications").concat("?").concat("carbonAppName").concat("=").concat(cAppName);
    String accessToken = databaseManager.getAccessToken(groupId, nodeId);
    CloseableHttpResponse httpResponse = Utils.doGet(groupId, nodeId, accessToken, url);
    JsonObject jsonResponse = HttpUtils.getJsonResponse(httpResponse);
    JsonArray artifacts = jsonResponse.getAsJsonArray("artifacts");
    CAppArtifacts cAppArtifacts = new CAppArtifacts();
    for (JsonElement artifact : artifacts) {
        JsonObject jsonObject = artifact.getAsJsonObject();
        CAppArtifactsInner cAppArtifact = new CAppArtifactsInner();
        cAppArtifact.setName(jsonObject.get("name").getAsString());
        cAppArtifact.setType(jsonObject.get("type").getAsString());
        cAppArtifacts.add(cAppArtifact);
    }
    return cAppArtifacts;
}
Also used : JsonArray(com.google.gson.JsonArray) CAppArtifactsInner(org.wso2.ei.dashboard.core.rest.model.CAppArtifactsInner) CAppArtifacts(org.wso2.ei.dashboard.core.rest.model.CAppArtifacts) JsonElement(com.google.gson.JsonElement) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) JsonObject(com.google.gson.JsonObject)

Example 84 with Artifacts

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

the class GroupsApi method getInboundEpsByNodeIds.

@GET
@Path("/{group-id}/inbound-endpoints")
@Produces({ "application/json" })
@Operation(summary = "Get inbound endpoints by node ids", description = "", tags = { "inboundEndpoints" })
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "List of inbound 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 getInboundEpsByNodeIds(@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) {
    InboundEndpointDelegate inboundEndpointDelegate = new InboundEndpointDelegate();
    Artifacts inboundEndpointList = inboundEndpointDelegate.getArtifactsList(groupId, nodes);
    Response.ResponseBuilder responseBuilder = Response.ok().entity(inboundEndpointList);
    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) InboundEndpointDelegate(org.wso2.ei.dashboard.micro.integrator.delegates.InboundEndpointDelegate) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 85 with Artifacts

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

the class JDBCDatabaseManager method fetchArtifacts.

@Override
public Artifacts fetchArtifacts(String artifactType, String groupId, List<String> nodeList) {
    Artifacts artifacts = new Artifacts();
    String nodeSearch = "";
    String nodeSearchTmp = nodeSearch;
    nodeList.forEach(node -> nodeSearchTmp.concat("NODE_ID=? OR "));
    nodeSearch = nodeSearchTmp;
    for (int i = 0; i < nodeList.size(); i++) {
        nodeSearch = nodeSearch.concat("NODE_ID=? OR ");
    }
    if (!nodeSearch.equals("")) {
        nodeSearch = nodeSearch.substring(0, nodeSearch.length() - 4);
    }
    String tableName = getTableName(artifactType);
    String getDistinctNamesQuery = "SELECT DISTINCT NAME FROM " + tableName + " WHERE GROUP_ID=? " + "AND (" + nodeSearch + ");";
    String getDetailsQuery = "SELECT NODE_ID, DETAILS FROM " + tableName + " WHERE NAME=? AND GROUP_ID=? AND " + "(" + nodeSearch + ");";
    try (Connection con = getConnection();
        PreparedStatement statement = con.prepareStatement(getDistinctNamesQuery)) {
        statement.setString(1, groupId);
        for (int i = 0, j = 2; i < nodeList.size(); i++, j++) {
            statement.setString(j, nodeList.get(i));
        }
        ResultSet resultSet = statement.executeQuery();
        while (resultSet.next()) {
            ArtifactsInner artifactsInner = new ArtifactsInner();
            String artifactName = resultSet.getString("NAME");
            artifactsInner.setName(artifactName);
            List<ArtifactDetails> artifactDetails = getArtifactDetails(getDetailsQuery, artifactName, groupId, nodeList);
            artifactsInner.setNodes(artifactDetails);
            artifacts.add(artifactsInner);
        }
        return artifacts;
    } catch (SQLException e) {
        throw new DashboardServerException("Error occurred fetching " + artifactType, e);
    }
}
Also used : Artifacts(org.wso2.ei.dashboard.core.rest.model.Artifacts) SQLException(java.sql.SQLException) ArtifactsInner(org.wso2.ei.dashboard.core.rest.model.ArtifactsInner) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) ArtifactDetails(org.wso2.ei.dashboard.core.rest.model.ArtifactDetails) PreparedStatement(java.sql.PreparedStatement) DashboardServerException(org.wso2.ei.dashboard.core.exception.DashboardServerException)

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