Skip to content

Commit

Permalink
Merge branch 'shaniR-shani2'
Browse files Browse the repository at this point in the history
  • Loading branch information
lalaji committed Mar 20, 2015
2 parents 90e1de3 + 66f5552 commit 453cdcc
Show file tree
Hide file tree
Showing 16 changed files with 562 additions and 6 deletions.
51 changes: 51 additions & 0 deletions modules/distribution/resources/migration-1.8.0_to_1.9.0/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Data Migration 1.7.0 to 1.8.0
=============================

1. Shutdown AM 1.7.0 if it is running.

2. Backup your API Manager Databases of your AM 1.7.0 instance.

3. Execute relevant sql script in in here against your API Manager Database.

4. Now point same WSO2 Carbon Database(User Store and Registry) and API Manager Databases of your AM 1.7.0 instance to AM 1.8.0.
(Configure AM_1.8.0/repository/datasource/master-datasources.xml to point same databases configured in AM 1.7.0)

5. Move your synapse configurations to APIM_1.8.0. For that, copy and replace APIM_1.7.0/repository/deployment/server/synapse-configs/default directory to APIM_1.8.0/repository/deployment/server/synapse-configs/default. Do not replace _TokenAPI_.xml, _RevokeAPI_.xml and _AuthorizeAPI_.xml files in the default/api subdirectory

6. Start AM 1.8.0 and Login.

7. Copy the <APIM_1.8.0_HOME>/dbscripts/migration-1.7.0_to_1.8.0/swagger-doc-migration directory to <APIM_1.8.0_HOME>(The new directory path will now be <APIM_1..0_HOME>/swagger-doc-migration).

8. Configure swagger-doc-migration/build.xml with the information for the below properties.

registry.home= Path to AM pack location
username= Username for the AM server
password= Password for the AM server
host= IP of running AM server [In a distributed setup, give the host of the Publisher node]
port= Port of running AM server [In a distributed setup, give the port of the Publisher node]
version= Version of AM server

9. Go inside swagger-doc-migration/ and execute "ant run". You should get a "BUILD SUCCESSFUL" message if it ran correctly.

