Resolve conflicts

feature/appm-store/pbac
geethkokila 6 years ago
commit 0dea5cd0aa

@ -19,72 +19,73 @@
package org.wso2.carbon.device.application.mgt.common; package org.wso2.carbon.device.application.mgt.common;
import org.wso2.carbon.device.application.mgt.common.jaxrs.Exclude; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.List; import java.util.List;
/**
* Application represents the an Application in Application Store. @ApiModel(value = "Application", description = "Application represents the an Application in Application Store")
*/
public class Application { public class Application {
@Exclude @ApiModelProperty(name = "id",
value = "The ID given to the application when it is stored in the APPM database")
private int id; private int id;
/** @ApiModelProperty(name = "name",
* Name of the application value = "Name of the application",
*/ required = true)
private String name; private String name;
/** @ApiModelProperty(name = "appCategory",
* Category of the application. value = "Category of the application",
* e.g: Educational, Gaming, Travel, Entertainment etc. required = true,
*/ example = "Educational, Gaming, Travel, Entertainment etc")
private String appCategory; private String appCategory;
/** @ApiModelProperty(name = "type",
* Type of the application value = "Type of the application",
* e.g. Mobile, Web, Web Clip etc required = true,
*/ example = "Mobile, Web, Web Clip etc")
private String type; private String type;
/** @ApiModelProperty(name = "subType",
* Subscription type of the application. value = "Subscription type of the application",
* e.g: PAID, FREE required = true,
*/ example = "PAID, FREE")
private String subType; private String subType;
/** @ApiModelProperty(name = "paymentCurrency",
* Payment currency of the application and the default value is '$'. value = "Payment currency of the application",
*/ required = true,
example = "$")
private String paymentCurrency; private String paymentCurrency;
/** @ApiModelProperty(name = "tags",
* List of application tags value = "List of application tags")
*/
private List<Tag> tags; private List<Tag> tags;
/** @ApiModelProperty(name = "user",
* Application creating user value = "Application creating user")
*/
private User user; private User user;
/** @ApiModelProperty(name = "unrestrictedRoles",
* List of roles that users should have to access the application value = "List of roles that users should have to access the application")
*/
private List<UnrestrictedRole> unrestrictedRoles; private List<UnrestrictedRole> unrestrictedRoles;
/** @ApiModelProperty(name = "isRestricted",
* If unrestricted roles are defined then isRestricted value is true otherwise it is false. value = "If unrestricted roles are defined then isRestricted value is true otherwise it is false")
*/
private boolean isRestricted; private boolean isRestricted;
/** @ApiModelProperty(name = "deviceType",
* Related device type of the application. value = "Related device type of the application",
* e.g: IoS, Android, Arduino, RaspberryPi etc required = true,
*/ example = "IoS, Android, Arduino, RaspberryPi etc")
private String deviceType; private String deviceType;
@ApiModelProperty(name = "applicationReleases",
value = "List of application releases",
required = true)
private List<ApplicationRelease> applicationReleases; private List<ApplicationRelease> applicationReleases;
public int getId() { public int getId() {

@ -18,107 +18,91 @@
*/ */
package org.wso2.carbon.device.application.mgt.common; package org.wso2.carbon.device.application.mgt.common;
import org.wso2.carbon.device.application.mgt.common.jaxrs.Exclude; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.sql.Timestamp; @ApiModel(value = "ApplicationRelease", description = "This class holds the details when releasing an Application to application store")
/**
* This class holds the details when releasing an Application to application store.
*/
public class ApplicationRelease { public class ApplicationRelease {
@Exclude @ApiModelProperty(name = "id",
value = "ID of the application release")
private int id; private int id;
/** @ApiModelProperty(name = "version",
* Version of the application release value = "Version of the application release")
*/
private String version; private String version;
/** @ApiModelProperty(name = "uuid",
* UUID of the application release value = "UUID of the application release")
*/
private String uuid; private String uuid;
/** @ApiModelProperty(name = "appStoredLoc",
* Application storing location value = "Application storing location")
*/
private String appStoredLoc; private String appStoredLoc;
/** @ApiModelProperty(name = "bannerLoc",
* Banner file storing location value = "Banner file storing location")
*/
private String bannerLoc; private String bannerLoc;
/** @ApiModelProperty(name = "screenshotLoc1",
* Screenshot storing location value = "Screenshot storing location")
*/
private String screenshotLoc1; private String screenshotLoc1;
/** @ApiModelProperty(name = "screenshotLoc2",
* Screenshot storing location value = "Screenshot storing location")
*/
private String screenshotLoc2; private String screenshotLoc2;
/** @ApiModelProperty(name = "screenshotLoc3",
* Screenshot storing location value = "Screenshot storing location")
*/
private String screenshotLoc3; private String screenshotLoc3;
/** @ApiModelProperty(name = "iconLoc",
* Application release creator value = "icon file storing location")
*/ private String iconLoc;
@ApiModelProperty(name = "applicationCreator",
value = "Application release creator")
private String applicationCreator; private String applicationCreator;
/** @ApiModelProperty(name = "releaseType",
* Release type of the application release value = "Release type of the application release",
* e.g: alpha, beta etc required = true,
*/ example = "alpha, beta etc")
private String releaseType; private String releaseType;
/** @ApiModelProperty(name = "price",
* Price of the application release value = "Price of the application release",
*/ required = true)
private Double price; private Double price;
/** @ApiModelProperty(name = "appHashValue",
* icon file storing location value = "Hash value of the application release")
*/
private String iconLoc;
/**
* Hash value of the application release
*/
private String appHashValue; private String appHashValue;
/** @ApiModelProperty(name = "isSharedWithAllTenants",
* If application release is shared with all tenants it is eqal to 1 otherwise 0 value = "If application release is shared with all tenants it is eqal to 1 otherwise 0",
*/ required = true)
private int isSharedWithAllTenants; private int isSharedWithAllTenants;
/** @ApiModelProperty(name = "metaData",
* MEta data of the application release value = "Meta data of the application release",
*/ required = true)
private String metaData; private String metaData;
/** @ApiModelProperty(name = "ratedUsers",
* Number of users who has rated the application release value = "Number of users who has rated the application release")
*/
private int ratedUsers; private int ratedUsers;
/** @ApiModelProperty(name = "rating",
* Rating value of the application release value = "Rating value of the application release")
*/
private Double rating; private Double rating;
/** @ApiModelProperty(name = "url",
* URL which is used for WEB-CLIP value = "URL which is used for WEB-CLIP")
*/
private String url; private String url;
/** @ApiModelProperty(name = "lifecycleState",
* Latest Lifecycle state of the application release value = "Latest Lifecycle state of the application release")
*/
private LifecycleState lifecycleState; private LifecycleState lifecycleState;
public int getRatedUsers() { public int getRatedUsers() {

@ -19,28 +19,41 @@
package org.wso2.carbon.device.application.mgt.common; package org.wso2.carbon.device.application.mgt.common;
import java.sql.Timestamp; import java.sql.Timestamp;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.List; import java.util.List;
@ApiModel(value = "LifecycleState", description = "LifecycleState represents the an Lifecycle state for an application release")
public class LifecycleState { public class LifecycleState {
@ApiModelProperty(name = "id",
value = "ID of the application release lifecycle",
required = true)
private int id; private int id;
@ApiModelProperty(name = "currentState",
value = "Current state of the application release",
required = true)
private String currentState; private String currentState;
@ApiModelProperty(name = "previousState",
value = "Previous state of the application release",
required = true)
private String previousState; private String previousState;
@ApiModelProperty(name = "nextStates",
value = "Next possible transferring states from the current state")
private List<String> nextStates; private List<String> nextStates;
@ApiModelProperty(name = "updatedBy",
value = "Username who is update the application release state")
private String updatedBy; private String updatedBy;
@ApiModelProperty(name = "updatedAt",
value = "Timestamp of the lifecycle has been updated")
private Timestamp updatedAt; private Timestamp updatedAt;
private int tenantId;
private int releaseId;
private int appId;
public int getId() { public int getId() {
return id; return id;
} }
@ -81,30 +94,6 @@ public class LifecycleState {
this.updatedAt = updatedAt; this.updatedAt = updatedAt;
} }
public int getTenantId() {
return tenantId;
}
public void setTenantId(int tenantId) {
this.tenantId = tenantId;
}
public int getReleaseId() {
return releaseId;
}
public void setReleaseId(int releaseId) {
this.releaseId = releaseId;
}
public int getAppId() {
return appId;
}
public void setAppId(int appId) {
this.appId = appId;
}
public List<String> getNextStates() { public List<String> getNextStates() {
return nextStates; return nextStates;
} }

@ -93,6 +93,20 @@
</instructions> </instructions>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
<systemPropertyVariables>
<jacoco-agent.destfile>${basedir}/target/coverage-reports/jacoco-unit.exec</jacoco-agent.destfile>
<log4j.configuration>file:src/test/resources/log4j.properties</log4j.configuration>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>

@ -33,7 +33,7 @@ public interface LifecycleStateDAO {
List<LifecycleState> getLifecycleStates(int appReleaseId) throws LifeCycleManagementDAOException; List<LifecycleState> getLifecycleStates(int appReleaseId) throws LifeCycleManagementDAOException;
void addLifecycleState(LifecycleState state) throws LifeCycleManagementDAOException; void addLifecycleState(LifecycleState state, int appId, int releaseId, int tenantId) throws LifeCycleManagementDAOException;
void deleteLifecycleState(int identifier) throws LifeCycleManagementDAOException; void deleteLifecycleState(int identifier) throws LifeCycleManagementDAOException;

@ -92,7 +92,6 @@ public class GenericLifecycleStateDAOImpl extends AbstractDAOImpl implements Lif
lifecycleState.setId(rs.getInt("ID")); lifecycleState.setId(rs.getInt("ID"));
lifecycleState.setCurrentState(rs.getString("CURRENT_STATE")); lifecycleState.setCurrentState(rs.getString("CURRENT_STATE"));
lifecycleState.setPreviousState(rs.getString("PREVIOUSE_STATE")); lifecycleState.setPreviousState(rs.getString("PREVIOUSE_STATE"));
lifecycleState.setTenantId(rs.getInt("TENANT_ID"));
lifecycleState.setUpdatedAt(rs.getTimestamp("UPDATED_AT")); lifecycleState.setUpdatedAt(rs.getTimestamp("UPDATED_AT"));
lifecycleState.setUpdatedBy(rs.getString("UPDATED_BY")); lifecycleState.setUpdatedBy(rs.getString("UPDATED_BY"));
lifecycleStates.add(lifecycleState); lifecycleStates.add(lifecycleState);
@ -109,7 +108,7 @@ public class GenericLifecycleStateDAOImpl extends AbstractDAOImpl implements Lif
} }
@Override @Override
public void addLifecycleState(LifecycleState state) throws LifeCycleManagementDAOException { public void addLifecycleState(LifecycleState state, int appId, int releaseId, int tenantId) throws LifeCycleManagementDAOException {
Connection conn = null; Connection conn = null;
PreparedStatement stmt = null; PreparedStatement stmt = null;
try { try {
@ -119,10 +118,10 @@ public class GenericLifecycleStateDAOImpl extends AbstractDAOImpl implements Lif
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
stmt.setString(1, state.getCurrentState()); stmt.setString(1, state.getCurrentState());
stmt.setString(2, state.getPreviousState()); stmt.setString(2, state.getPreviousState());
stmt.setInt(3, state.getTenantId()); stmt.setInt(3, tenantId);
stmt.setString(4, state.getUpdatedBy()); stmt.setString(4, state.getUpdatedBy());
stmt.setInt(5, state.getReleaseId()); stmt.setInt(5, releaseId);
stmt.setInt(6, state.getAppId()); stmt.setInt(6, appId);
stmt.executeUpdate(); stmt.executeUpdate();
} catch (DBConnectionException e) { } catch (DBConnectionException e) {

@ -126,21 +126,23 @@ public class ApplicationManagerImpl implements ApplicationManager {
"Invalid payload. Application creating payload should contains one application release, but " "Invalid payload. Application creating payload should contains one application release, but "
+ "the payload contains more than one"); + "the payload contains more than one");
} }
ConnectionManagerUtil.commitDBTransaction();
applicationRelease = application.getApplicationReleases().get(0); applicationRelease = application.getApplicationReleases().get(0);
applicationRelease = ApplicationManagementDAOFactory.getApplicationReleaseDAO(). applicationRelease = ApplicationManagementDAOFactory.getApplicationReleaseDAO().
createRelease(applicationRelease, application.getId(), tenantId); createRelease(applicationRelease, application.getId(), tenantId);
LifecycleState lifecycleState = new LifecycleState(); LifecycleState lifecycleState = new LifecycleState();
lifecycleState.setAppId(application.getId());
lifecycleState.setReleaseId(applicationRelease.getId());
lifecycleState.setUpdatedBy(userName); lifecycleState.setUpdatedBy(userName);
lifecycleState.setTenantId(tenantId);
lifecycleState.setCurrentState(AppLifecycleState.CREATED.toString()); lifecycleState.setCurrentState(AppLifecycleState.CREATED.toString());
lifecycleState.setPreviousState(AppLifecycleState.CREATED.toString()); lifecycleState.setPreviousState(AppLifecycleState.CREATED.toString());
addLifecycleState(application.getId(), applicationRelease.getUuid(), lifecycleState); addLifecycleState(application.getId(), applicationRelease.getUuid(), lifecycleState);
LifecycleStateDAO lifecycleStateDAO = ApplicationManagementDAOFactory.getLifecycleStateDAO();
lifecycleStateDAO.addLifecycleState(lifecycleState, application.getId(), applicationRelease.getId(), tenantId);
applicationRelease.setLifecycleState(lifecycleState); applicationRelease.setLifecycleState(lifecycleState);
applicationReleases.add(applicationRelease); applicationReleases.add(applicationRelease);
application.setApplicationReleases(applicationReleases); application.setApplicationReleases(applicationReleases);
ConnectionManagerUtil.commitDBTransaction();
} }
return application; return application;
@ -155,6 +157,11 @@ public class ApplicationManagerImpl implements ApplicationManager {
log.error(msg, e); log.error(msg, e);
ConnectionManagerUtil.rollbackDBTransaction(); ConnectionManagerUtil.rollbackDBTransaction();
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
} catch (LifeCycleManagementDAOException e) {
String msg = "Error occurred while adding application lifecycle state";
log.error(msg, e);
ConnectionManagerUtil.rollbackDBTransaction();
throw new ApplicationManagementException(msg, e);
}finally { }finally {
ConnectionManagerUtil.closeDBConnection(); ConnectionManagerUtil.closeDBConnection();
} }
@ -399,7 +406,6 @@ public class ApplicationManagerImpl implements ApplicationManager {
LifecycleState newAppLifecycleState = new LifecycleState(); LifecycleState newAppLifecycleState = new LifecycleState();
newAppLifecycleState.setPreviousState(appLifecycleState.getCurrentState()); newAppLifecycleState.setPreviousState(appLifecycleState.getCurrentState());
newAppLifecycleState.setCurrentState(AppLifecycleState.REMOVED.toString()); newAppLifecycleState.setCurrentState(AppLifecycleState.REMOVED.toString());
newAppLifecycleState.setTenantId(tenantId);
newAppLifecycleState.setUpdatedBy(userName); newAppLifecycleState.setUpdatedBy(userName);
addLifecycleState(applicationId, applicationRelease.getUuid(), newAppLifecycleState); addLifecycleState(applicationId, applicationRelease.getUuid(), newAppLifecycleState);
storedLocations.add(applicationRelease.getAppHashValue()); storedLocations.add(applicationRelease.getAppHashValue());
@ -437,7 +443,6 @@ public class ApplicationManagerImpl implements ApplicationManager {
LifecycleState newAppLifecycleState = new LifecycleState(); LifecycleState newAppLifecycleState = new LifecycleState();
newAppLifecycleState.setPreviousState(appLifecycleState.getCurrentState()); newAppLifecycleState.setPreviousState(appLifecycleState.getCurrentState());
newAppLifecycleState.setCurrentState(AppLifecycleState.REMOVED.toString()); newAppLifecycleState.setCurrentState(AppLifecycleState.REMOVED.toString());
newAppLifecycleState.setTenantId(tenantId);
newAppLifecycleState.setUpdatedBy(userName); newAppLifecycleState.setUpdatedBy(userName);
addLifecycleState(applicationId, applicationRelease.getUuid(), newAppLifecycleState); addLifecycleState(applicationId, applicationRelease.getUuid(), newAppLifecycleState);
}else{ }else{
@ -710,17 +715,12 @@ public class ApplicationManagerImpl implements ApplicationManager {
Application application = validateApplication(applicationId); Application application = validateApplication(applicationId);
ApplicationRelease applicationRelease = validateApplicationRelease(applicationId, applicationUuid); ApplicationRelease applicationRelease = validateApplicationRelease(applicationId, applicationUuid);
LifecycleStateDAO lifecycleStateDAO; LifecycleStateDAO lifecycleStateDAO;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
if (application != null) {
state.setAppId(applicationId);
}
if (applicationRelease != null) {
state.setReleaseId(applicationRelease.getId());
}
if (state.getCurrentState() != null && state.getPreviousState() != null && state.getUpdatedBy() != null) { if (state.getCurrentState() != null && state.getPreviousState() != null && state.getUpdatedBy() != null) {
validateLifecycleState(state); validateLifecycleState(state);
lifecycleStateDAO = ApplicationManagementDAOFactory.getLifecycleStateDAO(); lifecycleStateDAO = ApplicationManagementDAOFactory.getLifecycleStateDAO();
lifecycleStateDAO.addLifecycleState(state); lifecycleStateDAO.addLifecycleState(state, application.getId(), applicationRelease.getId(), tenantId);
} }
} catch (LifeCycleManagementDAOException | DBConnectionException e) { } catch (LifeCycleManagementDAOException | DBConnectionException e) {
throw new ApplicationManagementException("Failed to add lifecycle state", e); throw new ApplicationManagementException("Failed to add lifecycle state", e);

@ -39,6 +39,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.UUID; import java.util.UUID;
import java.nio.file.Files;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream; import java.util.zip.ZipInputStream;

@ -0,0 +1,69 @@
/*
* Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.wso2.carbon.device.application.mgt.core;
import com.dd.plist.NSDictionary;
import net.dongliu.apk.parser.bean.ApkMeta;
import org.testng.Assert;
import org.testng.annotations.Test;
import org.wso2.carbon.device.application.mgt.core.exception.ParsingException;
import org.wso2.carbon.device.application.mgt.core.util.ArtifactsParser;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
public class ArtifactParserTest {
private static final String APK_FILE = "src/test/resources/util/app-debug.apk";
private static final String APK_FILE_INVALID = "src/test/resources/util/app-debug1.apk";
private static final String IPA_FILE = "src/test/resources/util/iOSMDMAgent.ipa";
private static final String IPA_FILE_INVALID = "src/test/resources/util/iOSMDMAgent1.ipa";
@Test
public void testReadAndroidManifestFile() throws FileNotFoundException, ParsingException {
InputStream apk = new FileInputStream(APK_FILE);
ApkMeta apkMeta = ArtifactsParser.readAndroidManifestFile(apk);
Assert.assertEquals(apkMeta.getVersionName(), "1.0", "APK version name extraction failed.");
Assert.assertEquals(apkMeta.getPackageName(), "com.games.inosh.myapplication",
"APK package name extraction failed.");
}
@Test(expectedExceptions = java.io.FileNotFoundException.class)
public void testReadAndroidManifestInvalidFile() throws FileNotFoundException, ParsingException {
InputStream apk = new FileInputStream(APK_FILE_INVALID);
ArtifactsParser.readAndroidManifestFile(apk);
}
@Test
public void testReadiOSManifestFile() throws FileNotFoundException, ParsingException {
InputStream ipa = new FileInputStream(IPA_FILE);
NSDictionary ipaDictionary = ArtifactsParser.readiOSManifestFile(ipa);
Assert.assertEquals(ipaDictionary.objectForKey(ArtifactsParser.IPA_BUNDLE_IDENTIFIER_KEY).toString(),
"org.wso2.carbon.emm.ios.agent.inosh", "IPA bundle ID extraction failed.");
Assert.assertEquals(ipaDictionary.objectForKey(ArtifactsParser.IPA_BUNDLE_VERSION_KEY).toString(),
"GA", "IPA file version name extraction failed.");
}
@Test(expectedExceptions = java.io.FileNotFoundException.class)
public void testReadiOSManifestInvalidFile() throws FileNotFoundException, ParsingException {
InputStream ipa = new FileInputStream(IPA_FILE_INVALID);
ArtifactsParser.readiOSManifestFile(ipa);
}
}

@ -20,4 +20,9 @@
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" > <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="ApplicationManagementCore"> <suite name="ApplicationManagementCore">
<test name="Util classes tests" preserve-order="true">
<classes>
<class name="org.wso2.carbon.device.application.mgt.core.ArtifactParserTest"/>
</classes>
</test>
</suite> </suite>

@ -279,10 +279,6 @@ public interface ApplicationManagementAPI {
value = "The application that need to be created.", value = "The application that need to be created.",
required = true) required = true)
@Valid Application application, @Valid Application application,
@ApiParam(
name = "applicationRelease",
value = "Application Release")
@Valid ApplicationRelease applicationRelease,
@ApiParam( @ApiParam(
name = "binaryFile", name = "binaryFile",
value = "Binary file of uploading application", value = "Binary file of uploading application",

@ -109,7 +109,6 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
@Consumes("application/json") @Consumes("application/json")
public Response createApplication( public Response createApplication(
@Valid Application application, @Valid Application application,
@Valid ApplicationRelease applicationRelease,
@Multipart("binaryFile") Attachment binaryFile, @Multipart("binaryFile") Attachment binaryFile,
@Multipart("icon") Attachment iconFile, @Multipart("icon") Attachment iconFile,
@Multipart("banner") Attachment bannerFile, @Multipart("banner") Attachment bannerFile,
@ -120,18 +119,24 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
InputStream bannerFileStream; InputStream bannerFileStream;
List<InputStream> attachments = new ArrayList<>(); List<InputStream> attachments = new ArrayList<>();
List<ApplicationRelease> applicationReleases = new ArrayList<>(); List<ApplicationRelease> applicationReleases = new ArrayList<>();
ApplicationRelease applicationRelease;
try { try {
if (!isValidAppCreatingRequest(binaryFile, iconFile, bannerFile, attachmentList, application)) { if (!isValidAppCreatingRequest(binaryFile, iconFile, bannerFile, attachmentList, application)) {
return Response.status(Response.Status.BAD_REQUEST).build(); return Response.status(Response.Status.BAD_REQUEST).build();
} else if (binaryFile == null && ApplicationType.WEB_CLIP.toString().equals(application.getType())) { }
if (ApplicationType.WEB_CLIP.toString().equals(application.getType())) {
applicationRelease = application.getApplicationReleases().get(0);
applicationRelease = applicationStorageManager applicationRelease = applicationStorageManager
.uploadReleaseArtifact(applicationRelease, application.getType(), application.getDeviceType(), .uploadReleaseArtifact(applicationRelease, application.getType(), application.getDeviceType(),
null); null);
} else if (binaryFile != null && !ApplicationType.WEB_CLIP.toString().equals(application.getType())) { } else {
applicationRelease = application.getApplicationReleases().get(0);
applicationRelease = applicationStorageManager applicationRelease = applicationStorageManager
.uploadReleaseArtifact(applicationRelease, application.getType(), application.getDeviceType(), .uploadReleaseArtifact(applicationRelease, application.getType(), application.getDeviceType(),
binaryFile.getDataHandler().getInputStream()); binaryFile.getDataHandler().getInputStream());
if (applicationRelease.getAppStoredLoc() == null || applicationRelease.getAppHashValue() == null) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
} }
iconFileStream = iconFile.getDataHandler().getInputStream(); iconFileStream = iconFile.getDataHandler().getInputStream();
@ -140,13 +145,8 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
for (Attachment screenshot : attachmentList) { for (Attachment screenshot : attachmentList) {
attachments.add(screenshot.getDataHandler().getInputStream()); attachments.add(screenshot.getDataHandler().getInputStream());
} }
if (applicationRelease.getAppStoredLoc() == null || applicationRelease.getAppHashValue() == null) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
applicationRelease = applicationStorageManager.uploadImageArtifacts(applicationRelease, iconFileStream, applicationRelease = applicationStorageManager.uploadImageArtifacts(applicationRelease, iconFileStream,
bannerFileStream, attachments); bannerFileStream, attachments);
applicationRelease.setUuid(UUID.randomUUID().toString()); applicationRelease.setUuid(UUID.randomUUID().toString());
applicationReleases.add(applicationRelease); applicationReleases.add(applicationRelease);
application.setApplicationReleases(applicationReleases); application.setApplicationReleases(applicationReleases);
@ -452,6 +452,14 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
private boolean isValidAppCreatingRequest(Attachment binaryFile, Attachment iconFile, Attachment bannerFile, private boolean isValidAppCreatingRequest(Attachment binaryFile, Attachment iconFile, Attachment bannerFile,
List<Attachment> attachmentList, Application application){ List<Attachment> attachmentList, Application application){
if (application.getApplicationReleases().size() > 1) {
log.error(
"Invalid application creating request. Application creating request must have single application "
+ "release. Application name:" + application.getName() + " and type: " +
application.getType());
return false;
}
if (iconFile == null) { if (iconFile == null) {
log.error("Icon file is not found for the application release. Application name: " + log.error("Icon file is not found for the application release. Application name: " +
application.getName() + " and type: " + application.getType()); application.getName() + " and type: " + application.getType());

@ -2196,7 +2196,10 @@
<googlecode.plist.version>1.8</googlecode.plist.version> <googlecode.plist.version>1.8</googlecode.plist.version>
<net.dongliu.version>2.4.2</net.dongliu.version> <net.dongliu.version>2.4.2</net.dongliu.version>
<<<<<<< HEAD
=======
>>>>>>> 625589decc78a4f3da8091a227c0fac6e2617c9e
<!--websocket related lib versions--> <!--websocket related lib versions-->
<tomcat.websocket.version>7.0.85</tomcat.websocket.version> <tomcat.websocket.version>7.0.85</tomcat.websocket.version>
<javax.websocket.version>1.0</javax.websocket.version> <javax.websocket.version>1.0</javax.websocket.version>

Loading…
Cancel
Save