Remove application release management service source.

The application release management service source is moved to application management service. Therefore removed the application release management service source from the application management component.
feature/appm-store/pbac
lasantha 7 years ago
parent fc30d00ecd
commit 1b7451327e

@ -1,112 +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.ApplicationRelease;
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
import java.util.List;
/**
* ApplicationReleaseManager is responsible for handling all the operations related with
* {@link org.wso2.carbon.device.application.mgt.common.ApplicationRelease} which involving addition, updating ,
* deletion and viewing.
*/
public interface ApplicationReleaseManager {
/**
* To create an application release for an 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(int applicationId, ApplicationRelease applicationRelease)
throws ApplicationManagementException;
/**
* To get the application release of the Application/
*
* @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, String releaseType) throws ApplicationManagementException;
/**
* To get the application release of the Application/
*
* @param applicationUuid UUID of the Application.
* @return ApplicationRelease related with particular Application UUID and version.
* @throws ApplicationManagementException ApplicationManagementException
*/
ApplicationRelease getReleaseByUuid(String applicationUuid) throws ApplicationManagementException;
/**
* To get all the releases of a particular Application.
*
* @param applicationId ID of the Application to get all the releases.
* @return the List of the Application releases related with the particular Application.
* @throws ApplicationManagementException Application Management Exception.
*/
List<ApplicationRelease> getReleases(int applicationId) throws ApplicationManagementException;
/**
* To make a particular application release as the default / not default-one
*
* @param uuid UUID of the application
* @param version Version of the application
* @param isDefault is default or not.
* @param releaseChannel Release channel to make the
* @throws ApplicationManagementException Application Management Exception.
*/
void changeDefaultRelease(String uuid, String version, boolean isDefault, String releaseChannel)
throws ApplicationManagementException;
/**
* To update with a new release for an Application.
*
* @param appId ID of the Application
* @param applicationRelease ApplicationRelease
* @return Updated Application Release.
* @throws ApplicationManagementException Application Management Exception.
*/
ApplicationRelease updateRelease(int appId, ApplicationRelease applicationRelease)
throws ApplicationManagementException;
/**
* To delete a particular release
*
* @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, String releaseType) throws ApplicationManagementException;
/**
* To delete all the application releases related with the the particular application.
*
* @param applicationUuid UUID of the application.
* @throws ApplicationManagementException Application Management Exception.
*/
void deleteApplicationReleases(String applicationUuid) throws ApplicationManagementException;
}

