Added app release creation method and fixed issues

feature/appm-store/pbac
lasantha 7 years ago
parent 317386afb8
commit 569007514e

@ -56,6 +56,8 @@
org.apache.commons.logging,
javax.xml.*,
org.apache.commons.codec.binary;version="${commons-codec.wso2.osgi.version.range}",
org.wso2.carbon.device.mgt.core.dto.*;version="${carbon.device.mgt.version}",
org.wso2.carbon.device.mgt.core.dao.*;version="${carbon.device.mgt.version}",
org.w3c.dom,
org.json,
org.xml.sax,

@ -64,6 +64,12 @@ public interface ApplicationManager {
*/
ApplicationList getApplications(Filter filter) throws ApplicationManagementException;
/**
* To get the applications based on the search filter.
* @param appId id of the application
* @return Application release which is published and release of the Application(appId).
* @throws ApplicationManagementException Application Management Exception
*/
String getUuidOfLatestRelease(int appId) throws ApplicationManagementException;
@ -97,6 +103,16 @@ public interface ApplicationManager {
*/
Application getApplication(String appType, String appName) throws ApplicationManagementException;
/**
* To get Application with the given UUID.
*
* @param applicationId Id of the Application
* @return the Application identified by the application id
* @throws ApplicationManagementException Application Management Exception.
*/
Application getApplicationById(int applicationId) throws ApplicationManagementException;
/**
* To get Application with the given UUID.
*

@ -33,11 +33,11 @@ public interface ApplicationReleaseManager {
/**
* To create an application release for an Application.
*
* @param appicationUuid UUID of the Application
* @param applicationId ID of the Application
* @param applicationRelease ApplicatonRelease that need to be be created.
* @return the unique id of the application release, if the application release succeeded else -1
*/
ApplicationRelease createRelease(String appicationUuid, ApplicationRelease applicationRelease)
ApplicationRelease createRelease(int applicationId, ApplicationRelease applicationRelease)
throws ApplicationManagementException;
/**
@ -45,10 +45,11 @@ public interface ApplicationReleaseManager {
*
* @param applicationUuid UUID of the Application.
* @param version Version of the ApplicationRelease that need to be retrieved.
* @param releaseType Release type of the app release. (e.g: alpha, beta, default, released)
* @return ApplicationRelease related with particular Application UUID and version.
* @throws ApplicationManagementException ApplicationManagementException
*/
ApplicationRelease getRelease(String applicationUuid, String version) throws ApplicationManagementException;
ApplicationRelease getRelease(String applicationUuid, String version, String releaseType) throws ApplicationManagementException;
/**
* To get all the releases of a particular Application.
@ -87,9 +88,10 @@ public interface ApplicationReleaseManager {
*
* @param applicationUuid UUID of the Application, in which the ApplicationRelease need to be deleted.
* @param version Version of the ApplicationRelease that need to be deleted.
* @param releaseType Release type of the application.
* @throws ApplicationManagementException Application Management Exception.
*/
void deleteApplicationRelease(String applicationUuid, String version) throws ApplicationManagementException;
void deleteApplicationRelease(String applicationUuid, String version, String releaseType) throws ApplicationManagementException;
/**
* To delete all the application releases related with the the particular application.

@ -1,63 +0,0 @@
/*
* 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.common.services;
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
import java.util.List;
/**
* CategoryManager is responsible for handling add, delete, update opertaions related with {@link Category}
*/
public interface CategoryManager {
/**
* To create an application category.
*
* @param category Category that need to be created.
* @return the created Category.
* @throws ApplicationManagementException Application Management Exception
*/
Category createCategory(Category category) throws ApplicationManagementException;
/**
* To get all the current categories.
*
* @return list of Application categories.
* @throws ApplicationManagementException Application Management Exception.
*/
List<Category> getCategories() throws ApplicationManagementException;
/**
* To get the category with the given name.
*
* @param name Name of the category to retrieve.
* @return the category with the given name.
* @throws ApplicationManagementException Application Management Exception.
*/
Category getCategory(String name) throws ApplicationManagementException;
/**
* To delete the category with the given name.
*
* @param name Name of the category to be deleted.
* @throws ApplicationManagementException Application Management Exception.
*/
void deleteCategory(String name) throws ApplicationManagementException;
}

@ -84,6 +84,16 @@ public interface ApplicationDAO {
*/
Application getApplication(String appName, String appType, int tenantId) throws ApplicationManagementDAOException;
/**
* To get the application with the given uuid
*
* @param applicationId Id of the application to be retrieved.
* @param tenantId ID of the tenant.
* @return the application
* @throws ApplicationManagementDAOException Application Management DAO Exception.
*/
Application getApplicationById(int applicationId, int tenantId) throws ApplicationManagementDAOException;
/**
* To get the application with the given uuid
*

@ -343,6 +343,45 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
}
}
@Override
public Application getApplicationById(int applicationId, int tenantId) throws
ApplicationManagementDAOException {
if (log.isDebugEnabled()){
log.debug("Getting application with the id (" + applicationId + ") from the database");
}
Connection conn;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
conn = this.getDBConnection();
String sql = "SELECT AP_APP.ID AS APP_ID, AP_APP.NAME AS APP_NAME, AP_APP.TYPE AS APP_TYPE, AP_APP.APP_CATEGORY \n"
+ "AS APP_CATEGORY, AP_APP.IS_FREE, AP_APP_TAG.TAG, AP_UNRESTRICTED_ROLES.ROLE AS RELESE_ID FROM \n"
+ "AP_APP, AP_APP_TAG, AP_UNRESTRICTED_ROLES WHERE AP_APP.ID=? AND AP_APP.TENANT_ID=?;";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, applicationId);
stmt.setInt(2, tenantId);
rs = stmt.executeQuery();
if (log.isDebugEnabled()) {
log.debug("Successfully retrieved basic details of the application with the id "
+ applicationId);
}
return Util.loadApplication(rs);
} catch (SQLException e) {
throw new ApplicationManagementDAOException(
"Error occurred while getting application details with app id " + applicationId + " While executing query ", e);
} catch (JSONException e) {
throw new ApplicationManagementDAOException("Error occurred while parsing JSON", e);
} catch (DBConnectionException e) {
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e);
} finally {
Util.cleanupResources(stmt, rs);
}
}
@Override
public Boolean verifyApplicationExistenceById(int appId) throws ApplicationManagementDAOException {
if (log.isDebugEnabled()){

@ -231,7 +231,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
if (application.getUnrestrictedRoles().isEmpty()){
roleRestrictedApplicationList.getApplications().add(application);
}else{
if (isRoleExists(application.getUnrestrictedRoles(), userName){
if (isRoleExists(application.getUnrestrictedRoles(), userName)){
roleRestrictedApplicationList.getApplications().add(application);
}
}
@ -373,6 +373,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
// } finally {
// ConnectionManagerUtil.closeDBConnection();
// }
return null;
}
@Override
@ -388,11 +389,13 @@ public class ApplicationManagerImpl implements ApplicationManager {
return application;
}
if (application.getUnrestrictedRoles().isEmpty()){
isAppAllowed = true;
}else if(isRoleExists(application.getUnrestrictedRoles(), userName)){
if (!application.getUnrestrictedRoles().isEmpty()) {
if(isRoleExists(application.getUnrestrictedRoles(), userName)){
isAppAllowed = true ;
}
} else {
isAppAllowed = true;
}
if (!isAppAllowed){
return null;
@ -406,6 +409,40 @@ public class ApplicationManagerImpl implements ApplicationManager {
}
}
@Override
public Application getApplicationById(int applicationId) throws ApplicationManagementException{
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
Application application;
boolean isAppAllowed = false;
try {
ConnectionManagerUtil.openDBConnection();
application = ApplicationManagementDAOFactory.getApplicationDAO().getApplicationById(applicationId, tenantId);
if (isAdminUser(userName, tenantId, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION)) {
return application;
}
if (!application.getUnrestrictedRoles().isEmpty()) {
if(isRoleExists(application.getUnrestrictedRoles(), userName)){
isAppAllowed = true ;
}
} else {
isAppAllowed = true;
}
if (!isAppAllowed){
return null;
}
return application;
} catch (UserStoreException e) {
throw new ApplicationManagementException("User-store exception while getting application with the "
+ "application id " + applicationId);
} finally {
ConnectionManagerUtil.closeDBConnection();
}
}
public Boolean verifyApplicationExistenceById(int appId) throws ApplicationManagementException{
try {
Boolean isAppExist;
@ -443,6 +480,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
// } finally {
// ConnectionManagerUtil.closeDBConnection();
// }
return false;
}
/**

@ -31,6 +31,7 @@ import org.wso2.carbon.device.application.mgt.core.exception.NotFoundException;
import org.wso2.carbon.device.application.mgt.core.internal.DataHolder;
import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
@ -41,18 +42,18 @@ public class ApplicationReleaseManagerImpl implements ApplicationReleaseManager
private static Log log = LogFactory.getLog(ApplicationReleaseManagerImpl.class);
@Override
public ApplicationRelease createRelease(String appicationUuid, ApplicationRelease applicationRelease) throws
public ApplicationRelease createRelease(int applicationId, ApplicationRelease applicationRelease) throws
ApplicationManagementException {
Application application = validateApplication(appicationUuid);
validateReleaseCreateRequest(appicationUuid, applicationRelease);
Application application = validateApplication(applicationId);
validateReleaseCreateRequest(applicationRelease.getUuid(), applicationRelease);
if (log.isDebugEnabled()) {
log.debug("Application release request is received for the application " + application.toString());
}
applicationRelease.setCreatedAt(new Date());
applicationRelease.setCreatedAt((Timestamp) new Date());
try {
ConnectionManagerUtil.beginDBTransaction();
applicationRelease.setApplication(application);
applicationRelease = ApplicationManagementDAOFactory.getApplicationReleaseDAO().createRelease(applicationRelease);
applicationRelease = ApplicationManagementDAOFactory.getApplicationReleaseDAO().
createRelease(applicationRelease, application.getId());
ConnectionManagerUtil.commitDBTransaction();
return applicationRelease;
} catch (ApplicationManagementDAOException e) {
@ -64,18 +65,18 @@ public class ApplicationReleaseManagerImpl implements ApplicationReleaseManager
}
@Override
public ApplicationRelease getRelease(String applicationUuid, String version) throws
public ApplicationRelease getRelease(String applicationUuid, String version, String releaseType) throws
ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
Application application = validateApplication(applicationUuid);
Application application = validateApplicationRelease(applicationUuid);
if (log.isDebugEnabled()) {
log.debug("Application release retrieval request is received for the application " +
application.toString() + " and version " + version);
}
try {
ConnectionManagerUtil.openDBConnection();
return ApplicationManagementDAOFactory
.getApplicationReleaseDAO().getRelease(applicationUuid, version, tenantId);
return ApplicationManagementDAOFactory.getApplicationReleaseDAO()
.getRelease(application.getName(), application.getType(), version, releaseType, tenantId );
} finally {
ConnectionManagerUtil.closeDBConnection();
}
@ -84,47 +85,49 @@ public class ApplicationReleaseManagerImpl implements ApplicationReleaseManager
@Override
public List<ApplicationRelease> getReleases(String applicationUuid) throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
Application application = validateApplication(applicationUuid);
Application application = validateApplicationRelease(applicationUuid);
if (log.isDebugEnabled()) {
log.debug("Request is received to retrieve all the releases related with the application " +
application.toString());
}
try {
ConnectionManagerUtil.openDBConnection();
return ApplicationManagementDAOFactory
.getApplicationReleaseDAO().getApplicationReleases(applicationUuid, tenantId);
return ApplicationManagementDAOFactory.getApplicationReleaseDAO()
.getApplicationReleases(application.getName(), application.getType(), tenantId);
} finally {
ConnectionManagerUtil.closeDBConnection();
}
}
// ToDo
@Override
public void changeDefaultRelease(String uuid, String version, boolean isDefault, String releaseChannel) throws
ApplicationManagementException {
Application application = validateApplication(uuid);
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
if (log.isDebugEnabled()) {
log.debug("Request received to change the default release for the release channel " + releaseChannel
+ "for the application " + application.toString());
}
try {
ConnectionManagerUtil.beginDBTransaction();
ApplicationManagementDAOFactory.getApplicationReleaseDAO()
.changeReleaseDefault(uuid, version, isDefault, releaseChannel, tenantId);
ConnectionManagerUtil.commitDBTransaction();
} catch (ApplicationManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction();
throw e;
} finally {
ConnectionManagerUtil.closeDBConnection();
}
// Application application = validateApplicationRelease(uuid);
// int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
// if (log.isDebugEnabled()) {
// log.debug("Request received to change the default release for the release channel " + releaseChannel
// + "for the application " + application.toString());
// }
//
// try {
// ConnectionManagerUtil.beginDBTransaction();
// ApplicationManagementDAOFactory.getApplicationReleaseDAO()
// .changeReleaseDefault(uuid, version, isDefault, releaseChannel, tenantId);
// ConnectionManagerUtil.commitDBTransaction();
// } catch (ApplicationManagementDAOException e) {
// ConnectionManagerUtil.rollbackDBTransaction();
// throw e;
// } finally {
// ConnectionManagerUtil.closeDBConnection();
// }
}
// ToDo
@Override
public ApplicationRelease updateRelease(String applicationUuid, ApplicationRelease applicationRelease)
throws ApplicationManagementException {
// Application application = validateApplication(applicationUuid);
// Application application = validateApplicationRelease(applicationUuid);
// ApplicationRelease oldApplicationRelease = null;
// if (applicationRelease == null || applicationRelease.getVersion() != null) {
// throw new ApplicationManagementException(
@ -151,13 +154,14 @@ public class ApplicationReleaseManagerImpl implements ApplicationReleaseManager
// } finally {
// ConnectionManagerUtil.closeDBConnection();
// }
return null;
}
@Override
public void deleteApplicationRelease(String applicationUuid, String version)
public void deleteApplicationRelease(String applicationUuid, String version, String releaseType)
throws ApplicationManagementException {
Application application = validateApplication(applicationUuid);
ApplicationRelease applicationRelease = getRelease(applicationUuid, version);
Application application = validateApplicationRelease(applicationUuid);
ApplicationRelease applicationRelease = getRelease(applicationUuid, version, releaseType);
if (applicationRelease == null) {
throw new ApplicationManagementException(
"Cannot delete a non-existing application release for the " + "application with UUID "
@ -166,7 +170,7 @@ public class ApplicationReleaseManagerImpl implements ApplicationReleaseManager
try {
ConnectionManagerUtil.beginDBTransaction();
ApplicationManagementDAOFactory.getApplicationReleaseDAO().deleteRelease(application.getId(), version);
ApplicationManagementDAOFactory.getApplicationReleaseDAO().deleteReleaseProperties(applicationRelease.getId());
// ToDO remove storage details as well
ConnectionManagerUtil.commitDBTransaction();
} catch (ApplicationManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction();
@ -185,23 +189,42 @@ public class ApplicationReleaseManagerImpl implements ApplicationReleaseManager
}
}
/**
* To validate the pre-request of the ApplicationRelease.
*
* @param applicationID ID of the Application.
* @return Application related with the UUID
*/
private Application validateApplication(int applicationID) throws ApplicationManagementException {
if (applicationID <= 0) {
throw new ApplicationManagementException("Application UUID is null. Application UUID is a required "
+ "parameter to get the relevant application.");
}
Application application = DataHolder.getInstance().getApplicationManager().getApplicationById(applicationID);
if (application == null) {
throw new NotFoundException(
"Application of the " + applicationID + " does not exist.");
}
return application;
}
/**
* To validate the pre-request of the ApplicationRelease.
*
* @param applicationUuid UUID of the Application.
* @return Application related with the UUID
*/
private Application validateApplication(String applicationUuid) throws ApplicationManagementException {
private ApplicationRelease validateApplicationRelease(String applicationUuid) throws ApplicationManagementException {
if (applicationUuid == null) {
throw new ApplicationManagementException("Application UUID is null. Application UUID is a required "
+ "parameter to get the relevant application.");
}
Application application = DataHolder.getInstance().getApplicationManager().getApplication(applicationUuid);
if (application == null) {
ApplicationRelease applicationRelease = DataHolder.getInstance().getApplicationReleaseManager().getRelease();
if (applicationRelease == null) {
throw new NotFoundException(
"Application with UUID " + applicationUuid + " does not exist.");
}
return application;
return applicationRelease;
}
/**

@ -31,7 +31,6 @@ import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManage
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationStorageManagementException;
import org.wso2.carbon.device.application.mgt.common.exception.ResourceManagementException;
import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager;
import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException;
import org.wso2.carbon.device.application.mgt.core.internal.DataHolder;
import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil;
import org.wso2.carbon.device.application.mgt.core.util.Constants;
@ -208,7 +207,7 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
ApplicationStorageManagementException {
validateApplication(applicationUUID);
try {
List<ApplicationRelease> applicationReleases = DataHolder.getInstance().getReleaseManager()
List<ApplicationRelease> applicationReleases = DataHolder.getInstance().getApplicationReleaseManager()
.getReleases(applicationUUID);
for (ApplicationRelease applicationRelease : applicationReleases) {
deleteApplicationReleaseArtifacts(applicationUUID, applicationRelease.getVersion());

@ -21,7 +21,6 @@ package org.wso2.carbon.device.application.mgt.core.internal;
import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager;
import org.wso2.carbon.device.application.mgt.common.services.ApplicationReleaseManager;
import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager;
import org.wso2.carbon.device.application.mgt.common.services.CategoryManager;
import org.wso2.carbon.device.application.mgt.common.services.CommentsManager;
import org.wso2.carbon.device.application.mgt.common.services.LifecycleStateManager;
import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager;
@ -42,8 +41,6 @@ public class DataHolder {
private ApplicationReleaseManager releaseManager;
private CategoryManager categoryManager;
private CommentsManager commentsManager;
private LifecycleStateManager lifecycleStateManager;
@ -80,22 +77,14 @@ public class DataHolder {
this.applicationManager = applicationManager;
}
public ApplicationReleaseManager getReleaseManager() {
public ApplicationReleaseManager getApplicationReleaseManager() {
return releaseManager;
}
public void setReleaseManager(ApplicationReleaseManager releaseManager) {
public void setApplicationReleaseManager(ApplicationReleaseManager releaseManager) {
this.releaseManager = releaseManager;
}
public CategoryManager getCategoryManager() {
return categoryManager;
}
public void setCategoryManager(CategoryManager categoryManager) {
this.categoryManager = categoryManager;
}
public CommentsManager getCommentsManager() {
return commentsManager;
}

@ -26,7 +26,6 @@ import org.wso2.carbon.device.application.mgt.common.exception.InvalidConfigurat
import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager;
import org.wso2.carbon.device.application.mgt.common.services.ApplicationReleaseManager;
import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager;
import org.wso2.carbon.device.application.mgt.common.services.CategoryManager;
import org.wso2.carbon.device.application.mgt.common.services.CommentsManager;
import org.wso2.carbon.device.application.mgt.common.services.LifecycleStateManager;
import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager;
@ -38,7 +37,6 @@ import org.wso2.carbon.device.application.mgt.core.util.ApplicationManagementUti
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.ndatasource.core.DataSourceService;
import org.wso2.carbon.user.core.service.RealmService;
import org.wso2.carbon.utils.Axis2ConfigurationContextObserver;
import javax.naming.NamingException;
@ -80,13 +78,9 @@ public class ServiceComponent {
ApplicationReleaseManager applicationReleaseManager = ApplicationManagementUtil
.getApplicationReleaseManagerInstance();
DataHolder.getInstance().setReleaseManager(applicationReleaseManager);
DataHolder.getInstance().setApplicationReleaseManager(applicationReleaseManager);
bundleContext.registerService(ApplicationReleaseManager.class.getName(), applicationReleaseManager, null);
CategoryManager categoryManager = ApplicationManagementUtil.getCategoryManagerInstance();
DataHolder.getInstance().setCategoryManager(categoryManager);
bundleContext.registerService(CategoryManager.class.getName(), categoryManager, null);
CommentsManager commentsManager = ApplicationManagementUtil.getCommentsManagerInstance();
DataHolder.getInstance().setCommentsManager(commentsManager);
bundleContext.registerService(CommentsManager.class.getName(), commentsManager, null);

@ -24,7 +24,6 @@ import org.wso2.carbon.device.application.mgt.common.exception.InvalidConfigurat
import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager;
import org.wso2.carbon.device.application.mgt.common.services.ApplicationReleaseManager;
import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager;
import org.wso2.carbon.device.application.mgt.common.services.CategoryManager;
import org.wso2.carbon.device.application.mgt.common.services.CommentsManager;
import org.wso2.carbon.device.application.mgt.common.services.LifecycleStateManager;
import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager;
@ -55,12 +54,6 @@ public class ApplicationManagementUtil {
return getInstance(extension, ApplicationReleaseManager.class);
}
public static CategoryManager getCategoryManagerInstance() throws InvalidConfigurationException {
ConfigurationManager configurationManager = ConfigurationManager.getInstance();
Extension extension = configurationManager.getExtension(Extension.Name.CategoryManager);
return getInstance(extension, CategoryManager.class);
}
public static CommentsManager getCommentsManagerInstance() throws InvalidConfigurationException {
ConfigurationManager configurationManager = ConfigurationManager.getInstance();
Extension extension = configurationManager.getExtension(Extension.Name.CommentsManager);

@ -25,7 +25,6 @@ import org.wso2.carbon.device.application.mgt.publisher.api.beans.ErrorResponse;
import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager;
import org.wso2.carbon.device.application.mgt.common.services.ApplicationReleaseManager;
import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager;
import org.wso2.carbon.device.application.mgt.common.services.CategoryManager;
import org.wso2.carbon.device.application.mgt.common.services.LifecycleStateManager;
import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager;

@ -289,40 +289,6 @@ public interface ApplicationManagementAPI {
required = true)
@Valid Application application);
@POST
@Path("{appId}/release")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.MULTIPART_FORM_DATA)
@ApiOperation(
consumes = MediaType.MULTIPART_FORM_DATA,
produces = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Create an application release",
notes = "This will create a new application release",
tags = "Application Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = SCOPE, value = "perm:application:create")
})
}
)
@ApiResponses(
value = {
@ApiResponse(
code = 201,
message = "OK. \n Successfully created an application release.",
response = ApplicationRelease.class),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Error occurred while releasing the application.",
response = ErrorResponse.class)
})
Response createApplicationRelease(
@Multipart(value = "applicationRelease", type = "application/json") ApplicationRelease applicationRelease,
@Multipart(value = "binaryFile") Attachment binaryFile,
@PathParam("appId") int applicationId);
@POST
@Path("/upload-artifacts/{uuid}")

@ -70,11 +70,12 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
private static Log log = LogFactory.getLog(ApplicationManagementAPIImpl.class);
@GET
@Override
@Consumes("application/json")
public Response getApplications(
@QueryParam("query") String searchQuery,
@QueryParam("offset") int offset,
@QueryParam("limit") int limit) {
@QueryParam("limit") int limit,
@QueryParam("query") String searchQuery) {
ApplicationManager applicationManager = APIUtil.getApplicationManager();
ApplicationStorageManager applicationStorageManager = APIUtil.getApplicationStorageManager();
@ -104,11 +105,11 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
} catch (NotFoundException e) {
return Response.status(Response.Status.NOT_FOUND).build();
} catch (ApplicationManagementException e) {
String msg = "Error occurred while getting the application list";
String msg = "Error occurred while getting the application list for publisher ";
log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).build();
} catch (ApplicationStorageManagementException e) {
log.error("Error occurred while getting the image artifacts of the application", e);
log.error("Error occurred while getting the image artifacts of the application for publisher", e);
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
}
}
@ -271,39 +272,6 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
}
}
@Override
@POST
@Path("{appId}/release")
public Response createApplicationRelease(@Multipart("applicationRelease") ApplicationRelease applicationRelease,
@Multipart("binaryFile") Attachment binaryFile) {
ApplicationReleaseManager applicationReleaseManager = APIUtil.getApplicationReleaseManager();
ApplicationStorageManager applicationStorageManager = APIUtil.getApplicationStorageManager();
try {
applicationRelease = applicationReleaseManager.createRelease(applicationUUID, applicationRelease);
if (binaryFile != null) {
applicationStorageManager.uploadReleaseArtifacts(applicationUUID, applicationRelease.getVersion(),
binaryFile.getDataHandler().getInputStream());
}
return Response.status(Response.Status.CREATED).entity(applicationRelease).build();
} catch (ApplicationManagementException e) {
log.error("Error while creating an application release for the application with UUID " + applicationUUID,
e);
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
} catch (IOException e) {
String errorMessage =
"Error while uploading binary file for the application release of the application with UUID "
+ applicationUUID;
log.error(errorMessage, e);
return APIUtil.getResponse(new ApplicationManagementException(errorMessage, e),
Response.Status.INTERNAL_SERVER_ERROR);
} catch (ResourceManagementException e) {
log.error("Error occurred while uploading the releases artifacts of the application with the uuid "
+ applicationUUID + " for the release " + applicationRelease.getVersion(), e);
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Override
@POST
@Path("/upload-image-artifacts/{uuid}")

@ -105,9 +105,8 @@ public class ApplicationReleaseManagementAPIImpl implements ApplicationReleaseMa
applicationRelease = applicationStorageManager.uploadImageArtifacts(applicationId, applicationRelease,
iconFileStream, bannerFileStream, attachments);
// ToDo
applicationRelease.setUuid(UUID.randomUUID().toString());
applicationRelease = applicationReleaseManager.createRelease(applicationUUID, applicationRelease);
applicationRelease = applicationReleaseManager.createRelease(applicationId, applicationRelease);
return Response.status(Response.Status.CREATED).entity(applicationRelease).build();

@ -25,7 +25,6 @@ import org.wso2.carbon.device.application.mgt.publisher.api.beans.ErrorResponse;
import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager;
import org.wso2.carbon.device.application.mgt.common.services.ApplicationReleaseManager;
import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager;
import org.wso2.carbon.device.application.mgt.common.services.CategoryManager;
import org.wso2.carbon.device.application.mgt.common.services.LifecycleStateManager;
import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager;

@ -16,12 +16,10 @@
* under the License.
*
*/
package org.wso2.carbon.device.application.mgt.publisher.api.services.impl;
package org.wso2.carbon.device.application.mgt.store.api.services.impl;
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.store.api.APIUtil;
import org.wso2.carbon.device.application.mgt.store.api.FileStreamingOutput;
import org.wso2.carbon.device.application.mgt.publisher.api.services.ApplicationManagementAPI;
@ -32,25 +30,16 @@ import org.wso2.carbon.device.application.mgt.common.Filter;
import org.wso2.carbon.device.application.mgt.common.ImageArtifact;
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.ResourceManagementException;
import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager;
import org.wso2.carbon.device.application.mgt.common.services.ApplicationReleaseManager;
import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager;
import org.wso2.carbon.device.application.mgt.core.exception.NotFoundException;
import org.wso2.carbon.device.application.mgt.core.util.Constants;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
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;

@ -171,6 +171,11 @@
<artifactId>org.wso2.carbon.certificate.mgt.core</artifactId>
<version>${carbon.device.mgt.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.application.mgt.authhandler</artifactId>
<version>${carbon.device.mgt.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.application.mgt.core</artifactId>
@ -183,12 +188,12 @@
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.application.mgt.api</artifactId>
<artifactId>org.wso2.carbon.device.application.mgt.publisher.api</artifactId>
<version>${carbon.device.mgt.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.application.mgt.extensions</artifactId>
<artifactId>org.wso2.carbon.device.application.mgt.store.api</artifactId>
<version>${carbon.device.mgt.version}</version>
</dependency>
<dependency>
@ -196,6 +201,11 @@
<artifactId>org.wso2.carbon.device.application.mgt.publisher.ui</artifactId>
<version>${carbon.device.mgt.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.application.mgt.store.ui</artifactId>
<version>${carbon.device.mgt.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.policy.mgt.common</artifactId>
@ -267,11 +277,6 @@
<artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher</artifactId>
<version>${carbon.device.mgt.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.analytics.dashboard</artifactId>
<version>${carbon.device.mgt.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.server.feature</artifactId>
@ -347,6 +352,12 @@
<type>zip</type>
<version>${carbon.device.mgt.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.application.mgt.store.ui.feature</artifactId>
<type>zip</type>
<version>${carbon.device.mgt.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.application.mgt.feature</artifactId>
@ -470,6 +481,18 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.securevault</artifactId>
<version>${carbon.kernel.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.testing.osgi-mock</artifactId>
<version>${apache.osgi.mock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.governance</groupId>
<artifactId>org.wso2.carbon.governance.api</artifactId>
@ -1224,7 +1247,12 @@
<artifactId>commons-codec</artifactId>
<version>${version.commons.codec}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>${apache.http.compnents.core}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-lang.wso2</groupId>
<artifactId>commons-lang</artifactId>
@ -1594,6 +1622,42 @@
<artifactId>org.wso2.carbon.registry.resource</artifactId>
<version>${carbon.registry.resource.version}</version>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>${power.mock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-testng</artifactId>
<version>${power.mock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-dbcp.wso2</groupId>
<artifactId>commons-dbcp</artifactId>
<version>${commons.dbcp.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.governance</groupId>
<artifactId>org.wso2.carbon.governance.registry.extensions</artifactId>
<version>${carbon.governance.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<scope>test</scope>
<version>${slf4j.nop.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
@ -1736,31 +1800,9 @@
<version>${carbon.p2.plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven.checkstyle.plugin.version}</version>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<configuration>
<configLocation>
https://raw.githubusercontent.com/wso2/code-quality-tools/master/checkstyle/checkstyle.xml
</configLocation>
<suppressionsLocation>
https://raw.githubusercontent.com/wso2/code-quality-tools/master/checkstyle/suppressions.xml
</suppressionsLocation>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>false</failsOnError>
<failOnViolation>false</failOnViolation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.maven.plugin.version}</version>
</plugin>
</plugins>
</pluginManagement>
@ -1922,7 +1964,7 @@
<commons-lang.wso2.osgi.version.range>[2.6.0,3.0.0)</commons-lang.wso2.osgi.version.range>
<!-- Carbon API Management -->
<carbon.api.mgt.version>6.1.64</carbon.api.mgt.version>
<carbon.api.mgt.version>6.1.109</carbon.api.mgt.version>
<carbon.api.mgt.version.range>(6.0.0,7.0.0]</carbon.api.mgt.version.range>
<!-- Carbon Analytics -->
@ -1938,7 +1980,7 @@
<carbon.registry.imp.pkg.version.range>[4.4.8, 5.0.0)</carbon.registry.imp.pkg.version.range>
<!--CXF properties-->
<cxf.version>2.7.16</cxf.version>
<cxf.version>3.2.0</cxf.version>
<cxf.bindings.version>2.5.11</cxf.bindings.version>
<json-simple.version>1.1.wso2v1</json-simple.version>
<jackson.version>1.9.0</jackson.version>
@ -2022,6 +2064,12 @@
<!-- apache pdfbox version -->
<slf4j.simple.version>1.6.1</slf4j.simple.version>
<!--apache osgi mock version-->
<apache.osgi.mock.version>2.3.2</apache.osgi.mock.version>
<!-- apache http components core -->
<apache.http.compnents.core>4.4.3</apache.http.compnents.core>
<!-- api-mgt handler version properties -->
<org.apache.synapse.version>2.1.7-wso2v7</org.apache.synapse.version>
<org.apache.ws.security.wso2.version>1.5.11.wso2v15</org.apache.ws.security.wso2.version>
@ -2040,8 +2088,14 @@
<javassist.version>3.12.1.GA</javassist.version>
<maven.javadoc.skip>true</maven.javadoc.skip>
<!-- maven check style version -->
<maven.checkstyle.plugin.version>2.17</maven.checkstyle.plugin.version>
<!-- jacoco plugin version -->
<jacoco.maven.plugin.version>0.7.8</jacoco.maven.plugin.version>
<jacoco.ant.verision>0.7.5.201505241946</jacoco.ant.verision>
<ant.contrib.version>1.0b3</ant.contrib.version>
<power.mock.version>1.7.0</power.mock.version>
<commons.dbcp.version>1.4.0.wso2v1</commons.dbcp.version>
<slf4j.nop.version>1.7.25</slf4j.nop.version>
</properties>
</project>
Loading…
Cancel
Save