|
|
|
@ -19,6 +19,7 @@ package org.wso2.carbon.device.application.mgt.core.impl;
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
|
|
|
import org.apache.commons.io.IOUtils;
|
|
|
|
|
import org.apache.commons.lang.StringEscapeUtils;
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
import org.apache.commons.validator.routines.UrlValidator;
|
|
|
|
|
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
|
|
|
|
@ -2603,4 +2604,47 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
|
throw new UnexpectedServerErrorException(msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getPlistArtifact(String releaseUuid) throws ApplicationManagementException {
|
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
|
try {
|
|
|
|
|
ConnectionManagerUtil.openDBConnection();
|
|
|
|
|
ApplicationDTO applicationDTO = this.applicationDAO.getApplicationByUUID(releaseUuid, tenantId);
|
|
|
|
|
if (applicationDTO == null) {
|
|
|
|
|
String msg = "Couldn't find application for the release UUID: " + releaseUuid;
|
|
|
|
|
log.error(msg);
|
|
|
|
|
throw new NotFoundException(msg);
|
|
|
|
|
}
|
|
|
|
|
ApplicationReleaseDTO applicationReleaseDTO = applicationDTO.getApplicationReleaseDTOs().get(0);
|
|
|
|
|
String artifactDownloadEndpoint = ConfigurationManager.getInstance().getConfiguration()
|
|
|
|
|
.getArtifactDownloadEndpoint();
|
|
|
|
|
String artifactDownloadURL = artifactDownloadEndpoint + Constants.FORWARD_SLASH + applicationReleaseDTO.getUuid()
|
|
|
|
|
+ Constants.FORWARD_SLASH + applicationReleaseDTO.getInstallerName();
|
|
|
|
|
String plistContent = "<!DOCTYPE plist PUBLIC "-//Apple//DTDPLIST1.0//EN" "" +
|
|
|
|
|
"http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="" +
|
|
|
|
|
"1.0"><dict><key>items</key><array><dict><" +
|
|
|
|
|
"key>assets</key><array><dict><key>kind</key><" +
|
|
|
|
|
"string>software-package</string><key>url</key><string>" +
|
|
|
|
|
"$downloadURL</string></dict></array><key>metadata<" +
|
|
|
|
|
"/key><dict><key>bundle-identifier</key><string>" +
|
|
|
|
|
"$packageName</string><key>bundle-version</key><string>" +
|
|
|
|
|
"$bundleVersion</string><key>kind</key><string>" +
|
|
|
|
|
"software</string><key>title</key><string>$appName<" +
|
|
|
|
|
"/string></dict></dict></array></dict></plist>";
|
|
|
|
|
plistContent = plistContent.replace("$downloadURL", artifactDownloadURL)
|
|
|
|
|
.replace("$packageName", applicationReleaseDTO.getPackageName())
|
|
|
|
|
.replace("$bundleVersion", applicationReleaseDTO.getVersion())
|
|
|
|
|
.replace("$appName", applicationDTO.getName());
|
|
|
|
|
return StringEscapeUtils.unescapeXml(plistContent);
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
|
throw new ApplicationManagementException(
|
|
|
|
|
"Error occurred while obtaining the database connection for getting application for the release UUID: "
|
|
|
|
|
+ releaseUuid, e);
|
|
|
|
|
} catch (ApplicationManagementDAOException e) {
|
|
|
|
|
throw new ApplicationManagementException(
|
|
|
|
|
"Error occurred while getting application data for release UUID: " + releaseUuid, e);
|
|
|
|
|
} finally {
|
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|