10. To re-index log in to carbon console (ex: http://localhost:9443/carbon) and delete 'lastaccesstime' resource in '/_system/local/repository/components/org.wso2.carbon.registry/indexing' location. For that go to Home-> Resources->Browse and navigate to the above given location. You can delete the 'lastaccesstime' resource by selecting Actions-> Delete

11. shutdown AM 1.8.0 and delete <APIM_1.8.0_HOME>/repository/conf/solr directory and restart the server.


Tenant Migration (Only needs to be done if you are migrating a multi-tenanted setup)
====================================================================================

1. Move your tenant synapse configurations to APIM_1.8.0. For that, copy and replace specific folders for tenants(shown as 1,2,...) from APIM_1.7.0/repository/tenants/ to APIM_1.8.0/repository/tenants. Do not replace _TokenAPI_.xml, _RevokeAPI_.xml and _AuthorizeAPI_.xml files in the default/api subdirectory.

2. Start AM 1.8.0.

3. Configure swagger-doc-migration/build.xml with the information for the below properties. (swagger-doc-migration folder should be already copied to <APIM_1.8.0_HOME>)

registry.home= Path to AM pack location
username= Username for the AM server - respective tenant space
password= Password for the AM server - respective tenant space
host= IP of running AM server [In a distributed setup, give the host of the Publisher node]
port= Port of running AM server [In a distributed setup, give the port of the Publisher node]
version= Version of AM server

4. Go inside swagger-doc-migration/ and execute "ant run". You should get a "BUILD SUCCESSFUL" message if it ran correctly.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE AM_SUBSCRIPTION ADD SUBS_CREATE_STATE VARCHAR(50) DEFAULT 'SUBSCRIBE';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE AM_SUBSCRIPTION ADD SUBS_CREATE_STATE VARCHAR(50) DEFAULT 'SUBSCRIBE';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE AM_SUBSCRIPTION ADD COLUMN SUBS_CREATE_STATE VARCHAR(50) DEFAULT 'SUBSCRIBE';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE AM_APPLICATION GROUP_ID VARCHAR(100);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE AM_SUBSCRIPTION ADD COLUMN SUBS_CREATE_STATE VARCHAR(50) DEFAULT 'SUBSCRIBE';
3 changes: 2 additions & 1 deletion modules/distribution/resources/sql/h2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,8 @@ CREATE TABLE IF NOT EXISTS AM_APPLICATION (
APPLICATION_TIER VARCHAR(50) DEFAULT 'Unlimited',
CALLBACK_URL VARCHAR(512),
DESCRIPTION VARCHAR(512),
APPLICATION_STATUS VARCHAR(50) DEFAULT 'APPROVED',
APPLICATION_STATUS VARCHAR(50) DEFAULT 'APPROVED',
GROUP_ID VARCHAR(100),
FOREIGN KEY(SUBSCRIBER_ID) REFERENCES AM_SUBSCRIBER(SUBSCRIBER_ID) ON UPDATE CASCADE ON DELETE RESTRICT,
PRIMARY KEY(APPLICATION_ID),
UNIQUE (NAME,SUBSCRIBER_ID)
Expand Down
1 change: 1 addition & 0 deletions modules/distribution/resources/sql/mssql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ CREATE TABLE AM_APPLICATION (
APPLICATION_TIER VARCHAR(50) DEFAULT 'Unlimited',
CALLBACK_URL VARCHAR(512),
DESCRIPTION VARCHAR(512),
GROUP_ID VARCHAR(100),
APPLICATION_STATUS VARCHAR(50) DEFAULT 'APPROVED',
FOREIGN KEY(SUBSCRIBER_ID) REFERENCES AM_SUBSCRIBER(SUBSCRIBER_ID) ON UPDATE CASCADE,
PRIMARY KEY(APPLICATION_ID),
Expand Down
3 changes: 2 additions & 1 deletion modules/distribution/resources/sql/mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,8 @@ CREATE TABLE IF NOT EXISTS AM_APPLICATION (
APPLICATION_TIER VARCHAR(50) DEFAULT 'Unlimited',
CALLBACK_URL VARCHAR(512),
DESCRIPTION VARCHAR(512),
APPLICATION_STATUS VARCHAR(50) DEFAULT 'APPROVED',
APPLICATION_STATUS VARCHAR(50) DEFAULT 'APPROVED',
GROUP_ID VARCHAR(100),
FOREIGN KEY(SUBSCRIBER_ID) REFERENCES AM_SUBSCRIBER(SUBSCRIBER_ID) ON UPDATE CASCADE ON DELETE RESTRICT,
PRIMARY KEY(APPLICATION_ID),
UNIQUE (NAME,SUBSCRIBER_ID)
Expand Down
3 changes: 2 additions & 1 deletion modules/distribution/resources/sql/oracle.sql
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,8 @@ CREATE TABLE AM_APPLICATION (
APPLICATION_TIER VARCHAR2(50) DEFAULT 'Unlimited',
CALLBACK_URL VARCHAR2(512),
DESCRIPTION VARCHAR2(512),
APPLICATION_STATUS VARCHAR2(50) DEFAULT 'APPROVED',
APPLICATION_STATUS VARCHAR2(50) DEFAULT 'APPROVED',
GROUP_ID VARCHAR(100),
FOREIGN KEY(SUBSCRIBER_ID) REFERENCES AM_SUBSCRIBER(SUBSCRIBER_ID) ON DELETE CASCADE,
PRIMARY KEY(APPLICATION_ID),
UNIQUE (NAME,SUBSCRIBER_ID)
Expand Down
3 changes: 2 additions & 1 deletion modules/distribution/resources/sql/oracle_rac.sql
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,8 @@ CREATE TABLE AM_APPLICATION (
APPLICATION_TIER VARCHAR2(50) DEFAULT 'Unlimited',
CALLBACK_URL VARCHAR2(512),
DESCRIPTION VARCHAR2(512),
APPLICATION_STATUS VARCHAR2(50) DEFAULT 'APPROVED',
APPLICATION_STATUS VARCHAR2(50) DEFAULT 'APPROVED',
GROUP_ID VARCHAR(100),
FOREIGN KEY(SUBSCRIBER_ID) REFERENCES AM_SUBSCRIBER(SUBSCRIBER_ID) ON DELETE CASCADE,
PRIMARY KEY(APPLICATION_ID),
UNIQUE (NAME,SUBSCRIBER_ID)
Expand Down
1 change: 1 addition & 0 deletions modules/distribution/resources/sql/postgresql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ CREATE TABLE AM_APPLICATION (
CALLBACK_URL VARCHAR(512),
DESCRIPTION VARCHAR(512),
APPLICATION_STATUS VARCHAR(50) DEFAULT 'APPROVED',
GROUP_ID VARCHAR(100),
FOREIGN KEY(SUBSCRIBER_ID) REFERENCES AM_SUBSCRIBER(SUBSCRIBER_ID) ON UPDATE CASCADE ON DELETE RESTRICT,
PRIMARY KEY(APPLICATION_ID),
UNIQUE (NAME,SUBSCRIBER_ID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ public class GenerateAppKeyRequest extends AbstractRequest {
private String callbackUrl = "some-url";
private String authorizedDomains = "ALL";
private int validityTime = 360000;
private String appId ="1";




public GenerateAppKeyRequest(String application) {
this.application = application;
Expand All @@ -45,6 +49,7 @@ public void init() {
addParameter("callbackUrl", callbackUrl);
addParameter("authorizedDomains", authorizedDomains);
addParameter("validityTime", String.valueOf(validityTime));
addParameter("selectedAppID", appId);
}

public String getApplication(){ return application; }
Expand Down Expand Up @@ -80,4 +85,13 @@ public int getValidityTime() {
public void setValidityTime(int validityTime) {
this.validityTime = validityTime;
}

public String getAppId() {
return appId;
}


public void setAppId(String appId) {
this.appId = appId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
package org.wso2.am.integration.test.utils.clients;

import org.apache.commons.codec.binary.Base64;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.wso2.am.integration.test.utils.bean.GenerateAppKeyRequest;
import org.wso2.am.integration.test.utils.bean.SubscriptionRequest;
import org.wso2.am.integration.test.utils.validation.VerificationUtil;
Expand Down Expand Up @@ -101,6 +104,9 @@ public HttpResponse subscribe(SubscriptionRequest subscriptionRequest)
public HttpResponse generateApplicationKey(GenerateAppKeyRequest generateAppKeyRequest)
throws Exception {
checkAuthentication();
HttpResponse responseApp = getAllApplications();
String appId = getApplicationId(responseApp.getData(), generateAppKeyRequest.getApplication());
generateAppKeyRequest.setAppId(appId);
HttpResponse response = HttpRequestUtil.doPost(new URL(backEndUrl +
"/store/site/blocks/subscription/subscription-add/ajax/subscription-add.jag")
, generateAppKeyRequest.generateRequestParameters()
Expand Down Expand Up @@ -654,7 +660,26 @@ public HttpResponse getRecentlyAddedAPIs(String tenant, String limit) throws Exc
}

}


private String getApplicationId(String jsonStringOfApplications, String applicationName) throws Exception{
String applicationId=null;
JSONObject obj;
try {
obj = new JSONObject(jsonStringOfApplications);
JSONArray arr = obj.getJSONArray("applications");
for (int i = 0; i < arr.length(); i++)
{
String appName = arr.getJSONObject(i).getString("name");
if(applicationName.equals(appName)){
applicationId = arr.getJSONObject(i).getString("id");
}
}
} catch (JSONException e) {
throw new Exception("getting application Id failed ");
}
return applicationId;

}
/**
* Get the web page with filtered API when click the API Tag link
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
package org.wso2.am.integration.test.utils.store.utils;

import org.apache.commons.codec.binary.Base64;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.wso2.am.integration.test.utils.VerificationUtil;
import org.wso2.am.integration.test.utils.bean.GenerateAppKeyRequest;
import org.wso2.am.integration.test.utils.bean.SubscriptionRequest;
Expand Down Expand Up @@ -76,9 +79,11 @@ public HttpResponse subscribe(SubscriptionRequest subscriptionRequest)
public HttpResponse generateApplicationKey(GenerateAppKeyRequest generateAppKeyRequest)
throws Exception {
checkAuthentication();
HttpResponse response1=getAllApplications();
String appId = getApplicationId(response1.getData(), generateAppKeyRequest.getApplication());
HttpResponse response = HttpRequestUtil.doPost(new URL(backEndUrl + "/store/site/blocks/subscription/subscription-add/ajax/subscription-add.jag?"+
"action=generateApplicationKey&application="+ generateAppKeyRequest.getApplication() +
"&keytype=" + generateAppKeyRequest.getKeyType() + "&callbackUrl=&authorizedDomains=ALL&validityTime=360000"),
"&keytype=" + generateAppKeyRequest.getKeyType() + "&callbackUrl=&authorizedDomains=ALL&validityTime=360000&selectedAppID=" +appId),
"", requestHeaders);

if (response.getResponseCode() == 200) {
Expand Down Expand Up @@ -445,4 +450,24 @@ public HttpResponse removeAPISubscription(String API, String version, String pro
}

}

private String getApplicationId(String jsonStringOfApplications, String applicationName) throws Exception{
String applicationId=null;
JSONObject obj;
try {
obj = new JSONObject(jsonStringOfApplications);
JSONArray arr = obj.getJSONArray("applications");
for (int i = 0; i < arr.length(); i++)
{
String appName = arr.getJSONObject(i).getString("name");
if(applicationName.equals(appName)){
applicationId = arr.getJSONObject(i).getString("id");
}
}
} catch (JSONException e) {
throw new Exception("getting application Id failed ");
}
return applicationId;

}
}
Loading

0 comments on commit 453cdcc

Please sign in to comment.