diff --git a/.gitignore b/.gitignore index 9c3d08d3c0..b385911f89 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,5 @@ target # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* +components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/node_modules/ +components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/build/ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ApplicationManagementAPI.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ApplicationManagementAPI.java index ca883183cc..9c524570ba 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ApplicationManagementAPI.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ApplicationManagementAPI.java @@ -232,7 +232,6 @@ public interface ApplicationManagementAPI { required = true) @Valid Application application); - @POST @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @@ -649,4 +648,98 @@ public interface ApplicationManagementAPI { name = "version", value = "Version of the application") @QueryParam("version") String version); + + @GET + @Path("/image-artifacts/{uuid}") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + @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); + + @PUT + @Consumes("application/json") + @Path("/{uuid}/{version}/{channel}") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + produces = MediaType.APPLICATION_JSON, + httpMethod = "PUT", + value = "Make the particular application release as default or not", + notes = "Make the particular application release as default or not", + tags = "Application Management", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = SCOPE, value = "perm:application-mgt:login") + }) + } + ) + @ApiResponses( + value = { + @ApiResponse( + code = 200, + message = "OK. \n Successfully retrieved the lifecycle states.", + response = List.class), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Error occurred while getting the life-cycle states.", + response = ErrorResponse.class) + }) + Response updateDefaultVersion( + @ApiParam( + name = "UUID", + value = "Unique identifier of the Application", + required = true) + @PathParam("uuid") String applicationUUID, + @ApiParam( + name = "Version", + value = "Version of the Application Release", + required = true) + @PathParam("version") String version, + @ApiParam( + name = "Release Channel", + value = "Release Channel", + required = true) + @PathParam("channel") String channel, + @ApiParam( + name = "isDefault", + value = "Whether to make it default or not", + required = false) + @QueryParam("isDefault") boolean isDefault); } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ApplicationManagementAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ApplicationManagementAPIImpl.java index e488db3fb5..ad968282b4 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ApplicationManagementAPIImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ApplicationManagementAPIImpl.java @@ -425,7 +425,51 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { + applicationUUID).build(); } } catch (ApplicationManagementException e) { - log.error("Error while deleting application release with the applicaion UUID " + applicationUUID, e); + log.error("Error while deleting application release with the application UUID " + applicationUUID, e); + return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR); + } + } + + @Override + @GET + @Path("/image-artifacts/{uuid}") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + 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 { + InputStream imageArtifact = applicationStorageManager.getImageArtifact(applicationUUID, name, count); + FileStreamingOutput fileStreamingOutput = new FileStreamingOutput(imageArtifact); + Response.ResponseBuilder response = Response.status(Response.Status.OK).entity(fileStreamingOutput); + response.header("Content-Disposition", "attachment; filename=\"" + name + "\""); + 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); + } + } + + @Override + @PUT + @Consumes("application/json") + @Path("/{uuid}/{version}/{channel}") + public Response updateDefaultVersion(@PathParam("uuid") String applicationUUID, @PathParam("version") String + version, @PathParam("channel") String channel, @QueryParam("isDefault") boolean isDefault) { + ApplicationReleaseManager applicationReleaseManager = APIUtil.getApplicationReleaseManager(); + try { + applicationReleaseManager.changeDefaultRelease(applicationUUID, version, isDefault, channel); + return Response.status(Response.Status.OK) + .entity("Successfully changed the default version for the " + "release channel " + channel + + " for the application UUID " + applicationUUID).build(); + } catch (ApplicationManagementException e) { + log.error("Application Release Management Exception while changing the default release for the release " + + "channel " + channel + " for the application with UUID " + applicationUUID + " for the version " + + version); return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR); } } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Application.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Application.java index 4fe9a25c38..77c84bdf6a 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Application.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Application.java @@ -43,14 +43,8 @@ public class Application { private String description; - private String iconName; - - private String bannerName; - private String videoName; - private List screenshots; - private List tags; private Platform platform; @@ -73,6 +67,8 @@ public class Application { private Visibility visibility; + private int screenShotCount; + private User user; public int getId() { @@ -155,22 +151,6 @@ public class Application { this.description = description; } - public String getIconName() { - return iconName; - } - - public void setIconName(String iconName) { - this.iconName = iconName; - } - - public String getBannerName() { - return bannerName; - } - - public void setBannerName(String bannerName) { - this.bannerName = bannerName; - } - public String getVideoName() { return videoName; } @@ -179,14 +159,6 @@ public class Application { this.videoName = videoName; } - public List getScreenshots() { - return screenshots; - } - - public void setScreenshots(List screenshots) { - this.screenshots = screenshots; - } - public List getTags() { return tags; } @@ -251,6 +223,14 @@ public class Application { this.user = user; } + public void setScreenShotCount (int screenShotCount) { + this.screenShotCount = screenShotCount; + } + + public int getScreenShotCount() { + return screenShotCount; + } + @Override public String toString() { return "UUID : " + uuid + "\tIdentifier : " + identifier + "\tName : " + name + "\tShort Description : " diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Filter.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Filter.java index 1834d9c83f..becd16fb21 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Filter.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Filter.java @@ -46,6 +46,8 @@ public class Filter { private String sortBy; + private String userName; + public int getLimit() { return limit; } @@ -102,6 +104,14 @@ public class Filter { this.sortBy = sortBy; } + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + public boolean hasCondition() { if (filterProperties != null || searchQuery != null || filter != null) { return true; @@ -109,5 +119,4 @@ public class Filter { return false; } - } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationReleaseManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationReleaseManager.java index d0b8d546d0..a97050d19f 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationReleaseManager.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationReleaseManager.java @@ -25,7 +25,7 @@ import java.util.List; /** * ApplicationReleaseManager is responsible for handling all the operations related with - * {@link org.wso2.carbon.device.application.mgt.common.ApplicationRelease} which involving addition, updation , + * {@link org.wso2.carbon.device.application.mgt.common.ApplicationRelease} which involving addition, updating , * deletion and viewing. * */ @@ -59,11 +59,15 @@ public interface ApplicationReleaseManager { public List getReleases(String applicationUuid) throws ApplicationManagementException; /** - * To make a release as the default one for an application. - * - * @param id ID of the ApplicationRelease, that need to be made default. + * To make a particular application release as the default / not default-one + * @param uuid UUID of the application + * @param version Version of the application + * @param isDefault is default or not. + * @param releaseChannel Release channel to make the + * @throws ApplicationManagementException Application Management Exception. */ - public void makeDefaultRelease(int id) throws ApplicationManagementException; + public void changeDefaultRelease(String uuid, String version, boolean isDefault, String releaseChannel) + throws ApplicationManagementException; /** * To update with a new release for an Application. diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationStorageManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationStorageManager.java index 8d1f073f10..860812244a 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationStorageManager.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationStorageManager.java @@ -83,4 +83,16 @@ public interface ApplicationStorageManager { */ public void deleteAllApplicationReleaseArtifacts(String applicationUUID) throws ApplicationStorageManagementException; + + /** + * To get particular image artifact of the application. + * + * @param applicationUUID UUID of the application, to retrieve the image artifact. + * @param name Name of the artifact - icon/banner/screenshot + * @param count Position of a parameter to get the image artifact. + * @return the relevant image artifact. + * @throws ApplicationStorageManagementException Application Storage Management Exception. + */ + public InputStream getImageArtifact(String applicationUUID, String name, int count) throws + ApplicationStorageManagementException; } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationDAO.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationDAO.java index 3fbd9ea56b..f49a2d3f4b 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationDAO.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationDAO.java @@ -35,15 +35,15 @@ public interface ApplicationDAO { Application createApplication(Application application) throws ApplicationManagementDAOException; - ApplicationList getApplications(Filter filter) throws ApplicationManagementDAOException; + ApplicationList getApplications(Filter filter, int tenantId) throws ApplicationManagementDAOException; - Application getApplication(String uuid) throws ApplicationManagementDAOException; + Application getApplication(String uuid, int tenantId, String userName) throws ApplicationManagementDAOException; - int getApplicationId(String uuid) throws ApplicationManagementDAOException; + int getApplicationId(String uuid, int tenantId) throws ApplicationManagementDAOException; Application editApplication(Application application, int tenantId) throws ApplicationManagementDAOException; - void deleteApplication(String uuid) throws ApplicationManagementDAOException; + void deleteApplication(String uuid, int tenantId) throws ApplicationManagementDAOException; int getApplicationCount(Filter filter) throws ApplicationManagementDAOException; @@ -57,10 +57,13 @@ public interface ApplicationDAO { void addRelease(ApplicationRelease release) throws ApplicationManagementDAOException; - void changeLifecycle(String applicationUUID, String lifecycleIdentifier, String username) throws + void changeLifecycle(String applicationUUID, String lifecycleIdentifier, String username, int tenantId) throws ApplicationManagementDAOException; List getNextLifeCycleStates(String applicationUUID, int tenantId) throws ApplicationManagementDAOException; + void updateScreenShotCount(String applicationUUID, int tenantId, int count) throws + ApplicationManagementDAOException; + } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationReleaseDAO.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationReleaseDAO.java index 1cb2becfd1..2fce310266 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationReleaseDAO.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationReleaseDAO.java @@ -45,7 +45,8 @@ public interface ApplicationReleaseDAO { * @return ApplicationRelease for the particular version of the given application * @throws ApplicationManagementDAOException Application Management DAO Exception. */ - ApplicationRelease getRelease(String applicationUuid, String versionName) throws ApplicationManagementDAOException; + ApplicationRelease getRelease(String applicationUuid, String versionName, int tenantId) throws + ApplicationManagementDAOException; /** * To get all the releases of a particular application. @@ -54,7 +55,8 @@ public interface ApplicationReleaseDAO { * @return list of the application releases * @throws ApplicationManagementDAOException Application Management DAO Exception. */ - List getApplicationReleases(String applicationUUID) throws ApplicationManagementDAOException; + List getApplicationReleases(String applicationUUID, int tenantId) throws + ApplicationManagementDAOException; /** * To update an Application release. @@ -80,4 +82,16 @@ public interface ApplicationReleaseDAO { * @throws ApplicationManagementDAOException Application Management DAO Exception. */ void deleteReleaseProperties(int id) throws ApplicationManagementDAOException; + + /** + * To change the default version of a particular release channel. + * @param uuid UUID of the application + * @param version Version of the application + * @param isDefault true if the request is to make the application as default one unless false + * @throws ApplicationManagementDAOException Application Management DAO Exception. + */ + void changeReleaseDefault(String uuid, String version, boolean isDefault, String releaseChannel, int tenantId) + throws ApplicationManagementDAOException; + + } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/DAOFactory.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/DAOFactory.java index 5f97b518fa..4a29ee90a7 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/DAOFactory.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/DAOFactory.java @@ -60,6 +60,7 @@ public class DAOFactory { switch (databaseEngine) { case Constants.DataBaseTypes.DB_TYPE_H2: case Constants.DataBaseTypes.DB_TYPE_MYSQL: + case Constants.DataBaseTypes.DB_TYPE_POSTGRESQL: return new GenericApplicationDAOImpl(); default: throw new UnsupportedDatabaseEngineException("Unsupported database engine : " + databaseEngine); @@ -90,6 +91,7 @@ public class DAOFactory { switch (databaseEngine) { case Constants.DataBaseTypes.DB_TYPE_H2: case Constants.DataBaseTypes.DB_TYPE_MYSQL: + case Constants.DataBaseTypes.DB_TYPE_POSTGRESQL: return new GenericLifecycleStateImpl(); default: throw new UnsupportedDatabaseEngineException("Unsupported database engine : " + databaseEngine); @@ -107,6 +109,7 @@ public class DAOFactory { switch (databaseEngine) { case Constants.DataBaseTypes.DB_TYPE_H2: case Constants.DataBaseTypes.DB_TYPE_MYSQL: + case Constants.DataBaseTypes.DB_TYPE_POSTGRESQL: return new GenericApplicationReleaseDAOImpl(); default: throw new UnsupportedDatabaseEngineException("Unsupported database engine : " + databaseEngine); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/Util.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/Util.java index bb4284b00c..769e8a50ed 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/Util.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/Util.java @@ -27,7 +27,6 @@ import org.wso2.carbon.device.application.mgt.common.Lifecycle; import org.wso2.carbon.device.application.mgt.common.LifecycleState; import org.wso2.carbon.device.application.mgt.common.Platform; import org.wso2.carbon.device.application.mgt.common.User; -import org.wso2.carbon.device.application.mgt.core.util.JSONUtil; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -63,10 +62,8 @@ public class Util { application.setIdentifier(rs.getString("IDENTIFIER")); application.setShortDescription(rs.getString("SHORT_DESCRIPTION")); application.setDescription(rs.getString("DESCRIPTION")); - application.setIconName(rs.getString("ICON_NAME")); - application.setBannerName(rs.getString("BANNER_NAME")); + application.setScreenShotCount(rs.getInt("SCREEN_SHOT_COUNT")); application.setVideoName(rs.getString("VIDEO_NAME")); - application.setScreenshots(JSONUtil.jsonArrayStringToList(rs.getString("SCREENSHOTS"))); application.setCreatedAt(rs.getDate("CREATED_AT")); application.setModifiedAt(rs.getDate("MODIFIED_AT")); application.setUser(new User(rs.getString("CREATED_BY"), rs.getInt("TENANT_ID"))); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java index b513fd1289..de6896921c 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java @@ -33,7 +33,6 @@ 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.exception.ApplicationManagementDAOException; import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil; -import org.wso2.carbon.device.application.mgt.core.util.JSONUtil; import java.sql.Connection; import java.sql.Date; @@ -65,34 +64,32 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic ResultSet rs = null; String sql = ""; boolean isBatchExecutionSupported = ConnectionManagerUtil.isBatchQuerySupported(); - + int index = 0; try { conn = this.getDBConnection(); - sql += "INSERT INTO APPM_APPLICATION (UUID, IDENTIFIER, NAME, SHORT_DESCRIPTION, DESCRIPTION, ICON_NAME, " - + "BANNER_NAME, VIDEO_NAME, SCREENSHOTS, CREATED_BY, CREATED_AT, MODIFIED_AT, " + sql += "INSERT INTO APPM_APPLICATION (UUID, IDENTIFIER, NAME, SHORT_DESCRIPTION, DESCRIPTION, " + + "VIDEO_NAME, SCREEN_SHOT_COUNT, CREATED_BY, CREATED_AT, MODIFIED_AT, " + "APPLICATION_CATEGORY_ID, PLATFORM_ID, TENANT_ID, LIFECYCLE_STATE_ID, " + "LIFECYCLE_STATE_MODIFIED_AT, LIFECYCLE_STATE_MODIFIED_BY) VALUES " - + "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + + "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); - stmt.setString(1, application.getUuid()); - stmt.setString(2, application.getIdentifier()); - stmt.setString(3, application.getName()); - stmt.setString(4, application.getShortDescription()); - stmt.setString(5, application.getDescription()); - stmt.setString(6, application.getIconName()); - stmt.setString(7, application.getBannerName()); - stmt.setString(8, application.getVideoName()); - stmt.setString(9, JSONUtil.listToJsonArrayString(application.getScreenshots())); - stmt.setString(10, application.getUser().getUserName()); - stmt.setDate(11, new Date(application.getCreatedAt().getTime())); - stmt.setDate(12, new Date(application.getModifiedAt().getTime())); - stmt.setInt(13, application.getCategory().getId()); - stmt.setInt(14, application.getPlatform().getId()); - stmt.setInt(15, application.getUser().getTenantId()); - stmt.setInt(16, application.getCurrentLifecycle().getLifecycleState().getId()); - stmt.setDate(17, new Date(application.getCurrentLifecycle().getLifecycleStateModifiedAt().getTime())); - stmt.setString(18, application.getCurrentLifecycle().getGetLifecycleStateModifiedBy()); + stmt.setString(++index, application.getUuid()); + stmt.setString(++index, application.getIdentifier()); + stmt.setString(++index, application.getName()); + stmt.setString(++index, application.getShortDescription()); + stmt.setString(++index, application.getDescription()); + stmt.setString(++index, application.getVideoName()); + stmt.setInt(++index, application.getScreenShotCount()); + stmt.setString(++index, application.getUser().getUserName()); + stmt.setDate(++index, new Date(application.getCreatedAt().getTime())); + stmt.setDate(++index, new Date(application.getModifiedAt().getTime())); + stmt.setInt(++index, application.getCategory().getId()); + stmt.setInt(++index, application.getPlatform().getId()); + stmt.setInt(++index, application.getUser().getTenantId()); + stmt.setInt(++index, application.getCurrentLifecycle().getLifecycleState().getId()); + stmt.setDate(++index, new Date(application.getCurrentLifecycle().getLifecycleStateModifiedAt().getTime())); + stmt.setString(++index, application.getCurrentLifecycle().getGetLifecycleStateModifiedBy()); stmt.executeUpdate(); rs = stmt.getGeneratedKeys(); @@ -112,7 +109,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic @Override - public ApplicationList getApplications(Filter filter) throws ApplicationManagementDAOException { + public ApplicationList getApplications(Filter filter, int tenantId) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { log.debug("Getting application data from the database"); log.debug(String.format("Filter: limit=%s, offset=%", filter.getLimit(), filter.getOffset())); @@ -125,6 +122,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic ApplicationList applicationList = new ApplicationList(); List applications = new ArrayList<>(); Pagination pagination = new Pagination(); + int index = 0; if (filter == null) { throw new ApplicationManagementDAOException("Filter need to be instantiated"); @@ -140,20 +138,29 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic + "LS.DESCRIPTION AS LS_DESCRIPTION FROM APPM_APPLICATION AS APP INNER JOIN APPM_PLATFORM AS " + "APL ON APP.PLATFORM_ID = APL.ID INNER JOIN APPM_APPLICATION_CATEGORY AS CAT ON " + "APP.APPLICATION_CATEGORY_ID = CAT.ID INNER JOIN APPM_LIFECYCLE_STATE AS " - + "LS ON APP.LIFECYCLE_STATE_ID = LS.ID "; + + "LS ON APP.LIFECYCLE_STATE_ID = LS.ID WHERE APP.TENANT_ID = ? "; + String userName = filter.getUserName(); + if (!userName.equals("ALL")) { + sql += " AND APP.CREATED_BY = ? "; + } if (filter.getSearchQuery() != null && !filter.getSearchQuery().isEmpty()) { - sql += "WHERE APP.NAME LIKE ? "; + sql += "AND APP.NAME LIKE ? "; } - sql += "LIMIT ?,?;"; + sql += "LIMIT ? OFFSET ?;"; stmt = conn.prepareStatement(sql); - int index = 0; + stmt.setInt(++index, tenantId); + + if (!userName.equals("ALL")) { + stmt.setString(++index, userName); + } if (filter.getSearchQuery() != null && !filter.getSearchQuery().isEmpty()) { stmt.setString(++index, "%" + filter.getSearchQuery() + "%"); } - stmt.setInt(++index, filter.getOffset()); + stmt.setInt(++index, filter.getLimit()); + stmt.setInt(++index, filter.getOffset()); rs = stmt.executeQuery(); @@ -183,11 +190,14 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic applicationList.setApplications(applications); applicationList.setPagination(pagination); } catch (SQLException e) { - throw new ApplicationManagementDAOException("Error occurred while getting application List", e); + throw new ApplicationManagementDAOException("Error occurred while getting application list for the tenant" + + " " + tenantId + ". While executing " + sql, e); } catch (JSONException e) { - throw new ApplicationManagementDAOException("Error occurred while parsing JSON", e); + throw new ApplicationManagementDAOException("Error occurred while parsing JSON, while getting application" + + " list for the tenant " + tenantId, e); } catch (DBConnectionException e) { - throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e); + throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection while " + + "getting application list for the tenant " + tenantId, e); } finally { Util.cleanupResources(stmt, rs); } @@ -243,11 +253,12 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic } @Override - public Application getApplication(String uuid) throws ApplicationManagementDAOException { + public Application getApplication(String uuid, int tenantId, String userName) throws + ApplicationManagementDAOException { if (log.isDebugEnabled()) { log.debug("Getting application with the UUID(" + uuid + ") from the database"); } - Connection conn = null; + Connection conn; PreparedStatement stmt = null; ResultSet rs = null; String sql = ""; @@ -260,10 +271,17 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic + "LS.DESCRIPTION AS LS_DESCRIPTION FROM APPM_APPLICATION AS APP INNER JOIN APPM_PLATFORM AS " + "APL ON APP.PLATFORM_ID = APL.ID INNER JOIN APPM_APPLICATION_CATEGORY AS CAT ON " + "APP.APPLICATION_CATEGORY_ID = CAT.ID INNER JOIN APPM_LIFECYCLE_STATE AS " - + "LS ON APP.LIFECYCLE_STATE_ID = LS.ID WHERE UUID = ?"; + + "LS ON APP.LIFECYCLE_STATE_ID = LS.ID WHERE UUID = ? AND APP.TENANT_ID = ? "; + stmt = conn.prepareStatement(sql); stmt.setString(1, uuid); + stmt.setInt(2, tenantId); + + if (!userName.equals("ALL")) { + sql += "AND APP.CREATED_BY = ?"; + stmt.setString(3, userName); + } rs = stmt.executeQuery(); if (log.isDebugEnabled()) { @@ -301,8 +319,8 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic } @Override - public void changeLifecycle(String applicationUUID, String lifecycleIdentifier, String userName) throws - ApplicationManagementDAOException { + public void changeLifecycle(String applicationUUID, String lifecycleIdentifier, String userName, int tenantId) + throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { log.debug("Change Life cycle status change " + lifecycleIdentifier + "request received to the DAO " + "level for the application with " + "the UUID '" + applicationUUID + "' from the user " @@ -314,12 +332,14 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic conn = this.getDBConnection(); String sql = "UPDATE APPM_APPLICATION SET " + "LIFECYCLE_STATE_ID = (SELECT ID FROM APPM_LIFECYCLE_STATE WHERE IDENTIFIER = ?), " - + "LIFECYCLE_STATE_MODIFIED_BY = ?, LIFECYCLE_STATE_MODIFIED_AT = ? WHERE UUID = ?"; + + "LIFECYCLE_STATE_MODIFIED_BY = ?, LIFECYCLE_STATE_MODIFIED_AT = ? WHERE UUID = ? AND TENANT_ID " + + "= ?"; stmt = conn.prepareStatement(sql); stmt.setString(1, lifecycleIdentifier); stmt.setString(2, userName); stmt.setDate(3, new Date(System.currentTimeMillis())); stmt.setString(4, applicationUUID); + stmt.setInt(5, tenantId); stmt.executeUpdate(); } catch (DBConnectionException e) { throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e); @@ -341,13 +361,14 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic String sql = "SELECT STATE.NAME, TRANSITION.DESCRIPTION, TRANSITION.PERMISSION FROM ( SELECT * FROM " + "APPM_LIFECYCLE_STATE ) STATE RIGHT JOIN (SELECT * FROM APPM_LIFECYCLE_STATE_TRANSITION WHERE " - + "INITIAL_STATE = (SELECT LIFECYCLE_STATE_ID FROM APPM_APPLICATION WHERE UUID = ?)) " + + "INITIAL_STATE = (SELECT LIFECYCLE_STATE_ID FROM APPM_APPLICATION WHERE UUID = ? AND TENANT_ID = ?)) " + "TRANSITION ON TRANSITION.NEXT_STATE = STATE.ID"; try { connection = this.getDBConnection(); preparedStatement = connection.prepareStatement(sql); preparedStatement.setString(1, applicationUUID); + preparedStatement.setInt(2, tenantId); resultSet = preparedStatement.executeQuery(); List lifecycleStateTransitions = new ArrayList<>(); @@ -370,6 +391,31 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic } } + @Override + public void updateScreenShotCount(String applicationUUID, int tenantId, int count) + throws ApplicationManagementDAOException { + Connection connection; + PreparedStatement statement = null; + String sql = "UPDATE APPM_APPLICATION SET SCREEN_SHOT_COUNT = ? where UUID = ? and TENANT_ID = ?"; + + try { + connection = this.getDBConnection(); + statement = connection.prepareStatement(sql); + statement.setInt(1, count); + statement.setString(2, applicationUUID); + statement.setInt(3, tenantId); + statement.executeUpdate(); + } catch (DBConnectionException e) { + throw new ApplicationManagementDAOException("Database connection while trying to update the screen-shot " + + "count for the application with UUID " + applicationUUID + " for the tenant " + tenantId); + } catch (SQLException e) { + throw new ApplicationManagementDAOException("SQL exception while executing the query '" + sql + "' .", e); + } finally { + Util.cleanupResources(statement, null); + } + + } + @Override public Application editApplication(Application application, int tenantId) throws ApplicationManagementDAOException { Connection conn; @@ -379,35 +425,33 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic try { conn = this.getDBConnection(); int index = 0; - sql += "UPDATE APPM_APPLICATION SET NAME = IFNULL (?, NAME), SHORT_DESCRIPTION = IFNULL " - + "(?, SHORT_DESCRIPTION), DESCRIPTION = IFNULL (?, DESCRIPTION), ICON_NAME = IFNULL (?, ICON_NAME)" - + ", BANNER_NAME = IFNULL (?, BANNER_NAME), VIDEO_NAME = IFNULL (?, VIDEO_NAME), " - + "SCREENSHOTS = IFNULL (?, SCREENSHOTS), MODIFIED_AT = IFNULL (?, MODIFIED_AT), "; + sql += "UPDATE APPM_APPLICATION SET NAME = COALESCE (?, NAME), SHORT_DESCRIPTION = COALESCE " + + "(?, SHORT_DESCRIPTION), DESCRIPTION = COALESCE (?, DESCRIPTION), SCREEN_SHOT_COUNT = " + + "COALESCE (?, SCREEN_SHOT_COUNT), VIDEO_NAME = COALESCE (?, VIDEO_NAME), MODIFIED_AT = COALESCE " + + "(?, MODIFIED_AT), "; if (application.getPayment() != null) { - sql += " IS_FREE = IFNULL (?, IS_FREE), "; + sql += " IS_FREE = COALESCE (?, IS_FREE), "; if (application.getPayment().getPaymentCurrency() != null) { - sql += "PAYMENT_CURRENCY = IFNULL (?, PAYMENT_CURRENCY), "; + sql += "PAYMENT_CURRENCY = COALESCE (?, PAYMENT_CURRENCY), "; } - sql += "PAYMENT_PRICE = IFNULL (?, PAYMENT_PRICE), "; + sql += "PAYMENT_PRICE = COALESCE (?, PAYMENT_PRICE), "; } if (application.getCategory() != null && application.getCategory().getId() != 0) { - sql += "APPLICATION_CATEGORY_ID = IFNULL (?, APPLICATION_CATEGORY_ID), "; + sql += "APPLICATION_CATEGORY_ID = COALESCE (?, APPLICATION_CATEGORY_ID), "; } if (application.getPlatform() != null && application.getPlatform().getId() != 0) { - sql += "PLATFORM_ID = IFNULL (?, PLATFORM_ID), "; + sql += "PLATFORM_ID = COALESCE (?, PLATFORM_ID), "; } - sql += "TENANT_ID = IFNULL (?, TENANT_ID) WHERE UUID = ?"; + sql += "TENANT_ID = COALESCE (?, TENANT_ID) WHERE UUID = ?"; stmt = conn.prepareStatement(sql); stmt.setString(++index, application.getName()); stmt.setString(++index, application.getShortDescription()); stmt.setString(++index, application.getDescription()); - stmt.setString(++index, application.getIconName()); - stmt.setString(++index, application.getBannerName()); + stmt.setInt(++index, application.getScreenShotCount()); stmt.setString(++index, application.getVideoName()); - stmt.setString(++index, JSONUtil.listToJsonArrayString(application.getScreenshots())); stmt.setDate(++index, new Date(application.getModifiedAt().getTime())); if (application.getPayment() != null) { stmt.setBoolean(++index, application.getPayment().isFreeApp()); @@ -427,7 +471,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic stmt.setString(++index, application.getUuid()); stmt.executeUpdate(); - application.setId(getApplicationId(application.getUuid())); + application.setId(getApplicationId(application.getUuid(), tenantId)); sql = "DELETE FROM APPM_APPLICATION_TAG WHERE APPLICATION_ID = ?"; stmt = conn.prepareStatement(sql); @@ -499,14 +543,15 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic } @Override - public void deleteApplication(String uuid) throws ApplicationManagementDAOException { + public void deleteApplication(String uuid, int tenantId) throws ApplicationManagementDAOException { Connection conn; PreparedStatement stmt = null; try { conn = this.getDBConnection(); - String sql = "DELETE FROM APPM_APPLICATION WHERE UUID = ?"; + String sql = "DELETE FROM APPM_APPLICATION WHERE UUID = ? AND TENANT_ID = ?"; stmt = conn.prepareStatement(sql); stmt.setString(1, uuid); + stmt.setInt(2, tenantId); stmt.executeUpdate(); } catch (DBConnectionException e) { @@ -561,7 +606,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic } @Override - public int getApplicationId(String uuid) throws ApplicationManagementDAOException { + public int getApplicationId(String uuid, int tenantId) throws ApplicationManagementDAOException { Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; @@ -569,9 +614,10 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic int id = 0; try { conn = this.getDBConnection(); - sql = "SELECT ID FROM APPM_APPLICATION WHERE UUID = ?"; + sql = "SELECT ID FROM APPM_APPLICATION WHERE UUID = ? AND TENANT_ID = ?"; stmt = conn.prepareStatement(sql); stmt.setString(1, uuid); + stmt.setInt(2, tenantId); rs = stmt.executeQuery(); if (rs.next()) { id = rs.getInt(1); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/release/GenericApplicationReleaseDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/release/GenericApplicationReleaseDAOImpl.java index 50d39a780d..163326f075 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/release/GenericApplicationReleaseDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/release/GenericApplicationReleaseDAOImpl.java @@ -27,7 +27,12 @@ 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.util.ConnectionManagerUtil; -import java.sql.*; +import java.sql.Connection; +import java.sql.Date; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -44,6 +49,10 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements Connection connection; PreparedStatement statement = null; ResultSet resultSet = null; + + if (applicationRelease.isDefault()) { + + } String sql = "insert into APPM_APPLICATION_RELEASE(VERSION_NAME, RESOURCE, RELEASE_CHANNEL ," + "RELEASE_DETAILS, CREATED_AT, APPM_APPLICATION_ID, IS_DEFAULT) values (?, ?, ?, ?, ?, ?, ?)"; int index = 0; @@ -79,13 +88,13 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements } @Override - public ApplicationRelease getRelease(String applicationUuid, String versionName) + public ApplicationRelease getRelease(String applicationUuid, String versionName, int tenantId) throws ApplicationManagementDAOException { Connection connection; PreparedStatement statement = null; ResultSet resultSet = null; String sql = "SELECT * FROM APPM_APPLICATION_RELEASE WHERE VERSION_NAME = ? AND APPM_APPLICATION_ID = " - + "(SELECT ID FROM APPM_APPLICATION WHERE UUID = ?)"; + + "(SELECT ID FROM APPM_APPLICATION WHERE UUID = ? and TENANT_ID = ?)"; ApplicationRelease applicationRelease = null; ResultSet rsProperties = null; @@ -94,6 +103,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements statement = connection.prepareStatement(sql); statement.setString(1, versionName); statement.setString(2, applicationUuid); + statement.setInt(3, tenantId); resultSet = statement.executeQuery(); if (resultSet.next()) { @@ -132,13 +142,13 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements } @Override - public List getApplicationReleases(String applicationUUID) + public List getApplicationReleases(String applicationUUID, int tenantId) throws ApplicationManagementDAOException { Connection connection; PreparedStatement statement = null; ResultSet resultSet = null; String sql = "SELECT * FROM APPM_APPLICATION_RELEASE WHERE APPM_APPLICATION_ID = (SELECT ID FROM " - + "APPM_APPLICATION WHERE UUID = ?)"; + + "APPM_APPLICATION WHERE UUID = ? AND TENANT_ID = ?)"; List applicationReleases = new ArrayList<>(); ResultSet rsProperties = null; @@ -146,6 +156,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements connection = this.getDBConnection(); statement = connection.prepareStatement(sql); statement.setString(1, applicationUUID); + statement.setInt(2, tenantId); resultSet = statement.executeQuery(); while (resultSet.next()) { @@ -264,6 +275,40 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements } } + @Override + public void changeReleaseDefault(String uuid, String version, boolean isDefault, String releaseChannel, + int tenantId) throws ApplicationManagementDAOException { + Connection connection; + PreparedStatement statement = null; + String sql = "UPDATE APPM_APPLICATION_RELEASE SET IS_DEFAULT = ? AND RELEASE_CHANNEL = ? WHERE " + + "APPM_APPLICATION_ID = (SELECT ID from APPM_APPLICATION WHERE UUID = ? AND TENANT_ID = ?) " + + "AND VERSION_NAME = ?"; + + try { + if (isDefault) { + removeDefaultReleases(uuid, releaseChannel, tenantId); + } + connection = this.getDBConnection(); + statement = connection.prepareStatement(sql); + statement.setBoolean(1, isDefault); + statement.setString(2, releaseChannel.toUpperCase()); + statement.setString(3, uuid); + statement.setInt(4, tenantId); + statement.setString(5, version); + statement.executeUpdate(); + } catch (DBConnectionException e) { + throw new ApplicationManagementDAOException( + "Database Connection exception while try to change the " + "default release of the release channel " + + releaseChannel + " for the application " + uuid, e); + } catch (SQLException e) { + throw new ApplicationManagementDAOException( + "SQL Exception while trying to change the default release of " + "the release channel " + + releaseChannel + " for the application " + uuid, e); + } finally { + Util.cleanupResources(statement, null); + } + } + /** * To insert the application release properties. * @param connection Database Connection @@ -294,4 +339,30 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements } } } + + /** + * To make all the releases of particular release channel as non-default ones. + * + * @param uuid UUID of the Application. + * @param releaseChannel ReleaseChannel for which we need to make all the releases as non-default ones. + * @param tenantId ID of the tenant. + * @throws DBConnectionException Database Connection Exception. + * @throws SQLException SQL Exception. + */ + private void removeDefaultReleases(String uuid, String releaseChannel, int tenantId) + throws DBConnectionException, SQLException { + PreparedStatement statement = null; + try { + Connection connection = this.getDBConnection(); + String sql = "UPDATE APPM_APPLICATION_RELEASE SET IS_DEFAULT = FALSE WHERE APPM_APPLICATION_ID = (SELECT " + + "ID from APPM_APPLICATION WHERE UUID = ? AND TENANT_ID = ?) AND RELEASE_CHANNEL = ?"; + statement = connection.prepareStatement(sql); + statement.setString(1, uuid); + statement.setInt(2, tenantId); + statement.setString(3, releaseChannel.toUpperCase()); + statement.executeUpdate(); + } finally { + Util.cleanupResources(statement, null); + } + } } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java index 837ba1ea7c..6b2e0411f7 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java @@ -46,7 +46,6 @@ import org.wso2.carbon.user.api.UserRealm; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; -import java.io.InputStream; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -158,10 +157,10 @@ public class ApplicationManagerImpl implements ApplicationManager { try { ApplicationDAO applicationDAO = DAOFactory.getApplicationDAO(); ConnectionManagerUtil.beginDBTransaction(); - int appId = applicationDAO.getApplicationId(uuid); + int appId = applicationDAO.getApplicationId(uuid, tenantId); applicationDAO.deleteTags(appId); applicationDAO.deleteProperties(appId); - applicationDAO.deleteApplication(uuid); + applicationDAO.deleteApplication(uuid, tenantId); ConnectionManagerUtil.commitDBTransaction(); } catch (ApplicationManagementDAOException e) { ConnectionManagerUtil.rollbackDBTransaction(); @@ -174,15 +173,26 @@ public class ApplicationManagerImpl implements ApplicationManager { @Override public ApplicationList getApplications(Filter filter) throws ApplicationManagementException { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); + String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); + + try { + if (isAuthorized(userName, tenantId, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION)) { + userName = "ALL"; + } + } catch (UserStoreException e) { + throw new ApplicationManagementException("User-store exception while checking whether the user " + + userName + " of tenant " + tenantId + " has the publisher permission"); + } + filter.setUserName(userName); try { ConnectionManagerUtil.openDBConnection(); ApplicationDAO applicationDAO = DAOFactory.getApplicationDAO(); - return applicationDAO.getApplications(filter); + return applicationDAO.getApplications(filter, tenantId); } finally { ConnectionManagerUtil.closeDBConnection(); } - } @Override @@ -190,6 +200,7 @@ public class ApplicationManagerImpl implements ApplicationManager { ApplicationManagementException { boolean isAvailableNextState = false; String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); List nextLifeCycles = getLifeCycleStates(applicationUuid); for (LifecycleStateTransition lifecycleStateTransition : nextLifeCycles) { @@ -210,7 +221,7 @@ public class ApplicationManagerImpl implements ApplicationManager { try { ConnectionManagerUtil.beginDBTransaction(); ApplicationDAO applicationDAO = DAOFactory.getApplicationDAO(); - applicationDAO.changeLifecycle(applicationUuid, lifecycleIdentifier, userName); + applicationDAO.changeLifecycle(applicationUuid, lifecycleIdentifier, userName, tenantId); ConnectionManagerUtil.commitDBTransaction(); } catch (ApplicationManagementDAOException e) { ConnectionManagerUtil.rollbackDBTransaction(); @@ -278,20 +289,25 @@ public class ApplicationManagerImpl implements ApplicationManager { @Override public Application getApplication(String uuid) throws ApplicationManagementException { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); + String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); + + try { + if (isAuthorized(userName, tenantId, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION)) { + userName = "ALL"; + } + } catch (UserStoreException e) { + throw new ApplicationManagementException( + "User-store exception while getting application with the UUID " + uuid); + } try { ConnectionManagerUtil.openDBConnection(); - return DAOFactory.getApplicationDAO().getApplication(uuid); + return DAOFactory.getApplicationDAO().getApplication(uuid, tenantId, userName); } finally { ConnectionManagerUtil.closeDBConnection(); } } - public void uploadArtifacts(String applicationUUID, InputStream iconFileStream, InputStream bannerFileStream, - List screenShotStreams) - throws ApplicationManagementException { - - } - /** * To check whether current user is application owner or admin. * @@ -310,7 +326,8 @@ public class ApplicationManagerImpl implements ApplicationManager { } try { ConnectionManagerUtil.openDBConnection(); - Application application = DAOFactory.getApplicationDAO().getApplication(applicationUUID); + Application application = DAOFactory.getApplicationDAO() + .getApplication(applicationUUID, tenantId, userName); return application.getUser().getUserName().equals(userName) && application.getUser().getTenantId() == tenantId; } finally { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationReleaseManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationReleaseManagerImpl.java index 39eb043c82..b405f8f3db 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationReleaseManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationReleaseManagerImpl.java @@ -20,6 +20,7 @@ package org.wso2.carbon.device.application.mgt.core.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.application.mgt.common.Application; import org.wso2.carbon.device.application.mgt.common.ApplicationRelease; import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException; @@ -64,6 +65,7 @@ public class ApplicationReleaseManagerImpl implements ApplicationReleaseManager @Override public ApplicationRelease getRelease(String applicationUuid, String version) throws ApplicationManagementException { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); Application application = validateApplication(applicationUuid); if (log.isDebugEnabled()) { log.debug("Application release retrieval request is received for the application " + @@ -71,7 +73,7 @@ public class ApplicationReleaseManagerImpl implements ApplicationReleaseManager } try { ConnectionManagerUtil.openDBConnection(); - return DAOFactory.getApplicationReleaseDAO().getRelease(applicationUuid, version); + return DAOFactory.getApplicationReleaseDAO().getRelease(applicationUuid, version, tenantId); } finally { ConnectionManagerUtil.closeDBConnection(); } @@ -79,6 +81,7 @@ public class ApplicationReleaseManagerImpl implements ApplicationReleaseManager @Override public List getReleases(String applicationUuid) throws ApplicationManagementException { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); Application application = validateApplication(applicationUuid); if (log.isDebugEnabled()) { log.debug("Request is received to retrieve all the releases related with the application " + @@ -86,15 +89,33 @@ public class ApplicationReleaseManagerImpl implements ApplicationReleaseManager } try { ConnectionManagerUtil.openDBConnection(); - return DAOFactory.getApplicationReleaseDAO().getApplicationReleases(applicationUuid); + return DAOFactory.getApplicationReleaseDAO().getApplicationReleases(applicationUuid, tenantId); } finally { ConnectionManagerUtil.closeDBConnection(); } } @Override - public void makeDefaultRelease(int id) throws ApplicationManagementException { + public void changeDefaultRelease(String uuid, String version, boolean isDefault, String releaseChannel) throws + ApplicationManagementException { + Application application = validateApplication(uuid); + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); + if (log.isDebugEnabled()) { + log.debug("Request received to change the default release for the release channel " + releaseChannel + + "for the application " + application.toString()); + } + try { + ConnectionManagerUtil.beginDBTransaction(); + DAOFactory.getApplicationReleaseDAO() + .changeReleaseDefault(uuid, version, isDefault, releaseChannel, tenantId); + ConnectionManagerUtil.commitDBTransaction(); + } catch (ApplicationManagementDAOException e) { + ConnectionManagerUtil.rollbackDBTransaction(); + throw e; + } finally { + ConnectionManagerUtil.closeDBConnection(); + } } @Override diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationStorageManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationStorageManagerImpl.java index c5882ef1d8..287cd5370b 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationStorageManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationStorageManagerImpl.java @@ -21,12 +21,18 @@ package org.wso2.carbon.device.application.mgt.core.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.application.mgt.common.Application; import org.wso2.carbon.device.application.mgt.common.ApplicationRelease; 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.DBConnectionException; +import org.wso2.carbon.device.application.mgt.common.exception.TransactionManagementException; import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager; +import org.wso2.carbon.device.application.mgt.core.dao.common.DAOFactory; +import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException; import org.wso2.carbon.device.application.mgt.core.internal.DataHolder; +import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil; import org.wso2.carbon.device.application.mgt.core.util.Constants; import java.io.File; @@ -36,6 +42,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.util.Arrays; import java.util.List; /** @@ -47,18 +54,8 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager @Override public void uploadImageArtifacts(String applicationUUID, InputStream iconFileStream, InputStream bannerFileStream, List screenShotStreams) throws ApplicationStorageManagementException { - Application application; - try { - application = DataHolder.getInstance().getApplicationManager().getApplication(applicationUUID); - } catch (ApplicationManagementException e) { - throw new ApplicationStorageManagementException( - "Exception while retrieving the application details for " + "the application with UUID " - + applicationUUID); - } - if (application == null) { - throw new ApplicationStorageManagementException("Application with UUID " + applicationUUID + " does not " - + "exist. Cannot upload the artifacts to non-existing application."); - } + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); + Application application = validateApplication(applicationUUID); String artifactDirectoryPath = Constants.artifactPath + application.getId(); if (log.isDebugEnabled()) { log.debug("Artifact Directory Path for saving the artifacts related with application " + applicationUUID @@ -66,10 +63,8 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager } createArtifactDirectory(artifactDirectoryPath); if (iconFileStream != null) { - String iconName = application.getIconName(); - iconName = (iconName == null) ? "icon" : iconName; try { - saveFile(iconFileStream, artifactDirectoryPath + File.separator + iconName); + saveFile(iconFileStream, artifactDirectoryPath + File.separator + Constants.IMAGE_ARTIFACTS[0]); } catch (IOException e) { throw new ApplicationStorageManagementException( "IO Exception while saving the icon file in the server for " + "the application " @@ -77,10 +72,8 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager } } if (bannerFileStream != null) { - String bannerName = application.getBannerName(); - bannerName = (bannerName == null) ? "banner" : bannerName; try { - saveFile(bannerFileStream, artifactDirectoryPath + File.separator + bannerName); + saveFile(bannerFileStream, artifactDirectoryPath + File.separator + Constants.IMAGE_ARTIFACTS[1]); } catch (IOException e) { throw new ApplicationStorageManagementException( "IO Exception while saving the banner file in the server for" + " the application " @@ -88,18 +81,11 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager } } if (screenShotStreams != null) { - int count = 1; + int count = application.getScreenShotCount() + 1; String screenshotName; - List screenShotNames = application.getScreenshots(); - boolean isScreenShotNameExist = (screenShotNames == null || screenShotNames.isEmpty()); - int screenShotNameLength = isScreenShotNameExist ? screenShotNames.size() : 0; for (InputStream screenshotStream : screenShotStreams) { try { - if (isScreenShotNameExist && count <= screenShotNameLength) { - screenshotName = screenShotNames.get(count); - } else { - screenshotName = "screenshot_" + count; - } + screenshotName = Constants.IMAGE_ARTIFACTS[2] + count; saveFile(screenshotStream, artifactDirectoryPath + File.separator + screenshotName); count++; } catch (IOException e) { @@ -108,24 +94,35 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager e); } } + try { + ConnectionManagerUtil.beginDBTransaction(); + DAOFactory.getApplicationDAO().updateScreenShotCount(applicationUUID, tenantId, count - 1); + ConnectionManagerUtil.commitDBTransaction(); + } catch (TransactionManagementException e) { + ConnectionManagerUtil.rollbackDBTransaction(); + throw new ApplicationStorageManagementException("Transaction Management exception while trying to " + + "update the screen-shot count of the application " + applicationUUID + " for the tenant " + + tenantId, e); + } catch (DBConnectionException e) { + ConnectionManagerUtil.rollbackDBTransaction(); + throw new ApplicationStorageManagementException("Database connection management exception while " + + "trying to update the screen-shot count for the application " + applicationUUID + " for the" + + " tenant " + tenantId, e); + } catch (ApplicationManagementDAOException e) { + ConnectionManagerUtil.rollbackDBTransaction(); + throw new ApplicationStorageManagementException("Application Management DAO exception while trying to" + + " update the screen-shot count for the application " + applicationUUID + " for the tenant " + + tenantId, e); + } finally { + ConnectionManagerUtil.closeDBConnection(); + } } } @Override public void uploadReleaseArtifacts(String applicationUUID, String versionName, InputStream binaryFile) throws ApplicationStorageManagementException { - Application application; - try { - application = DataHolder.getInstance().getApplicationManager().getApplication(applicationUUID); - } catch (ApplicationManagementException e) { - throw new ApplicationStorageManagementException( - "Exception while retrieving the application details for " + "the application with UUID " - + applicationUUID); - } - if (application == null) { - throw new ApplicationStorageManagementException("Application with UUID " + applicationUUID + " does not " - + "exist. Cannot upload release artifacts for not existing application."); - } + Application application = validateApplication(applicationUUID); String artifactDirectoryPath = Constants.artifactPath + application.getId(); if (log.isDebugEnabled()) { log.debug("Artifact Directory Path for saving the application release related artifacts related with " @@ -148,18 +145,7 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager @Override public InputStream getReleasedArtifacts(String applicationUUID, String versionName) throws ApplicationStorageManagementException { - Application application; - try { - application = DataHolder.getInstance().getApplicationManager().getApplication(applicationUUID); - } catch (ApplicationManagementException e) { - throw new ApplicationStorageManagementException( - "Exception while retrieving the application details for " + "the application with UUID " - + applicationUUID); - } - if (application == null) { - throw new ApplicationStorageManagementException("Application with UUID " + applicationUUID + " does not " - + "exist. Cannot retrieve release artifacts for not existing application."); - } + Application application = validateApplication(applicationUUID); String artifactPath = Constants.artifactPath + application.getId() + File.separator + versionName; if (log.isDebugEnabled()) { @@ -182,18 +168,7 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager @Override public void deleteApplicationArtifacts(String applicationUUID) throws ApplicationStorageManagementException { - Application application; - try { - application = DataHolder.getInstance().getApplicationManager().getApplication(applicationUUID); - } catch (ApplicationManagementException e) { - throw new ApplicationStorageManagementException( - "Exception while retrieving the application details for " + "the application with UUID " - + applicationUUID); - } - if (application == null) { - throw new ApplicationStorageManagementException("Application with UUID " + applicationUUID + " does not " - + "exist. Cannot delete the artifacts of a non-existing application."); - } + Application application = validateApplication(applicationUUID); String artifactDirectoryPath = Constants.artifactPath + application.getId(); File artifactDirectory = new File(artifactDirectoryPath); @@ -205,18 +180,7 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager @Override public void deleteApplicationReleaseArtifacts(String applicationUUID, String version) throws ApplicationStorageManagementException { - Application application; - try { - application = DataHolder.getInstance().getApplicationManager().getApplication(applicationUUID); - } catch (ApplicationManagementException e) { - throw new ApplicationStorageManagementException( - "Exception while retrieving the application details for " + "the application with UUID " - + applicationUUID); - } - if (application == null) { - throw new ApplicationStorageManagementException("Application with UUID " + applicationUUID + " does not " - + "exist. Cannot delete the artifacts of a non-existing application."); - } + Application application = validateApplication(applicationUUID); String artifactPath = Constants.artifactPath + application.getId() + File.separator + version; File artifact = new File(artifactPath); @@ -225,8 +189,10 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager } } - @Override public void deleteAllApplicationReleaseArtifacts(String applicationUUID) - throws ApplicationStorageManagementException { + @Override + public void deleteAllApplicationReleaseArtifacts(String applicationUUID) throws + ApplicationStorageManagementException { + Application application = validateApplication(applicationUUID); try { List applicationReleases = DataHolder.getInstance().getReleaseManager() .getReleases(applicationUUID); @@ -240,6 +206,31 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager } } + @Override + public InputStream getImageArtifact(String applicationUUID, String name, int count) throws + ApplicationStorageManagementException { + Application application = validateApplication(applicationUUID); + validateImageArtifactNames(name); + String imageArtifactPath = Constants.artifactPath + application.getId() + File.separator + name.toLowerCase(); + + if (name.equalsIgnoreCase(Constants.IMAGE_ARTIFACTS[2])) { + imageArtifactPath += count; + } + File imageFile = new File(imageArtifactPath); + if (!imageFile.exists()) { + throw new ApplicationStorageManagementException( + "Image artifact " + name + " does not exist for the " + "application with UUID " + applicationUUID); + } else { + try { + return new FileInputStream(imageArtifactPath); + } catch (FileNotFoundException e) { + throw new ApplicationStorageManagementException( + "File not found exception while trying to get the image artifact " + name + " for the " + + "application " + applicationUUID, e); + } + } + } + /** * To save a file in a given location. * @@ -294,4 +285,44 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager } artifactDirectory.delete(); } + + /** + * To validate the image artifact names. + * @param name Name of the image artifact. + * @throws ApplicationStorageManagementException Application Storage Management Exception + */ + private void validateImageArtifactNames(String name) throws ApplicationStorageManagementException { + if (name == null || name.isEmpty()) { + throw new ApplicationStorageManagementException("Image artifact name cannot be null or empty. It is a " + + "required parameter"); + } + if (!Arrays.asList(Constants.IMAGE_ARTIFACTS).contains(name.toLowerCase())) { + throw new ApplicationStorageManagementException("Provide artifact name is not valid. Please provide the " + + "name among " + Arrays.toString(Constants.IMAGE_ARTIFACTS)); + } + } + + /** + * To validate the Application before storing and retrieving the artifacts of a particular application. + * + * @param uuid UUID of the Application + * @return {@link Application} if it is validated + * @throws ApplicationStorageManagementException Application Storage Management Exception will be thrown if a + * valid application related with the specific UUID + * could not be found. + */ + private Application validateApplication(String uuid) throws ApplicationStorageManagementException { + Application application = null; + try { + application = DataHolder.getInstance().getApplicationManager().getApplication(uuid); + } catch (ApplicationManagementException e) { + throw new ApplicationStorageManagementException( + "Exception while retrieving the application details for the application with UUID " + + uuid); + } + if (application == null) { + throw new ApplicationStorageManagementException("Application with UUID " + uuid + " does not exist."); + } + return application; + } } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/Constants.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/Constants.java index 467be38824..9c6992b204 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/Constants.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/Constants.java @@ -58,4 +58,9 @@ public class Constants { * Path to save the Application related artifacts. */ public static String artifactPath = ""; + + /** + * Name of the image artifacts that are saved in the file system. + */ + public static final String[] IMAGE_ARTIFACTS = {"icon", "banner", "screenshot"}; } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/pom.xml new file mode 100644 index 0000000000..e7d27b5f74 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/pom.xml @@ -0,0 +1,122 @@ + + + + 4.0.0 + + + org.wso2.carbon.devicemgt + application-mgt + 3.0.46-SNAPSHOT + + org.wso2.carbon.device.application.mgt.publisher.ui + 3.0.46-SNAPSHOT + + + + + org.wso2.maven + carbon-p2-plugin + ${carbon.p2.plugin.version} + + + 4-p2-feature-generation + package + + p2-feature-gen + + + org.wso2.carbon.device.application.mgt + ../../etc/feature.properties + + + org.wso2.carbon.p2.category.type:server + + org.eclipse.equinox.p2.type.group:false + + + + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.5.0 + + + npm install (initialize) + + exec + + initialize + + ${basedir}/src/main/resources/publisher + ${npm.executable} + + install + + + + + npm run build (compile) + + exec + + compile + + ${basedir}/src/main/resources/publisher + ${npm.executable} + + run + ${npm.build.command} + + + + + + ${npm.working.dir} + + + + + + + + platform-windows + + + windows + + + + + npm.cmd + + + + + false + npm + build_prod + ./src/main/ + + diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/.babelrc b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/.babelrc new file mode 100644 index 0000000000..3c078e9f99 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/.babelrc @@ -0,0 +1,5 @@ +{ + "presets": [ + "es2015" + ] +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/package.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/package.json new file mode 100644 index 0000000000..804eea3d0d --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/package.json @@ -0,0 +1,56 @@ +{ + "name": "publisher", + "version": "1.0.0", + "description": "WSO2 IoT Server App Publisher", + "main": "App.js", + "repository": { + "type": "git", + "url": "git://github.com/wso2/carbon-devicemgt" + }, + "license": "Apache License 2.0", + "dependencies": { + "axios": "^0.16.2", + "flux": "^3.1.3", + "history": "^4.6.3", + "latest-version": "^3.1.0", + "material-ui": "^0.19.0", + "material-ui-datatables": "^0.18.2", + "prop-types": "^15.5.10", + "qs": "^6.5.0", + "react": "^15.6.1", + "react-dom": "^15.6.1", + "react-dropzone": "^4.1.0", + "react-images-uploader": "^1.1.0", + "react-material-ui-form-validator": "^0.5.0", + "react-modal": "^2.2.2", + "react-router": "^4.1.2", + "react-router-dom": "^4.1.2", + "react-scripts": "1.0.10", + "react-sliding-pane": "^1.2.3", + "react-tap-event-plugin": "^2.0.1" + }, + "devDependencies": { + "babel-core": "^6.24.1", + "babel-loader": "^7.0.0", + "babel-plugin-transform-class-properties": "^6.24.1", + "babel-preset-es2015": "^6.24.1", + "chai": "^4.0.2", + "babel-preset-react": "^6.24.1", + "babel-register": "^6.24.1", + "css-loader": "^0.28.2", + "less": "^2.7.2", + "less-loader": "^4.0.4", + "mocha": "^3.4.1", + "mock-local-storage": "^1.0.2", + "style-loader": "^0.18.1", + "webpack": "^2.5.0" + }, + "scripts": { + "start": "react-scripts start", + "build": "react-scripts build --history-api-fallback", + "test": "react-scripts test --env=jsdom", + "eject": "react-scripts eject", + "build_prod": "NODE_ENV=production webpack -p --progress --colors --config webpack.config.js", + "build_dev": "NODE_ENV=development webpack -d --config webpack.config.js --watch " + } +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/images/favicon.png b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/images/favicon.png new file mode 100644 index 0000000000..a1deab3581 Binary files /dev/null and b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/images/favicon.png differ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/index.html b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/index.html new file mode 100644 index 0000000000..39ac2df1c6 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/index.html @@ -0,0 +1,57 @@ + + + + + + + + + + + + WSO2 IoT App Publisher + + + +
+ + + diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/manifest.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/manifest.json new file mode 100644 index 0000000000..2a700bb50e --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/manifest.json @@ -0,0 +1,15 @@ +{ + "short_name": "App Publisher", + "name": "WSO2 IoT App Publisher", + "icons": [ + { + "src": "images/favicon.png", + "sizes": "16x16", + "type": "image/png" + } + ], + "start_url": "./index.html", + "display": "standalone", + "theme_color": "#000000", + "background_color": "#ffffff" +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.css b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.css new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.js new file mode 100644 index 0000000000..faa4e14359 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.js @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2017, 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. + */ + +import './App.css' +import React, {Component} from 'react'; +import createHistory from 'history/createHashHistory'; +import {HashRouter as Router, Redirect, Route, Switch} from 'react-router-dom' +import {BaseLayout, ApplicationCreate, Login, NotFound, PublisherOverview, PlatformCreate} from './components' + +const history = createHistory({basename: '/publisher'}); + +/** + * This component defines the layout and the routes for the app. + * All the content will be loaded inside the Base component. + * The base component includes the Core layout and the routers according to which the content will be displayed. + * + * The Router and Route components. + * The Router and Route is used for navigation. + * We specify the component which needs to be rendered for an URL. + * Ex: When navigate to publisher/overview, the overview component will be rendered inside the main layout. + * */ + +class Base extends Component { + constructor() { + super(); + this.state = { + user: "admin" + } + } + + render() { + if (this.state.user) { + return ( +
+ + + + + + + + + + + + + + + + +
+ ) + } + + return () + } +} + +/** + * This component is referred by the index.js to initiate the application. + * */ +class Publisher extends Component { + render() { + return ( +
+ + + + + + + +
+ ); + } +} + +Publisher.propTypes = { + user: Object +}; + +export default Publisher; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.test.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.test.js new file mode 100644 index 0000000000..79b7f3f665 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.test.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2017, 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. + */ + +import React from 'react'; +import ReactDOM from 'react-dom'; +import App from './App'; + +it('renders without crashing', () => { + const div = document.createElement('div'); + ReactDOM.render(, div); +}); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/actions/ApplicationActions.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/actions/ApplicationActions.js new file mode 100644 index 0000000000..9eb827eb70 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/actions/ApplicationActions.js @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2017, 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. + */ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/actions/PlatformActions.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/actions/PlatformActions.js new file mode 100644 index 0000000000..9eb827eb70 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/actions/PlatformActions.js @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2017, 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. + */ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/actions/ReviewActions.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/actions/ReviewActions.js new file mode 100644 index 0000000000..9eb827eb70 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/actions/ReviewActions.js @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2017, 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. + */ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/api/AuthHandler.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/api/AuthHandler.js new file mode 100644 index 0000000000..9eb827eb70 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/api/AuthHandler.js @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2017, 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. + */ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/api/Endpoints.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/api/Endpoints.js new file mode 100644 index 0000000000..e3e76b69c2 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/api/Endpoints.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2017, 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. + */ + +/** + * Defines the list of App Manager APIs. + * */ \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/common/constants.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/common/constants.js new file mode 100644 index 0000000000..9eb827eb70 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/common/constants.js @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2017, 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. + */ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/common/dispatcher.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/common/dispatcher.js new file mode 100644 index 0000000000..96803dfb20 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/common/dispatcher.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2017, 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. + */ + +import {Dispatcher} from 'flux'; + +export default new Dispatcher(); + diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/ApplicationCreate.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/ApplicationCreate.js new file mode 100644 index 0000000000..849a994663 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/ApplicationCreate.js @@ -0,0 +1,231 @@ +/* + * Copyright (c) 2017, 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. + */ + +import React, {Component} from 'react'; +import Dialog from 'material-ui/Dialog'; +import {withRouter} from 'react-router-dom'; +import {Step1, Step2, Step3} from './Forms'; +import FlatButton from 'material-ui/FlatButton'; +import RaisedButton from 'material-ui/RaisedButton'; +import {Card, CardActions, CardTitle} from 'material-ui/Card'; +import {Step, StepLabel, Stepper,} from 'material-ui/Stepper'; + + +/** + * The App Create Component. + * + * Application creation is handled through a Wizard. (We use Material UI Stepper.) + * + * In each step, data will be set to the state separately. + * When the wizard is completed, data will be arranged and sent to the api. + * */ +class ApplicationCreate extends Component { + constructor() { + super(); + this.setStepData.bind(this); + this.removeStepData.bind(this); + this.handleSubmit.bind(this); + this.handleCancel.bind(this); + this.handleYes.bind(this); + this.handleNo.bind(this); + this.state = { + finished: false, + stepIndex: 0, + stepData: [], + isDialogOpen: false + }; + } + + /** + * Handles next button click event. + * */ + handleNext = () => { + const {stepIndex} = this.state; + this.setState({ + stepIndex: stepIndex + 1, + finished: stepIndex >= 2, + }); + }; + + /** + * Handles form submit. + * */ + handleSubmit = () => { + console.log(this.state.stepData); + }; + + /** + * Handles cancel button click event. + * This will show a confirmation dialog to cancel the application creation process. + * */ + handleCancel = () => { + this.setState({isDialogOpen: true}); + }; + + /** + * Handled [ < Prev ] button click. + * This clears the data in the current step and returns to the previous step. + * */ + handlePrev = () => { + const {stepIndex} = this.state; + if (stepIndex > 0) { + this.removeStepData(); + this.setState({stepIndex: stepIndex - 1}); + } + }; + + /** + * Saves form data in each step in to the state. + * */ + setStepData = (step, data) => { + console.log(step, data, this.state.stepData); + let tmpStepData = this.state.stepData; + tmpStepData.push({step: step, data: data}); + + this.setState({stepData: tmpStepData}) + }; + + /** + * Remove the last data point + * */ + removeStepData = () => { + let tempData = this.state.stepData; + tempData.pop(); + this.setState({stepData: tempData}); + }; + + /** + * Handles the Yes button in app creation cancellation dialog. + * Clears all the form data and reset the wizard. + * */ + handleYes = () => { + this.setState({finished: false, stepIndex: 0, stepData: [], isDialogOpen: false}); + }; + + /** + * Handles No button in app creation cancellation dialog. + * Returns to the same step. + * */ + handleNo = () => { + this.setState({isDialogOpen: false}); + }; + + /** + * Defines all the Steps in the stepper. (Wizard) + * + * Extension Point: If any extra steps needed, follow the instructions below. + * 1. Create the required form ./Forms directory. + * 2. Add defined case statements. + * 3. Define the Step in render function. + * + * */ + getStepContent(stepIndex) { + switch (stepIndex) { + case 0: + return ; + case 1: + return ; + case 2: + return ; + default: + return 'You\'re a long way from home sonny jim!'; + } + } + + + render() { + const {finished, stepIndex} = this.state; + const contentStyle = {margin: '0 16px'}; + + /** + * Defines the dialog box actions. [Yes][No] + * */ + const actions = [ + , + , + ]; + + + return ( +
+ + + + {/** + * The stepper goes here. + */} + +
+ + + Select Application Platform + + + Enter Application Details + + + Release + + +
+ {finished ? ( +
+

Create App?

+
+ + + +
+ ) : ( +
+ {this.getStepContent(stepIndex)} +
+ )} +
+
+
+
+ + Do you really want to cancel? + +
); + } +} + +export default withRouter(ApplicationCreate); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/ApplicationListing.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/ApplicationListing.js new file mode 100644 index 0000000000..d81c32a790 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/ApplicationListing.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2017, 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. + */ + +import React, {Component} from 'react'; +import {withRouter} from 'react-router-dom'; + + +/** + * Application List Component. + * */ +class ApplicationListing extends Component{ + +} + +export default withRouter(ApplicationListing); \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/ApplicationView.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/ApplicationView.js new file mode 100644 index 0000000000..3959357f2e --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/ApplicationView.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2017, 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. + */ + +import React, {Component} from 'react'; +import {withRouter} from 'react-router-dom'; + +/** + * Application view component. + * Shows the details of the application. + * */ +class ApplicationView extends Component{ + +} + +export default withRouter(ApplicationView); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step1.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step1.js new file mode 100644 index 0000000000..8ce132ba24 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step1.js @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2017, 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. + */ + +import React, {Component} from 'react'; +import MenuItem from 'material-ui/MenuItem'; +import TextField from 'material-ui/TextField'; +import FlatButton from 'material-ui/FlatButton'; +import SelectField from 'material-ui/SelectField'; +import RaisedButton from 'material-ui/RaisedButton'; + +/** + * The first step of the application creation wizard. + * This contains following components: + * * Application Title + * * Store Type + * * Application Platform + * + * Parent Component: Create + * Props: + * 1. handleNext: {type: function, Invokes handleNext function of parent component} + * 2. setData : {type: function, Sets current form data to the state of the parent component} + * 3. removeData: {type: function, Invokes the removeStepData function click of parent} + * */ +class Step1 extends Component { + constructor() { + super(); + this.state = { + finished: false, + stepIndex: 0, + store: 1, + platform: 1, + stepData: [] + }; + } + + /** + * Invokes the handleNext function in Create component. + * */ + handleNext = () => { + this.props.handleNext(); + }; + + /** + * Persist the current form data to the state. + * */ + setStepData() { + this.props.setData("step1", {step: "Dfds"}); + this.handleNext.bind(this); + } + + /** + * Handles Next button click. + * Validates the form. + * Sets the data to the state. + * Invokes the handleNext method of Create component. + * */ + handleClick() { + this.setStepData(); + this.handleNext(); + } + + /** + * Triggers when changing the Platform selection. + * */ + onChangePlatform = (event, index, value) => { + this.setState({platform: value}); + }; + + /** + * Triggers when changing the Store selection. + * */ + onChangeStore = (event, index, value) => { + this.setState({store: value}); + }; + + render() { + const contentStyle = {margin: '0 16px'}; + return ( +
+
+
+
+
+ + + +
+ + + + + +
+ +
+
+
+ +
+
+
+
+ ); + } +} + +export default Step1; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step2.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step2.js new file mode 100644 index 0000000000..67c709392b --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step2.js @@ -0,0 +1,209 @@ +/* + * Copyright (c) 2017, 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. + */ + +import Chip from 'material-ui/Chip'; +import React, {Component} from 'react'; +import MenuItem from 'material-ui/MenuItem'; +import TextField from 'material-ui/TextField'; +import FlatButton from 'material-ui/FlatButton'; +import SelectField from 'material-ui/SelectField'; +import RaisedButton from 'material-ui/RaisedButton'; + +/** + * The Second step of application create wizard. + * This contains following components. + * * App Title + * * Short Description + * * Application Description + * * Application Visibility + * * Application Tags : {Used Material UI Chip component} + * * Application Category. + * * Platform Specific properties. + * * Screenshots + * * Banner + * * Icon + * + * Parent Component: Create + * Props: + * * handleNext : {type: function, Invokes handleNext function in Parent.} + * * handlePrev : {type: function, Invokes handlePrev function in Parent} + * * setData : {type: function, Invokes setStepData function in Parent} + * * removeData : {type: Invokes removeStepData function in Parent} + * */ +class Step2 extends Component { + constructor() { + super(); + this.state = { + tags: [], + defValue: "", + category: 1 + }; + + this.styles = { + chip: { + margin: 4, + }, + wrapper: { + display: 'flex', + flexWrap: 'wrap', + }, + }; + + } + + /** + * Create a tag on Enter key press and set it to the state. + * Clears the tags text field. + * Chip gets two parameters: Key and value. + * */ + addTags(event) { + let tags = this.state.tags; + if (event.charCode === 13) { + event.preventDefault(); + tags.push({key: Math.floor(Math.random() * 1000), value: event.target.value}); + this.setState({tags, defValue: ""}, console.log(this.state.tags)); + } + } + + /** + * + * */ + handleTagChange(event) { + let defaultValue = this.state.defValue; + defaultValue = event.target.value; + this.setState({defValue: defaultValue}) + } + + /** + * Invokes the handleNext function in Create component. + * */ + handleNext() { + this.props.handleNext(); + } + + /** + * Invokes the handlePrev function in Create component. + * */ + handlePrev() { + this.props.handlePrev(); + } + + /** + * Handles Chip delete function. + * Removes the tag from state.tags + * */ + handleRequestDelete = (key) => { + this.chipData = this.state.tags; + const chipToDelete = this.chipData.map((chip) => chip.key).indexOf(key); + this.chipData.splice(chipToDelete, 1); + this.setState({tags: this.chipData}); + }; + + /** + * Creates Chip array from state.tags. + * */ + renderChip(data) { + console.log(data); + return ( + this.handleRequestDelete(data.key)} + style={this.styles.chip} + > + {data.value} + + ); + } + + render() { + const contentStyle = {margin: '0 16px'}; + return ( +
+
+
+
+
+
+
+
+
+ {this.state.tags.map(this.renderChip, this)} +
+
+ + +
+ {/*Platform Specific Properties.*/} +
+ fdfdfd +
+
+ +
+
+
+ + +
+
+
+ ); + } +} + +export default Step2; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step3.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step3.js new file mode 100644 index 0000000000..dc3e912a9c --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step3.js @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2017, 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. + */ + +import React, {Component} from 'react'; +import Toggle from 'material-ui/Toggle'; +import MenuItem from 'material-ui/MenuItem'; +import TextField from 'material-ui/TextField'; +import FlatButton from 'material-ui/FlatButton'; +import SelectField from 'material-ui/SelectField'; +import RaisedButton from 'material-ui/RaisedButton'; + +/** + * The Third step of application create wizard. {Application Release Step} + * This step is not compulsory. + * + * When click finish, user will prompt to confirm the application creation. + * User can go ahead and create the app or cancel. + * + * This contains following components: + * * Toggle to select application release. Un-hides the Application Release form. + * + * Application Release Form. + * * Release Channel + * * Application Version + * * Upload component for application. + * + * Parent Component: Create + * Props: + * * handleFinish : {type: function, Invokes handleNext function in Parent.} + * * handlePrev : {type: function, Invokes handlePrev function in Parent} + * * setData : {type: function, Invokes setStepData function in Parent} + * * removeData : {type: Invokes removeStepData function in Parent} + * */ +class Step3 extends Component { + constructor() { + super(); + this.state = { + showForm: false, + releaseChannel: 1 + } + } + + /** + * Handles finish button click. + * This invokes handleNext function in parent component. + * */ + handleFinish() { + this.props.handleFinish(); + } + + /** + * Invokes Prev button click. + * */ + handlePrev() { + this.props.handlePrev(); + } + + /** + * Handles release application selection. + * */ + handleToggle() { + let hide = this.state.showForm; + this.setState({showForm: !hide}); + } + + + render() { + const contentStyle = {margin: '0 16px'}; + return ( +
+
+ + + {/*If toggle is true, the release form will be shown.*/} + {!this.state.showForm ?
:
+ + + + +
+
+
} + +
+ + +
+
+
+ ); + } +} + +export default Step3; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/index.js new file mode 100644 index 0000000000..9f5ad0bdac --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/index.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2017, 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. + */ + +import Step1 from './Step1'; +import Step2 from './Step2'; +import Step3 from './Step3'; + +export {Step1, Step2, Step3}; \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Base/BaseLayout.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Base/BaseLayout.js new file mode 100644 index 0000000000..1916005a0a --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Base/BaseLayout.js @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2017, 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. + */ + +import Badge from 'material-ui/Badge'; +import React, {Component} from 'react'; +import AppBar from 'material-ui/AppBar'; +import Drawer from 'material-ui/Drawer'; +import {withRouter} from 'react-router-dom'; +import IconButton from 'material-ui/IconButton'; +import {List, ListItem} from 'material-ui/List'; +import Apps from 'material-ui/svg-icons/navigation/apps'; +import Add from 'material-ui/svg-icons/content/add-circle'; +import Feedback from 'material-ui/svg-icons/action/feedback'; +import Dashboard from 'material-ui/svg-icons/action/dashboard'; +import DevicesOther from 'material-ui/svg-icons/hardware/devices-other'; +import NotificationsIcon from 'material-ui/svg-icons/social/notifications'; +import ActionAccountCircle from 'material-ui/svg-icons/action/account-circle'; + +/** + * Base Layout: + * App bar + * Left Navigation + * Middle content. + * */ +class BaseLayout extends Component { + + constructor() { + super(); + this.state = { + notifications: 0, + user: 'Admin' + } + } + + componentWillMount() { + + } + + handleApplicationClick() { + this.handleHistory('/assets/apps'); + } + + handleOverviewClick() { + this.handleHistory('/overview'); + } + + handleApplicationCreateClick() { + this.handleHistory('/assets/apps/create'); + } + + handlePlatformClick() { + this.handleHistory('/assets/platforms'); + } + + handlePlatformCreateClick() { + this.handleHistory('/assets/platforms/create'); + } + + handleReviewClick() { + this.handleHistory('/assets/reviews'); + } + + /** + * The method to update the history. + * to: The URL to route. + * */ + handleHistory(to) { + this.props.history.push(to); + } + + render() { + return ( +
+ + + + + + + { + console.log("Clicked") + }}> + + +
+ } + /> +
+ + + }/> + } + initiallyOpen={false} + primaryTogglesNestedList={true} + onClick={this.handleApplicationClick.bind(this)} + nestedItems={[ + } + />]} + /> + } + initiallyOpen={false} + primaryTogglesNestedList={true} + onClick={this.handlePlatformClick.bind(this)} + nestedItems={[ + } + />]} + /> + }/> + + +
+
+ {this.props.children} +
+
); + } + +} + +export default withRouter(BaseLayout); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Error/NotFound.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Error/NotFound.js new file mode 100644 index 0000000000..81a1b0320b --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Error/NotFound.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2017, 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. + */ +import React, {Component} from 'react'; + +/** + * Error page. + * */ +class Error extends Component { + + constructor() { + super(); + } + + render() { + return ( +
+ 404 not found +
+ ); + } +} + +export default Error; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Overview/PublisherOverview.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Overview/PublisherOverview.js new file mode 100644 index 0000000000..c9640bab15 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Overview/PublisherOverview.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2017, 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. + */ +import React, {Component} from 'react'; + +/** + * + * ***NEW*** + * The Publisher overview component. + * This component could be used to view app analytics. + * i.e number of overall downloads, ratings ect. + * */ +class PublisherOverview extends Component { + + constructor() { + super(); + } + + componentWillMount() { + } + + render() { + + return ( + +
+ Overview +
+ ); + } +} + +export default PublisherOverview; \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/PlatformCreate.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/PlatformCreate.js new file mode 100644 index 0000000000..0928586b5a --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/PlatformCreate.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2017, 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. + */ +import React, {Component} from 'react'; + +/** + * Platform Create component + * */ +class PlatformCreate extends Component { + + constructor() { + super(); + } + + render() { + return ( +
+ Create Platform +
+ ); + } +} + +export default PlatformCreate; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/PlatformListing.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/PlatformListing.js new file mode 100644 index 0000000000..e51137e453 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/PlatformListing.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2017, 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. + */ +import React, {Component} from 'react'; + +/** + * Platform Listing component. + * */ +class PlatformListing extends Component { + + constructor() { + super(); + } + + render() { + return ( +
+ Platform View +
+ ); + } +} + +export default PlatformListing; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/PlatformView.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/PlatformView.js new file mode 100644 index 0000000000..dce6e9f716 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/PlatformView.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2017, 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. + */ +import React, {Component} from 'react'; + +/** + * Platform view component. + * */ +class PlatformView extends Component { + + constructor() { + super(); + } + + render() { + return ( +
+ Platform View +
+ ); + } +} + +export default PlatformView; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Reviews/ReviewListing.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Reviews/ReviewListing.js new file mode 100644 index 0000000000..2575b736f7 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Reviews/ReviewListing.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2017, 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. + */ +import React, {Component} from 'react'; + +/** + * Review Listing. + * */ +class ReviewListing extends Component { + + constructor() { + super(); + } + + render() { + return ( +
+ Reviews List +
+ ); + } +} + +export default ReviewListing; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Reviews/ReviewView.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Reviews/ReviewView.js new file mode 100644 index 0000000000..da5bdac607 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Reviews/ReviewView.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2017, 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. + */ +import React, {Component} from 'react'; + +/** + * Review details view. + * */ +class ReviewView extends Component { + + constructor() { + super(); + } + + render() { + return ( +
+ Review +
+ ); + } +} + +export default ReviewView; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/UIComponents/DataTable.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/UIComponents/DataTable.js new file mode 100644 index 0000000000..649d93f32b --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/UIComponents/DataTable.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2017, 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. + */ +import React, {Component} from 'react'; + +/** + * Error page. + * */ +class DataTable extends Component { + + constructor() { + super(); + } + + render() { + return ( +
+ Data Table +
+ ); + } +} + +export default DataTable; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/User/Login/Login.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/User/Login/Login.js new file mode 100644 index 0000000000..72255be8dd --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/User/Login/Login.js @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2017, 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. + */ + +import qs from 'qs'; +import React, {Component} from 'react'; +import Checkbox from 'material-ui/Checkbox'; +import {Redirect, Switch} from 'react-router-dom'; +import RaisedButton from 'material-ui/RaisedButton'; +import {Card, CardActions, CardTitle} from 'material-ui/Card'; +import {TextValidator, ValidatorForm} from 'react-material-ui-form-validator'; + +//todo: remove the {TextValidator, ValidatorForm} and implement it manually. + + +/** + * The Login Component. + * + * This component contains the Login form and methods to handle field change events. + * The user name and password will be set to the state and sent to the api. + * + * If the user is already logged in, it will redirect to the last point where the user was. + * */ +class Login extends Component { + constructor() { + super(); + this.state = { + isLoggedIn: true, + referrer: "/", + userName: "", + password: "", + rememberMe: true + } + } + + componentDidMount() { + let queryString = this.props.location.search; + console.log(queryString); + queryString = queryString.replace(/^\?/, ''); + /* With QS version up we can directly use {ignoreQueryPrefix: true} option */ + let params = qs.parse(queryString); + if (params.referrer) { + this.setState({referrer: params.referrer}); + } + } + + handleLogin(event) { + event.preventDefault(); + } + + /** + * Handles the username field change event. + * */ + onUserNameChange(event) { + this.setState( + { + userName: event.target.value + } + ); + } + + /** + * Handles the password field change event. + * */ + onPasswordChange(event) { + this.setState( + { + password: event.target.value + } + ); + } + + /** + * Handles the remember me check. + * */ + handleRememberMe() { + this.setState( + { + rememberMe: !this.state.rememberMe + } + ); + } + + render() { + + if (!this.state.isLoggedIn) { + return ( +
+ + {/*TODO: Style the components.*/} + + + + + console.log(errors)}> + +
+ +
+ +
+ +
+
+
+
); + } else { + return ( + + + + ); + } + } +} + +export default Login; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/index.js new file mode 100644 index 0000000000..3ed7d23ef6 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/index.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2017, 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. + */ + +import Login from './User/Login/Login'; +import NotFound from './Error/NotFound'; +import BaseLayout from './Base/BaseLayout'; +import PlatformCreate from './Platform/PlatformCreate'; +import PublisherOverview from './Overview/PublisherOverview'; +import ApplicationCreate from './Application/ApplicationCreate'; + +/** + * Contains all UI components related to Application, Login and Platform + */ + +export {Login, BaseLayout, ApplicationCreate, NotFound, PublisherOverview, PlatformCreate}; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.css b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.css new file mode 100644 index 0000000000..b4cc7250b9 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.css @@ -0,0 +1,5 @@ +body { + margin: 0; + padding: 0; + font-family: sans-serif; +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.js new file mode 100644 index 0000000000..e94b572737 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2017, 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. + */ + +import './index.css'; +import React from 'react'; +import Publisher from './App'; +import ReactDOM from 'react-dom'; +import registerServiceWorker from './registerServiceWorker'; +import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'; + +/** + * This is the base js file of the app. All the content will be rendered in the root element. + * */ +ReactDOM.render(, document.getElementById('root')); +registerServiceWorker(); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/registerServiceWorker.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/registerServiceWorker.js new file mode 100644 index 0000000000..94bc5f9982 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/registerServiceWorker.js @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2017, 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. + */ + +// In production, we register a service worker to serve assets from local cache. + +// This lets the app load faster on subsequent visits in production, and gives +// it offline capabilities. However, it also means that developers (and users) +// will only see deployed updates on the "N+1" visit to a page, since previously +// cached resources are updated in the background. + +// To learn more about the benefits of this model, read https://goo.gl/KwvDNy. +// This link also includes instructions on opting out of this behavior. + +const isLocalhost = Boolean( + window.location.hostname === 'localhost' || + // [::1] is the IPv6 localhost address. + window.location.hostname === '[::1]' || + // 127.0.0.1/8 is considered localhost for IPv4. + window.location.hostname.match( + /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ + ) +); + +export default function register() { + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { + // The URL constructor is available in all browsers that support SW. + const publicUrl = new URL(process.env.PUBLIC_URL, window.location); + if (publicUrl.origin !== window.location.origin) { + // Our service worker won't work if PUBLIC_URL is on a different origin + // from what our page is served on. This might happen if a CDN is used to + // serve assets; see https://github.com/facebookincubator/create-react-app/issues/2374 + return; + } + + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/publisher/service-worker.js`; + + if (!isLocalhost) { + // Is not local host. Just register service worker + registerValidSW(swUrl); + } else { + // This is running on localhost. Lets check if a service worker still exists or not. + checkValidServiceWorker(swUrl); + } + }); + } +} + +function registerValidSW(swUrl) { + navigator.serviceWorker + .register(swUrl) + .then(registration => { + registration.onupdatefound = () => { + const installingWorker = registration.installing; + installingWorker.onstatechange = () => { + if (installingWorker.state === 'installed') { + if (navigator.serviceWorker.controller) { + // At this point, the old content will have been purged and + // the fresh content will have been added to the cache. + // It's the perfect time to display a "New content is + // available; please refresh." message in your web app. + console.log('New content is available; please refresh.'); + } else { + // At this point, everything has been precached. + // It's the perfect time to display a + // "Content is cached for offline use." message. + console.log('Content is cached for offline use.'); + } + } + }; + }; + }) + .catch(error => { + console.error('Error during service worker registration:', error); + }); +} + +function checkValidServiceWorker(swUrl) { + // Check if the service worker can be found. If it can't reload the page. + fetch(swUrl) + .then(response => { + // Ensure service worker exists, and that we really are getting a JS file. + if ( + response.status === 404 || + response.headers.get('content-type').indexOf('javascript') === -1 + ) { + // No service worker found. Probably a different app. Reload the page. + navigator.serviceWorker.ready.then(registration => { + registration.unregister().then(() => { + window.location.reload(); + }); + }); + } else { + // Service worker found. Proceed as normal. + registerValidSW(swUrl); + } + }) + .catch(() => { + console.log( + 'No internet connection found. App is running in offline mode.' + ); + }); +} + +export function unregister() { + if ('serviceWorker' in navigator) { + navigator.serviceWorker.ready.then(registration => { + registration.unregister(); + }); + } +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/ApplicationStore.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/ApplicationStore.js new file mode 100644 index 0000000000..8d3763b6f0 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/ApplicationStore.js @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2017, 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. + */ + +export class ApplicationStore {}; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/PlatformStore.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/PlatformStore.js new file mode 100644 index 0000000000..51babc360d --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/PlatformStore.js @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2017, 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. + */ +export class PlatformStore{}; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/ReviewStore.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/ReviewStore.js new file mode 100644 index 0000000000..08ce7b2504 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/ReviewStore.js @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2017, 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. + */ + +export class ReviewStore{}; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/index.js new file mode 100644 index 0000000000..7416155217 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/index.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2017, 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. + */ + +import ReviewStore from './ReviewStore'; +import PlatformStore from './PlatformStore'; +import ApplicationStore from './ApplicationStore'; + + +export {ApplicationStore, PlatformStore, ReviewStore}; \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/webpack.config.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/webpack.config.js new file mode 100644 index 0000000000..c6483f4aaa --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/webpack.config.js @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2017, 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. + */ +var path = require('path'); + +const config = { + entry: { + index: './src/index.js' + }, + output: { + path: path.resolve(__dirname, 'public/dist'), + filename: '[name].js' + }, + devtool: "source-map", + plugins: [], + watch: false, + module: { + rules: [ + { + test: /\.(js|jsx)$/, + exclude: /node_modules/, + use: [ + { + loader: 'babel-loader', + options: { + presets: ['es2015', 'react'], + plugins: ['transform-class-properties'] + } + } + ] + }, + { + test: /\.css$/, + use: [ 'style-loader', 'css-loader' ] + }, + { + test: /\.less$/, + use: [{ + loader: "style-loader" // creates style nodes from JS strings + }, { + loader: "css-loader" // translates CSS into CommonJS + }, { + loader: "less-loader" // compiles Less to CSS + }] + } + ] + } +}; + +if (process.env.NODE_ENV === "development") { + config.watch = true; +} + +module.exports = config; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/pom.xml new file mode 100644 index 0000000000..55d169e8de --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/pom.xml @@ -0,0 +1,126 @@ + + + + 4.0.0 + + + org.wso2.carbon.devicemgt + application-mgt + 3.0.46-SNAPSHOT + + org.wso2.carbon.device.application.mgt.store.ui + 3.0.46-SNAPSHOT + + + + + + + + org.wso2.maven + carbon-p2-plugin + ${carbon.p2.plugin.version} + + + 4-p2-feature-generation + package + + p2-feature-gen + + + org.wso2.carbon.device.application.mgt.store + ../../etc/feature.properties + + + org.wso2.carbon.p2.category.type:server + + org.eclipse.equinox.p2.type.group:false + + + + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.5.0 + + + npm install (initialize) + + exec + + initialize + + ${basedir}/src/main/resources/store + ${npm.executable} + + install + + + + + npm run build (compile) + + exec + + compile + + ${basedir}/src/main/resources/publisher + ${npm.executable} + + run + ${npm.build.command} + + + + + + ${npm.working.dir} + + + + + + + + platform-windows + + + windows + + + + + npm.cmd + + + + + false + npm + build_prod + ./src/main/ + + + \ No newline at end of file diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml index 9770fd0643..61523a4ba9 100644 --- a/components/application-mgt/pom.xml +++ b/components/application-mgt/pom.xml @@ -37,7 +37,7 @@ org.wso2.carbon.device.application.mgt.core org.wso2.carbon.device.application.mgt.common org.wso2.carbon.device.application.mgt.api - org.wso2.carbon.device.application.mgt.ui + org.wso2.carbon.device.application.mgt.publisher.ui diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui.feature/pom.xml b/features/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui.feature/pom.xml new file mode 100644 index 0000000000..3bb9936115 --- /dev/null +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui.feature/pom.xml @@ -0,0 +1,33 @@ + + + + 4.0.0 + + + org.wso2.carbon.devicemgt + application-mgt-feature + 3.0.46-SNAPSHOT + + org.wso2.carbon.device.application.mgt.publisher.ui.feature + 3.0.46-SNAPSHOT + + + \ No newline at end of file diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/application-mgt.xml b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/application-mgt.xml index 1fb22c2b4a..cd8091d261 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/application-mgt.xml +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/application-mgt.xml @@ -61,7 +61,6 @@ - ${carbon.home}/repository/resources/mobileapps/images/ - ${carbon.home}/repository/resources/mobileapps/binary/ + repository/resources/mobileapps/ \ No newline at end of file diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql index f344747a4a..809efada34 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql @@ -125,10 +125,8 @@ CREATE TABLE IF NOT EXISTS `APPM_APPLICATION` ( `NAME` VARCHAR(100) NOT NULL, `SHORT_DESCRIPTION` VARCHAR(255) NULL, `DESCRIPTION` TEXT NULL, - `ICON_NAME` VARCHAR(100) NULL, - `BANNER_NAME` VARCHAR(100) NULL, + `SCREEN_SHOT_COUNT` INT DEFAULT 0, `VIDEO_NAME` VARCHAR(100) NULL, - `SCREENSHOTS` TEXT NULL, `CREATED_BY` VARCHAR(255) NULL, `CREATED_AT` DATETIME NOT NULL, `MODIFIED_AT` DATETIME NULL, @@ -183,7 +181,7 @@ CREATE TABLE IF NOT EXISTS APPM_APPLICATION_RELEASE ( ID INT NOT NULL AUTO_INCREMENT, VERSION_NAME VARCHAR(100) NOT NULL, RESOURCE TEXT NULL, - RELEASE_CHANNEL VARCHAR(50) NULL, + RELEASE_CHANNEL VARCHAR(50) DEFAULT 'ALPHA', RELEASE_DETAILS TEXT NULL, CREATED_AT DATETIME NOT NULL, APPM_APPLICATION_ID INT NOT NULL, diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql index 379b6de3da..4845697026 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql @@ -126,10 +126,8 @@ CREATE TABLE IF NOT EXISTS `APPM_APPLICATION` ( `NAME` VARCHAR(100) NOT NULL, `SHORT_DESCRIPTION` VARCHAR(255) NULL, `DESCRIPTION` TEXT NULL, - `ICON_NAME` VARCHAR(100) NULL, - `BANNER_NAME` VARCHAR(100) NULL, `VIDEO_NAME` VARCHAR(100) NULL, - `SCREENSHOTS` TEXT NULL, + `SCREEN_SHOT_COUNT` INT DEFAULT 0, `CREATED_BY` VARCHAR(255) NULL, `CREATED_AT` DATETIME NOT NULL, `MODIFIED_AT` DATETIME NULL, @@ -191,7 +189,7 @@ CREATE TABLE IF NOT EXISTS `APPM_APPLICATION_RELEASE` ( `ID` INT NOT NULL AUTO_INCREMENT UNIQUE , `VERSION_NAME` VARCHAR(100) NOT NULL, `RESOURCE` TEXT NULL, - `RELEASE_CHANNEL` VARCHAR(50) NULL, + `RELEASE_CHANNEL` VARCHAR(50) DEFAULT 'ALPHA', `RELEASE_DETAILS` TEXT NULL, `CREATED_AT` DATETIME NOT NULL, `APPM_APPLICATION_ID` INT NOT NULL, @@ -307,8 +305,8 @@ CREATE TABLE IF NOT EXISTS `APPM_PLATFORM_TENANT_MAPPING` ( CONSTRAINT `fk_APPM_PLATFORM_TENANT_MAPPING_APPM_SUPPORTED_PLATFORM1` FOREIGN KEY (`PLATFORM_ID`) REFERENCES `APPM_PLATFORM` (`ID`) - ON DELETE NO ACTION - ON UPDATE NO ACTION) + ON DELETE CASCADE + ON UPDATE CASCADE ) ENGINE = InnoDB COMMENT = 'This table contains the data related relationship between application platofrm and appication mappings'; diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/postgresql.sql b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/postgresql.sql index 96e806a012..6616a56c2a 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/postgresql.sql +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/postgresql.sql @@ -41,4 +41,206 @@ FOREIGN KEY(PLATFORM_ID) REFERENCES APPM_PLATFORM(ID) ON DELETE CASCADE, PRIMARY KEY (ID, TENANT_ID, PLATFORM_ID) ); -CREATE INDEX FK_PLATFROM_TENANT_MAPPING_PLATFORM ON APPM_PLATFORM_TENANT_MAPPING(PLATFORM_ID ASC); \ No newline at end of file +CREATE INDEX FK_PLATFROM_TENANT_MAPPING_PLATFORM ON APPM_PLATFORM_TENANT_MAPPING(PLATFORM_ID ASC); + +DROP TABLE IF EXISTS APPM_APPLICATION_CATEGORY; +DROP SEQUENCE IF EXISTS APPM_APPLICATION_CATEGORY_PK_SEQ; +CREATE SEQUENCE APPM_APPLICATION_CATEGORY_PK_SEQ; + +CREATE TABLE IF NOT EXISTS APPM_APPLICATION_CATEGORY ( + ID INT DEFAULT NEXTVAL('APPM_APPLICATION_CATEGORY_PK_SEQ'), + NAME VARCHAR(100) NOT NULL, + DESCRIPTION TEXT NULL, + PUBLISHED BOOLEAN DEFAULT FALSE, + PRIMARY KEY (ID)); + +INSERT INTO APPM_APPLICATION_CATEGORY (NAME, DESCRIPTION, PUBLISHED) VALUES ('Enterprise', 'Enterprise level +applications which the artifacts need to be provided', TRUE); +INSERT INTO APPM_APPLICATION_CATEGORY (NAME, DESCRIPTION, PUBLISHED) VALUES ('Public', 'Public category in which the +application need to be downloaded from the public application store', TRUE); + +DROP TABLE IF EXISTS APPM_LIFECYCLE_STATE; +DROP SEQUENCE IF EXISTS APPM_LIFECYCLE_STATE_PK_SEQ; +CREATE SEQUENCE APPM_LIFECYCLE_STATE_PK_SEQ; + +-- ----------------------------------------------------- +-- Table APPM_LIFECYCLE_STATE +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS APPM_LIFECYCLE_STATE ( + ID INT DEFAULT NEXTVAL('APPM_LIFECYCLE_STATE_PK_SEQ'), + NAME VARCHAR(100) NOT NULL, + IDENTIFIER VARCHAR(100) NOT NULL, + DESCRIPTION TEXT NULL, + PRIMARY KEY (ID)); + +DROP INDEX IF EXISTS APPM_LIFECYCLE_STATE_IDENTIFIER_UNIQUE; +CREATE INDEX APPM_LIFECYCLE_STATE_IDENTIFIER_UNIQUE ON APPM_LIFECYCLE_STATE(IDENTIFIER ASC); + +INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) VALUES ('CREATED', 'CREATED', 'Application creation +initial state'); +INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) +VALUES ('IN REVIEW', 'IN REVIEW', 'Application is in in-review state'); +INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) +VALUES ('APPROVED', 'APPROVED', 'State in which Application is approved after reviewing.'); +INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) +VALUES ('REJECTED', 'REJECTED', 'State in which Application is rejected after reviewing.'); +INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) +VALUES ('PUBLISHED', 'PUBLISHED', 'State in which Application is in published state.'); +INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) +VALUES ('UNPUBLISHED', 'UNPUBLISHED', 'State in which Application is in un published state.'); +INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) +VALUES ('RETIRED', 'RETIRED', 'Retiring an application to indicate end of life state,'); + +DROP TABLE IF EXISTS APPM_LIFECYCLE_STATE_TRANSITION; +DROP SEQUENCE IF EXISTS APPM_LIFECYCLE_STATE_TRANSITION_PK_SEQ; +CREATE SEQUENCE APPM_LIFECYCLE_STATE_TRANSITION_PK_SEQ; + +CREATE TABLE IF NOT EXISTS APPM_LIFECYCLE_STATE_TRANSITION +( + ID INT DEFAULT NEXTVAL('APPM_LIFECYCLE_STATE_TRANSITION_PK_SEQ'), + INITIAL_STATE INT, + NEXT_STATE INT, + PERMISSION VARCHAR(1024), + DESCRIPTION VARCHAR(2048), + PRIMARY KEY (INITIAL_STATE, NEXT_STATE), + FOREIGN KEY (INITIAL_STATE) REFERENCES APPM_LIFECYCLE_STATE(ID) ON DELETE CASCADE, + FOREIGN KEY (NEXT_STATE) REFERENCES APPM_LIFECYCLE_STATE(ID) ON DELETE CASCADE +); + +INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES + (1, 2, null, 'Submit for review'); +INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES + (2, 1, null, 'Revoke from review'); +INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES + (2, 3, '/permission/admin/manage/device-mgt/application/review', 'APPROVE'); +INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES + (2, 4, '/permission/admin/manage/device-mgt/application/review', 'REJECT'); +INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES + (3, 4, '/permission/admin/manage/device-mgt/application/review', 'REJECT'); +INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES + (3, 5, null, 'PUBLISH'); +INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES + (5, 6, null, 'UN PUBLISH'); +INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES + (6, 5, null, 'PUBLISH'); +INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES + (4, 1, null, 'Return to CREATE STATE'); +INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES + (6, 1, null, 'Return to CREATE STATE'); +INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES + (6, 7, null, 'Retire'); + + +DROP TABLE IF EXISTS APPM_APPLICATION; +DROP SEQUENCE IF EXISTS APPM_APPLICATION_PK_SEQ; +CREATE SEQUENCE APPM_APPLICATION_PK_SEQ; + +CREATE TABLE IF NOT EXISTS APPM_APPLICATION ( + ID INT DEFAULT NEXTVAL('APPM_APPLICATION_PK_SEQ') UNIQUE, + UUID VARCHAR(100) NOT NULL, + IDENTIFIER VARCHAR(255) NULL, + NAME VARCHAR(100) NOT NULL, + SHORT_DESCRIPTION VARCHAR(255) NULL, + DESCRIPTION TEXT NULL, + SCREEN_SHOT_COUNT INT DEFAULT 0, + VIDEO_NAME VARCHAR(100) NULL, + CREATED_BY VARCHAR(255) NULL, + CREATED_AT TIMESTAMP NOT NULL, + MODIFIED_AT TIMESTAMP NULL, + IS_FREE BOOLEAN DEFAULT TRUE, + PAYMENT_CURRENCY VARCHAR(45) NULL, + PAYMENT_PRICE DECIMAL(10,2) NULL, + APPLICATION_CATEGORY_ID INT NOT NULL, + LIFECYCLE_STATE_ID INT NOT NULL, + LIFECYCLE_STATE_MODIFIED_BY VARCHAR(255) NULL, + LIFECYCLE_STATE_MODIFIED_AT TIMESTAMP NULL, + TENANT_ID INT NOT NULL, + PLATFORM_ID INT NOT NULL, + PRIMARY KEY (ID, APPLICATION_CATEGORY_ID, LIFECYCLE_STATE_ID, PLATFORM_ID), + FOREIGN KEY (APPLICATION_CATEGORY_ID) + REFERENCES APPM_APPLICATION_CATEGORY (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT fk_APPM_APPLICATION_APPM_LIFECYCLE_STATE1 + FOREIGN KEY (LIFECYCLE_STATE_ID) + REFERENCES APPM_LIFECYCLE_STATE (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT fk_APPM_APPLICATION_APPM_PLATFORM1 + FOREIGN KEY (PLATFORM_ID) + REFERENCES APPM_PLATFORM (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION); + +CREATE INDEX IF NOT EXISTS FK_APPLICATION_APPLICATION_CATEGORY ON APPM_APPLICATION(APPLICATION_CATEGORY_ID ASC); +CREATE INDEX IF NOT EXISTS UK_APPLICATION_UUID ON APPM_APPLICATION(UUID ASC); + +DROP TABLE IF EXISTS APPM_APPLICATION_PROPERTY; +-- ----------------------------------------------------- +-- Table APPM_APPLICATION_PROPERTY +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS APPM_APPLICATION_PROPERTY ( + PROP_KEY VARCHAR(255) NOT NULL, + PROP_VAL TEXT NULL, + APPLICATION_ID INT NOT NULL, + PRIMARY KEY (PROP_KEY, APPLICATION_ID), + CONSTRAINT FK_APPLICATION_PROPERTY_APPLICATION + FOREIGN KEY (APPLICATION_ID) + REFERENCES APPM_APPLICATION (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION); + +CREATE INDEX FK_APPLICATION_PROPERTY_APPLICATION ON APPM_APPLICATION_PROPERTY(APPLICATION_ID ASC); + +CREATE TABLE IF NOT EXISTS APPM_APPLICATION_TAG ( + NAME VARCHAR(45) NOT NULL, + APPLICATION_ID INT NOT NULL, + PRIMARY KEY (APPLICATION_ID, NAME), + CONSTRAINT fk_APPM_APPLICATION_TAG_APPM_APPLICATION1 + FOREIGN KEY (APPLICATION_ID) + REFERENCES APPM_APPLICATION (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION); + +CREATE INDEX IF NOT EXISTS FK_APPLICATION_TAG_APPLICATION ON APPM_APPLICATION_TAG(APPLICATION_ID ASC); + +DROP TABLE IF EXISTS APPM_APPLICATION_RELEASE; +DROP SEQUENCE IF EXISTS APPM_APPLICATION_RELEASE_PK_SEQ; +CREATE SEQUENCE APPM_APPLICATION_RELEASE_PK_SEQ; +-- ----------------------------------------------------- +-- Table APPM_APPLICATION_RELEASE +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS APPM_APPLICATION_RELEASE ( + ID INT DEFAULT NEXTVAL('APPM_APPLICATION_RELEASE_PK_SEQ') UNIQUE, + VERSION_NAME VARCHAR(100) NOT NULL, + RESOURCE TEXT NULL, + RELEASE_CHANNEL VARCHAR(50) DEFAULT 'ALPHA', + RELEASE_DETAILS TEXT NULL, + CREATED_AT TIMESTAMP NOT NULL, + APPM_APPLICATION_ID INT NOT NULL, + IS_DEFAULT BOOLEAN DEFAULT FALSE, + PRIMARY KEY (APPM_APPLICATION_ID, VERSION_NAME), + CONSTRAINT FK_APPLICATION_VERSION_APPLICATION + FOREIGN KEY (APPM_APPLICATION_ID) + REFERENCES APPM_APPLICATION (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION); + +CREATE INDEX FK_APPLICATION_VERSION_APPLICATION ON APPM_APPLICATION_RELEASE(APPM_APPLICATION_ID ASC); + +DROP TABLE IF EXISTS APPM_RELEASE_PROPERTY; +-- ----------------------------------------------------- +-- Table APPM_RELEASE_PROPERTY +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS APPM_RELEASE_PROPERTY ( + PROP_KEY VARCHAR(255) NOT NULL, + PROP_VALUE TEXT NULL, + APPLICATION_RELEASE_ID INT NOT NULL, + PRIMARY KEY (PROP_KEY, APPLICATION_RELEASE_ID), + CONSTRAINT FK_RELEASE_PROPERTY_APPLICATION_RELEASE + FOREIGN KEY (APPLICATION_RELEASE_ID) + REFERENCES APPM_APPLICATION_RELEASE (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION); + +CREATE INDEX FK_RELEASE_PROPERTY_APPLICATION_RELEASE ON APPM_RELEASE_PROPERTY(APPLICATION_RELEASE_ID ASC); diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.store.ui.feature/pom.xml b/features/application-mgt/org.wso2.carbon.device.application.mgt.store.ui.feature/pom.xml new file mode 100644 index 0000000000..521c166505 --- /dev/null +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.store.ui.feature/pom.xml @@ -0,0 +1,33 @@ + + + + 4.0.0 + + + org.wso2.carbon.devicemgt + application-mgt-feature + 3.0.46-SNAPSHOT + + org.wso2.carbon.device.application.mgt.store.ui.feature + 3.0.46-SNAPSHOT + + + \ No newline at end of file diff --git a/features/application-mgt/pom.xml b/features/application-mgt/pom.xml index 4a39791ffc..f70cb75863 100644 --- a/features/application-mgt/pom.xml +++ b/features/application-mgt/pom.xml @@ -35,9 +35,10 @@ org.wso2.carbon.device.application.mgt.api.feature - org.wso2.carbon.device.application.mgt.ui.feature + org.wso2.carbon.device.application.mgt.feature org.wso2.carbon.device.application.mgt.server.feature + org.wso2.carbon.device.application.mgt.publisher.ui.feature \ No newline at end of file