Merge branch 'newAPPM' into 'application-manager-new'

Comment unused file copying and samples for wso2 app manager.

See merge request entgra/product-iots!11
merge-requests/12/head
Dharmakeerthi Lasantha 6 years ago
commit 77ca1626a6

@ -451,16 +451,16 @@
</excludes>
</fileSet>
<fileSet>
<directory>
../p2-profile/iot-core-profile/target/wso2carbon-core-${carbon.kernel.version}/wso2/deployment/server/jaggeryapps/social/
</directory>
<outputDirectory>${pom.artifactId}-${pom.version}/repository/deployment/server/jaggeryapps/social
</outputDirectory>
<excludes>
<exclude>**/jaggery.conf</exclude>
</excludes>
</fileSet>
<!-- <fileSet>-->
<!-- <directory>-->
<!-- ../p2-profile/iot-core-profile/target/wso2carbon-core-${carbon.kernel.version}/wso2/deployment/server/jaggeryapps/social/-->
<!-- </directory>-->
<!-- <outputDirectory>${pom.artifactId}-${pom.version}/repository/deployment/server/jaggeryapps/social-->
<!-- </outputDirectory>-->
<!-- <excludes>-->
<!-- <exclude>**/jaggery.conf</exclude>-->
<!-- </excludes>-->
<!-- </fileSet>-->
<!-- Copying Android Mutual SSL and Windows Synapse files -->
<fileSet>
@ -1610,13 +1610,13 @@
<fileMode>755</fileMode>
</file>
<file>
<source>src/core/jaggeryapps/social/jaggery.conf</source>
<outputDirectory>
${pom.artifactId}-${pom.version}/repository/deployment/server/jaggeryapps/social/
</outputDirectory>
<fileMode>755</fileMode>
</file>
<!-- <file>-->
<!-- <source>src/core/jaggeryapps/social/jaggery.conf</source>-->
<!-- <outputDirectory>-->
<!-- ${pom.artifactId}-${pom.version}/repository/deployment/server/jaggeryapps/social/-->
<!-- </outputDirectory>-->
<!-- <fileMode>755</fileMode>-->
<!-- </file>-->
<!--<file>-->
<!--<source>src/core/jaggeryapps/store/jaggery.conf</source>-->
<!--<outputDirectory>-->

@ -43,26 +43,27 @@
</definition>
</datasource>
<datasource>
<name>WSO2APPM_DB</name>
<description>The datasource used for App Manager database</description>
<jndiConfig>
<name>jdbc/WSO2APPM_DB</name>
</jndiConfig>
<definition type="RDBMS">
<configuration>
<url>jdbc:h2:repository/database/WSO2APPM_DB;DB_CLOSE_ON_EXIT=FALSE</url>
<username>wso2carbon</username>
<password>wso2carbon</password>
<driverClassName>org.h2.Driver</driverClassName>
<maxActive>50</maxActive>
<maxWait>60000</maxWait>
<testOnBorrow>true</testOnBorrow>
<validationQuery>SELECT 1</validationQuery>
<validationInterval>30000</validationInterval>
</configuration>
</definition>
</datasource>
<!-- todo remove-->
<!-- <datasource>-->
<!-- <name>WSO2APPM_DB</name>-->
<!-- <description>The datasource used for App Manager database</description>-->
<!-- <jndiConfig>-->
<!-- <name>jdbc/WSO2APPM_DB</name>-->
<!-- </jndiConfig>-->
<!-- <definition type="RDBMS">-->
<!-- <configuration>-->
<!-- <url>jdbc:h2:repository/database/WSO2APPM_DB;DB_CLOSE_ON_EXIT=FALSE</url>-->
<!-- <username>wso2carbon</username>-->
<!-- <password>wso2carbon</password>-->
<!-- <driverClassName>org.h2.Driver</driverClassName>-->
<!-- <maxActive>50</maxActive>-->
<!-- <maxWait>60000</maxWait>-->
<!-- <testOnBorrow>true</testOnBorrow>-->
<!-- <validationQuery>SELECT 1</validationQuery>-->
<!-- <validationInterval>30000</validationInterval>-->
<!-- </configuration>-->
<!-- </definition>-->
<!-- </datasource>-->
<datasource>
<name>WSO2AM_DB</name>
@ -123,25 +124,26 @@
</configuration>
</definition>
</datasource>
<datasource>
<name>WSO2_SOCIAL_DB</name>
<description>The datasource used for Store social database</description>
<jndiConfig>
<name>jdbc/WSO2_SOCIAL_DB</name>
</jndiConfig>
<definition type="RDBMS">
<configuration>
<url>jdbc:h2:repository/database/WSO2_SOCIAL_DB;DB_CLOSE_ON_EXIT=FALSE</url>
<username>wso2carbon</username>
<password>wso2carbon</password>
<driverClassName>org.h2.Driver</driverClassName>
<maxActive>50</maxActive>
<maxWait>60000</maxWait>
<testOnBorrow>true</testOnBorrow>
<validationQuery>SELECT 1</validationQuery>
<validationInterval>30000</validationInterval>
</configuration>
</definition>
</datasource>
<!-- todo remove-->
<!-- <datasource>-->
<!-- <name>WSO2_SOCIAL_DB</name>-->
<!-- <description>The datasource used for Store social database</description>-->
<!-- <jndiConfig>-->
<!-- <name>jdbc/WSO2_SOCIAL_DB</name>-->
<!-- </jndiConfig>-->
<!-- <definition type="RDBMS">-->
<!-- <configuration>-->
<!-- <url>jdbc:h2:repository/database/WSO2_SOCIAL_DB;DB_CLOSE_ON_EXIT=FALSE</url>-->
<!-- <username>wso2carbon</username>-->
<!-- <password>wso2carbon</password>-->
<!-- <driverClassName>org.h2.Driver</driverClassName>-->
<!-- <maxActive>50</maxActive>-->
<!-- <maxWait>60000</maxWait>-->
<!-- <testOnBorrow>true</testOnBorrow>-->
<!-- <validationQuery>SELECT 1</validationQuery>-->
<!-- <validationInterval>30000</validationInterval>-->
<!-- </configuration>-->
<!-- </definition>-->
<!-- </datasource>-->
</datasources>
</datasources-configuration>