@ -1,261 +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.core.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.application.mgt.common.Application;
import org.wso2.carbon.device.application.mgt.common.ApplicationRelease;
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
import org.wso2.carbon.device.application.mgt.common.services.ApplicationReleaseManager;
import org.wso2.carbon.device.application.mgt.core.dao.common.ApplicationManagementDAOFactory;
import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException;
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;
/**
* Concrete implementation for Application Release Management related tasks.
*/
public class ApplicationReleaseManagerImpl implements ApplicationReleaseManager {
private static Log log = LogFactory.getLog(ApplicationReleaseManagerImpl.class);
@Override
public ApplicationRelease createRelease(int applicationId, ApplicationRelease applicationRelease) throws
ApplicationManagementException {
Application application = validateApplication(applicationId);
validateReleaseCreateRequest(applicationRelease);
if (log.isDebugEnabled()) {
log.debug("Application release request is received for the application " + application.toString());
}
applicationRelease.setCreatedAt((Timestamp) new Date());
try {
ConnectionManagerUtil.beginDBTransaction();
applicationRelease = ApplicationManagementDAOFactory.getApplicationReleaseDAO().
createRelease(applicationRelease, application.getId());
ConnectionManagerUtil.commitDBTransaction();
return applicationRelease;
} catch (ApplicationManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction();
throw e;
} finally {
ConnectionManagerUtil.closeDBConnection();
}
}
//todo
@Override
public ApplicationRelease getRelease(String applicationUuid, String version, String releaseType) throws
ApplicationManagementException {
return null;
// int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
// 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(application.getName(), application.getType(), version, releaseType, tenantId );
// } finally {
// ConnectionManagerUtil.closeDBConnection();
// }
}
//todo
@Override public ApplicationRelease getReleaseByUuid(String applicationUuid) throws ApplicationManagementException {
return null;
}
@Override
public List<ApplicationRelease> getReleases(int applicationId) throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
Application application = validateApplication(applicationId);
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(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 = 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(int appId, ApplicationRelease applicationRelease)
throws ApplicationManagementException {
// Application application = validateApplicationRelease(applicationUuid);
// ApplicationRelease oldApplicationRelease = null;
// if (applicationRelease == null || applicationRelease.getVersion() != null) {
// throw new ApplicationManagementException(
// "Version is important to update the release of the application " + "with application UUID "
// + applicationUuid);
// }
// oldApplicationRelease = getRelease(applicationUuid, applicationRelease.getVersion());
// if (oldApplicationRelease == null) {
// throw new ApplicationManagementException(
// "Application release for the application " + applicationUuid + " with version " + applicationRelease
// .getVersion() + " does not exist. Cannot update the "
// + "release that is not existing.");
// }
// applicationRelease.setApplication(application);
// try {
// ConnectionManagerUtil.beginDBTransaction();
// ApplicationRelease newApplicationRelease = ApplicationManagementDAOFactory.getApplicationReleaseDAO()
// .updateRelease(applicationRelease);
// ConnectionManagerUtil.commitDBTransaction();
// return newApplicationRelease;
// } catch (ApplicationManagementDAOException e) {
// ConnectionManagerUtil.rollbackDBTransaction();
// throw e;
// } finally {
// ConnectionManagerUtil.closeDBConnection();
// }
return null;
}
//todo
@Override
public void deleteApplicationRelease(String applicationUuid, String version, String releaseType)
throws ApplicationManagementException {
// 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 "
// + applicationUuid);
// }
// try {
// ConnectionManagerUtil.beginDBTransaction();
// ApplicationManagementDAOFactory.getApplicationReleaseDAO().deleteRelease(application.getId(), version);
//// ToDO remove storage details as well
// ConnectionManagerUtil.commitDBTransaction();
// } catch (ApplicationManagementDAOException e) {
// ConnectionManagerUtil.rollbackDBTransaction();
// throw e;
// } finally {
// ConnectionManagerUtil.closeDBConnection();
// }
}
//todo
@Override
public void deleteApplicationReleases(String applicationUuid) throws ApplicationManagementException {
// List<ApplicationRelease> applicationReleases = getReleases(applicationUuid);
//
// for (ApplicationRelease applicationRelease : applicationReleases) {
// deleteApplicationRelease(applicationUuid, applicationRelease.getVersion());
// }
}
/**
* 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 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.");
}
ApplicationRelease applicationRelease = DataHolder.getInstance().getApplicationReleaseManager()
.getReleaseByUuid(applicationUuid);
if (applicationRelease == null) {
throw new NotFoundException(
"Application with UUID " + applicationUuid + " does not exist.");
}
return applicationRelease;
}
/**
* To validate a create release request to make sure all the pre-conditions satisfied.
*
* @param applicationRelease ApplicationRelease that need to be created.
* @throws ApplicationManagementException Application Management Exception.
*/
private void validateReleaseCreateRequest(ApplicationRelease applicationRelease)
throws ApplicationManagementException {
if (applicationRelease == null || applicationRelease.getVersion() == null) {
throw new ApplicationManagementException("ApplicationRelease version name is a mandatory parameter for "
+ "creating release. It cannot be found.");
}
if (getRelease(applicationRelease.getUuid(), applicationRelease.getVersion(),
applicationRelease.getReleaseType()) != null) {
throw new ApplicationManagementException( "Application Release for the Application UUID " +
applicationRelease.getUuid() + " " + "with the version " + applicationRelease.getVersion() +
" already exists. Cannot create an " + "application release with the same version.");
}
}
}

@ -19,7 +19,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.CommentsManager;
import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager;
@ -38,8 +37,6 @@ public class DataHolder {
private ApplicationManager applicationManager;
private ApplicationReleaseManager releaseManager;
private CommentsManager commentsManager;
private SubscriptionManager subscriptionManager;
@ -74,14 +71,6 @@ public class DataHolder {
this.applicationManager = applicationManager;
}
public ApplicationReleaseManager getApplicationReleaseManager() {
return releaseManager;
}
public void setApplicationReleaseManager(ApplicationReleaseManager releaseManager) {
this.releaseManager = releaseManager;
}
public CommentsManager getCommentsManager() {
return commentsManager;
}

@ -24,7 +24,6 @@ import org.osgi.framework.BundleContext;
import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.device.application.mgt.common.exception.InvalidConfigurationException;
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.CommentsManager;
import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager;
@ -75,11 +74,6 @@ public class ServiceComponent {
DataHolder.getInstance().setApplicationManager(applicationManager);
bundleContext.registerService(ApplicationManager.class.getName(), applicationManager, null);
ApplicationReleaseManager applicationReleaseManager = ApplicationManagementUtil
.getApplicationReleaseManagerInstance();
DataHolder.getInstance().setApplicationReleaseManager(applicationReleaseManager);
bundleContext.registerService(ApplicationReleaseManager.class.getName(), applicationReleaseManager, null);
CommentsManager commentsManager = ApplicationManagementUtil.getCommentsManagerInstance();
DataHolder.getInstance().setCommentsManager(commentsManager);
bundleContext.registerService(CommentsManager.class.getName(), commentsManager, null);

@ -35,7 +35,6 @@ public class APIUtil {
private static Log log = LogFactory.getLog(APIUtil.class);
private static ApplicationManager applicationManager;
private static ApplicationReleaseManager applicationReleaseManager;
private static ApplicationStorageManager applicationStorageManager;
private static SubscriptionManager subscriptionManager;
private static UnrestrictedRoleManager unrestrictedRoleManager;
@ -60,29 +59,6 @@ public class APIUtil {
return applicationManager;
}
/**
* To get the Application Release Manager from the osgi context.
*
* @return ApplicationRelease Manager instance in the current osgi context.
*/
public static ApplicationReleaseManager getApplicationReleaseManager() {
if (applicationReleaseManager == null) {
synchronized (APIUtil.class) {
if (applicationReleaseManager == null) {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
applicationReleaseManager = (ApplicationReleaseManager) ctx
.getOSGiService(ApplicationReleaseManager.class, null);
if (applicationReleaseManager == null) {
String msg = "Application Release Manager service has not initialized.";
log.error(msg);
throw new IllegalStateException(msg);
}
}
}
}
return applicationReleaseManager;
}
/**
* To get the Application Storage Manager from the osgi context.
* @return ApplicationStoreManager instance in the current osgi context.

@ -23,7 +23,6 @@ import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.application.mgt.common.services.CommentsManager;
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.SubscriptionManager;
import org.wso2.carbon.device.application.mgt.publisher.api.beans.ErrorResponse;
@ -38,7 +37,6 @@ public class APIUtil {
private static Log log = LogFactory.getLog(APIUtil.class);
private static ApplicationManager applicationManager;
private static ApplicationReleaseManager applicationReleaseManager;
private static ApplicationStorageManager applicationStorageManager;
private static SubscriptionManager subscriptionManager;
@ -53,23 +51,6 @@ public class APIUtil {
return applicationManager;
}
/**
* To get the Application Release Manager from the osgi context.
*
* @return ApplicationRelease Manager instance in the current osgi context.
*/
public static ApplicationReleaseManager getApplicationReleaseManager() {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
ApplicationReleaseManager applicationReleaseManager = (ApplicationReleaseManager) ctx
.getOSGiService(ApplicationReleaseManager.class, null);
if (applicationReleaseManager == null) {
String msg = "Application Release Manager service has not initialized.";
log.error(msg);
throw new IllegalStateException(msg);
}
return applicationReleaseManager;
}
/**
* To get the Application Storage Manager from the osgi context.
*

@ -21,23 +21,15 @@ 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.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.common.Application;
import org.wso2.carbon.device.application.mgt.common.ApplicationList;
import org.wso2.carbon.device.application.mgt.common.ApplicationRelease;
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.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.application.mgt.store.api.services.ApplicationManagementAPI;
import java.io.InputStream;
import java.util.List;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
@ -138,7 +130,6 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
@GET
public Response getApplicationRelease(@PathParam("uuid") String applicationUUID,
@QueryParam("version") String version) {
ApplicationReleaseManager applicationReleaseManager = APIUtil.getApplicationReleaseManager();
return null;
// try {
// if (version == null || version.isEmpty()) {

Loading…
Cancel
Save