mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
adding appliction release functionalites and fixed build failure
This commit is contained in:
parent
f17c36d13f
commit
669881eae7
@ -36,7 +36,7 @@ public interface ApplicationManager {
|
|||||||
* @throws ApplicationManagementException Application Management Exception
|
* @throws ApplicationManagementException Application Management Exception
|
||||||
*/
|
*/
|
||||||
Application createApplication(Application application)
|
Application createApplication(Application application)
|
||||||
throws ApplicationManagementException, DeviceManagementDAOException;
|
throws ApplicationManagementException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates an already existing application.
|
* Updates an already existing application.
|
||||||
|
|||||||
@ -84,12 +84,12 @@ public interface ApplicationReleaseManager {
|
|||||||
/**
|
/**
|
||||||
* To update with a new release for an Application.
|
* To update with a new release for an Application.
|
||||||
*
|
*
|
||||||
* @param applicationUuid UUID of the Application
|
* @param appId ID of the Application
|
||||||
* @param applicationRelease ApplicationRelease
|
* @param applicationRelease ApplicationRelease
|
||||||
* @return Updated Application Release.
|
* @return Updated Application Release.
|
||||||
* @throws ApplicationManagementException Application Management Exception.
|
* @throws ApplicationManagementException Application Management Exception.
|
||||||
*/
|
*/
|
||||||
ApplicationRelease updateRelease(String applicationUuid, ApplicationRelease applicationRelease)
|
ApplicationRelease updateRelease(int appId, ApplicationRelease applicationRelease)
|
||||||
throws ApplicationManagementException;
|
throws ApplicationManagementException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -21,6 +21,7 @@ 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.ApplicationRelease;
|
||||||
import org.wso2.carbon.device.application.mgt.common.ImageArtifact;
|
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.ApplicationStorageManagementException;
|
||||||
import org.wso2.carbon.device.application.mgt.common.exception.ResourceManagementException;
|
import org.wso2.carbon.device.application.mgt.common.exception.ResourceManagementException;
|
||||||
|
|
||||||
@ -43,6 +44,20 @@ public interface ApplicationStorageManager {
|
|||||||
ApplicationRelease uploadImageArtifacts(int applicationId, ApplicationRelease applicationRelease,
|
ApplicationRelease uploadImageArtifacts(int applicationId, ApplicationRelease applicationRelease,
|
||||||
InputStream iconFile, InputStream bannerFile, List<InputStream> screenshots) throws ResourceManagementException;
|
InputStream iconFile, InputStream bannerFile, List<InputStream> screenshots) throws ResourceManagementException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To upload image artifacts related with an Application.
|
||||||
|
*
|
||||||
|
* @param applicationId ID of the application
|
||||||
|
* @param uuid Unique Identifier of the application
|
||||||
|
* @param iconFile Icon File input stream
|
||||||
|
* @param bannerFile Banner File input stream
|
||||||
|
* @param screenshots Input Streams of screenshots
|
||||||
|
* @throws ResourceManagementException Resource Management Exception.
|
||||||
|
*/
|
||||||
|
ApplicationRelease updateImageArtifacts(int applicationId, String uuid, InputStream iconFile,
|
||||||
|
InputStream bannerFile, List<InputStream> screenshots)
|
||||||
|
throws ResourceManagementException, ApplicationManagementException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To upload release artifacts for an Application.
|
* To upload release artifacts for an Application.
|
||||||
*
|
*
|
||||||
@ -54,6 +69,17 @@ public interface ApplicationStorageManager {
|
|||||||
ApplicationRelease uploadReleaseArtifacts(int applicationId, ApplicationRelease applicationRelease, InputStream binaryFile)
|
ApplicationRelease uploadReleaseArtifacts(int applicationId, ApplicationRelease applicationRelease, InputStream binaryFile)
|
||||||
throws ResourceManagementException;
|
throws ResourceManagementException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To upload release artifacts for an Application.
|
||||||
|
*
|
||||||
|
* @param applicationId Id of the application.
|
||||||
|
* @param applicationUuid UUID of the application related with the release.
|
||||||
|
* @param binaryFile Binary File for the release.
|
||||||
|
* @throws ResourceManagementException Resource Management Exception.
|
||||||
|
*/
|
||||||
|
ApplicationRelease updateReleaseArtifacts(int applicationId, String applicationUuid, InputStream binaryFile)
|
||||||
|
throws ResourceManagementException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To get released artifacts for the particular version of the application.
|
* To get released artifacts for the particular version of the application.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -28,9 +28,9 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface LifecycleStateManager {
|
public interface LifecycleStateManager {
|
||||||
|
|
||||||
List<LifecycleState> getLifecycleStates() throws LifecycleManagementException;
|
List<LifecycleState> getLifecycleStates(int appReleaseId) throws LifecycleManagementException;
|
||||||
|
|
||||||
void addLifecycleState(LifecycleState state) throws LifecycleManagementException;
|
void addLifecycleState(LifecycleState state) throws LifecycleManagementException;
|
||||||
|
|
||||||
void deleteLifecycleState(String identifier) throws LifecycleManagementException;
|
void deleteLifecycleState(int identifier) throws LifecycleManagementException;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -78,7 +78,10 @@
|
|||||||
org.wso2.carbon,
|
org.wso2.carbon,
|
||||||
org.apache.commons.io,
|
org.apache.commons.io,
|
||||||
org.apache.commons.codec.binary;version="${commons-codec.wso2.osgi.version.range}",
|
org.apache.commons.codec.binary;version="${commons-codec.wso2.osgi.version.range}",
|
||||||
org.wso2.carbon.base
|
org.apache.commons.codec.digest;version="${commons-codec.wso2.osgi.version.range}",
|
||||||
|
org.wso2.carbon.base,
|
||||||
|
org.wso2.carbon.device.mgt.core.dto.*;version="${carbon.device.mgt.version}",
|
||||||
|
org.wso2.carbon.device.mgt.core.dao.*;version="${carbon.device.mgt.version}"
|
||||||
</Import-Package>
|
</Import-Package>
|
||||||
<Export-Package>
|
<Export-Package>
|
||||||
!org.wso2.carbon.device.application.mgt.core.internal.*,
|
!org.wso2.carbon.device.application.mgt.core.internal.*,
|
||||||
|
|||||||
@ -22,6 +22,7 @@ package org.wso2.carbon.device.application.mgt.core.dao.impl.application.release
|
|||||||
import org.wso2.carbon.device.application.mgt.common.ApplicationRelease;
|
import org.wso2.carbon.device.application.mgt.common.ApplicationRelease;
|
||||||
import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException;
|
import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException;
|
||||||
import org.wso2.carbon.device.application.mgt.core.dao.ApplicationReleaseDAO;
|
import org.wso2.carbon.device.application.mgt.core.dao.ApplicationReleaseDAO;
|
||||||
|
import org.wso2.carbon.device.application.mgt.core.dao.common.ApplicationManagementDAOFactory;
|
||||||
import org.wso2.carbon.device.application.mgt.core.dao.common.Util;
|
import org.wso2.carbon.device.application.mgt.core.dao.common.Util;
|
||||||
import org.wso2.carbon.device.application.mgt.core.dao.impl.AbstractDAOImpl;
|
import org.wso2.carbon.device.application.mgt.core.dao.impl.AbstractDAOImpl;
|
||||||
import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException;
|
import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException;
|
||||||
@ -104,7 +105,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|||||||
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ApplicationRelease getRelease(String applicationName,String applicationType, String versionName,
|
public ApplicationRelease getRelease(String applicationName, String applicationType, String versionName,
|
||||||
String releaseType, int tenantId) throws ApplicationManagementDAOException {
|
String releaseType, int tenantId) throws ApplicationManagementDAOException {
|
||||||
|
|
||||||
Connection connection;
|
Connection connection;
|
||||||
@ -133,7 +134,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|||||||
|
|
||||||
if (resultSet.next()) {
|
if (resultSet.next()) {
|
||||||
applicationRelease = new ApplicationRelease();
|
applicationRelease = new ApplicationRelease();
|
||||||
applicationRelease.setId(resultSet.getInt("RELESE_ID"));
|
applicationRelease.setId(resultSet.getInt("RELEASE_ID"));
|
||||||
applicationRelease.setVersion(resultSet.getString("RELEASE_VERSION"));
|
applicationRelease.setVersion(resultSet.getString("RELEASE_VERSION"));
|
||||||
applicationRelease.setUuid(resultSet.getString("UUID"));
|
applicationRelease.setUuid(resultSet.getString("UUID"));
|
||||||
applicationRelease.setReleaseType(resultSet.getString("RELEASE_TYPE"));
|
applicationRelease.setReleaseType(resultSet.getString("RELEASE_TYPE"));
|
||||||
@ -221,7 +222,11 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|||||||
applicationRelease.setPublishedBy(resultSet.getString("PUBLISHED_BY"));
|
applicationRelease.setPublishedBy(resultSet.getString("PUBLISHED_BY"));
|
||||||
applicationRelease.setPublishedAt(resultSet.getTimestamp("PUBLISHED_AT"));
|
applicationRelease.setPublishedAt(resultSet.getTimestamp("PUBLISHED_AT"));
|
||||||
applicationRelease.setStarts(resultSet.getInt("STARS"));
|
applicationRelease.setStarts(resultSet.getInt("STARS"));
|
||||||
applicationReleases.add(applicationRelease);
|
if ("REMOVED".equals(ApplicationManagementDAOFactory.getLifecycleStateDAO().
|
||||||
|
getLatestLifeCycleStateByReleaseID(applicationRelease.getId()).getCurrentState())){
|
||||||
|
applicationReleases.add(applicationRelease);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return applicationReleases;
|
return applicationReleases;
|
||||||
} catch (DBConnectionException e) {
|
} catch (DBConnectionException e) {
|
||||||
|
|||||||
@ -31,46 +31,46 @@ import java.sql.SQLException;
|
|||||||
*/
|
*/
|
||||||
public class OracleApplicationDAOImpl extends GenericApplicationDAOImpl {
|
public class OracleApplicationDAOImpl extends GenericApplicationDAOImpl {
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
protected PreparedStatement generateGetApplicationsStatement(Filter filter, Connection conn,
|
// protected PreparedStatement generateGetApplicationsStatement(Filter filter, Connection conn,
|
||||||
int tenantId) throws SQLException {
|
// int tenantId) throws SQLException {
|
||||||
int index = 0;
|
// int index = 0;
|
||||||
String sql = "SELECT APP.*, APL.NAME AS APL_NAME, APL.IDENTIFIER AS APL_IDENTIFIER, CAT.ID AS CAT_ID, "
|
// String sql = "SELECT APP.*, APL.NAME AS APL_NAME, APL.IDENTIFIER AS APL_IDENTIFIER, CAT.ID AS CAT_ID, "
|
||||||
+ "CAT.NAME AS CAT_NAME, LS.NAME AS LS_NAME, LS.IDENTIFIER AS LS_IDENTIFIER, "
|
// + "CAT.NAME AS CAT_NAME, LS.NAME AS LS_NAME, LS.IDENTIFIER AS LS_IDENTIFIER, "
|
||||||
+ "LS.DESCRIPTION AS LS_DESCRIPTION " + "FROM APPM_APPLICATION APP " + "INNER JOIN APPM_PLATFORM APL "
|
// + "LS.DESCRIPTION AS LS_DESCRIPTION " + "FROM APPM_APPLICATION APP " + "INNER JOIN APPM_PLATFORM APL "
|
||||||
+ "ON APP.PLATFORM_ID = APL.ID " + "INNER JOIN APPM_APPLICATION_CATEGORY CAT "
|
// + "ON APP.PLATFORM_ID = APL.ID " + "INNER JOIN APPM_APPLICATION_CATEGORY CAT "
|
||||||
+ "ON APP.APPLICATION_CATEGORY_ID = CAT.ID " + "INNER JOIN APPM_LIFECYCLE_STATE LS "
|
// + "ON APP.APPLICATION_CATEGORY_ID = CAT.ID " + "INNER JOIN APPM_LIFECYCLE_STATE LS "
|
||||||
+ "ON APP.LIFECYCLE_STATE_ID = LS.ID WHERE APP.TENANT_ID = ? ";
|
// + "ON APP.LIFECYCLE_STATE_ID = LS.ID WHERE APP.TENANT_ID = ? ";
|
||||||
|
//
|
||||||
String userName = filter.getUserName();
|
// String userName = filter.getUserName();
|
||||||
if (!userName.equals("ALL")) {
|
// if (!userName.equals("ALL")) {
|
||||||
sql += " AND APP.CREATED_BY = ? ";
|
// sql += " AND APP.CREATED_BY = ? ";
|
||||||
}
|
// }
|
||||||
if (filter.getSearchQuery() != null && !filter.getSearchQuery().isEmpty()) {
|
// if (filter.getSearchQuery() != null && !filter.getSearchQuery().isEmpty()) {
|
||||||
sql += "AND LOWER (APP.NAME) ";
|
// sql += "AND LOWER (APP.NAME) ";
|
||||||
if (filter.isFullMatch()) {
|
// if (filter.isFullMatch()) {
|
||||||
sql += "= ?";
|
// sql += "= ?";
|
||||||
} else {
|
// } else {
|
||||||
sql += "LIKE ?";
|
// sql += "LIKE ?";
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
sql += " ORDER BY APP.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
|
// sql += " ORDER BY APP.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
|
||||||
PreparedStatement stmt = conn.prepareStatement(sql);
|
// PreparedStatement stmt = conn.prepareStatement(sql);
|
||||||
stmt.setInt(++index, tenantId);
|
// stmt.setInt(++index, tenantId);
|
||||||
|
//
|
||||||
if (!userName.equals("ALL")) {
|
// if (!userName.equals("ALL")) {
|
||||||
stmt.setString(++index, userName);
|
// stmt.setString(++index, userName);
|
||||||
}
|
// }
|
||||||
if (filter.getSearchQuery() != null && !filter.getSearchQuery().isEmpty()) {
|
// if (filter.getSearchQuery() != null && !filter.getSearchQuery().isEmpty()) {
|
||||||
if (filter.isFullMatch()) {
|
// if (filter.isFullMatch()) {
|
||||||
stmt.setString(++index, filter.getSearchQuery().toLowerCase());
|
// stmt.setString(++index, filter.getSearchQuery().toLowerCase());
|
||||||
} else {
|
// } else {
|
||||||
stmt.setString(++index, "%" + filter.getSearchQuery().toLowerCase() + "%");
|
// stmt.setString(++index, "%" + filter.getSearchQuery().toLowerCase() + "%");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
stmt.setInt(++index, filter.getOffset());
|
// stmt.setInt(++index, filter.getOffset());
|
||||||
stmt.setInt(++index, filter.getLimit());
|
// stmt.setInt(++index, filter.getLimit());
|
||||||
return stmt;
|
// return stmt;
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,8 +66,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Application createApplication(Application application)
|
public Application createApplication(Application application) throws ApplicationManagementException {
|
||||||
throws ApplicationManagementException, DeviceManagementDAOException {
|
|
||||||
|
|
||||||
User loggedInUser = new User(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(),
|
User loggedInUser = new User(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(),
|
||||||
PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true));
|
PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true));
|
||||||
@ -112,7 +111,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
String msg = "Error occurred while getting device type id of " + application.getType();
|
String msg = "Error occurred while getting device type id of " + application.getType();
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
ConnectionManagerUtil.rollbackDBTransaction();
|
ConnectionManagerUtil.rollbackDBTransaction();
|
||||||
throw new DeviceManagementDAOException(msg, e);
|
throw new ApplicationManagementException(msg, e);
|
||||||
} catch(ApplicationManagementException e){
|
} catch(ApplicationManagementException e){
|
||||||
String msg = "Error occurred while adding application";
|
String msg = "Error occurred while adding application";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
|
|||||||
@ -45,7 +45,7 @@ public class ApplicationReleaseManagerImpl implements ApplicationReleaseManager
|
|||||||
public ApplicationRelease createRelease(int applicationId, ApplicationRelease applicationRelease) throws
|
public ApplicationRelease createRelease(int applicationId, ApplicationRelease applicationRelease) throws
|
||||||
ApplicationManagementException {
|
ApplicationManagementException {
|
||||||
Application application = validateApplication(applicationId);
|
Application application = validateApplication(applicationId);
|
||||||
validateReleaseCreateRequest(applicationRelease.getUuid(), applicationRelease);
|
validateReleaseCreateRequest(applicationRelease);
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Application release request is received for the application " + application.toString());
|
log.debug("Application release request is received for the application " + application.toString());
|
||||||
}
|
}
|
||||||
@ -64,24 +64,27 @@ public class ApplicationReleaseManagerImpl implements ApplicationReleaseManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//todo
|
||||||
@Override
|
@Override
|
||||||
public ApplicationRelease getRelease(String applicationUuid, String version, String releaseType) throws
|
public ApplicationRelease getRelease(String applicationUuid, String version, String releaseType) throws
|
||||||
ApplicationManagementException {
|
ApplicationManagementException {
|
||||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
return null;
|
||||||
Application application = validateApplicationRelease(applicationUuid);
|
// int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
||||||
if (log.isDebugEnabled()) {
|
// Application application = validateApplicationRelease(applicationUuid);
|
||||||
log.debug("Application release retrieval request is received for the application " +
|
// if (log.isDebugEnabled()) {
|
||||||
application.toString() + " and version " + version);
|
// log.debug("Application release retrieval request is received for the application " +
|
||||||
}
|
// application.toString() + " and version " + version);
|
||||||
try {
|
// }
|
||||||
ConnectionManagerUtil.openDBConnection();
|
// try {
|
||||||
return ApplicationManagementDAOFactory.getApplicationReleaseDAO()
|
// ConnectionManagerUtil.openDBConnection();
|
||||||
.getRelease(application.getName(), application.getType(), version, releaseType, tenantId );
|
// return ApplicationManagementDAOFactory.getApplicationReleaseDAO()
|
||||||
} finally {
|
// .getRelease(application.getName(), application.getType(), version, releaseType, tenantId );
|
||||||
ConnectionManagerUtil.closeDBConnection();
|
// } finally {
|
||||||
}
|
// ConnectionManagerUtil.closeDBConnection();
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//todo
|
||||||
@Override public ApplicationRelease getReleaseByUuid(String applicationUuid) throws ApplicationManagementException {
|
@Override public ApplicationRelease getReleaseByUuid(String applicationUuid) throws ApplicationManagementException {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -130,7 +133,7 @@ public class ApplicationReleaseManagerImpl implements ApplicationReleaseManager
|
|||||||
|
|
||||||
// ToDo
|
// ToDo
|
||||||
@Override
|
@Override
|
||||||
public ApplicationRelease updateRelease(String applicationUuid, ApplicationRelease applicationRelease)
|
public ApplicationRelease updateRelease(int appId, ApplicationRelease applicationRelease)
|
||||||
throws ApplicationManagementException {
|
throws ApplicationManagementException {
|
||||||
// Application application = validateApplicationRelease(applicationUuid);
|
// Application application = validateApplicationRelease(applicationUuid);
|
||||||
// ApplicationRelease oldApplicationRelease = null;
|
// ApplicationRelease oldApplicationRelease = null;
|
||||||
@ -162,36 +165,38 @@ public class ApplicationReleaseManagerImpl implements ApplicationReleaseManager
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//todo
|
||||||
@Override
|
@Override
|
||||||
public void deleteApplicationRelease(String applicationUuid, String version, String releaseType)
|
public void deleteApplicationRelease(String applicationUuid, String version, String releaseType)
|
||||||
throws ApplicationManagementException {
|
throws ApplicationManagementException {
|
||||||
Application application = validateApplicationRelease(applicationUuid);
|
// Application application = validateApplicationRelease(applicationUuid);
|
||||||
ApplicationRelease applicationRelease = getRelease(applicationUuid, version, releaseType);
|
// ApplicationRelease applicationRelease = getRelease(applicationUuid, version, releaseType);
|
||||||
if (applicationRelease == null) {
|
// if (applicationRelease == null) {
|
||||||
throw new ApplicationManagementException(
|
// throw new ApplicationManagementException(
|
||||||
"Cannot delete a non-existing application release for the " + "application with UUID "
|
// "Cannot delete a non-existing application release for the " + "application with UUID "
|
||||||
+ applicationUuid);
|
// + applicationUuid);
|
||||||
}
|
// }
|
||||||
try {
|
// try {
|
||||||
ConnectionManagerUtil.beginDBTransaction();
|
// ConnectionManagerUtil.beginDBTransaction();
|
||||||
ApplicationManagementDAOFactory.getApplicationReleaseDAO().deleteRelease(application.getId(), version);
|
// ApplicationManagementDAOFactory.getApplicationReleaseDAO().deleteRelease(application.getId(), version);
|
||||||
// ToDO remove storage details as well
|
//// ToDO remove storage details as well
|
||||||
ConnectionManagerUtil.commitDBTransaction();
|
// ConnectionManagerUtil.commitDBTransaction();
|
||||||
} catch (ApplicationManagementDAOException e) {
|
// } catch (ApplicationManagementDAOException e) {
|
||||||
ConnectionManagerUtil.rollbackDBTransaction();
|
// ConnectionManagerUtil.rollbackDBTransaction();
|
||||||
throw e;
|
// throw e;
|
||||||
} finally {
|
// } finally {
|
||||||
ConnectionManagerUtil.closeDBConnection();
|
// ConnectionManagerUtil.closeDBConnection();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//todo
|
||||||
@Override
|
@Override
|
||||||
public void deleteApplicationReleases(String applicationUuid) throws ApplicationManagementException {
|
public void deleteApplicationReleases(String applicationUuid) throws ApplicationManagementException {
|
||||||
List<ApplicationRelease> applicationReleases = getReleases(applicationUuid);
|
// List<ApplicationRelease> applicationReleases = getReleases(applicationUuid);
|
||||||
|
//
|
||||||
for (ApplicationRelease applicationRelease : applicationReleases) {
|
// for (ApplicationRelease applicationRelease : applicationReleases) {
|
||||||
deleteApplicationRelease(applicationUuid, applicationRelease.getVersion());
|
// deleteApplicationRelease(applicationUuid, applicationRelease.getVersion());
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -224,7 +229,8 @@ public class ApplicationReleaseManagerImpl implements ApplicationReleaseManager
|
|||||||
throw new ApplicationManagementException("Application UUID is null. Application UUID is a required "
|
throw new ApplicationManagementException("Application UUID is null. Application UUID is a required "
|
||||||
+ "parameter to get the relevant application.");
|
+ "parameter to get the relevant application.");
|
||||||
}
|
}
|
||||||
ApplicationRelease applicationRelease = DataHolder.getInstance().getApplicationReleaseManager().getRelease();
|
ApplicationRelease applicationRelease = DataHolder.getInstance().getApplicationReleaseManager()
|
||||||
|
.getReleaseByUuid(applicationUuid);
|
||||||
if (applicationRelease == null) {
|
if (applicationRelease == null) {
|
||||||
throw new NotFoundException(
|
throw new NotFoundException(
|
||||||
"Application with UUID " + applicationUuid + " does not exist.");
|
"Application with UUID " + applicationUuid + " does not exist.");
|
||||||
@ -235,21 +241,20 @@ public class ApplicationReleaseManagerImpl implements ApplicationReleaseManager
|
|||||||
/**
|
/**
|
||||||
* To validate a create release request to make sure all the pre-conditions satisfied.
|
* To validate a create release request to make sure all the pre-conditions satisfied.
|
||||||
*
|
*
|
||||||
* @param applicationUuid UUID of the Application.
|
|
||||||
* @param applicationRelease ApplicationRelease that need to be created.
|
* @param applicationRelease ApplicationRelease that need to be created.
|
||||||
* @throws ApplicationManagementException Application Management Exception.
|
* @throws ApplicationManagementException Application Management Exception.
|
||||||
*/
|
*/
|
||||||
private void validateReleaseCreateRequest(String applicationUuid, ApplicationRelease applicationRelease)
|
private void validateReleaseCreateRequest(ApplicationRelease applicationRelease)
|
||||||
throws ApplicationManagementException {
|
throws ApplicationManagementException {
|
||||||
if (applicationRelease == null || applicationRelease.getVersion() == null) {
|
if (applicationRelease == null || applicationRelease.getVersion() == null) {
|
||||||
throw new ApplicationManagementException("ApplicationRelease version name is a mandatory parameter for "
|
throw new ApplicationManagementException("ApplicationRelease version name is a mandatory parameter for "
|
||||||
+ "creating release. It cannot be found.");
|
+ "creating release. It cannot be found.");
|
||||||
}
|
}
|
||||||
if (getRelease(applicationUuid, applicationRelease.getVersion()) != null) {
|
if (getRelease(applicationRelease.getUuid(), applicationRelease.getVersion(),
|
||||||
throw new ApplicationManagementException(
|
applicationRelease.getReleaseType()) != null) {
|
||||||
"Application Release for the Application UUID " + applicationUuid + " " + "with the version "
|
throw new ApplicationManagementException( "Application Release for the Application UUID " +
|
||||||
+ applicationRelease.getVersion() + " already exists. Cannot create an "
|
applicationRelease.getUuid() + " " + "with the version " + applicationRelease.getVersion() +
|
||||||
+ "application release with the same version.");
|
" already exists. Cannot create an " + "application release with the same version.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -117,8 +117,6 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
|
|||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return applicationRelease;
|
return applicationRelease;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -126,7 +124,32 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
|
|||||||
"IO Exception while saving the screens hots for the " + "application " + applicationId, e);
|
"IO Exception while saving the screens hots for the " + "application " + applicationId, e);
|
||||||
} catch (ApplicationStorageManagementException e) {
|
} catch (ApplicationStorageManagementException e) {
|
||||||
ConnectionManagerUtil.rollbackDBTransaction();
|
ConnectionManagerUtil.rollbackDBTransaction();
|
||||||
throw new ApplicationStorageManagementException("Application Management DAO exception while trying to"
|
throw new ApplicationStorageManagementException("Application Management DAO exception while trying to "
|
||||||
|
+ "update the screen-shot count for the application " + applicationId + " for the tenant id "
|
||||||
|
+ tenantId, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ApplicationRelease updateImageArtifacts(int applicationId, String uuid, InputStream iconFileStream,
|
||||||
|
InputStream bannerFileStream, List<InputStream> screenShotStreams)
|
||||||
|
throws ResourceManagementException, ApplicationManagementException {
|
||||||
|
|
||||||
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
||||||
|
|
||||||
|
try {
|
||||||
|
ApplicationRelease applicationRelease = validateApplicationRelease(uuid);
|
||||||
|
applicationRelease = uploadImageArtifacts(applicationId, applicationRelease, iconFileStream, bannerFileStream, screenShotStreams);
|
||||||
|
return applicationRelease;
|
||||||
|
} catch (ApplicationStorageManagementException e) {
|
||||||
|
ConnectionManagerUtil.rollbackDBTransaction();
|
||||||
|
throw new ApplicationStorageManagementException("Application Storage exception while trying to"
|
||||||
|
+ " update the screen-shot count for the application " + applicationId + " for the tenant "
|
||||||
|
+ tenantId, e);
|
||||||
|
} catch (ApplicationManagementException e) {
|
||||||
|
ConnectionManagerUtil.rollbackDBTransaction();
|
||||||
|
throw new ApplicationManagementException("Application Management DAO exception while trying to"
|
||||||
+ " update the screen-shot count for the application " + applicationId + " for the tenant "
|
+ " update the screen-shot count for the application " + applicationId + " for the tenant "
|
||||||
+ tenantId, e);
|
+ tenantId, e);
|
||||||
}
|
}
|
||||||
@ -167,100 +190,125 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InputStream getReleasedArtifacts(String applicationUUID, String versionName)
|
public ApplicationRelease updateReleaseArtifacts(int applicationId, String applicationUuid, InputStream binaryFile)
|
||||||
throws ApplicationStorageManagementException {
|
throws ResourceManagementException {
|
||||||
// todo this should be validate application release
|
|
||||||
Application application = validateApplication(applicationUUID);
|
|
||||||
String artifactPath = storagePath + application.getId() + File.separator + versionName;
|
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
||||||
log.debug("ApplicationRelease artifacts are searched in the location " + artifactPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
File binaryFile = new File(artifactPath);
|
ApplicationRelease applicationRelease = null;
|
||||||
|
try {
|
||||||
if (!binaryFile.exists()) {
|
applicationRelease = validateApplicationRelease(applicationUuid);
|
||||||
throw new ApplicationStorageManagementException("Binary file does not exist for this release");
|
applicationRelease = uploadReleaseArtifacts(applicationId, applicationRelease,binaryFile);
|
||||||
} else {
|
return applicationRelease;
|
||||||
try {
|
} catch (ApplicationManagementException e) {
|
||||||
return new FileInputStream(artifactPath);
|
throw new ApplicationStorageManagementException("Application Management exception while trying to"
|
||||||
} catch (FileNotFoundException e) {
|
+ " update the Application artifact for the application " + applicationId + " for the tenant "
|
||||||
throw new ApplicationStorageManagementException(
|
+ tenantId, e);
|
||||||
"Binary file does not exist for the version " + versionName + " for the application ", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//todo
|
||||||
|
@Override
|
||||||
|
public InputStream getReleasedArtifacts(String applicationUUID, String versionName)
|
||||||
|
throws ApplicationStorageManagementException {
|
||||||
|
return null;
|
||||||
|
// todo this should be validate application release
|
||||||
|
// Application application = validateApplication(applicationUUID);
|
||||||
|
// String artifactPath = storagePath + application.getId() + File.separator + versionName;
|
||||||
|
//
|
||||||
|
// if (log.isDebugEnabled()) {
|
||||||
|
// log.debug("ApplicationRelease artifacts are searched in the location " + artifactPath);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// File binaryFile = new File(artifactPath);
|
||||||
|
//
|
||||||
|
// if (!binaryFile.exists()) {
|
||||||
|
// throw new ApplicationStorageManagementException("Binary file does not exist for this release");
|
||||||
|
// } else {
|
||||||
|
// try {
|
||||||
|
// return new FileInputStream(artifactPath);
|
||||||
|
// } catch (FileNotFoundException e) {
|
||||||
|
// throw new ApplicationStorageManagementException(
|
||||||
|
// "Binary file does not exist for the version " + versionName + " for the application ", e);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
//todo
|
||||||
@Override
|
@Override
|
||||||
public void deleteApplicationArtifacts(String applicationUUID) throws ApplicationStorageManagementException {
|
public void deleteApplicationArtifacts(String applicationUUID) throws ApplicationStorageManagementException {
|
||||||
// todo this should be validate application release
|
// todo this should be validate application release
|
||||||
Application application = validateApplication(applicationUUID);
|
// Application application = validateApplication(applicationUUID);
|
||||||
String artifactDirectoryPath = storagePath + application.getId();
|
// String artifactDirectoryPath = storagePath + application.getId();
|
||||||
File artifactDirectory = new File(artifactDirectoryPath);
|
// File artifactDirectory = new File(artifactDirectoryPath);
|
||||||
|
//
|
||||||
if (artifactDirectory.exists()) {
|
// if (artifactDirectory.exists()) {
|
||||||
StorageManagementUtil.deleteDir(artifactDirectory);
|
// StorageManagementUtil.deleteDir(artifactDirectory);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//todo
|
||||||
@Override
|
@Override
|
||||||
public void deleteApplicationReleaseArtifacts(String applicationUUID, String version)
|
public void deleteApplicationReleaseArtifacts(String applicationUUID, String version)
|
||||||
throws ApplicationStorageManagementException {
|
throws ApplicationStorageManagementException {
|
||||||
// todo this should be validate application release
|
// todo this should be validate application release
|
||||||
Application application = validateApplication(applicationUUID);
|
// Application application = validateApplication(applicationUUID);
|
||||||
String artifactPath = storagePath + application.getId() + File.separator + version;
|
// String artifactPath = storagePath + application.getId() + File.separator + version;
|
||||||
File artifact = new File(artifactPath);
|
// File artifact = new File(artifactPath);
|
||||||
|
//
|
||||||
if (artifact.exists()) {
|
// if (artifact.exists()) {
|
||||||
StorageManagementUtil.deleteDir(artifact);
|
// StorageManagementUtil.deleteDir(artifact);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//todo
|
||||||
@Override
|
@Override
|
||||||
public void deleteAllApplicationReleaseArtifacts(String applicationUUID) throws
|
public void deleteAllApplicationReleaseArtifacts(String applicationUUID) throws
|
||||||
ApplicationStorageManagementException {
|
ApplicationStorageManagementException {
|
||||||
// todo this should be validate application release
|
// todo this should be validate application release
|
||||||
validateApplication(applicationUUID);
|
// validateApplication(applicationUUID);
|
||||||
try {
|
// try {
|
||||||
List<ApplicationRelease> applicationReleases = DataHolder.getInstance().getApplicationReleaseManager()
|
// List<ApplicationRelease> applicationReleases = DataHolder.getInstance().getApplicationReleaseManager()
|
||||||
.getReleases(applicationUUID);
|
// .getReleases(applicationUUID);
|
||||||
for (ApplicationRelease applicationRelease : applicationReleases) {
|
// for (ApplicationRelease applicationRelease : applicationReleases) {
|
||||||
deleteApplicationReleaseArtifacts(applicationUUID, applicationRelease.getVersion());
|
// deleteApplicationReleaseArtifacts(applicationUUID, applicationRelease.getVersion());
|
||||||
}
|
// }
|
||||||
} catch (ApplicationManagementException e) {
|
// } catch (ApplicationManagementException e) {
|
||||||
throw new ApplicationStorageManagementException(
|
// throw new ApplicationStorageManagementException(
|
||||||
"Application Management Exception while getting releases " + "for the application "
|
// "Application Management Exception while getting releases " + "for the application "
|
||||||
+ applicationUUID, e);
|
// + applicationUUID, e);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//todo
|
||||||
@Override
|
@Override
|
||||||
public ImageArtifact getImageArtifact(String applicationUUID, String name, int count) throws
|
public ImageArtifact getImageArtifact(String applicationUUID, String name, int count) throws
|
||||||
ApplicationStorageManagementException {
|
ApplicationStorageManagementException {
|
||||||
|
return null;
|
||||||
// todo this should be validate application release
|
// todo this should be validate application release
|
||||||
Application application = validateApplication(applicationUUID);
|
// Application application = validateApplication(applicationUUID);
|
||||||
validateImageArtifactNames(name);
|
// validateImageArtifactNames(name);
|
||||||
String imageArtifactPath = storagePath + application.getId() + File.separator + name.toLowerCase();
|
// String imageArtifactPath = storagePath + application.getId() + File.separator + name.toLowerCase();
|
||||||
|
//
|
||||||
if (name.equalsIgnoreCase(Constants.IMAGE_ARTIFACTS[2])) {
|
// if (name.equalsIgnoreCase(Constants.IMAGE_ARTIFACTS[2])) {
|
||||||
imageArtifactPath += count;
|
// imageArtifactPath += count;
|
||||||
}
|
// }
|
||||||
File imageFile = new File(imageArtifactPath);
|
// File imageFile = new File(imageArtifactPath);
|
||||||
if (!imageFile.exists()) {
|
// if (!imageFile.exists()) {
|
||||||
throw new ApplicationStorageManagementException(
|
// throw new ApplicationStorageManagementException(
|
||||||
"Image artifact " + name + " does not exist for the " + "application with UUID " + applicationUUID);
|
// "Image artifact " + name + " does not exist for the " + "application with UUID " + applicationUUID);
|
||||||
} else {
|
// } else {
|
||||||
try {
|
// try {
|
||||||
return StorageManagementUtil.createImageArtifact(imageFile, imageArtifactPath);
|
// return StorageManagementUtil.createImageArtifact(imageFile, imageArtifactPath);
|
||||||
} catch (FileNotFoundException e) {
|
// } catch (FileNotFoundException e) {
|
||||||
throw new ApplicationStorageManagementException(
|
// throw new ApplicationStorageManagementException(
|
||||||
"File not found exception while trying to get the image artifact " + name + " for the "
|
// "File not found exception while trying to get the image artifact " + name + " for the "
|
||||||
+ "application " + applicationUUID, e);
|
// + "application " + applicationUUID, e);
|
||||||
} catch (IOException e) {
|
// } catch (IOException e) {
|
||||||
throw new ApplicationStorageManagementException("IO Exception while trying to detect the image "
|
// throw new ApplicationStorageManagementException("IO Exception while trying to detect the image "
|
||||||
+ "artifact " + name + " for the application " + applicationUUID, e);
|
// + "artifact " + name + " for the application " + applicationUUID, e);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -311,7 +359,8 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
|
|||||||
throw new ApplicationManagementException("Application UUID is null. Application UUID is a required "
|
throw new ApplicationManagementException("Application UUID is null. Application UUID is a required "
|
||||||
+ "parameter to get the relevant application.");
|
+ "parameter to get the relevant application.");
|
||||||
}
|
}
|
||||||
ApplicationRelease applicationRelease = DataHolder.getInstance().getApplicationReleaseManager().getRelease();
|
ApplicationRelease applicationRelease = DataHolder.getInstance().getApplicationReleaseManager().
|
||||||
|
getReleaseByUuid(applicationUuid);
|
||||||
if (applicationRelease == null) {
|
if (applicationRelease == null) {
|
||||||
throw new NotFoundException(
|
throw new NotFoundException(
|
||||||
"Application with UUID " + applicationUuid + " does not exist.");
|
"Application with UUID " + applicationUuid + " does not exist.");
|
||||||
|
|||||||
@ -38,12 +38,12 @@ public class LifecycleStateManagerImpl implements LifecycleStateManager {
|
|||||||
private static final Log log = LogFactory.getLog(LifecycleStateManagerImpl.class);
|
private static final Log log = LogFactory.getLog(LifecycleStateManagerImpl.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<LifecycleState> getLifecycleStates() throws LifecycleManagementException {
|
public List<LifecycleState> getLifecycleStates(int appReleaseId) throws LifecycleManagementException {
|
||||||
List<LifecycleState> lifecycleStates = null;
|
List<LifecycleState> lifecycleStates = null;
|
||||||
try {
|
try {
|
||||||
ConnectionManagerUtil.openDBConnection();
|
ConnectionManagerUtil.openDBConnection();
|
||||||
LifecycleStateDAO lifecycleStateDAO = ApplicationManagementDAOFactory.getLifecycleStateDAO();
|
LifecycleStateDAO lifecycleStateDAO = ApplicationManagementDAOFactory.getLifecycleStateDAO();
|
||||||
lifecycleStates = lifecycleStateDAO.getLifecycleStates();
|
lifecycleStates = lifecycleStateDAO.getLifecycleStates(appReleaseId);
|
||||||
} catch (LifeCycleManagementDAOException | DBConnectionException e) {
|
} catch (LifeCycleManagementDAOException | DBConnectionException e) {
|
||||||
throw new LifecycleManagementException("Failed get lifecycle states.", e);
|
throw new LifecycleManagementException("Failed get lifecycle states.", e);
|
||||||
} finally {
|
} finally {
|
||||||
@ -66,7 +66,7 @@ public class LifecycleStateManagerImpl implements LifecycleStateManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteLifecycleState(String identifier) throws LifecycleManagementException {
|
public void deleteLifecycleState(int identifier) throws LifecycleManagementException {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ConnectionManagerUtil.openDBConnection();
|
ConnectionManagerUtil.openDBConnection();
|
||||||
|
|||||||
@ -98,52 +98,53 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|||||||
|
|
||||||
private List<DeviceIdentifier> installApplication(String applicationUUID, List<DeviceIdentifier> deviceList,
|
private List<DeviceIdentifier> installApplication(String applicationUUID, List<DeviceIdentifier> deviceList,
|
||||||
String versionName) throws ApplicationManagementException {
|
String versionName) throws ApplicationManagementException {
|
||||||
List<DeviceIdentifier> failedDeviceList = new ArrayList<>(deviceList);
|
return null;
|
||||||
// Todo: try whether we can optimise this by sending bulk inserts to db
|
// List<DeviceIdentifier> failedDeviceList = new ArrayList<>(deviceList);
|
||||||
// Todo: atomicity is not maintained as deveice managment provider service uses separate db connection. fix this??
|
// // Todo: try whether we can optimise this by sending bulk inserts to db
|
||||||
log.info("Install application: " + applicationUUID + "[" + versionName + "]" + " to: "
|
// // Todo: atomicity is not maintained as deveice managment provider service uses separate db connection. fix this??
|
||||||
+ deviceList.size() + " devices.");
|
// log.info("Install application: " + applicationUUID + "[" + versionName + "]" + " to: "
|
||||||
for (DeviceIdentifier device : deviceList) {
|
// + deviceList.size() + " devices.");
|
||||||
org.wso2.carbon.device.mgt.common.DeviceIdentifier deviceIdentifier = new org.wso2.carbon.device.mgt
|
// for (DeviceIdentifier device : deviceList) {
|
||||||
.common.DeviceIdentifier(device.getId(), device.getType());
|
// org.wso2.carbon.device.mgt.common.DeviceIdentifier deviceIdentifier = new org.wso2.carbon.device.mgt
|
||||||
try {
|
// .common.DeviceIdentifier(device.getId(), device.getType());
|
||||||
DeviceManagementProviderService dmpService = HelperUtil.getDeviceManagementProviderService();
|
// try {
|
||||||
if (!dmpService.isEnrolled(deviceIdentifier)) {
|
// DeviceManagementProviderService dmpService = HelperUtil.getDeviceManagementProviderService();
|
||||||
log.error("Device with ID: [" + device.getId() + "] is not enrolled to install the application.");
|
// if (!dmpService.isEnrolled(deviceIdentifier)) {
|
||||||
} else {
|
// log.error("Device with ID: [" + device.getId() + "] is not enrolled to install the application.");
|
||||||
if (log.isDebugEnabled()) {
|
// } else {
|
||||||
log.debug("Installing application to : " + device.getId());
|
// if (log.isDebugEnabled()) {
|
||||||
}
|
// log.debug("Installing application to : " + device.getId());
|
||||||
//Todo: generating one time download link for the application and put install operation to device.
|
// }
|
||||||
|
// //Todo: generating one time download link for the application and put install operation to device.
|
||||||
// put app install operation to the device
|
//
|
||||||
ProfileOperation operation = new ProfileOperation();
|
// // put app install operation to the device
|
||||||
operation.setCode(INSTALL_APPLICATION);
|
// ProfileOperation operation = new ProfileOperation();
|
||||||
operation.setType(Operation.Type.PROFILE);
|
// operation.setCode(INSTALL_APPLICATION);
|
||||||
operation.setPayLoad("{'type':'enterprise', 'url':'http://10.100.5.76:8000/app-debug.apk', 'app':'"
|
// operation.setType(Operation.Type.PROFILE);
|
||||||
+ applicationUUID + "'}");
|
// operation.setPayLoad("{'type':'enterprise', 'url':'http://10.100.5.76:8000/app-debug.apk', 'app':'"
|
||||||
List<org.wso2.carbon.device.mgt.common.DeviceIdentifier> deviceIdentifiers = new ArrayList<>();
|
// + applicationUUID + "'}");
|
||||||
deviceIdentifiers.add(deviceIdentifier);
|
// List<org.wso2.carbon.device.mgt.common.DeviceIdentifier> deviceIdentifiers = new ArrayList<>();
|
||||||
dmpService.addOperation(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID,
|
// deviceIdentifiers.add(deviceIdentifier);
|
||||||
operation, deviceIdentifiers);
|
// dmpService.addOperation(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID,
|
||||||
|
// operation, deviceIdentifiers);
|
||||||
DeviceApplicationMapping deviceApp = new DeviceApplicationMapping();
|
//
|
||||||
deviceApp.setDeviceIdentifier(device.getId());
|
// DeviceApplicationMapping deviceApp = new DeviceApplicationMapping();
|
||||||
deviceApp.setApplicationUUID(applicationUUID);
|
// deviceApp.setDeviceIdentifier(device.getId());
|
||||||
deviceApp.setVersionName(versionName);
|
// deviceApp.setApplicationUUID(applicationUUID);
|
||||||
deviceApp.setInstalled(false);
|
// deviceApp.setVersionName(versionName);
|
||||||
dmpService.addDeviceApplicationMapping(deviceApp);
|
// deviceApp.setInstalled(false);
|
||||||
// DeviceManagementDAOFactory.openConnection();
|
// dmpService.addDeviceApplicationMapping(deviceApp);
|
||||||
// ApplicationManagementDAOFactory.getSubscriptionDAO().addDeviceApplicationMapping(device.getId(), applicationUUID, false);
|
//// DeviceManagementDAOFactory.openConnection();
|
||||||
failedDeviceList.remove(device);
|
//// ApplicationManagementDAOFactory.getSubscriptionDAO().addDeviceApplicationMapping(device.getId(), applicationUUID, false);
|
||||||
}
|
// failedDeviceList.remove(device);
|
||||||
} catch (DeviceManagementException | OperationManagementException | InvalidDeviceException e) {
|
// }
|
||||||
log.error("Error while installing application to device[" + deviceIdentifier.getId() + "]", e);
|
// } catch (DeviceManagementException | OperationManagementException | InvalidDeviceException e) {
|
||||||
}
|
// log.error("Error while installing application to device[" + deviceIdentifier.getId() + "]", e);
|
||||||
|
// }
|
||||||
// finally {
|
// finally {
|
||||||
// DeviceManagementDAOFactory.closeConnection();
|
// DeviceManagementDAOFactory.closeConnection();
|
||||||
// }
|
// }
|
||||||
}
|
// }
|
||||||
return failedDeviceList;
|
// return failedDeviceList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,6 +28,7 @@ import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
//todo need to work on business logic
|
||||||
/**
|
/**
|
||||||
* This is the default implementation for the visibility manager.
|
* This is the default implementation for the visibility manager.
|
||||||
*/
|
*/
|
||||||
@ -35,39 +36,40 @@ public class UnrestrictedRoleManagerImpl implements UnrestrictedRoleManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Visibility put(int applicationID, Visibility visibility) throws VisibilityManagementException {
|
public Visibility put(int applicationID, Visibility visibility) throws VisibilityManagementException {
|
||||||
if (visibility == null) {
|
return null;
|
||||||
visibility = new Visibility();
|
// if (visibility == null) {
|
||||||
visibility.setType(Visibility.Type.PUBLIC);
|
// visibility = new Visibility();
|
||||||
}
|
// visibility.setType(Visibility.Type.PUBLIC);
|
||||||
if (visibility.getAllowedList() == null && !visibility.getType().equals(Visibility.Type.PUBLIC)) {
|
// }
|
||||||
throw new VisibilityManagementException("Visibility is configured for '" + visibility.getType()
|
// if (visibility.getAllowedList() == null && !visibility.getType().equals(Visibility.Type.PUBLIC)) {
|
||||||
+ "' but doesn't have any allowed list provided!");
|
// throw new VisibilityManagementException("Visibility is configured for '" + visibility.getType()
|
||||||
}
|
// + "' but doesn't have any allowed list provided!");
|
||||||
boolean isTransactionStarted = false;
|
// }
|
||||||
try {
|
// boolean isTransactionStarted = false;
|
||||||
isTransactionStarted = ConnectionManagerUtil.isTransactionStarted();
|
// try {
|
||||||
if (!isTransactionStarted) {
|
// isTransactionStarted = ConnectionManagerUtil.isTransactionStarted();
|
||||||
ConnectionManagerUtil.beginDBTransaction();
|
// if (!isTransactionStarted) {
|
||||||
}
|
// ConnectionManagerUtil.beginDBTransaction();
|
||||||
VisibilityDAO visibilityDAO = ApplicationManagementDAOFactory.getVisibilityDAO();
|
// }
|
||||||
int visibilityTypeId = visibilityDAO.getVisibilityID(visibility.getType());
|
// VisibilityDAO visibilityDAO = ApplicationManagementDAOFactory.getVisibilityDAO();
|
||||||
visibilityDAO.delete(applicationID);
|
// int visibilityTypeId = visibilityDAO.getVisibilityID(visibility.getType());
|
||||||
visibilityDAO.add(applicationID, visibilityTypeId, visibility.getAllowedList());
|
// visibilityDAO.delete(applicationID);
|
||||||
if (!isTransactionStarted) {
|
// visibilityDAO.add(applicationID, visibilityTypeId, visibility.getAllowedList());
|
||||||
ConnectionManagerUtil.commitDBTransaction();
|
// if (!isTransactionStarted) {
|
||||||
}
|
// ConnectionManagerUtil.commitDBTransaction();
|
||||||
return visibility;
|
// }
|
||||||
} catch (ApplicationManagementException e) {
|
// return visibility;
|
||||||
if (!isTransactionStarted) {
|
// } catch (ApplicationManagementException e) {
|
||||||
ConnectionManagerUtil.rollbackDBTransaction();
|
// if (!isTransactionStarted) {
|
||||||
}
|
// ConnectionManagerUtil.rollbackDBTransaction();
|
||||||
throw new VisibilityManagementException("Problem occured when trying to fetch the application with ID - "
|
// }
|
||||||
+ applicationID, e);
|
// throw new VisibilityManagementException("Problem occured when trying to fetch the application with ID - "
|
||||||
} finally {
|
// + applicationID, e);
|
||||||
if (!isTransactionStarted) {
|
// } finally {
|
||||||
ConnectionManagerUtil.closeDBConnection();
|
// if (!isTransactionStarted) {
|
||||||
}
|
// ConnectionManagerUtil.closeDBConnection();
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -87,28 +89,28 @@ public class UnrestrictedRoleManagerImpl implements UnrestrictedRoleManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove(int applicationID) throws VisibilityManagementException {
|
public void remove(int applicationID) throws VisibilityManagementException {
|
||||||
boolean isTransactionStarted = false;
|
// boolean isTransactionStarted = false;
|
||||||
try {
|
// try {
|
||||||
isTransactionStarted = ConnectionManagerUtil.isTransactionStarted();
|
// isTransactionStarted = ConnectionManagerUtil.isTransactionStarted();
|
||||||
if (!isTransactionStarted) {
|
// if (!isTransactionStarted) {
|
||||||
ConnectionManagerUtil.beginDBTransaction();
|
// ConnectionManagerUtil.beginDBTransaction();
|
||||||
}
|
// }
|
||||||
VisibilityDAO visibilityDAO = ApplicationManagementDAOFactory.getVisibilityDAO();
|
// VisibilityDAO visibilityDAO = ApplicationManagementDAOFactory.getVisibilityDAO();
|
||||||
visibilityDAO.delete(applicationID);
|
// visibilityDAO.delete(applicationID);
|
||||||
if (!isTransactionStarted) {
|
// if (!isTransactionStarted) {
|
||||||
ConnectionManagerUtil.commitDBTransaction();
|
// ConnectionManagerUtil.commitDBTransaction();
|
||||||
}
|
// }
|
||||||
} catch (ApplicationManagementException e) {
|
// } catch (ApplicationManagementException e) {
|
||||||
if (!isTransactionStarted) {
|
// if (!isTransactionStarted) {
|
||||||
ConnectionManagerUtil.rollbackDBTransaction();
|
// ConnectionManagerUtil.rollbackDBTransaction();
|
||||||
}
|
// }
|
||||||
throw new VisibilityManagementException("Problem occurred when trying to fetch the application with ID - "
|
// throw new VisibilityManagementException("Problem occurred when trying to fetch the application with ID - "
|
||||||
+ applicationID, e);
|
// + applicationID, e);
|
||||||
} finally {
|
// } finally {
|
||||||
if (!isTransactionStarted) {
|
// if (!isTransactionStarted) {
|
||||||
ConnectionManagerUtil.closeDBConnection();
|
// ConnectionManagerUtil.closeDBConnection();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,7 +66,7 @@
|
|||||||
<tasks>
|
<tasks>
|
||||||
<copy todir="${basedir}/../../../repository/deployment/server/webapps" overwrite="true">
|
<copy todir="${basedir}/../../../repository/deployment/server/webapps" overwrite="true">
|
||||||
<fileset dir="${basedir}/target">
|
<fileset dir="${basedir}/target">
|
||||||
<include name="api#application-mgt#v1.0.war" />
|
<include name="api#application-mgt-publisher#v1.0.war" />
|
||||||
</fileset>
|
</fileset>
|
||||||
</copy>
|
</copy>
|
||||||
</tasks>
|
</tasks>
|
||||||
|
|||||||
@ -168,7 +168,7 @@ public interface ApplicationReleaseManagementAPI {
|
|||||||
|
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("/upload-artifacts/{uuid}")
|
@Path("/update-image-artifacts/{appId}/{uuid}")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@Consumes(MediaType.MULTIPART_FORM_DATA)
|
@Consumes(MediaType.MULTIPART_FORM_DATA)
|
||||||
@ApiOperation(
|
@ApiOperation(
|
||||||
@ -195,12 +195,13 @@ public interface ApplicationReleaseManagementAPI {
|
|||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
Response updateApplicationImageArtifacts(
|
Response updateApplicationImageArtifacts(
|
||||||
|
@ApiParam(name = "appId", value = "ID of the application", required = true) @PathParam("appId") int applicatioId,
|
||||||
@ApiParam(name = "uuid", value = "UUID of the application", required = true) @PathParam("uuid") String applicationUUID,
|
@ApiParam(name = "uuid", value = "UUID of the application", required = true) @PathParam("uuid") String applicationUUID,
|
||||||
@Multipart(value = "icon") Attachment iconFile, @Multipart(value = "banner") Attachment bannerFile,
|
@Multipart(value = "icon") Attachment iconFile, @Multipart(value = "banner") Attachment bannerFile,
|
||||||
@Multipart(value = "screenshot") List<Attachment> screenshots);
|
@Multipart(value = "screenshot") List<Attachment> screenshots);
|
||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Path("/upload-artifacts/{uuid}")
|
@Path("/update-artifacts/{appId}/{uuid}")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@Consumes(MediaType.MULTIPART_FORM_DATA)
|
@Consumes(MediaType.MULTIPART_FORM_DATA)
|
||||||
@ApiOperation(
|
@ApiOperation(
|
||||||
@ -226,11 +227,10 @@ public interface ApplicationReleaseManagementAPI {
|
|||||||
message = "Internal Server Error. \n Error occurred while getting the application list.",
|
message = "Internal Server Error. \n Error occurred while getting the application list.",
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
Response updateApplicationArtifacts(
|
Response updateApplicationArtifact(
|
||||||
|
@ApiParam(name = "id", value = "Id of the application", required = true) @PathParam("uuid") int applicationId,
|
||||||
@ApiParam(name = "uuid", value = "UUID of the application", required = true) @PathParam("uuid") String applicationUUID,
|
@ApiParam(name = "uuid", value = "UUID of the application", required = true) @PathParam("uuid") String applicationUUID,
|
||||||
@Multipart(value = "icon", required = false) Attachment iconFile,
|
@Multipart("binaryFile") Attachment binaryFile );
|
||||||
@Multipart(value = "banner", required = false) Attachment bannerFile,
|
|
||||||
@Multipart(value = "screenshot", required = false) List<Attachment> screenshots);
|
|
||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Path("/{appId}/{uuid}")
|
@Path("/{appId}/{uuid}")
|
||||||
|
|||||||
@ -58,7 +58,6 @@ import javax.ws.rs.QueryParam;
|
|||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of Application Management related APIs.
|
* Implementation of Application Management related APIs.
|
||||||
*/
|
*/
|
||||||
@ -70,7 +69,6 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|||||||
private static Log log = LogFactory.getLog(ApplicationManagementAPIImpl.class);
|
private static Log log = LogFactory.getLog(ApplicationManagementAPIImpl.class);
|
||||||
|
|
||||||
|
|
||||||
//todo need to pass uuid
|
|
||||||
@GET
|
@GET
|
||||||
@Override
|
@Override
|
||||||
@Consumes("application/json")
|
@Consumes("application/json")
|
||||||
@ -117,7 +115,9 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|||||||
@GET
|
@GET
|
||||||
@Consumes("application/json")
|
@Consumes("application/json")
|
||||||
@Path("/{appType}")
|
@Path("/{appType}")
|
||||||
public Response getApplication(@PathParam("appType") String appType, @QueryParam("appName") String appName) {
|
public Response getApplication(
|
||||||
|
@PathParam("appType") String appType,
|
||||||
|
@QueryParam("appName") String appName) {
|
||||||
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
||||||
ApplicationStorageManager applicationStorageManager = APIUtil.getApplicationStorageManager();
|
ApplicationStorageManager applicationStorageManager = APIUtil.getApplicationStorageManager();
|
||||||
try {
|
try {
|
||||||
@ -161,10 +161,6 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|||||||
log.error(msg);
|
log.error(msg);
|
||||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||||
}
|
}
|
||||||
}catch (DeviceManagementDAOException e) {
|
|
||||||
String msg = "Error occurred while getting the device type";
|
|
||||||
log.error(msg, e);
|
|
||||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
|
||||||
}catch (ApplicationManagementException e) {
|
}catch (ApplicationManagementException e) {
|
||||||
String msg = "Error occurred while creating the application";
|
String msg = "Error occurred while creating the application";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
|
|||||||
@ -145,7 +145,7 @@ public class ApplicationReleaseManagementAPIImpl implements ApplicationReleaseMa
|
|||||||
try {
|
try {
|
||||||
List<UnrestrictedRole> unrestrictedRoles = unrestrictedRoleManager.getUnrestrictedRoles(applicationId, tenantId);
|
List<UnrestrictedRole> unrestrictedRoles = unrestrictedRoleManager.getUnrestrictedRoles(applicationId, tenantId);
|
||||||
if(unrestrictedRoles == null || applicationManager.isUserAllowable(unrestrictedRoles,userName)){
|
if(unrestrictedRoles == null || applicationManager.isUserAllowable(unrestrictedRoles,userName)){
|
||||||
applicationReleases= applicationReleaseManager.getReleases(applicationId);
|
applicationReleases = applicationReleaseManager.getReleases(applicationId);
|
||||||
return Response.status(Response.Status.OK).entity(applicationReleases).build();
|
return Response.status(Response.Status.OK).entity(applicationReleases).build();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -204,7 +204,7 @@ public class ApplicationReleaseManagementAPIImpl implements ApplicationReleaseMa
|
|||||||
iconFileStream, bannerFileStream, attachments);
|
iconFileStream, bannerFileStream, attachments);
|
||||||
|
|
||||||
if (applicationRelease != null) {
|
if (applicationRelease != null) {
|
||||||
applicationRelease = applicationReleaseManager.updateRelease(applicationUUID, applicationRelease);
|
applicationRelease = applicationReleaseManager.updateRelease(applicationId, applicationRelease);
|
||||||
}
|
}
|
||||||
return Response.status(Response.Status.OK).entity(applicationRelease).build();
|
return Response.status(Response.Status.OK).entity(applicationRelease).build();
|
||||||
} catch (NotFoundException e) {
|
} catch (NotFoundException e) {
|
||||||
@ -213,54 +213,52 @@ public class ApplicationReleaseManagementAPIImpl implements ApplicationReleaseMa
|
|||||||
log.error("Error while updating the application release of the application with UUID " + applicationUUID);
|
log.error("Error while updating the application release of the application with UUID " + applicationUUID);
|
||||||
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
|
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
log.error("Error while updating the release artifacts of the application with UUID " + applicationUUID);
|
log.error("Error while updating the release artifacts of the application with UUID " + applicationUUID);
|
||||||
return APIUtil.getResponse(new ApplicationManagementException(
|
return APIUtil.getResponse(new ApplicationManagementException(
|
||||||
"Error while updating the release artifacts of the application with UUID "
|
"Error while updating the release artifacts of the application with UUID "
|
||||||
+ applicationUUID), Response.Status.INTERNAL_SERVER_ERROR);
|
+ applicationUUID), Response.Status.INTERNAL_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
catch (ResourceManagementException e) {
|
catch (ResourceManagementException e) {
|
||||||
log.error("Error occurred while updating the releases artifacts of the application with the uuid "
|
log.error("Error occurred while updating the releases artifacts of the application with the uuid "
|
||||||
+ applicationUUID + " for the release " + applicationRelease.getVersion(), e);
|
+ applicationUUID + " for the release " + applicationRelease.getVersion(), e);
|
||||||
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
|
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo
|
|
||||||
@Override
|
@Override
|
||||||
@POST
|
@POST
|
||||||
@Path("/upload-image-artifacts/{uuid}")
|
@Path("/update-image-artifacts/{appId}/{uuid}")
|
||||||
public Response updateApplicationImageArtifacts(@PathParam("uuid") String applicationUUID,
|
public Response updateApplicationImageArtifacts(
|
||||||
@Multipart("icon") Attachment iconFile, @Multipart("banner") Attachment bannerFile,
|
@PathParam("appId") int appId,
|
||||||
|
@PathParam("uuid") String applicationUUID,
|
||||||
|
@Multipart("icon") Attachment iconFile,
|
||||||
|
@Multipart("banner") Attachment bannerFile,
|
||||||
@Multipart("screenshot") List<Attachment> attachmentList) {
|
@Multipart("screenshot") List<Attachment> attachmentList) {
|
||||||
|
|
||||||
ApplicationStorageManager applicationStorageManager = APIUtil.getApplicationStorageManager();
|
ApplicationStorageManager applicationStorageManager = APIUtil.getApplicationStorageManager();
|
||||||
|
ApplicationReleaseManager applicationReleaseManager = APIUtil.getApplicationReleaseManager();
|
||||||
|
ApplicationRelease applicationRelease = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
InputStream iconFileStream;
|
InputStream iconFileStream = null;
|
||||||
InputStream bannerFileStream;
|
InputStream bannerFileStream = null;
|
||||||
List<InputStream> attachments = new ArrayList<>();
|
List<InputStream> attachments = new ArrayList<>();
|
||||||
|
|
||||||
if (iconFile != null) {
|
if (iconFile != null) {
|
||||||
iconFileStream = iconFile.getDataHandler().getInputStream();
|
iconFileStream = iconFile.getDataHandler().getInputStream();
|
||||||
} else {
|
|
||||||
throw new ApplicationManagementException(
|
|
||||||
"Icon file is not uploaded for the application " + applicationUUID);
|
|
||||||
}
|
}
|
||||||
if (bannerFile != null) {
|
if (bannerFile != null) {
|
||||||
bannerFileStream = bannerFile.getDataHandler().getInputStream();
|
bannerFileStream = bannerFile.getDataHandler().getInputStream();
|
||||||
} else {
|
|
||||||
throw new ApplicationManagementException(
|
|
||||||
"Banner file is not uploaded for the application " + applicationUUID);
|
|
||||||
}
|
}
|
||||||
if (attachmentList != null && !attachmentList.isEmpty()) {
|
if (attachmentList != null && !attachmentList.isEmpty()) {
|
||||||
for (Attachment screenshot : attachmentList) {
|
for (Attachment screenshot : attachmentList) {
|
||||||
attachments.add(screenshot.getDataHandler().getInputStream());
|
attachments.add(screenshot.getDataHandler().getInputStream());
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
throw new ApplicationManagementException(
|
|
||||||
"Screen-shot are not uploaded for the application " + applicationUUID);
|
|
||||||
}
|
}
|
||||||
// applicationStorageManager
|
applicationRelease = applicationStorageManager.updateImageArtifacts
|
||||||
// .uploadImageArtifacts(applicationUUID, iconFileStream, bannerFileStream, attachments);
|
(appId, applicationUUID, iconFileStream, bannerFileStream, attachments);
|
||||||
|
applicationReleaseManager.updateRelease(appId,applicationRelease);
|
||||||
return Response.status(Response.Status.OK)
|
return Response.status(Response.Status.OK)
|
||||||
.entity("Successfully uploaded artifacts for the application " + applicationUUID).build();
|
.entity("Successfully uploaded artifacts for the application " + applicationUUID).build();
|
||||||
} catch (NotFoundException e) {
|
} catch (NotFoundException e) {
|
||||||
@ -275,54 +273,53 @@ public class ApplicationReleaseManagementAPIImpl implements ApplicationReleaseMa
|
|||||||
"Exception while trying to read icon, " + "banner files for the application " +
|
"Exception while trying to read icon, " + "banner files for the application " +
|
||||||
applicationUUID, e), Response.Status.BAD_REQUEST);
|
applicationUUID, e), Response.Status.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
// catch (ResourceManagementException e) {
|
catch (ResourceManagementException e) {
|
||||||
// log.error("Error occurred while uploading the image artifacts of the application with the uuid "
|
log.error("Error occurred while uploading the image artifacts of the application with the uuid "
|
||||||
// + applicationUUID, e);
|
+ applicationUUID, e);
|
||||||
// return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
|
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
|
||||||
// }
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@PUT
|
||||||
|
@Path("/update-artifacts/{appId}/{uuid}")
|
||||||
|
public Response updateApplicationArtifact(
|
||||||
|
@PathParam("appId") int applicationId,
|
||||||
|
@PathParam("uuid") String applicationUuuid,
|
||||||
|
@Multipart("binaryFile") Attachment binaryFile) {
|
||||||
|
ApplicationStorageManager applicationStorageManager = APIUtil.getApplicationStorageManager();
|
||||||
|
ApplicationReleaseManager applicationReleaseManager = APIUtil.getApplicationReleaseManager();
|
||||||
|
ApplicationRelease applicationRelease = null;
|
||||||
|
try {
|
||||||
|
|
||||||
|
if (binaryFile != null) {
|
||||||
|
applicationRelease = applicationStorageManager.updateReleaseArtifacts(applicationId, applicationUuuid,
|
||||||
|
binaryFile.getDataHandler().getInputStream());
|
||||||
|
applicationReleaseManager.updateRelease(applicationId, applicationRelease);
|
||||||
|
return Response.status(Response.Status.OK)
|
||||||
|
.entity("Successfully uploaded artifacts for the application " + applicationUuuid).build();
|
||||||
|
|
||||||
|
}
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST)
|
||||||
|
.entity("Uploading artifacts for the application is failed " + applicationUuuid).build();
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("Exception while trying to read icon, banner files for the application " + applicationUuuid);
|
||||||
|
return APIUtil.getResponse(new ApplicationManagementException(
|
||||||
|
"Exception while trying to read icon, banner files for the application " +
|
||||||
|
applicationUuuid, e), Response.Status.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
catch (ResourceManagementException e) {
|
||||||
|
log.error("Error occurred while uploading the image artifacts of the application with the uuid "
|
||||||
|
+ applicationUuuid, e);
|
||||||
|
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
|
||||||
|
} catch (ApplicationManagementException e) {
|
||||||
|
log.error("Error occurred while updating the image artifacts of the application with the uuid "
|
||||||
|
+ applicationUuuid, e);
|
||||||
|
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo
|
//todo
|
||||||
@Override
|
|
||||||
@PUT
|
|
||||||
@Path("/upload-image-artifacts/{uuid}")
|
|
||||||
public Response updateApplicationArtifacts(@PathParam("uuid") String applicationUUID,
|
|
||||||
@Multipart("icon") Attachment iconFile, @Multipart("banner") Attachment bannerFile,
|
|
||||||
@Multipart("screenshot") List<Attachment> attachmentList) {
|
|
||||||
ApplicationStorageManager applicationStorageManager = APIUtil.getApplicationStorageManager();
|
|
||||||
try {
|
|
||||||
InputStream iconFileStream = null;
|
|
||||||
InputStream bannerFileStream = null;
|
|
||||||
List<InputStream> attachments = new ArrayList<>();
|
|
||||||
|
|
||||||
if (iconFile != null) {
|
|
||||||
iconFileStream = iconFile.getDataHandler().getInputStream();
|
|
||||||
}
|
|
||||||
if (bannerFile != null) {
|
|
||||||
bannerFileStream = bannerFile.getDataHandler().getInputStream();
|
|
||||||
}
|
|
||||||
if (attachmentList != null) {
|
|
||||||
for (Attachment screenshot : attachmentList) {
|
|
||||||
attachments.add(screenshot.getDataHandler().getInputStream());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// applicationStorageManager
|
|
||||||
// .uploadImageArtifacts(applicationUUID, iconFileStream, bannerFileStream, attachments);
|
|
||||||
return Response.status(Response.Status.OK)
|
|
||||||
.entity("Successfully updated artifacts for the application " + applicationUUID).build();
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error("Exception while trying to read icon, banner files for the application " + applicationUUID);
|
|
||||||
return APIUtil.getResponse(new ApplicationManagementException(
|
|
||||||
"Exception while trying to read icon, banner files for the application " +
|
|
||||||
applicationUUID, e), Response.Status.BAD_REQUEST);
|
|
||||||
}
|
|
||||||
// catch (ResourceManagementException e) {
|
|
||||||
// log.error("Error occurred while uploading the image artifacts of the application with the uuid "
|
|
||||||
// + applicationUUID, e);
|
|
||||||
// return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("/release/{uuid}")
|
@Path("/release/{uuid}")
|
||||||
|
|||||||
@ -45,16 +45,17 @@ public class LifecycleManagementAPIImpl implements LifecycleManagementAPI {
|
|||||||
|
|
||||||
@GET
|
@GET
|
||||||
public Response getLifecycleStates() {
|
public Response getLifecycleStates() {
|
||||||
LifecycleStateManager lifecycleStateManager = APIUtil.getLifecycleStateManager();
|
return null;
|
||||||
List<LifecycleState> lifecycleStates = new ArrayList<>();
|
// LifecycleStateManager lifecycleStateManager = APIUtil.getLifecycleStateManager();
|
||||||
try {
|
// List<LifecycleState> lifecycleStates = new ArrayList<>();
|
||||||
lifecycleStates = lifecycleStateManager.getLifecycleStates();
|
// try {
|
||||||
} catch (LifecycleManagementException e) {
|
// lifecycleStates = lifecycleStateManager.getLifecycleStates();
|
||||||
String msg = "Error occurred while retrieving lifecycle states.";
|
// } catch (LifecycleManagementException e) {
|
||||||
log.error(msg, e);
|
// String msg = "Error occurred while retrieving lifecycle states.";
|
||||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
// log.error(msg, e);
|
||||||
}
|
// return Response.status(Response.Status.BAD_REQUEST).build();
|
||||||
return Response.status(Response.Status.OK).entity(lifecycleStates).build();
|
// }
|
||||||
|
// return Response.status(Response.Status.OK).entity(lifecycleStates).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@ -73,15 +74,16 @@ public class LifecycleManagementAPIImpl implements LifecycleManagementAPI {
|
|||||||
@DELETE
|
@DELETE
|
||||||
@Path("/{identifier}")
|
@Path("/{identifier}")
|
||||||
public Response deleteLifecycleState(@PathParam("identifier") String identifier) {
|
public Response deleteLifecycleState(@PathParam("identifier") String identifier) {
|
||||||
LifecycleStateManager lifecycleStateManager = APIUtil.getLifecycleStateManager();
|
return null;
|
||||||
try {
|
// LifecycleStateManager lifecycleStateManager = APIUtil.getLifecycleStateManager();
|
||||||
lifecycleStateManager.deleteLifecycleState(identifier);
|
// try {
|
||||||
} catch (LifecycleManagementException e) {
|
// lifecycleStateManager.deleteLifecycleState(identifier);
|
||||||
String msg = "Error occurred while deleting lifecycle state.";
|
// } catch (LifecycleManagementException e) {
|
||||||
log.error(msg, e);
|
// String msg = "Error occurred while deleting lifecycle state.";
|
||||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
// log.error(msg, e);
|
||||||
}
|
// return Response.status(Response.Status.BAD_REQUEST).build();
|
||||||
return Response.status(Response.Status.OK).entity("Lifecycle state deleted successfully.").build();
|
// }
|
||||||
|
// return Response.status(Response.Status.OK).entity("Lifecycle state deleted successfully.").build();
|
||||||
}
|
}
|
||||||
|
|
||||||
// @PUT
|
// @PUT
|
||||||
|
|||||||
@ -21,24 +21,13 @@ package org.wso2.carbon.device.application.mgt.store.api;
|
|||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||||
<<<<<<< HEAD:components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/APIUtil.java
|
|
||||||
import org.wso2.carbon.device.application.mgt.publisher.api.beans.ErrorResponse;
|
|
||||||
=======
|
|
||||||
import org.wso2.carbon.device.application.mgt.api.beans.ErrorResponse;
|
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.CommentsManager;
|
import org.wso2.carbon.device.application.mgt.common.services.CommentsManager;
|
||||||
>>>>>>> de78869eeae15c1d3bfe854092cbbb05be87c4a9:components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/APIUtil.java
|
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager;
|
import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager;
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.PlatformManager;
|
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.LifecycleStateManager;
|
import org.wso2.carbon.device.application.mgt.common.services.LifecycleStateManager;
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.ApplicationReleaseManager;
|
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.ApplicationStorageManager;
|
||||||
<<<<<<< HEAD:components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/APIUtil.java
|
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.LifecycleStateManager;
|
|
||||||
=======
|
|
||||||
>>>>>>> de78869eeae15c1d3bfe854092cbbb05be87c4a9:components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/APIUtil.java
|
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager;
|
import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager;
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.PlatformStorageManager;
|
import org.wso2.carbon.device.application.mgt.publisher.api.beans.ErrorResponse;
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.CategoryManager;
|
|
||||||
|
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
@ -49,16 +38,12 @@ public class APIUtil {
|
|||||||
|
|
||||||
private static Log log = LogFactory.getLog(APIUtil.class);
|
private static Log log = LogFactory.getLog(APIUtil.class);
|
||||||
|
|
||||||
<<<<<<< HEAD:components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/APIUtil.java
|
|
||||||
private static ApplicationManager applicationManager;
|
private static ApplicationManager applicationManager;
|
||||||
private static LifecycleStateManager lifecycleStateManager;
|
private static LifecycleStateManager lifecycleStateManager;
|
||||||
private static ApplicationReleaseManager applicationReleaseManager;
|
private static ApplicationReleaseManager applicationReleaseManager;
|
||||||
private static ApplicationStorageManager applicationStorageManager;
|
private static ApplicationStorageManager applicationStorageManager;
|
||||||
private static SubscriptionManager subscriptionManager;
|
private static SubscriptionManager subscriptionManager;
|
||||||
private static CategoryManager categoryManager;
|
|
||||||
|
|
||||||
=======
|
|
||||||
>>>>>>> de78869eeae15c1d3bfe854092cbbb05be87c4a9:components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/APIUtil.java
|
|
||||||
public static ApplicationManager getApplicationManager() {
|
public static ApplicationManager getApplicationManager() {
|
||||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||||
ApplicationManager applicationManager = (ApplicationManager) ctx.getOSGiService(ApplicationManager.class, null);
|
ApplicationManager applicationManager = (ApplicationManager) ctx.getOSGiService(ApplicationManager.class, null);
|
||||||
@ -70,20 +55,6 @@ public class APIUtil {
|
|||||||
return applicationManager;
|
return applicationManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD:components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/APIUtil.java
|
|
||||||
=======
|
|
||||||
public static PlatformManager getPlatformManager() {
|
|
||||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
|
||||||
PlatformManager platformManager = (PlatformManager) ctx.getOSGiService(PlatformManager.class, null);
|
|
||||||
if (platformManager == null) {
|
|
||||||
String msg = "Platform Manager service has not initialized.";
|
|
||||||
log.error(msg);
|
|
||||||
throw new IllegalStateException(msg);
|
|
||||||
}
|
|
||||||
return platformManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
>>>>>>> de78869eeae15c1d3bfe854092cbbb05be87c4a9:components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/APIUtil.java
|
|
||||||
public static LifecycleStateManager getLifecycleStateManager() {
|
public static LifecycleStateManager getLifecycleStateManager() {
|
||||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||||
LifecycleStateManager lifecycleStateManager = (LifecycleStateManager) ctx
|
LifecycleStateManager lifecycleStateManager = (LifecycleStateManager) ctx
|
||||||
@ -130,55 +101,6 @@ public class APIUtil {
|
|||||||
return applicationStorageManager;
|
return applicationStorageManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
<<<<<<< HEAD:components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/APIUtil.java
|
|
||||||
=======
|
|
||||||
* To get the Platform Storage Manager from the osgi context.
|
|
||||||
*
|
|
||||||
* @return PlatformStoreManager instance in the current osgi context.
|
|
||||||
*/
|
|
||||||
public static PlatformStorageManager getPlatformStorageManager() {
|
|
||||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
|
||||||
PlatformStorageManager platformStorageManager = (PlatformStorageManager) ctx
|
|
||||||
.getOSGiService(PlatformStorageManager.class, null);
|
|
||||||
if (platformStorageManager == null) {
|
|
||||||
String msg = "Platform Storage Manager service has not initialized.";
|
|
||||||
log.error(msg);
|
|
||||||
throw new IllegalStateException(msg);
|
|
||||||
}
|
|
||||||
return platformStorageManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
>>>>>>> de78869eeae15c1d3bfe854092cbbb05be87c4a9:components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/APIUtil.java
|
|
||||||
* To get the Category Manager from the osgi context.
|
|
||||||
*
|
|
||||||
* @return CategoryManager instance in the current osgi context.
|
|
||||||
*/
|
|
||||||
public static CategoryManager getCategoryManager() {
|
|
||||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
|
||||||
CategoryManager categoryManager = (CategoryManager) ctx.getOSGiService(CategoryManager.class, null);
|
|
||||||
if (categoryManager == null) {
|
|
||||||
String msg = "Category Manager service has not initialized.";
|
|
||||||
log.error(msg);
|
|
||||||
throw new IllegalStateException(msg);
|
|
||||||
}
|
|
||||||
return categoryManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Response getResponse(Exception ex, Response.Status status) {
|
|
||||||
return getResponse(ex.getMessage(), status);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Response getResponse(String message, Response.Status status) {
|
|
||||||
ErrorResponse errorMessage = new ErrorResponse();
|
|
||||||
errorMessage.setMessage(message);
|
|
||||||
if (status == null) {
|
|
||||||
status = Response.Status.INTERNAL_SERVER_ERROR;
|
|
||||||
}
|
|
||||||
errorMessage.setCode(status.getStatusCode());
|
|
||||||
return Response.status(status).entity(errorMessage).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To get the Subscription Manager from the osgi context.
|
* To get the Subscription Manager from the osgi context.
|
||||||
@ -213,4 +135,19 @@ public class APIUtil {
|
|||||||
}
|
}
|
||||||
return commentsManager;
|
return commentsManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Response getResponse(Exception ex, Response.Status status) {
|
||||||
|
return getResponse(ex.getMessage(), status);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Response getResponse(String message, Response.Status status) {
|
||||||
|
ErrorResponse errorMessage = new ErrorResponse();
|
||||||
|
errorMessage.setMessage(message);
|
||||||
|
if (status == null) {
|
||||||
|
status = Response.Status.INTERNAL_SERVER_ERROR;
|
||||||
|
}
|
||||||
|
errorMessage.setCode(status.getStatusCode());
|
||||||
|
return Response.status(status).entity(errorMessage).build();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -217,42 +217,6 @@ public interface ApplicationManagementAPI {
|
|||||||
@QueryParam("appName") String appName
|
@QueryParam("appName") String appName
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("/release-artifacts/{uuid}/{version}")
|
|
||||||
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
|
||||||
@Consumes(MediaType.MULTIPART_FORM_DATA)
|
|
||||||
@ApiOperation(
|
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
|
||||||
produces = MediaType.APPLICATION_OCTET_STREAM,
|
|
||||||
httpMethod = "GET",
|
|
||||||
value = "Get an application release",
|
|
||||||
notes = "This will return the application release indicated by Application UUID and version",
|
|
||||||
tags = "Application Management",
|
|
||||||
extensions = {
|
|
||||||
@Extension(properties = {
|
|
||||||
@ExtensionProperty(name = SCOPE, value = "perm:application:get")
|
|
||||||
})
|
|
||||||
}
|
|
||||||
)
|
|
||||||
@ApiResponses(
|
|
||||||
value = {
|
|
||||||
@ApiResponse(
|
|
||||||
code = 200,
|
|
||||||
message = "OK. \n Successfully retrieved the Application release.",
|
|
||||||
response = Attachment.class),
|
|
||||||
@ApiResponse(
|
|
||||||
code = 500,
|
|
||||||
message = "Internal Server Error. \n Error occurred while releasing the application.",
|
|
||||||
response = ErrorResponse.class)
|
|
||||||
})
|
|
||||||
Response getApplicationReleaseArtifacts(
|
|
||||||
@ApiParam(name = "UUID", value = "Unique identifier of the Application", required = true) @PathParam("uuid") String applicationUUID,
|
|
||||||
@ApiParam(name = "Version", value = "Version of the Application release need to be retrieved", required = true) @PathParam("version") String version);
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/release/{uuid}")
|
@Path("/release/{uuid}")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@ -284,38 +248,4 @@ public interface ApplicationManagementAPI {
|
|||||||
@ApiParam(name = "ID", value = "Identifier of the Application", required = true) @PathParam("uuid") String applicationUUID,
|
@ApiParam(name = "ID", value = "Identifier of the Application", required = true) @PathParam("uuid") String applicationUUID,
|
||||||
@ApiParam(name = "version", value = "Version of the application", required = false) @QueryParam("version") String version);
|
@ApiParam(name = "version", value = "Version of the application", required = false) @QueryParam("version") String version);
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("/image-artifacts/{uuid}")
|
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
|
||||||
@ApiOperation(
|
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
|
||||||
produces = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "DELETE",
|
|
||||||
value = "Delete the releases of a particular applicaion",
|
|
||||||
notes = "This will delete the releases or specific release of an application",
|
|
||||||
tags = "Application Management",
|
|
||||||
extensions = {
|
|
||||||
@Extension(properties = {
|
|
||||||
@ExtensionProperty(name = SCOPE, value = "perm:application:get")
|
|
||||||
})
|
|
||||||
}
|
|
||||||
)
|
|
||||||
@ApiResponses(
|
|
||||||
value = {
|
|
||||||
@ApiResponse(
|
|
||||||
code = 200,
|
|
||||||
message = "OK. \n Successfully deleted the Application release."),
|
|
||||||
@ApiResponse(
|
|
||||||
code = 500,
|
|
||||||
message = "Internal Server Error. \n Error occurred while deleting the release of a"
|
|
||||||
+ "particular application.",
|
|
||||||
response = ErrorResponse.class)
|
|
||||||
})
|
|
||||||
Response getApplicationImageArtifacts(
|
|
||||||
@ApiParam(name = "UUID", value = "Unique identifier of the Application", required = true) @PathParam("uuid") String applicationUUID,
|
|
||||||
@ApiParam(name = "name", value = "Name of the artifact to be retrieved", required = true) @QueryParam("name") String name,
|
|
||||||
@ApiParam(name = "count", value = "Count of the screen-shot artifact to be retrieved", required = false) @QueryParam("count") int count);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -163,51 +163,4 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo We must remove following methods - By DLPDS
|
|
||||||
@Override
|
|
||||||
@GET
|
|
||||||
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
|
||||||
@Path("/release-artifacts/{uuid}/{version}")
|
|
||||||
public Response getApplicationReleaseArtifacts(@PathParam("uuid") String applicationUUID,
|
|
||||||
@PathParam("version") String version) {
|
|
||||||
ApplicationStorageManager applicationStorageManager = APIUtil.getApplicationStorageManager();
|
|
||||||
try {
|
|
||||||
InputStream binaryFile = applicationStorageManager.getReleasedArtifacts(applicationUUID, version);
|
|
||||||
FileStreamingOutput fileStreamingOutput = new FileStreamingOutput(binaryFile);
|
|
||||||
Response.ResponseBuilder response = Response.status(Response.Status.OK).entity(fileStreamingOutput);
|
|
||||||
response.header("Content-Disposition", "attachment; filename=\"" + version + "\"");
|
|
||||||
return response.build();
|
|
||||||
} catch (ApplicationStorageManagementException e) {
|
|
||||||
log.error("Error while retrieving the binary file of the application release for the application UUID " +
|
|
||||||
applicationUUID + " and version " + version, e);
|
|
||||||
if (e.getMessage().contains("Binary file does not exist")) {
|
|
||||||
return APIUtil.getResponse(e, Response.Status.NOT_FOUND);
|
|
||||||
} else {
|
|
||||||
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@GET
|
|
||||||
@Path("/image-artifacts/{uuid}")
|
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
|
||||||
public Response getApplicationImageArtifacts(@PathParam("uuid") String applicationUUID,
|
|
||||||
@QueryParam("name") String name, @QueryParam("count") int count) {
|
|
||||||
if (name == null || name.isEmpty()) {
|
|
||||||
return Response.status(Response.Status.BAD_REQUEST).entity("Name should not be null. Name is mandatory to"
|
|
||||||
+ " retrieve the particular image artifact of the release").build();
|
|
||||||
}
|
|
||||||
ApplicationStorageManager applicationStorageManager = APIUtil.getApplicationStorageManager();
|
|
||||||
try {
|
|
||||||
ImageArtifact imageArtifact = applicationStorageManager.getImageArtifact(applicationUUID, name, count);
|
|
||||||
Response.ResponseBuilder response = Response.status(Response.Status.OK).entity(imageArtifact);
|
|
||||||
return response.build();
|
|
||||||
} catch (ApplicationStorageManagementException e) {
|
|
||||||
log.error("Application Storage Management Exception while getting the image artifact " + name + " of "
|
|
||||||
+ "the application with UUID " + applicationUUID, e);
|
|
||||||
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,7 +41,7 @@
|
|||||||
<artifactId>maven-dependency-plugin</artifactId>
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>copy</id>
|
<id>publisher-copy</id>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>copy</goal>
|
<goal>copy</goal>
|
||||||
@ -50,7 +50,7 @@
|
|||||||
<artifactItems>
|
<artifactItems>
|
||||||
<artifactItem>
|
<artifactItem>
|
||||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
<artifactId>org.wso2.carbon.device.application.mgt.api
|
<artifactId>org.wso2.carbon.device.application.mgt.publisher.api
|
||||||
</artifactId>
|
</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<type>war</type>
|
<type>war</type>
|
||||||
@ -58,7 +58,30 @@
|
|||||||
<outputDirectory>
|
<outputDirectory>
|
||||||
${project.build.directory}/maven-shared-archive-resources/webapps
|
${project.build.directory}/maven-shared-archive-resources/webapps
|
||||||
</outputDirectory>
|
</outputDirectory>
|
||||||
<destFileName>api#application-mgt#v1.0.war</destFileName>
|
<destFileName>api#application-mgt-publisher#v1.0.war</destFileName>
|
||||||
|
</artifactItem>
|
||||||
|
</artifactItems>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>store-copy</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<artifactItems>
|
||||||
|
<artifactItem>
|
||||||
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.device.application.mgt.store.api
|
||||||
|
</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>war</type>
|
||||||
|
<overWrite>true</overWrite>
|
||||||
|
<outputDirectory>
|
||||||
|
${project.build.directory}/maven-shared-archive-resources/webapps
|
||||||
|
</outputDirectory>
|
||||||
|
<destFileName>api#application-mgt-store#v1.0.war</destFileName>
|
||||||
</artifactItem>
|
</artifactItem>
|
||||||
</artifactItems>
|
</artifactItems>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user