@ -1,194 +0,0 @@
/*
* 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.
*/
package org.wso2.mdm.qsg;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import org.wso2.mdm.qsg.dto.EMMQSGConfig;
import org.wso2.mdm.qsg.dto.HTTPResponse;
import org.wso2.mdm.qsg.dto.MobileApplication;
import org.wso2.mdm.qsg.utils.Constants;
import org.wso2.mdm.qsg.utils.HTTPInvoker;
import org.wso2.mdm.qsg.utils.QSGUtils;
import java.io.File;
import java.util.HashMap;
/**
* This class holds the app-mgt related operations.
*/
public class AppOperations {
private static String appmPublisherMobileBinariesUrl = "/api/appm/publisher/v1.1/apps/mobile/binaries";
private static String appmPublisherResourcesUrl = "/api/appm/publisher/v1.1/apps/static-contents?appType=mobileapp";
private static String appmPublisherAppsUrl = "/api/appm/publisher/v1.1/apps/mobileapp";
public static MobileApplication uploadApplication(String platform, String appName, String appContentType) {
String appUploadEndpoint = EMMQSGConfig.getInstance().getEmmHost() + appmPublisherMobileBinariesUrl;
String filePath = "apps" + File.separator + platform + File.separator + appName;
HTTPResponse httpResponse = HTTPInvoker.uploadFile(appUploadEndpoint, filePath, appContentType);
if (Constants.HTTPStatus.OK == httpResponse.getResponseCode()) {
JSONObject appMeta = null;
MobileApplication application = new MobileApplication();
try {
appMeta = (JSONObject) new JSONParser().parse(httpResponse.getResponse());
application.setPackageId((String) appMeta.get("package"));
application.setAppId(QSGUtils.getResourceId((String) appMeta.get("path")));
application.setVersion((String) appMeta.get("version"));
application.setPlatform(platform);
} catch (ParseException e) {
e.printStackTrace();
}
return application;
}
return null;
}
public static MobileApplication getPublicApplication(String packageId, String version, String platform) {
MobileApplication application = new MobileApplication();
application.setVersion(version);
application.setPackageId(packageId);
application.setPlatform(platform);
return application;
}
private static String uploadAsset(String path) {
String resUploadEndpoint = EMMQSGConfig.getInstance().getEmmHost() + appmPublisherResourcesUrl;
HTTPResponse httpResponse = HTTPInvoker.uploadFile(resUploadEndpoint, path, "image/jpeg");
if (Constants.HTTPStatus.OK == httpResponse.getResponseCode()) {
JSONObject resp = null;
try {
resp = (JSONObject) new JSONParser().parse(httpResponse.getResponse());
return (String) resp.get("id");
} catch (ParseException e) {
e.printStackTrace();
}
}
return null;
}
public static MobileApplication uploadAssets(String platform, MobileApplication application) {
String assetDir = "apps" + File.separator + platform + File.separator + "images";
//Upload the icon file
String imgFile = assetDir + File.separator + "icon.jpg";
String uploadPath = uploadAsset(imgFile);
if (uploadPath != null && !uploadPath.isEmpty()) {
application.setIcon(uploadPath);
} else {
System.out.println("Unable to upload the app icon file.");
return null;
}
//Upload the banner file
imgFile = assetDir + File.separator + "banner.jpg";
uploadPath = uploadAsset(imgFile);
if (uploadPath != null && !uploadPath.isEmpty()) {
application.setBanner(uploadPath);
} else {
System.out.println("Unable to upload the app banner file.");
return null;
}
//Upload the screenshot1 file
imgFile = assetDir + File.separator + "screen1.jpg";
uploadPath = uploadAsset(imgFile);
if (uploadPath != null && !uploadPath.isEmpty()) {
application.setScreenshot1(uploadPath);
} else {
System.out.println("Unable to upload the app screenshot1 file.");
return null;
}
//Upload the screenshot2 file
imgFile = assetDir + File.separator + "screen2.jpg";
uploadPath = uploadAsset(imgFile);
if (uploadPath != null && !uploadPath.isEmpty()) {
application.setScreenshot2(uploadPath);
} else {
System.out.println("Unable to upload the app screenshot2 file.");
return null;
}
//Upload the screenshot3 file
imgFile = assetDir + File.separator + "screen3.jpg";
uploadPath = uploadAsset(imgFile);
if (uploadPath != null && !uploadPath.isEmpty()) {
application.setScreenshot3(uploadPath);
} else {
System.out.println("Unable to upload the app screenshot3 file.");
return null;
}
return application;
}
public static boolean addApplication(String name, MobileApplication mblApp, boolean isEnterpriseApp) {
HashMap<String, String> headers = new HashMap<String, String>();
String appEndpoint = EMMQSGConfig.getInstance().getEmmHost() + appmPublisherAppsUrl;
//Set the application payload
JSONObject application = new JSONObject();
application.put("name", name);
application.put("description", "Sample application");
application.put("type", "enterprise");
//Set appMeta data
JSONObject appMeta = new JSONObject();
appMeta.put("package", mblApp.getPackageId());
appMeta.put("version", mblApp.getVersion());
if (isEnterpriseApp) {
application.put("marketType", "enterprise");
appMeta.put("path", mblApp.getAppId());
} else {
application.put("marketType", "public");
}
application.put("provider", "admin");
application.put("displayName", name);
application.put("category", "Business");
application.put("thumbnailUrl", mblApp.getIcon());
application.put("version", mblApp.getVersion());
application.put("banner", mblApp.getBanner());
application.put("platform", mblApp.getPlatform());
application.put("appType", mblApp.getPlatform());
//application.put("appUrL", mblApp.getAppId());
application.put("mediaType", "application/vnd.wso2-mobileapp+xml");
//Set screenshots
JSONArray screenshots = new JSONArray();
screenshots.add(mblApp.getScreenshot1());
screenshots.add(mblApp.getScreenshot2());
screenshots.add(mblApp.getScreenshot3());
application.put("appmeta", appMeta);
application.put("screenshots", screenshots);
//Set the headers
headers.put(Constants.Header.CONTENT_TYPE, Constants.ContentType.APPLICATION_JSON);
HTTPResponse
httpResponse =
HTTPInvoker.sendHTTPPostWithOAuthSecurity(appEndpoint, application.toJSONString(), headers);
if (Constants.HTTPStatus.OK == httpResponse.getResponseCode()) {
return true;
}
return false;
}
}

@ -113,59 +113,6 @@ public class QSGExecutor {
System.exit(0);
}
System.out.println("Upload the android application ");
//Upload the android application
MobileApplication application = AppOperations.uploadApplication(Constants.DeviceType.ANDROID, "con-app.apk",
"application/vnd.android.package-archive");
if (application == null) {
System.out.println("Unable to upload the sample android application. Terminating the IoTS QSG now.");
System.exit(0);
}
//Upload the assets
application = AppOperations.uploadAssets(Constants.DeviceType.ANDROID, application);
if (application == null) {
System.out.println(
"Unable to upload the assets for sample android application. Terminating the IoTS QSG now.");
System.exit(0);
}
System.out.println("Create the android application ");
//Create application entry in publisher
status = AppOperations.addApplication("WSO2Con-Android", application, true);
if (!status) {
System.out.println("Unable to create the android mobile application. Terminating the IoTS QSG now.");
System.exit(0);
}
System.out.println("Upload the iOS application ");
//Add the iOS policy
status = PolicyOperations.createPasscodePolicy("ios-passcode-policy1", Constants.DeviceType.IOS);
if (!status) {
System.out.println("Unable to create the ios passcode policy. Terminating the IoTS QSG now.");
System.exit(0);
}
//Upload the ios application
MobileApplication iOSApplication = AppOperations.uploadApplication(Constants.DeviceType.IOS, "PNDemo.ipa","application/octet-stream");
iOSApplication.setVersion("1.0.0");
//Upload the assets
iOSApplication = AppOperations.uploadAssets(Constants.DeviceType.IOS, iOSApplication);
if (iOSApplication == null) {
System.out.println(
"Unable to upload the assets for sample iOS application. Terminating the IoTS QSG now.");
System.exit(0);
}
System.out.println("Create the iOS application ");
//Create application entry in publisher
status = AppOperations.addApplication("WSO2Con-iOS", iOSApplication, true);
if (!status) {
System.out.println("Unable to create the iOS mobile application. Terminating the IoTS QSG now.");
System.exit(0);
}
System.out.println("Exit");
}
}

Loading…
Cancel
Save