forked from community/device-mgt-core
Improve app manager APIs See merge request entgra/carbon-device-mgt!83feature/appm-store/pbac
commit
79d09ecbfd
@ -1,4 +1,4 @@
|
|||||||
package org.wso2.carbon.device.application.mgt.core.lifecycle;
|
package org.wso2.carbon.device.application.mgt.common;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
2
components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/lifecycle/config/LifecycleState.java → components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/config/LifecycleState.java
2
components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/lifecycle/config/LifecycleState.java → components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/config/LifecycleState.java
@ -1,4 +1,4 @@
|
|||||||
package org.wso2.carbon.device.application.mgt.core.lifecycle.config;
|
package org.wso2.carbon.device.application.mgt.common.config;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAttribute;
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
@ -0,0 +1,68 @@
|
|||||||
|
/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.wso2.carbon.device.application.mgt.common.dto;
|
||||||
|
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
|
||||||
|
public class DeviceSubscriptionDTO {
|
||||||
|
|
||||||
|
private int id;
|
||||||
|
private String subscribedBy;
|
||||||
|
private Timestamp subscribedTimestamp;
|
||||||
|
private boolean isUnsubscribed;
|
||||||
|
private String unsubscribedBy;
|
||||||
|
private Timestamp unsubscribedTimestapm;
|
||||||
|
private String subscribedFrom;
|
||||||
|
private int deviceId;
|
||||||
|
|
||||||
|
public int getId() { return id; }
|
||||||
|
|
||||||
|
public void setId(int id) { this.id = id; }
|
||||||
|
|
||||||
|
public String getSubscribedBy() { return subscribedBy; }
|
||||||
|
|
||||||
|
public void setSubscribedBy(String subscribedBy) { this.subscribedBy = subscribedBy; }
|
||||||
|
|
||||||
|
public Timestamp getSubscribedTimestamp() { return subscribedTimestamp; }
|
||||||
|
|
||||||
|
public void setSubscribedTimestamp(Timestamp subscribedTimestamp) {
|
||||||
|
this.subscribedTimestamp = subscribedTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isUnsubscribed() { return isUnsubscribed; }
|
||||||
|
|
||||||
|
public void setUnsubscribed(boolean unsubscribed) { isUnsubscribed = unsubscribed; }
|
||||||
|
|
||||||
|
public String getUnsubscribedBy() { return unsubscribedBy; }
|
||||||
|
|
||||||
|
public void setUnsubscribedBy(String unsubscribedBy) { this.unsubscribedBy = unsubscribedBy; }
|
||||||
|
|
||||||
|
public Timestamp getUnsubscribedTimestapm() { return unsubscribedTimestapm; }
|
||||||
|
|
||||||
|
public void setUnsubscribedTimestapm(Timestamp unsubscribedTimestapm) {
|
||||||
|
this.unsubscribedTimestapm = unsubscribedTimestapm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSubscribedFrom() { return subscribedFrom; }
|
||||||
|
|
||||||
|
public void setSubscribedFrom(String subscribedFrom) { this.subscribedFrom = subscribedFrom; }
|
||||||
|
|
||||||
|
public int getDeviceId() { return deviceId; }
|
||||||
|
|
||||||
|
public void setDeviceId(int deviceId) { this.deviceId = deviceId; }
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.device.application.mgt.core.exception;
|
||||||
|
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exception thrown during the ApplicationDTO Management DAO operations.
|
||||||
|
*/
|
||||||
|
public class SubscriptionManagementDAOException extends ApplicationManagementException {
|
||||||
|
|
||||||
|
public SubscriptionManagementDAOException(String message, Throwable throwable) {
|
||||||
|
super(message, throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SubscriptionManagementDAOException(String message) {
|
||||||
|
super(message, new Exception());
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,121 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.device.application.mgt.publisher.api.services.admin;
|
||||||
|
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
|
import io.swagger.annotations.ApiResponse;
|
||||||
|
import io.swagger.annotations.ApiResponses;
|
||||||
|
import io.swagger.annotations.Extension;
|
||||||
|
import io.swagger.annotations.ExtensionProperty;
|
||||||
|
import io.swagger.annotations.Info;
|
||||||
|
import io.swagger.annotations.SwaggerDefinition;
|
||||||
|
import io.swagger.annotations.Tag;
|
||||||
|
import org.wso2.carbon.apimgt.annotations.api.Scope;
|
||||||
|
import org.wso2.carbon.apimgt.annotations.api.Scopes;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.ApplicationList;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.ErrorResponse;
|
||||||
|
|
||||||
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.DELETE;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.PathParam;
|
||||||
|
import javax.ws.rs.Produces;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APIs to handle application management related tasks.
|
||||||
|
*/
|
||||||
|
@SwaggerDefinition(
|
||||||
|
info = @Info(
|
||||||
|
version = "1.0.0",
|
||||||
|
title = "ApplicationDTO Management Publisher Service",
|
||||||
|
extensions = {
|
||||||
|
@Extension(properties = {
|
||||||
|
@ExtensionProperty(name = "name", value = "ApplicationManagementPublisherAdminService"),
|
||||||
|
@ExtensionProperty(name = "context", value = "/api/application-mgt-publisher/v1.0/admin/applications"),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
),
|
||||||
|
tags = {
|
||||||
|
@Tag(name = "application_management, device_management", description = "App publisher related Admin APIs")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@Scopes(
|
||||||
|
scopes = {
|
||||||
|
@Scope(
|
||||||
|
name = "Delete Application Release",
|
||||||
|
description = "Delete Application Release",
|
||||||
|
key = "perm:admin:app:publisher:update",
|
||||||
|
permissions = {"/app-mgt/publisher/admin/application/update"}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@Path("/admin/applications")
|
||||||
|
@Api(value = "ApplicationDTO Management")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
public interface ApplicationManagementPublisherAdminAPI {
|
||||||
|
|
||||||
|
String SCOPE = "scope";
|
||||||
|
|
||||||
|
@DELETE
|
||||||
|
@Path("/release/{appId}/{uuid}")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@ApiOperation(
|
||||||
|
consumes = MediaType.APPLICATION_JSON,
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "DELETE",
|
||||||
|
value = "Delete application release.",
|
||||||
|
notes = "This will delete application release for given UUID",
|
||||||
|
tags = "Application Management",
|
||||||
|
extensions = {
|
||||||
|
@Extension(properties = {
|
||||||
|
@ExtensionProperty(name = SCOPE, value = "perm:admin:app:publisher:update")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ApiResponses(
|
||||||
|
value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 200,
|
||||||
|
message = "OK. \n Successfully delete application release.",
|
||||||
|
response = ApplicationList.class),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 404,
|
||||||
|
message = "Not Found. There doesn't have an application release for UUID" +
|
||||||
|
"query."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 500,
|
||||||
|
message = "Internal Server Error. \n Error occurred while deleting application release.",
|
||||||
|
response = ErrorResponse.class)
|
||||||
|
}) Response deleteApplicationRelease(
|
||||||
|
@ApiParam(
|
||||||
|
name = "appId",
|
||||||
|
value = "application Id",
|
||||||
|
required = true)
|
||||||
|
@PathParam("appId") int applicationId,
|
||||||
|
@ApiParam(
|
||||||
|
name = "uuid",
|
||||||
|
value = "application release UUID",
|
||||||
|
required = true)
|
||||||
|
@PathParam("uuid") String releaseUuid);
|
||||||
|
}
|
@ -0,0 +1,104 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.device.application.mgt.publisher.api.services.impl.admin;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
|
||||||
|
import org.apache.cxf.jaxrs.ext.multipart.Multipart;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.ApplicationArtifact;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.ApplicationList;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.ApplicationType;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.Filter;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.dto.LifecycleStateDTO;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationStorageManagementException;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.exception.RequestValidatingException;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.response.Application;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.response.ApplicationRelease;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.wrapper.ApplicationReleaseWrapper;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.wrapper.ApplicationUpdateWrapper;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.wrapper.ApplicationWrapper;
|
||||||
|
import org.wso2.carbon.device.application.mgt.core.exception.BadRequestException;
|
||||||
|
import org.wso2.carbon.device.application.mgt.core.exception.ForbiddenException;
|
||||||
|
import org.wso2.carbon.device.application.mgt.core.exception.NotFoundException;
|
||||||
|
import org.wso2.carbon.device.application.mgt.core.util.APIUtil;
|
||||||
|
import org.wso2.carbon.device.application.mgt.publisher.api.services.ApplicationManagementPublisherAPI;
|
||||||
|
import org.wso2.carbon.device.application.mgt.publisher.api.services.admin.ApplicationManagementPublisherAdminAPI;
|
||||||
|
|
||||||
|
import javax.activation.DataHandler;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.DELETE;
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.POST;
|
||||||
|
import javax.ws.rs.PUT;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.PathParam;
|
||||||
|
import javax.ws.rs.Produces;
|
||||||
|
import javax.ws.rs.QueryParam;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of Application Management related APIs.
|
||||||
|
*/
|
||||||
|
@Produces({"application/json"})
|
||||||
|
@Path("/applications")
|
||||||
|
public class ApplicationManagementPublisherAdminAPIImpl implements ApplicationManagementPublisherAdminAPI {
|
||||||
|
|
||||||
|
private static Log log = LogFactory.getLog(ApplicationManagementPublisherAdminAPIImpl.class);
|
||||||
|
|
||||||
|
@DELETE
|
||||||
|
@Path("/release/{appId}/{uuid}")
|
||||||
|
public Response deleteApplicationRelease(
|
||||||
|
@PathParam("appId") int applicationId,
|
||||||
|
@PathParam("uuid") String releaseUuid) {
|
||||||
|
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
||||||
|
try {
|
||||||
|
applicationManager.deleteApplicationRelease(applicationId, releaseUuid);
|
||||||
|
String responseMsg = "Successfully deleted the application release for uuid: " + releaseUuid + "";
|
||||||
|
return Response.status(Response.Status.OK).entity(responseMsg).build();
|
||||||
|
} catch (NotFoundException e) {
|
||||||
|
String msg = "Couldn't found application release which is having application id: " + applicationId
|
||||||
|
+ " and application release UUID:" + releaseUuid;
|
||||||
|
log.error(msg, e);
|
||||||
|
return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
|
||||||
|
} catch (ForbiddenException e) {
|
||||||
|
String msg =
|
||||||
|
"You don't have require permission to delete the application release which has UUID " + releaseUuid
|
||||||
|
+ " and application ID " + applicationId;
|
||||||
|
log.error(msg, e);
|
||||||
|
return Response.status(Response.Status.FORBIDDEN).entity(msg).build();
|
||||||
|
}catch (ApplicationManagementException e) {
|
||||||
|
String msg = "Error occurred while deleting the application: " + applicationId;
|
||||||
|
log.error(msg, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue