|
|
@ -29,6 +29,8 @@ 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.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.exception.ApplicationManagementDAOException;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.exception.BadRequestException;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.util.Constants;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
|
|
|
|
|
|
@ -51,53 +53,26 @@ public class AppmDataHandlerImpl implements AppmDataHandler {
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
ApplicationStorageManager applicationStorageManager = Util.getApplicationStorageManager();
|
|
|
|
ApplicationStorageManager applicationStorageManager = Util.getApplicationStorageManager();
|
|
|
|
ApplicationReleaseDAO applicationReleaseDAO = ApplicationManagementDAOFactory.getApplicationReleaseDAO();
|
|
|
|
ApplicationReleaseDAO applicationReleaseDAO = ApplicationManagementDAOFactory.getApplicationReleaseDAO();
|
|
|
|
String artifactPath = null;
|
|
|
|
String artifactPath;
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(uuid) || StringUtils.isEmpty(artifactName)) {
|
|
|
|
String appReleaseHashValue = null;
|
|
|
|
// todo throw
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ApplicationReleaseArtifactPaths applicationReleaseArtifactPaths = null;
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
applicationReleaseArtifactPaths = applicationReleaseDAO
|
|
|
|
appReleaseHashValue = applicationReleaseDAO.getReleaseHashValue(uuid, tenantId);
|
|
|
|
.getReleaseArtifactPaths(uuid, tenantId);
|
|
|
|
artifactPath = appReleaseHashValue + Constants.FORWARD_SLASH + artifactName;
|
|
|
|
|
|
|
|
return applicationStorageManager.getFileSttream(artifactPath);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (ApplicationManagementDAOException e) {
|
|
|
|
} catch (ApplicationManagementDAOException e) {
|
|
|
|
// todo throw
|
|
|
|
// todo throw
|
|
|
|
// throw new ApplicationManagementException();
|
|
|
|
// throw new ApplicationManagementException();
|
|
|
|
// e.printStackTrace();
|
|
|
|
// e.printStackTrace();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String installerFileName = applicationReleaseArtifactPaths.getInstallerPath();
|
|
|
|
|
|
|
|
String iconFileName = applicationReleaseArtifactPaths.getIconPath();
|
|
|
|
|
|
|
|
String bannerFileName = applicationReleaseArtifactPaths.getBannerPath();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(installerFileName) && artifactName.equals(installerFileName)) {
|
|
|
|
|
|
|
|
artifactPath = applicationReleaseArtifactPaths.getInstallerPath();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(iconFileName) && artifactName.equals(iconFileName)) {
|
|
|
|
|
|
|
|
artifactPath = applicationReleaseArtifactPaths.getIconPath();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(bannerFileName) && artifactName.equals(bannerFileName)) {
|
|
|
|
|
|
|
|
artifactPath = applicationReleaseArtifactPaths.getBannerPath();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (String screenshotPath : applicationReleaseArtifactPaths.getScreenshotPaths()) {
|
|
|
|
|
|
|
|
if (screenshotPath != null && screenshotPath.contains(artifactName)) {
|
|
|
|
|
|
|
|
artifactPath = screenshotPath;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (artifactPath != null) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
return applicationStorageManager.getFileSttream(artifactPath);
|
|
|
|
|
|
|
|
}catch (ApplicationStorageManagementException e) {
|
|
|
|
}catch (ApplicationStorageManagementException e) {
|
|
|
|
// todo throw
|
|
|
|
// todo throw
|
|
|
|
// throw new ApplicationManagementException();
|
|
|
|
// throw new ApplicationManagementException();
|
|
|
|
// e.printStackTrace();
|
|
|
|
// e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|