Improve web clip registering in APPM

feature/appm-store/pbac
lasanthaDLPDS 6 years ago
parent 0ae7479d49
commit 28bc9f3a77

@ -23,6 +23,6 @@ package org.wso2.carbon.device.application.mgt.common;
* Application Types.
*/
public enum ApplicationType {
ENTERPRISE, PUBLIC, WEB, WEB_CLIP
ENTERPRISE, PUBLIC, WEB_APP, WEB_CLIP
}

@ -35,7 +35,7 @@ import org.wso2.carbon.device.application.mgt.common.response.Tag;
import org.wso2.carbon.device.application.mgt.common.wrapper.ApplicationReleaseWrapper;
import org.wso2.carbon.device.application.mgt.common.wrapper.ApplicationUpdateWrapper;
import org.wso2.carbon.device.application.mgt.common.wrapper.ApplicationWrapper;
import org.wso2.carbon.device.application.mgt.common.wrapper.WebClipWrapper;
import org.wso2.carbon.device.application.mgt.common.wrapper.WebAppWrapper;
import java.util.List;
@ -54,7 +54,7 @@ public interface ApplicationManager {
Application createApplication(ApplicationWrapper applicationWrapper, ApplicationArtifact applicationArtifact)
throws ApplicationManagementException, RequestValidatingException;
Application createWebClip(WebClipWrapper webClipWrapper, ApplicationArtifact applicationArtifact)
Application createWebClip(WebAppWrapper webAppWrapper, ApplicationArtifact applicationArtifact)
throws ApplicationManagementException;
/**

@ -19,17 +19,22 @@ package org.wso2.carbon.device.application.mgt.common.wrapper;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotNull;
//todo add version attribute
@ApiModel(value = "ApplicationReleaseDTO", description = "This class holds the details when releasing an ApplicationDTO to application store")
public class WebClipReleaseWrapper {
public class WebAppReleaseWrapper {
@ApiModelProperty(name = "description",
value = "Description of the web clip release")
@NotNull
private String description;
@ApiModelProperty(name = "releaseType",
value = "Release type of the web clip release",
required = true,
example = "alpha, beta etc")
@NotNull
private String releaseType;
@ApiModelProperty(name = "price",
@ -40,6 +45,7 @@ public class WebClipReleaseWrapper {
@ApiModelProperty(name = "isSharedWithAllTenants",
value = "If web clip release is shared with all tenants it is equal to 1 otherwise 0",
required = true)
@NotNull
private boolean isSharedWithAllTenants;
@ApiModelProperty(name = "metaData",
@ -47,8 +53,15 @@ public class WebClipReleaseWrapper {
required = true)
private String metaData;
@ApiModelProperty(name = "version",
value = "Version of the web app release.",
required = true)
@NotNull
private String version;
@ApiModelProperty(name = "url",
value = "URL which is used for WEB-CLIP")
@NotNull
private String url;
public String getReleaseType() {
@ -94,4 +107,12 @@ public class WebClipReleaseWrapper {
public String getDescription() { return description; }
public void setDescription(String description) { this.description = description; }
public boolean isSharedWithAllTenants() { return isSharedWithAllTenants; }
public void setSharedWithAllTenants(boolean sharedWithAllTenants) { isSharedWithAllTenants = sharedWithAllTenants; }
public String getVersion() { return version; }
public void setVersion(String version) { this.version = version; }
}

@ -19,33 +19,45 @@ package org.wso2.carbon.device.application.mgt.common.wrapper;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotNull;
import java.util.List;
@ApiModel(value = "WebClipWrapper", description = "WebClipWrapper represents an ApplicationDTO in ApplicationDTO Store")
public class WebClipWrapper {
@ApiModel(value = "WebAppWrapper", description = "WebAppWrapper represents an ApplicationDTO in ApplicationDTO Store")
public class WebAppWrapper {
@ApiModelProperty(name = "name",
value = "Name of the web clip",
required = true)
@NotNull
private String name;
@ApiModelProperty(name = "description",
value = "Description of the web clip",
required = true)
@NotNull
private String description;
@ApiModelProperty(name = "categories",
value = "List of Categories",
required = true,
example = "Educational, Gaming, Travel, Entertainment etc")
@NotNull
private List<String> categories;
@ApiModelProperty(name = "subType",
value = "Subscription method of the web clip",
required = true,
example = "PAID, FREE")
@NotNull
private String subMethod;
@ApiModelProperty(name = "Web App Type",
value = "Type of the web app",
required = true,
example = "WEB_APP, WEB_CLIP")
@NotNull
private String type;
@ApiModelProperty(name = "paymentCurrency",
value = "Payment currency of the web clip",
required = true,
@ -54,16 +66,19 @@ public class WebClipWrapper {
@ApiModelProperty(name = "tags",
value = "List of tags")
@NotNull
private List<String> tags;
@ApiModelProperty(name = "unrestrictedRoles",
value = "List of roles that users should have to view the web clip")
@NotNull
private List<String> unrestrictedRoles;
@ApiModelProperty(name = "applicationReleaseWrappers",
value = "List of web clip releases",
required = true)
private List<WebClipReleaseWrapper> webClipReleaseWrappers;
@NotNull
private List<WebAppReleaseWrapper> webAppReleaseWrappers;
public String getName() {
return name;
@ -87,10 +102,10 @@ public class WebClipWrapper {
public void setDescription(String description) { this.description = description; }
public List<WebClipReleaseWrapper> getWebClipReleaseWrappers() { return webClipReleaseWrappers; }
public List<WebAppReleaseWrapper> getWebAppReleaseWrappers() { return webAppReleaseWrappers; }
public void setWebClipReleaseWrappers(List<WebClipReleaseWrapper> webClipReleaseWrappers) {
this.webClipReleaseWrappers = webClipReleaseWrappers; }
public void setWebAppReleaseWrappers(List<WebAppReleaseWrapper> webAppReleaseWrappers) {
this.webAppReleaseWrappers = webAppReleaseWrappers; }
public List<String> getCategories() { return categories; }
@ -99,4 +114,8 @@ public class WebClipWrapper {
public String getSubMethod() { return subMethod; }
public void setSubMethod(String subMethod) { this.subMethod = subMethod; }
public String getType() { return type; }
public void setType(String type) { this.type = type; }
}

@ -1028,7 +1028,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
Connection conn;
String sql = "UPDATE " +
"AP_APP_CATEGORY cat " +
"SET cat.CATEGORY_NAME = ? " +
"SET cat.CATEGORY = ? " +
"WHERE " +
"cat.ID = ? AND " +
"cat.TENANT_ID = ?";

@ -58,8 +58,8 @@ import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorage
import org.wso2.carbon.device.application.mgt.common.wrapper.ApplicationReleaseWrapper;
import org.wso2.carbon.device.application.mgt.common.wrapper.ApplicationUpdateWrapper;
import org.wso2.carbon.device.application.mgt.common.wrapper.ApplicationWrapper;
import org.wso2.carbon.device.application.mgt.common.wrapper.WebClipReleaseWrapper;
import org.wso2.carbon.device.application.mgt.common.wrapper.WebClipWrapper;
import org.wso2.carbon.device.application.mgt.common.wrapper.WebAppReleaseWrapper;
import org.wso2.carbon.device.application.mgt.common.wrapper.WebAppWrapper;
import org.wso2.carbon.device.application.mgt.core.config.ConfigurationManager;
import org.wso2.carbon.device.application.mgt.core.dao.ApplicationDAO;
import org.wso2.carbon.device.application.mgt.core.dao.ApplicationReleaseDAO;
@ -622,7 +622,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
}
@Override
public Application createWebClip(WebClipWrapper webClipWrapper, ApplicationArtifact applicationArtifact)
public Application createWebClip(WebAppWrapper webAppWrapper, ApplicationArtifact applicationArtifact)
throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
@ -632,7 +632,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
}
List<Integer> categoryIds;
ApplicationDTO applicationDTO = APIUtil.convertToAppDTO(webClipWrapper);
ApplicationDTO applicationDTO = APIUtil.convertToAppDTO(webAppWrapper);
List<String> unrestrictedRoles = applicationDTO.getUnrestrictedRoles();
List<String> tags = applicationDTO.getTags();
List<String> categories = applicationDTO.getAppCategories();
@ -645,7 +645,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
throw new ApplicationManagementException(msg, e);
} catch (ApplicationManagementDAOException e) {
String msg = "Error occurred while getting data which is related to application. application name: "
+ webClipWrapper.getName() + ".";
+ webAppWrapper.getName() + ".";
log.error(msg);
throw new ApplicationManagementException(msg, e);
} finally {
@ -665,7 +665,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
applicationDTO.getApplicationReleaseDTOs().clear();
applicationDTO.getApplicationReleaseDTOs().add(applicationReleaseDTO);
} catch (ResourceManagementException e) {
String msg = "Error Occured when uploading artifacts of the application: " + webClipWrapper.getName();
String msg = "Error Occured when uploading artifacts of the application: " + webAppWrapper.getName();
log.error(msg);
throw new ApplicationManagementException(msg, e);
}
@ -748,7 +748,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
} catch (LifeCycleManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction();
String msg =
"Error occurred while adding lifecycle state. application name: " + webClipWrapper.getName() + ".";
"Error occurred while adding lifecycle state. application name: " + webAppWrapper.getName() + ".";
log.error(msg);
try {
applicationStorageManager.deleteAllApplicationReleaseArtifacts(
@ -764,13 +764,13 @@ public class ApplicationManagerImpl implements ApplicationManager {
} catch (ApplicationManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction();
String msg = "Error occurred while adding application or application release. application name: "
+ webClipWrapper.getName() + ".";
+ webAppWrapper.getName() + ".";
log.error(msg);
deleteApplicationArtifacts(Collections.singletonList(applicationReleaseDTO.getAppHashValue()));
throw new ApplicationManagementException(msg, e);
} catch (LifecycleManagementException e) {
ConnectionManagerUtil.rollbackDBTransaction();
String msg = "Error occurred when getting initial lifecycle state. application name: " + webClipWrapper
String msg = "Error occurred when getting initial lifecycle state. application name: " + webAppWrapper
.getName() + ".";
log.error(msg);
deleteApplicationArtifacts(Collections.singletonList(applicationReleaseDTO.getAppHashValue()));
@ -782,7 +782,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
} catch (VisibilityManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction();
String msg =
"Error occurred while adding unrestricted roles. application name: " + webClipWrapper.getName()
"Error occurred while adding unrestricted roles. application name: " + webAppWrapper.getName()
+ ".";
log.error(msg);
deleteApplicationArtifacts(Collections.singletonList(applicationReleaseDTO.getAppHashValue()));
@ -2489,37 +2489,37 @@ public class ApplicationManagerImpl implements ApplicationManager {
log.error(msg);
throw new BadRequestException(msg);
}
} else if (param instanceof WebClipWrapper) {
WebClipWrapper webClipWrapper = (WebClipWrapper) param;
if (StringUtils.isEmpty(webClipWrapper.getName())) {
} else if (param instanceof WebAppWrapper) {
WebAppWrapper webAppWrapper = (WebAppWrapper) param;
if (StringUtils.isEmpty(webAppWrapper.getName())) {
String msg = "Web Clip name cannot be empty.";
log.error(msg);
throw new BadRequestException(msg);
}
if (webClipWrapper.getCategories() == null) {
if (webAppWrapper.getCategories() == null) {
String msg = "Web Clip category can't be null.";
log.error(msg);
throw new BadRequestException(msg);
}
if (webClipWrapper.getCategories().isEmpty()) {
if (webAppWrapper.getCategories().isEmpty()) {
String msg = "Web clip category can't be empty.";
log.error(msg);
throw new BadRequestException(msg);
}
List<WebClipReleaseWrapper> webClipReleaseWrappers;
webClipReleaseWrappers = webClipWrapper.getWebClipReleaseWrappers();
List<WebAppReleaseWrapper> webAppReleaseWrappers;
webAppReleaseWrappers = webAppWrapper.getWebAppReleaseWrappers();
if (webClipReleaseWrappers == null || webClipReleaseWrappers.size() != 1) {
if (webAppReleaseWrappers == null || webAppReleaseWrappers.size() != 1) {
String msg = "Invalid web clip creating request. Web clip creating request must have single "
+ "web clip release. Web clip name:" + webClipWrapper.getName() + ".";
+ "web clip release. Web clip name:" + webAppWrapper.getName() + ".";
log.error(msg);
throw new BadRequestException(msg);
}
try {
ConnectionManagerUtil.openDBConnection();
List<String> unrestrictedRoles = webClipWrapper.getUnrestrictedRoles();
List<String> unrestrictedRoles = webAppWrapper.getUnrestrictedRoles();
if (unrestrictedRoles != null && !unrestrictedRoles.isEmpty()) {
if (!isValidRestrictedRole(unrestrictedRoles)) {
@ -2538,7 +2538,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
Filter filter = new Filter();
filter.setFullMatch(true);
filter.setAppName(webClipWrapper.getName().trim());
filter.setAppName(webAppWrapper.getName().trim());
filter.setOffset(0);
filter.setLimit(1);
List<ApplicationDTO> applicationList = applicationDAO.getApplications(filter, -1, tenantId);
@ -2551,7 +2551,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
}
List<CategoryDTO> registeredCategories = this.applicationDAO.getAllCategories(tenantId);
List<String> appCategories = webClipWrapper.getCategories();
List<String> appCategories = webAppWrapper.getCategories();
if (registeredCategories.isEmpty()) {
ConnectionManagerUtil.rollbackDBTransaction();
@ -2583,7 +2583,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
throw new ApplicationManagementException(msg, e);
} catch (ApplicationManagementDAOException e) {
String msg = "Error occurred while getting data which is related to web clip. web clip name: "
+ webClipWrapper.getName() + ".";
+ webAppWrapper.getName() + ".";
log.error(msg);
throw new ApplicationManagementException(msg, e);
} catch (UserStoreException e) {
@ -2614,16 +2614,16 @@ public class ApplicationManagerImpl implements ApplicationManager {
log.error(msg);
throw new BadRequestException(msg);
}
} if (param instanceof WebClipReleaseWrapper){
WebClipReleaseWrapper webClipReleaseWrapper = (WebClipReleaseWrapper) param;
} if (param instanceof WebAppReleaseWrapper){
WebAppReleaseWrapper webAppReleaseWrapper = (WebAppReleaseWrapper) param;
UrlValidator urlValidator = new UrlValidator();
if (StringUtils
.isEmpty(webClipReleaseWrapper.getUrl())){
.isEmpty(webAppReleaseWrapper.getUrl())){
String msg = "URL should't be null for the application release creating request for application type WEB_CLIP";
log.error(msg);
throw new BadRequestException(msg);
}
if (!urlValidator.isValid(webClipReleaseWrapper.getUrl())){
if (!urlValidator.isValid(webAppReleaseWrapper.getUrl())){
String msg = "Request payload contains an invalid Web Clip URL.";
log.error(msg);
throw new BadRequestException(msg);

@ -30,8 +30,8 @@ import org.wso2.carbon.device.application.mgt.common.services.*;
import org.wso2.carbon.device.application.mgt.common.ErrorResponse;
import org.wso2.carbon.device.application.mgt.common.wrapper.ApplicationReleaseWrapper;
import org.wso2.carbon.device.application.mgt.common.wrapper.ApplicationWrapper;
import org.wso2.carbon.device.application.mgt.common.wrapper.WebClipReleaseWrapper;
import org.wso2.carbon.device.application.mgt.common.wrapper.WebClipWrapper;
import org.wso2.carbon.device.application.mgt.common.wrapper.WebAppReleaseWrapper;
import org.wso2.carbon.device.application.mgt.common.wrapper.WebAppWrapper;
import org.wso2.carbon.device.application.mgt.core.config.ConfigurationManager;
import org.wso2.carbon.device.application.mgt.core.exception.BadRequestException;
import org.wso2.carbon.device.application.mgt.core.exception.UnexpectedServerErrorException;
@ -235,16 +235,17 @@ public class APIUtil {
List<ApplicationReleaseDTO> applicationReleaseEntities = applicationWrapper.getApplicationReleaseWrappers()
.stream().map(APIUtil::releaseWrapperToReleaseDTO).collect(Collectors.toList());
applicationDTO.setApplicationReleaseDTOs(applicationReleaseEntities);
} else if (param instanceof WebClipWrapper){
WebClipWrapper webClipWrapper = (WebClipWrapper) param;
applicationDTO.setName(webClipWrapper.getName());
applicationDTO.setDescription(webClipWrapper.getDescription());
applicationDTO.setAppCategories(webClipWrapper.getCategories());
applicationDTO.setSubType(webClipWrapper.getSubMethod());
applicationDTO.setPaymentCurrency(webClipWrapper.getPaymentCurrency());
applicationDTO.setTags(webClipWrapper.getTags());
applicationDTO.setUnrestrictedRoles(webClipWrapper.getUnrestrictedRoles());
List<ApplicationReleaseDTO> applicationReleaseEntities = webClipWrapper.getWebClipReleaseWrappers()
} else if (param instanceof WebAppWrapper){
WebAppWrapper webAppWrapper = (WebAppWrapper) param;
applicationDTO.setName(webAppWrapper.getName());
applicationDTO.setDescription(webAppWrapper.getDescription());
applicationDTO.setAppCategories(webAppWrapper.getCategories());
applicationDTO.setSubType(webAppWrapper.getSubMethod());
applicationDTO.setPaymentCurrency(webAppWrapper.getPaymentCurrency());
applicationDTO.setType(webAppWrapper.getType());
applicationDTO.setTags(webAppWrapper.getTags());
applicationDTO.setUnrestrictedRoles(webAppWrapper.getUnrestrictedRoles());
List<ApplicationReleaseDTO> applicationReleaseEntities = webAppWrapper.getWebAppReleaseWrappers()
.stream().map(APIUtil::releaseWrapperToReleaseDTO).collect(Collectors.toList());
applicationDTO.setApplicationReleaseDTOs(applicationReleaseEntities);
}
@ -262,14 +263,15 @@ public class APIUtil {
applicationReleaseDTO.setIsSharedWithAllTenants(applicationReleaseWrapper.getIsSharedWithAllTenants());
applicationReleaseDTO.setMetaData(applicationReleaseWrapper.getMetaData());
applicationReleaseDTO.setSupportedOsVersions(applicationReleaseWrapper.getSupportedOsVersions());
} else if (param instanceof WebClipReleaseWrapper){
WebClipReleaseWrapper webClipReleaseWrapper = (WebClipReleaseWrapper) param;
applicationReleaseDTO.setDescription(webClipReleaseWrapper.getDescription());
applicationReleaseDTO.setReleaseType(webClipReleaseWrapper.getReleaseType());
applicationReleaseDTO.setPrice(webClipReleaseWrapper.getPrice());
applicationReleaseDTO.setInstallerName(webClipReleaseWrapper.getUrl());
applicationReleaseDTO.setIsSharedWithAllTenants(webClipReleaseWrapper.getIsSharedWithAllTenants());
applicationReleaseDTO.setMetaData(webClipReleaseWrapper.getMetaData());
} else if (param instanceof WebAppReleaseWrapper){
WebAppReleaseWrapper webAppReleaseWrapper = (WebAppReleaseWrapper) param;
applicationReleaseDTO.setDescription(webAppReleaseWrapper.getDescription());
applicationReleaseDTO.setReleaseType(webAppReleaseWrapper.getReleaseType());
applicationReleaseDTO.setVersion(webAppReleaseWrapper.getVersion());
applicationReleaseDTO.setPrice(webAppReleaseWrapper.getPrice());
applicationReleaseDTO.setInstallerName(webAppReleaseWrapper.getUrl());
applicationReleaseDTO.setIsSharedWithAllTenants(webAppReleaseWrapper.getIsSharedWithAllTenants());
applicationReleaseDTO.setMetaData(webAppReleaseWrapper.getMetaData());
}
return applicationReleaseDTO;
}
@ -278,7 +280,11 @@ public class APIUtil {
throws BadRequestException, UnexpectedServerErrorException {
Application application = new Application();
DeviceType deviceType = getDeviceTypeData(applicationDTO.getDeviceTypeId());
//This is for handling web-apps
if (applicationDTO.getDeviceTypeId() > 0) {
DeviceType deviceType = getDeviceTypeData(applicationDTO.getDeviceTypeId());
application.setDeviceType(deviceType.getName());
}
application.setId(applicationDTO.getId());
application.setName(applicationDTO.getName());
application.setDescription(applicationDTO.getDescription());
@ -288,7 +294,6 @@ public class APIUtil {
application.setPaymentCurrency(applicationDTO.getPaymentCurrency());
application.setTags(applicationDTO.getTags());
application.setUnrestrictedRoles(applicationDTO.getUnrestrictedRoles());
application.setDeviceType(deviceType.getName());
application.setRating(applicationDTO.getAppRating());
List<ApplicationRelease> applicationReleases = applicationDTO.getApplicationReleaseDTOs()
.stream().map(APIUtil::releaseDtoToRelease).collect(Collectors.toList());

@ -24,8 +24,10 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.json.JSONException;
@ -60,6 +62,12 @@ public class HandlerUtil {
} else if (httpMethod instanceof HttpGet) {
HttpGet method = (HttpGet) httpMethod;
response = client.execute(method);
} else if (httpMethod instanceof HttpPut) {
HttpPut method = (HttpPut) httpMethod;
response = client.execute(method);
} else if (httpMethod instanceof HttpDelete) {
HttpDelete method = (HttpDelete) httpMethod;
response = client.execute(method);
}
ProxyResponse proxyResponse = new ProxyResponse();

@ -42,7 +42,7 @@ import org.wso2.carbon.device.application.mgt.common.response.ApplicationRelease
import org.wso2.carbon.device.application.mgt.common.wrapper.ApplicationReleaseWrapper;
import org.wso2.carbon.device.application.mgt.common.wrapper.ApplicationUpdateWrapper;
import org.wso2.carbon.device.application.mgt.common.wrapper.ApplicationWrapper;
import org.wso2.carbon.device.application.mgt.common.wrapper.WebClipWrapper;
import org.wso2.carbon.device.application.mgt.common.wrapper.WebAppWrapper;
import java.util.List;
import javax.validation.Valid;
@ -375,7 +375,7 @@ public interface ApplicationManagementPublisherAPI {
name = "webapp",
value = "The web app that need to be created.",
required = true)
@Multipart("webapp") WebClipWrapper webClipWrapper,
@Multipart("webapp") WebAppWrapper webAppWrapper,
@ApiParam(
name = "icon",
value = "Icon of the uploading web app",

@ -32,7 +32,7 @@ import org.wso2.carbon.device.application.mgt.common.services.AppmDataHandler;
import org.wso2.carbon.device.application.mgt.common.wrapper.ApplicationReleaseWrapper;
import org.wso2.carbon.device.application.mgt.common.wrapper.ApplicationUpdateWrapper;
import org.wso2.carbon.device.application.mgt.common.wrapper.ApplicationWrapper;
import org.wso2.carbon.device.application.mgt.common.wrapper.WebClipWrapper;
import org.wso2.carbon.device.application.mgt.common.wrapper.WebAppWrapper;
import org.wso2.carbon.device.application.mgt.core.exception.BadRequestException;
import org.wso2.carbon.device.application.mgt.core.exception.ForbiddenException;
import org.wso2.carbon.device.application.mgt.core.exception.UnexpectedServerErrorException;
@ -209,7 +209,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
@Consumes("multipart/mixed")
@Path("/web-app")
public Response createWebApp(
@Multipart("webapp") WebClipWrapper webClipWrapper,
@Multipart("webapp") WebAppWrapper webAppWrapper,
@Multipart("icon") Attachment iconFile,
@Multipart("banner") Attachment bannerFile,
@Multipart("screenshot1") Attachment screenshot1,
@ -218,12 +218,12 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
ApplicationManager applicationManager = APIUtil.getApplicationManager();
List<Attachment> attachmentList = constructAttachmentList(screenshot1, screenshot2, screenshot3);
try {
applicationManager.validateAppCreatingRequest(webClipWrapper);
applicationManager.validateReleaseCreatingRequest(webClipWrapper.getWebClipReleaseWrappers().get(0));
applicationManager.validateAppCreatingRequest(webAppWrapper);
applicationManager.validateReleaseCreatingRequest(webAppWrapper.getWebAppReleaseWrappers().get(0));
applicationManager.validateImageArtifacts(iconFile, bannerFile, attachmentList);
// Created new application entry
Application application = applicationManager.createWebClip(webClipWrapper,
Application application = applicationManager.createWebClip(webAppWrapper,
constructApplicationArtifact(null, iconFile, bannerFile, attachmentList));
if (application != null) {
return Response.status(Response.Status.CREATED).entity(application).build();

@ -36,7 +36,7 @@ CREATE TABLE IF NOT EXISTS AP_APP_RELEASE(
APP_HASH_VALUE VARCHAR(1000) NOT NULL,
SHARED_WITH_ALL_TENANTS BOOLEAN NOT NULL DEFAULT FALSE,
APP_META_INFO CLOB NULL DEFAULT NULL,
SUPPORTED_OS_VERSIONS VARCHAR(45) NOT NULL,
SUPPORTED_OS_VERSIONS VARCHAR(45) NULL DEFAULT NULL,
RATING DOUBLE NULL DEFAULT NULL,
CURRENT_STATE VARCHAR(45) NOT NULL,
RATED_USERS INTEGER NULL,

Loading…
Cancel
Save