You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by is...@apache.org on 2014/01/07 08:08:10 UTC
[19/42] creating Stratos Manager product
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/249e1290/products/stratos-manager/dbscripts/billing-h2.sql
----------------------------------------------------------------------
diff --git a/products/stratos-manager/dbscripts/billing-h2.sql b/products/stratos-manager/dbscripts/billing-h2.sql
new file mode 100755
index 0000000..ccf1393
--- /dev/null
+++ b/products/stratos-manager/dbscripts/billing-h2.sql
@@ -0,0 +1,128 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF 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.
+*/
+
+CREATE TABLE IF NOT EXISTS BC_CUSTOMER (
+ BC_ID INTEGER AUTO_INCREMENT,
+ BC_NAME VARCHAR (64),
+ BC_STARTED_DATE TIMESTAMP,
+ BC_EMAIL VARCHAR (64),
+ BC_ADDRESS VARCHAR (256),
+ CONSTRAINT PK_BC_CUSTOMER PRIMARY KEY (BC_ID)
+);
+
+CREATE HASH INDEX BC_CUSTOMER_IND_BY_BC_NAME ON BC_CUSTOMER(BC_NAME);
+CREATE HASH INDEX BC_CUSTOMER_IND_BY_BC_EMAIL ON BC_CUSTOMER(BC_EMAIL);
+
+CREATE TABLE IF NOT EXISTS BC_ITEM (
+ BC_ID INTEGER AUTO_INCREMENT,
+ BC_NAME VARCHAR (64),
+ BC_COST VARCHAR (64),
+ BC_DESCRIPTION VARCHAR(128),
+ BC_PARENT_ITEM_ID INTEGER,
+ CONSTRAINT PK_BC_ITEM PRIMARY KEY (BC_ID)
+);
+INSERT INTO BC_ITEM (BC_NAME,BC_COST,BC_DESCRIPTION,BC_PARENT_ITEM_ID) values ('Demo',NULL,NULL,NULL);
+INSERT INTO BC_ITEM (BC_NAME,BC_COST,BC_DESCRIPTION,BC_PARENT_ITEM_ID) values ('SMB',NULL,NULL,NULL);
+INSERT INTO BC_ITEM (BC_NAME,BC_COST,BC_DESCRIPTION,BC_PARENT_ITEM_ID) values ('Professional',NULL,NULL,NULL);
+INSERT INTO BC_ITEM (BC_NAME,BC_COST,BC_DESCRIPTION,BC_PARENT_ITEM_ID) values ('Enterprise',NULL,NULL,NULL);
+
+ALTER TABLE BC_ITEM ADD CONSTRAINT IF NOT EXISTS BC_ITEM_FK_BY_PARENT_ITEM_ID FOREIGN KEY (BC_PARENT_ITEM_ID) REFERENCES BC_ITEM (BC_ID);
+
+
+CREATE TABLE IF NOT EXISTS BC_SUBSCRIPTION (
+ BC_ID INTEGER AUTO_INCREMENT,
+ BC_FILTER VARCHAR (32),
+ BC_IS_ACTIVE INTEGER,
+ BC_ACTIVE_SINCE TIMESTAMP,
+ BC_ACTIVE_UNTIL TIMESTAMP,
+ BC_ITEM_ID INTEGER,
+ BC_TENANT_ID INTEGER,
+ CONSTRAINT PK_BC_SUBSCRIPTION PRIMARY KEY (BC_ID)
+);
+
+ALTER TABLE BC_SUBSCRIPTION ADD CONSTRAINT IF NOT EXISTS BC_SUBSCRIPTION_FK_BY_ITEM_ID FOREIGN KEY (BC_ITEM_ID) REFERENCES BC_ITEM (BC_ID);
+
+CREATE TABLE IF NOT EXISTS BC_INVOICE (
+ BC_ID INTEGER AUTO_INCREMENT,
+ BC_TENANT_ID INTEGER,
+ BC_DATE TIMESTAMP,
+ BC_START_DATE TIMESTAMP,
+ BC_END_DATE TIMESTAMP,
+ BC_BOUGHT_FORWARD VARCHAR (64),
+ BC_CARRIED_FORWARD VARCHAR (64),
+ BC_TOTAL_PAYMENTS VARCHAR (64),
+ BC_TOTAL_COST VARCHAR (64),
+ CONSTRAINT PK_BC_INVOICE PRIMARY KEY (BC_ID)
+);
+
+
+CREATE TABLE IF NOT EXISTS BC_PAYMENT (
+ BC_ID INTEGER AUTO_INCREMENT,
+ BC_DATE TIMESTAMP,
+ BC_AMOUNT VARCHAR (64),
+ BC_DESCRIPTION VARCHAR (128),
+ BC_INVOICE_ID INTEGER,
+ BC_TENANT_ID INTEGER,
+ CONSTRAINT PK_BC_PAYMENT PRIMARY KEY (BC_ID)
+);
+
+ALTER TABLE BC_PAYMENT ADD CONSTRAINT IF NOT EXISTS BC_PAYMENT_FK_BY_INVOICE_ID FOREIGN KEY (BC_INVOICE_ID) REFERENCES BC_INVOICE (BC_ID);
+
+-- this is n-n relationship
+CREATE TABLE IF NOT EXISTS BC_PAYMENT_SUBSCRIPTION (
+ BC_PAYMENT_ID INTEGER,
+ BC_SUBSCRIPTION_ID INTEGER,
+ CONSTRAINT PK_BC_SUBSCRIPTION_ORDER PRIMARY KEY (BC_PAYMENT_ID, BC_SUBSCRIPTION_ID)
+);
+
+ALTER TABLE BC_PAYMENT_SUBSCRIPTION ADD CONSTRAINT IF NOT EXISTS BC_PAYMENT_SUBSCRIPTION_FK_BY_PAYMENT_ID FOREIGN KEY (BC_PAYMENT_ID) REFERENCES BC_PAYMENT (BC_ID);
+ALTER TABLE BC_PAYMENT_SUBSCRIPTION ADD CONSTRAINT IF NOT EXISTS BC_PAYMENT_SUBSCRIPTION_FK_BY_SUBSCRIPTION_ID FOREIGN KEY (BC_SUBSCRIPTION_ID) REFERENCES BC_SUBSCRIPTION (BC_ID);
+
+CREATE TABLE IF NOT EXISTS BC_INVOICE_SUBSCRIPTION (
+ BC_ID INTEGER AUTO_INCREMENT,
+ BC_INVOICE_ID INTEGER,
+ BC_SUBSCRIPTION_ID INTEGER,
+ CONSTRAINT PK_BC_INVOICE_ITEM PRIMARY KEY (BC_ID)
+);
+
+ALTER TABLE BC_INVOICE_SUBSCRIPTION ADD CONSTRAINT IF NOT EXISTS BC_INVOICE_SUBSCRIPTION_FK_BY_INVOICE_ID FOREIGN KEY (BC_INVOICE_ID) REFERENCES BC_INVOICE (BC_ID);
+ALTER TABLE BC_INVOICE_SUBSCRIPTION ADD CONSTRAINT IF NOT EXISTS BC_INVOICE_SUBSCRIPTION_FK_BY_SUBSCRIPTION_ID FOREIGN KEY (BC_SUBSCRIPTION_ID) REFERENCES BC_SUBSCRIPTION (BC_ID);
+
+
+CREATE TABLE IF NOT EXISTS BC_INVOICE_SUBSCRIPTION_ITEM (
+ BC_INVOICE_SUBSCRIPTION_ID INTEGER,
+ BC_ITEM_ID INTEGER,
+ BC_COST VARCHAR (64),
+ BC_DESCRIPTION VARCHAR (64),
+ CONSTRAINT PK_BC_INVOICE_SUBSCRIPTION_ITEM PRIMARY KEY (BC_INVOICE_SUBSCRIPTION_ID, BC_ITEM_ID)
+);
+
+ALTER TABLE BC_INVOICE_SUBSCRIPTION_ITEM ADD CONSTRAINT IF NOT EXISTS BC_INVOICE_SUBSCRIPTION_ITEM_FK_BY_INVOICE_SUBSCRIPTION_ID FOREIGN KEY (BC_INVOICE_SUBSCRIPTION_ID) REFERENCES BC_INVOICE_SUBSCRIPTION (BC_ID);
+ALTER TABLE BC_INVOICE_SUBSCRIPTION_ITEM ADD CONSTRAINT IF NOT EXISTS BC_INVOICE_SUBSCRIPTION_ITEM_FK_BY_ITEM_ID FOREIGN KEY (BC_ITEM_ID) REFERENCES BC_ITEM(BC_ID);
+
+CREATE TABLE IF NOT EXISTS BC_DISCOUNT (
+ BC_ID INTEGER AUTO_INCREMENT,
+ BC_TENANT_ID INTEGER,
+ BC_PERCENTAGE FLOAT,
+ BC_AMOUNT FLOAT,
+ BC_START_DATE TIMESTAMP,
+ BC_END_DATE TIMESTAMP,
+ BC_PERCENTAGE_TYPE INTEGER,
+ CONSTRAINT PK_BC_DISCOUNT PRIMARY KEY (BC_ID)
+);
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/249e1290/products/stratos-manager/dbscripts/billing-mysql.sql
----------------------------------------------------------------------
diff --git a/products/stratos-manager/dbscripts/billing-mysql.sql b/products/stratos-manager/dbscripts/billing-mysql.sql
new file mode 100755
index 0000000..cfe828f
--- /dev/null
+++ b/products/stratos-manager/dbscripts/billing-mysql.sql
@@ -0,0 +1,139 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF 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.
+*/
+
+CREATE TABLE IF NOT EXISTS BC_CUSTOMER (
+ BC_ID INTEGER AUTO_INCREMENT,
+ BC_NAME VARCHAR (64),
+ BC_STARTED_DATE TIMESTAMP,
+ BC_EMAIL VARCHAR (64),
+ BC_ADDRESS VARCHAR (256),
+ CONSTRAINT PK_BC_CUSTOMER PRIMARY KEY (BC_ID)
+)ENGINE INNODB;
+
+CREATE INDEX BC_CUSTOMER_IND_BY_BC_NAME USING HASH ON BC_CUSTOMER(BC_NAME);
+CREATE INDEX BC_CUSTOMER_IND_BY_BC_EMAIL USING HASH ON BC_CUSTOMER(BC_EMAIL);
+
+CREATE TABLE IF NOT EXISTS BC_ITEM (
+ BC_ID INTEGER AUTO_INCREMENT,
+ BC_NAME VARCHAR (64),
+ BC_COST VARCHAR (64),
+ BC_DESCRIPTION VARCHAR(128),
+ BC_PARENT_ITEM_ID INTEGER,
+ CONSTRAINT PK_BC_ITEM PRIMARY KEY (BC_ID)
+)ENGINE INNODB;
+INSERT INTO BC_ITEM (BC_NAME,BC_COST,BC_DESCRIPTION,BC_PARENT_ITEM_ID) values ("Demo",NULL,NULL,NULL);
+INSERT INTO BC_ITEM (BC_NAME,BC_COST,BC_DESCRIPTION,BC_PARENT_ITEM_ID) values ("SMB",NULL,NULL,NULL);
+INSERT INTO BC_ITEM (BC_NAME,BC_COST,BC_DESCRIPTION,BC_PARENT_ITEM_ID) values ("Professional",NULL,NULL,NULL);
+INSERT INTO BC_ITEM (BC_NAME,BC_COST,BC_DESCRIPTION,BC_PARENT_ITEM_ID) values ("Enterprise",NULL,NULL,NULL);
+
+ALTER TABLE BC_ITEM ADD CONSTRAINT BC_ITEM_FK_BY_PARENT_ITEM_ID FOREIGN KEY (BC_PARENT_ITEM_ID) REFERENCES BC_ITEM (BC_ID);
+
+
+CREATE TABLE IF NOT EXISTS BC_SUBSCRIPTION (
+ BC_ID INTEGER AUTO_INCREMENT,
+ BC_FILTER VARCHAR (32),
+ BC_IS_ACTIVE INTEGER,
+ BC_ACTIVE_SINCE TIMESTAMP,
+ BC_ACTIVE_UNTIL TIMESTAMP,
+ BC_ITEM_ID INTEGER,
+ BC_TENANT_ID INTEGER,
+ CONSTRAINT PK_BC_SUBSCRIPTION PRIMARY KEY (BC_ID)
+)ENGINE INNODB;
+
+ALTER TABLE BC_SUBSCRIPTION ADD CONSTRAINT BC_SUBSCRIPTION_FK_BY_ITEM_ID FOREIGN KEY (BC_ITEM_ID) REFERENCES BC_ITEM (BC_ID);
+
+CREATE TABLE IF NOT EXISTS BC_INVOICE (
+ BC_ID INTEGER AUTO_INCREMENT,
+ BC_TENANT_ID INTEGER,
+ BC_DATE TIMESTAMP,
+ BC_START_DATE TIMESTAMP,
+ BC_END_DATE TIMESTAMP,
+ BC_BOUGHT_FORWARD VARCHAR (64),
+ BC_CARRIED_FORWARD VARCHAR (64),
+ BC_TOTAL_PAYMENTS VARCHAR (64),
+ BC_TOTAL_COST VARCHAR (64),
+ CONSTRAINT PK_BC_INVOICE PRIMARY KEY (BC_ID)
+)ENGINE INNODB;
+
+
+CREATE TABLE IF NOT EXISTS BC_PAYMENT (
+ BC_ID INTEGER AUTO_INCREMENT,
+ BC_DATE TIMESTAMP,
+ BC_AMOUNT VARCHAR (64),
+ BC_DESCRIPTION VARCHAR (128),
+ BC_INVOICE_ID INTEGER,
+ BC_TENANT_ID INTEGER,
+ CONSTRAINT PK_BC_SUBSCRIPTION_ORDER PRIMARY KEY (BC_ID)
+)ENGINE INNODB;
+
+ALTER TABLE BC_PAYMENT ADD CONSTRAINT BC_PAYMENT_FK_BY_INVOICE_ID FOREIGN KEY (BC_INVOICE_ID) REFERENCES BC_INVOICE (BC_ID);
+
+CREATE TABLE IF NOT EXISTS BC_REGISTRATION_PAYMENT (
+ BC_ID INTEGER AUTO_INCREMENT,
+ BC_DATE TIMESTAMP,
+ BC_AMOUNT VARCHAR (64),
+ BC_DESCRIPTION VARCHAR (128),
+ BC_USAGE_PLAN VARCHAR (64),
+ BC_TENANT_ID INTEGER,
+ CONSTRAINT PK_BC_REGISTRATION_PAYMENT PRIMARY KEY (BC_ID)
+)ENGINE INNODB;
+
+-- this is n-n relationship
+CREATE TABLE IF NOT EXISTS BC_PAYMENT_SUBSCRIPTION (
+ BC_PAYMENT_ID INTEGER,
+ BC_SUBSCRIPTION_ID INTEGER,
+ CONSTRAINT PK_BC_SUBSCRIPTION_ORDER PRIMARY KEY (BC_PAYMENT_ID, BC_SUBSCRIPTION_ID)
+)ENGINE INNODB;
+
+ALTER TABLE BC_PAYMENT_SUBSCRIPTION ADD CONSTRAINT BC_PAYMENT_SUBSCRIPTION_FK_BY_PAYMENT_ID FOREIGN KEY (BC_PAYMENT_ID) REFERENCES BC_PAYMENT (BC_ID);
+ALTER TABLE BC_PAYMENT_SUBSCRIPTION ADD CONSTRAINT BC_PAYMENT_SUBSCRIPTION_FK_BY_SUBSCRIPTION_ID FOREIGN KEY (BC_SUBSCRIPTION_ID) REFERENCES BC_SUBSCRIPTION (BC_ID);
+
+CREATE TABLE IF NOT EXISTS BC_INVOICE_SUBSCRIPTION (
+ BC_ID INTEGER AUTO_INCREMENT,
+ BC_INVOICE_ID INTEGER,
+ BC_SUBSCRIPTION_ID INTEGER,
+ CONSTRAINT PK_BC_INVOICE_ITEM PRIMARY KEY (BC_ID)
+)ENGINE INNODB;
+
+ALTER TABLE BC_INVOICE_SUBSCRIPTION ADD CONSTRAINT BC_INVOICE_SUBSCRIPTION_FK_BY_INVOICE_ID FOREIGN KEY (BC_INVOICE_ID) REFERENCES BC_INVOICE (BC_ID);
+ALTER TABLE BC_INVOICE_SUBSCRIPTION ADD CONSTRAINT BC_INVOICE_SUBSCRIPTION_FK_BY_SUBSCRIPTION_ID FOREIGN KEY (BC_SUBSCRIPTION_ID) REFERENCES BC_SUBSCRIPTION (BC_ID);
+
+
+CREATE TABLE IF NOT EXISTS BC_INVOICE_SUBSCRIPTION_ITEM (
+ BC_INVOICE_SUBSCRIPTION_ID INTEGER,
+ BC_ITEM_ID INTEGER,
+ BC_COST VARCHAR (64),
+ BC_DESCRIPTION varchar (64),
+ CONSTRAINT PK_BC_INVOICE_SUBSCRIPTION_ITEM PRIMARY KEY (BC_INVOICE_SUBSCRIPTION_ID, BC_ITEM_ID)
+)ENGINE INNODB;
+
+ALTER TABLE BC_INVOICE_SUBSCRIPTION_ITEM ADD CONSTRAINT BC_INVOICE_SUBSCRIPTION_ITEM_FK_BY_INVOICE_SUBSCRIPTION_ID FOREIGN KEY (BC_INVOICE_SUBSCRIPTION_ID) REFERENCES BC_INVOICE_SUBSCRIPTION (BC_ID);
+ALTER TABLE BC_INVOICE_SUBSCRIPTION_ITEM ADD CONSTRAINT BC_INVOICE_SUBSCRIPTION_ITEM_FK_BY_ITEM_ID FOREIGN KEY (BC_ITEM_ID) REFERENCES BC_ITEM(BC_ID);
+
+CREATE TABLE IF NOT EXISTS BC_DISCOUNT (
+ BC_ID INTEGER AUTO_INCREMENT,
+ BC_TENANT_ID INTEGER,
+ BC_PERCENTAGE FLOAT,
+ BC_AMOUNT FLOAT,
+ BC_START_DATE TIMESTAMP,
+ BC_END_DATE TIMESTAMP,
+ BC_PERCENTAGE_TYPE INTEGER,
+ CONSTRAINT PK_BC_DISCOUNT PRIMARY KEY (BC_ID)
+)ENGINE INNODB;
+
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/249e1290/products/stratos-manager/dbscripts/metering_h2.sql
----------------------------------------------------------------------
diff --git a/products/stratos-manager/dbscripts/metering_h2.sql b/products/stratos-manager/dbscripts/metering_h2.sql
new file mode 100755
index 0000000..1f38fe2
--- /dev/null
+++ b/products/stratos-manager/dbscripts/metering_h2.sql
@@ -0,0 +1,133 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF 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.
+*/
+
+--
+-- TABLES
+--
+
+CREATE TABLE IF NOT EXISTS USAGE_HOURLY_ANALYTICS (
+ ID VARCHAR(200) NOT NULL,
+ HOUR_FACT TIMESTAMP,
+ SERVER_NAME VARCHAR(100),
+ TENANT_ID VARCHAR(50),
+ PAYLOAD_TYPE VARCHAR(50),
+ PAYLOAD_VALUE BIGINT,
+ PRIMARY KEY (ID)
+);
+
+CREATE TABLE IF NOT EXISTS USAGE_DAILY_ANALYTICS (
+ ID VARCHAR(200) NOT NULL,
+ DAY_FACT TIMESTAMP,
+ SERVER_NAME VARCHAR(100),
+ TENANT_ID VARCHAR(50),
+ PAYLOAD_TYPE VARCHAR(50),
+ PAYLOAD_VALUE BIGINT,
+ PRIMARY KEY (ID)
+);
+
+CREATE TABLE IF NOT EXISTS USAGE_MONTHLY_ANALYTICS (
+ ID VARCHAR(200) NOT NULL,
+ MONTH_FACT TIMESTAMP,
+ SERVER_NAME VARCHAR(100),
+ TENANT_ID VARCHAR(50),
+ PAYLOAD_TYPE VARCHAR(50),
+ PAYLOAD_VALUE BIGINT,
+ PRIMARY KEY (ID)
+);
+
+CREATE TABLE IF NOT EXISTS USAGE_LAST_HOURLY_TS (
+ ID VARCHAR(200) NOT NULL,
+ TIMESTMP TIMESTAMP,
+ PRIMARY KEY (ID)
+);
+
+CREATE TABLE IF NOT EXISTS USAGE_LAST_DAILY_TS (
+ ID VARCHAR(200) NOT NULL,
+ TIMESTMP TIMESTAMP,
+ PRIMARY KEY (ID)
+);
+
+CREATE TABLE IF NOT EXISTS USAGE_LAST_MONTHLY_TS (
+ ID VARCHAR(200) NOT NULL,
+ TIMESTMP TIMESTAMP,
+ PRIMARY KEY (ID)
+);
+
+CREATE TABLE IF NOT EXISTS SERVICE_STATS_HOURLY_ANALYTICS (
+ ID VARCHAR(200) NOT NULL,
+ HOUR_FACT TIMESTAMP,
+ SERVER_NAME VARCHAR(100),
+ TENANT_ID VARCHAR(50),
+ REQUEST_COUNT BIGINT,
+ RESPONSE_COUNT BIGINT,
+ FAULT_COUNT BIGINT,
+ PRIMARY KEY (ID)
+);
+
+CREATE TABLE IF NOT EXISTS SERVICE_STATS_DAILY_ANALYTICS (
+ ID VARCHAR(200) NOT NULL,
+ DAY_FACT TIMESTAMP,
+ SERVER_NAME VARCHAR(100),
+ TENANT_ID VARCHAR(50),
+ REQUEST_COUNT BIGINT,
+ RESPONSE_COUNT BIGINT,
+ FAULT_COUNT BIGINT,
+ PRIMARY KEY (ID)
+);
+
+CREATE TABLE IF NOT EXISTS SERVICE_STATS_MONTHLY_ANALYTICS (
+ ID VARCHAR(200) NOT NULL,
+ MONTH_FACT TIMESTAMP,
+ SERVER_NAME VARCHAR(100),
+ TENANT_ID VARCHAR(50),
+ REQUEST_COUNT BIGINT,
+ RESPONSE_COUNT BIGINT,
+ FAULT_COUNT BIGINT,
+ PRIMARY KEY (ID)
+);
+
+CREATE TABLE IF NOT EXISTS SERVICE_STATS_LAST_HOURLY_TS (
+ ID VARCHAR(200) NOT NULL,
+ TIMESTMP TIMESTAMP,
+ PRIMARY KEY (ID)
+);
+
+CREATE TABLE IF NOT EXISTS SERVICE_STATS_LAST_DAILY_TS (
+ ID VARCHAR(200) NOT NULL,
+ TIMESTMP TIMESTAMP,
+ PRIMARY KEY (ID)
+);
+
+CREATE TABLE IF NOT EXISTS SERVICE_STATS_LAST_MONTHLY_TS (
+ ID VARCHAR(200) NOT NULL,
+ TIMESTMP TIMESTAMP,
+ PRIMARY KEY (ID)
+);
+
+CREATE TABLE IF NOT EXISTS REGISTRY_USAGE_HOURLY_ANALYTICS (
+ ID VARCHAR(50),
+ TENANT_ID VARCHAR(50),
+ HISTORY_USAGE BIGINT,
+ CURRENT_USAGE BIGINT,
+ PRIMARY KEY (ID)
+);
+
+
+COMMIT;
+
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/249e1290/products/stratos-manager/dbscripts/metering_mysql.sql
----------------------------------------------------------------------
diff --git a/products/stratos-manager/dbscripts/metering_mysql.sql b/products/stratos-manager/dbscripts/metering_mysql.sql
new file mode 100755
index 0000000..755403d
--- /dev/null
+++ b/products/stratos-manager/dbscripts/metering_mysql.sql
@@ -0,0 +1,168 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF 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.
+*/
+
+-- WSO2 METERING DATABASE SQL FOR MySQL
+
+SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
+
+SET AUTOCOMMIT=0;
+START TRANSACTION;
+
+--
+-- TABLES
+--
+
+CREATE TABLE IF NOT EXISTS USAGE_HOURLY_ANALYTICS (
+ ID VARCHAR(200) NOT NULL,
+ HOUR_FACT TIMESTAMP,
+ SERVER_NAME VARCHAR(100),
+ TENANT_ID VARCHAR(50),
+ PAYLOAD_TYPE VARCHAR(50),
+ PAYLOAD_VALUE BIGINT,
+ PRIMARY KEY (`ID`)
+) ENGINE=INNODB;
+
+CREATE TABLE IF NOT EXISTS USAGE_DAILY_ANALYTICS (
+ ID VARCHAR(200) NOT NULL,
+ DAY_FACT TIMESTAMP,
+ SERVER_NAME VARCHAR(100),
+ TENANT_ID VARCHAR(50),
+ PAYLOAD_TYPE VARCHAR(50),
+ PAYLOAD_VALUE BIGINT,
+ PRIMARY KEY (`ID`)
+) ENGINE=INNODB;
+
+CREATE TABLE IF NOT EXISTS USAGE_MONTHLY_ANALYTICS (
+ ID VARCHAR(200) NOT NULL,
+ MONTH_FACT TIMESTAMP,
+ SERVER_NAME VARCHAR(100),
+ TENANT_ID VARCHAR(50),
+ PAYLOAD_TYPE VARCHAR(50),
+ PAYLOAD_VALUE BIGINT,
+ PRIMARY KEY (`ID`)
+) ENGINE=INNODB;
+
+CREATE TABLE IF NOT EXISTS USAGE_LAST_HOURLY_TS (
+ ID VARCHAR(200) NOT NULL,
+ TIMESTMP TIMESTAMP,
+ PRIMARY KEY (`ID`)
+) ENGINE=INNODB;
+
+CREATE TABLE IF NOT EXISTS USAGE_LAST_DAILY_TS (
+ ID VARCHAR(200) NOT NULL,
+ TIMESTMP TIMESTAMP,
+ PRIMARY KEY (`ID`)
+) ENGINE=INNODB;
+
+CREATE TABLE IF NOT EXISTS USAGE_LAST_MONTHLY_TS (
+ ID VARCHAR(200) NOT NULL,
+ TIMESTMP TIMESTAMP,
+ PRIMARY KEY (`ID`)
+) ENGINE=INNODB;
+
+CREATE TABLE IF NOT EXISTS SERVICE_STATS_HOURLY_ANALYTICS (
+ ID VARCHAR(200) NOT NULL,
+ HOUR_FACT TIMESTAMP,
+ SERVER_NAME VARCHAR(100),
+ TENANT_ID VARCHAR(50),
+ REQUEST_COUNT BIGINT,
+ RESPONSE_COUNT BIGINT,
+ FAULT_COUNT BIGINT,
+ PRIMARY KEY (`ID`)
+) ENGINE=INNODB;
+
+CREATE TABLE IF NOT EXISTS SERVICE_STATS_DAILY_ANALYTICS (
+ ID VARCHAR(200) NOT NULL,
+ DAY_FACT TIMESTAMP,
+ SERVER_NAME VARCHAR(100),
+ TENANT_ID VARCHAR(50),
+ REQUEST_COUNT BIGINT,
+ RESPONSE_COUNT BIGINT,
+ FAULT_COUNT BIGINT,
+ PRIMARY KEY (`ID`)
+) ENGINE=INNODB;
+
+CREATE TABLE IF NOT EXISTS SERVICE_STATS_MONTHLY_ANALYTICS (
+ ID VARCHAR(200) NOT NULL,
+ MONTH_FACT TIMESTAMP,
+ SERVER_NAME VARCHAR(100),
+ TENANT_ID VARCHAR(50),
+ REQUEST_COUNT BIGINT,
+ RESPONSE_COUNT BIGINT,
+ FAULT_COUNT BIGINT,
+ PRIMARY KEY (`ID`)
+) ENGINE=INNODB;
+
+CREATE TABLE IF NOT EXISTS SERVICE_STATS_LAST_HOURLY_TS (
+ ID VARCHAR(200) NOT NULL,
+ TIMESTMP TIMESTAMP,
+ PRIMARY KEY (`ID`)
+) ENGINE=INNODB;
+
+CREATE TABLE IF NOT EXISTS SERVICE_STATS_LAST_DAILY_TS (
+ ID VARCHAR(200) NOT NULL,
+ TIMESTMP TIMESTAMP,
+ PRIMARY KEY (`ID`)
+) ENGINE=INNODB;
+
+CREATE TABLE IF NOT EXISTS SERVICE_STATS_LAST_MONTHLY_TS (
+ ID VARCHAR(200) NOT NULL,
+ TIMESTMP TIMESTAMP,
+ PRIMARY KEY (`ID`)
+) ENGINE=INNODB;
+
+CREATE TABLE IF NOT EXISTS REGISTRY_USAGE_HOURLY_ANALYTICS (
+ ID VARCHAR(50),
+ TENANT_ID VARCHAR(50),
+ HISTORY_USAGE BIGINT,
+ CURRENT_USAGE BIGINT,
+ PRIMARY KEY (`ID`)
+) ENGINE=INNODB;
+
+CREATE TABLE IF NOT EXISTS CARTRIDGE_STATS_HOURLY_ANALYTICS (
+ HOUR_FACT TIMESTAMP,
+ TENANT_ID VARCHAR(50),
+ CARTRIDGE_TYPE VARCHAR(20),
+ IMAGE_ID VARCHAR(100),
+ NODE_ID VARCHAR(100),
+ DURATION_HOURS INT(5),
+ PRIMARY KEY (`NODE_ID`)
+) ENGINE=INNODB;
+
+CREATE TABLE IF NOT EXISTS CARTRIDGE_STATS_LAST_HOURLY_TS (
+ ID VARCHAR(200) NOT NULL,
+ TIMESTMP TIMESTAMP,
+ PRIMARY KEY (`ID`)
+) ENGINE=INNODB;
+
+CREATE TABLE IF NOT EXISTS CARTRIDGE_STATS_LAST_DAILY_TS (
+ ID VARCHAR(200) NOT NULL,
+ TIMESTMP TIMESTAMP,
+ PRIMARY KEY (`ID`)
+) ENGINE=INNODB;
+
+CREATE TABLE IF NOT EXISTS CARTRIDGE_STATS_LAST_MONTHLY_TS (
+ ID VARCHAR(200) NOT NULL,
+ TIMESTMP TIMESTAMP,
+ PRIMARY KEY (`ID`)
+) ENGINE=INNODB;
+
+
+COMMIT;
+
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/249e1290/products/stratos-manager/dbscripts/migration.sql
----------------------------------------------------------------------
diff --git a/products/stratos-manager/dbscripts/migration.sql b/products/stratos-manager/dbscripts/migration.sql
new file mode 100755
index 0000000..421fd1d
--- /dev/null
+++ b/products/stratos-manager/dbscripts/migration.sql
@@ -0,0 +1,26 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF 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.
+*/
+
+ALTER TABLE UM_TENANT ADD UM_CREATED_DATE TIMESTAMP NOT NULL DEFAULT '2010-06-01 00:00:01';
+ALTER TABLE UM_TENANT ADD UNIQUE INDEX INDEX_UM_TENANT_UM_DOMAIN_NAME (UM_DOMAIN_NAME);
+
+ALTER TABLE REG_ASSOCIATION ADD INDEX REG_ASSOCIATION_INDEX_SOURCEPATH (REG_SOURCEPATH, REG_TENANT_ID);
+ALTER TABLE REG_ASSOCIATION ADD INDEX REG_ASSOCIATION_INDEX_TARGETPATH (REG_TARGETPATH, REG_TENANT_ID);
+ALTER TABLE REG_ASSOCIATION ADD INDEX REG_ASSOCIATION_INDEX_ASSOCIATION_TYPE (REG_ASSOCIATION_TYPE, REG_TENANT_ID);
+
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/249e1290/products/stratos-manager/dbscripts/s2_h2.sql
----------------------------------------------------------------------
diff --git a/products/stratos-manager/dbscripts/s2_h2.sql b/products/stratos-manager/dbscripts/s2_h2.sql
new file mode 100644
index 0000000..d88149d
--- /dev/null
+++ b/products/stratos-manager/dbscripts/s2_h2.sql
@@ -0,0 +1,115 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF 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.
+*/
+
+--
+-- Create schema s2_db
+--
+
+-- CREATE SCHEMA IF NOT EXISTS s2_db;
+-- SET SCHEMA s2_db;
+
+--
+-- Definition of table s2_db.CARTRIDGE_INSTANCE
+--
+
+DROP TABLE IF EXISTS CARTRIDGE_INSTANCE;
+CREATE TABLE CARTRIDGE_INSTANCE (
+ ID int(11) NOT NULL AUTO_INCREMENT,
+ INSTANCE_IP varchar(255) NOT NULL,
+ TENANT_ID int(11) DEFAULT NULL,
+ TENANT_DOMAIN varchar(255) DEFAULT NULL,
+ CARTRIDGE_TYPE varchar(255) NOT NULL,
+ STATE varchar(255) NOT NULL,
+ CLUSTER_DOMAIN varchar(255) NOT NULL,
+ CLUSTER_SUBDOMAIN varchar(255) NOT NULL,
+ PRIMARY KEY (ID)
+);
+
+--
+-- Definition of table CARTRIDGE_SUBSCRIPTION
+--
+
+DROP TABLE IF EXISTS CARTRIDGE_SUBSCRIPTION;
+CREATE TABLE CARTRIDGE_SUBSCRIPTION (
+ SUBSCRIPTION_ID int(11) NOT NULL AUTO_INCREMENT,
+ TENANT_ID int(11) NOT NULL,
+ CARTRIDGE varchar(30) NOT NULL,
+ PROVIDER varchar(30) NOT NULL,
+ HOSTNAME varchar(255) NOT NULL,
+ POLICY varchar(50) NULL,
+ CLUSTER_DOMAIN varchar(255) NOT NULL,
+ CLUSTER_SUBDOMAIN varchar(255) NOT NULL,
+ MGT_DOMAIN varchar(255) NOT NULL,
+ MGT_SUBDOMAIN varchar(255) NOT NULL,
+ STATE varchar(30) NOT NULL,
+ ALIAS varchar(255) NOT NULL,
+ TENANT_DOMAIN varchar(255) NOT NULL,
+ BASE_DIR varchar(255) NOT NULL,
+ REPO_ID int(11) DEFAULT NULL,
+ DATA_CARTRIDGE_ID int(11) DEFAULT NULL,
+ MAPPED_DOMAIN varchar(255),
+ PRIMARY KEY (SUBSCRIPTION_ID)
+);
+
+
+
+--
+-- Definition of table DATA_CARTRIDGE
+--
+
+DROP TABLE IF EXISTS DATA_CARTRIDGE;
+CREATE TABLE DATA_CARTRIDGE (
+ DATA_CART_ID int(11) NOT NULL AUTO_INCREMENT,
+ TYPE varchar(30) NOT NULL,
+ USER_NAME varchar(255) NOT NULL,
+ PASSWORD varchar(255) NOT NULL,
+ STATE varchar(255) NOT NULL,
+ PRIMARY KEY (DATA_CART_ID)
+);
+
+
+--
+-- Definition of table PORT_MAPPING
+--
+
+DROP TABLE IF EXISTS PORT_MAPPING;
+CREATE TABLE PORT_MAPPING (
+ PORT_MAPPING_ID int(11) NOT NULL AUTO_INCREMENT,
+ SUBSCRIPTION_ID int(11) NOT NULL,
+ TYPE varchar(30) NOT NULL,
+ PRIMARY_PORT varchar(30) NOT NULL,
+ PROXY_PORT varchar(30) NOT NULL,
+ STATE varchar(30) NOT NULL,
+ PRIMARY KEY (PORT_MAPPING_ID)
+);
+
+
+--
+-- Definition of table REPOSITORY
+--
+
+DROP TABLE IF EXISTS REPOSITORY;
+CREATE TABLE REPOSITORY (
+ REPO_ID int(11) NOT NULL AUTO_INCREMENT,
+ REPO_NAME varchar(255) NOT NULL,
+ STATE varchar(30) NOT NULL,
+ REPO_USER_NAME varchar(255) NOT NULL,
+ REPO_USER_PASSWORD varchar(255) NOT NULL,
+ PRIMARY KEY (REPO_ID)
+);
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/249e1290/products/stratos-manager/dbscripts/stratos_mysql.sql
----------------------------------------------------------------------
diff --git a/products/stratos-manager/dbscripts/stratos_mysql.sql b/products/stratos-manager/dbscripts/stratos_mysql.sql
new file mode 100644
index 0000000..9b2393b
--- /dev/null
+++ b/products/stratos-manager/dbscripts/stratos_mysql.sql
@@ -0,0 +1,159 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF 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.
+*/
+
+-- MySQL Administrator dump 1.4
+--
+-- ------------------------------------------------------
+-- Server version 5.5.24-0ubuntu0.12.04.1
+
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8 */;
+
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+
+
+--
+-- Create schema stratos_foundation
+--
+
+CREATE DATABASE IF NOT EXISTS stratos_foundation;
+USE stratos_foundation;
+
+--
+-- Definition of table `stratos_foundation`.`CARTRIDGE_INSTANCE`
+--
+
+DROP TABLE IF EXISTS `stratos_foundation`.`CARTRIDGE_INSTANCE`;
+CREATE TABLE `stratos_foundation`.`CARTRIDGE_INSTANCE` (
+ `ID` int(11) NOT NULL AUTO_INCREMENT,
+ `INSTANCE_IP` varchar(255) NOT NULL,
+ `TENANT_ID` int(11) DEFAULT NULL,
+ `TENANT_DOMAIN` varchar(255) DEFAULT NULL,
+ `CARTRIDGE_TYPE` varchar(255) NOT NULL,
+ `STATE` varchar(255) NOT NULL,
+ `CLUSTER_DOMAIN` varchar(255) NOT NULL,
+ `CLUSTER_SUBDOMAIN` varchar(255) NOT NULL,
+ PRIMARY KEY (`ID`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
+
+--
+-- Definition of table `stratos_foundation`.`CARTRIDGE_SUBSCRIPTION`
+--
+
+DROP TABLE IF EXISTS `stratos_foundation`.`CARTRIDGE_SUBSCRIPTION`;
+CREATE TABLE `stratos_foundation`.`CARTRIDGE_SUBSCRIPTION` (
+ `SUBSCRIPTION_ID` int(11) NOT NULL AUTO_INCREMENT,
+ `TENANT_ID` int(11) NOT NULL,
+ `CARTRIDGE` varchar(30) NOT NULL,
+ `PROVIDER` varchar(30) NOT NULL,
+ `HOSTNAME` varchar(255) NOT NULL,
+ `POLICY` varchar(50) NULL,
+ `CLUSTER_DOMAIN` varchar(255) NOT NULL,
+ `CLUSTER_SUBDOMAIN` varchar(255) NOT NULL,
+ `MGT_DOMAIN` varchar(255) NOT NULL,
+ `MGT_SUBDOMAIN` varchar(255) NOT NULL,
+ `STATE` varchar(30) NOT NULL,
+ `ALIAS` varchar(255) NOT NULL,
+ `TENANT_DOMAIN` varchar(255) NOT NULL,
+ `BASE_DIR` varchar(255) NULL,
+ `REPO_ID` int(11) DEFAULT NULL,
+ `DATA_CARTRIDGE_ID` int(11) DEFAULT NULL,
+ `MAPPED_DOMAIN` varchar(255),
+ `SUBSCRIPTION_KEY` varchar(255) NOT NULL,
+ PRIMARY KEY (`SUBSCRIPTION_ID`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
+
+
+
+--
+-- Definition of table `stratos_foundation`.`DATA_CARTRIDGE`
+--
+
+DROP TABLE IF EXISTS `stratos_foundation`.`DATA_CARTRIDGE`;
+CREATE TABLE `stratos_foundation`.`DATA_CARTRIDGE` (
+ `DATA_CART_ID` int(11) NOT NULL AUTO_INCREMENT,
+ `TYPE` varchar(30) NOT NULL,
+ `USER_NAME` varchar(255) NOT NULL,
+ `PASSWORD` varchar(255) NOT NULL,
+ `STATE` varchar(255) NOT NULL,
+ PRIMARY KEY (`DATA_CART_ID`) USING BTREE
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
+
+
+--
+-- Definition of table `stratos_foundation`.`PORT_MAPPING`
+--
+
+DROP TABLE IF EXISTS `stratos_foundation`.`PORT_MAPPING`;
+CREATE TABLE `stratos_foundation`.`PORT_MAPPING` (
+ `PORT_MAPPING_ID` int(11) NOT NULL AUTO_INCREMENT,
+ `SUBSCRIPTION_ID` int(11) NOT NULL,
+ `TYPE` varchar(30) NOT NULL,
+ `PRIMARY_PORT` varchar(30) NOT NULL,
+ `PROXY_PORT` varchar(30) NOT NULL,
+ `STATE` varchar(30) NOT NULL,
+ PRIMARY KEY (`PORT_MAPPING_ID`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
+
+
+--
+-- Definition of table `stratos_foundation`.`REPOSITORY`
+--
+
+DROP TABLE IF EXISTS `stratos_foundation`.`REPOSITORY`;
+CREATE TABLE `stratos_foundation`.`REPOSITORY` (
+ `REPO_ID` int(11) NOT NULL AUTO_INCREMENT,
+ `REPO_NAME` varchar(255) NOT NULL,
+ `STATE` varchar(30) NOT NULL,
+ `REPO_USER_NAME` varchar(255) NOT NULL,
+ `REPO_USER_PASSWORD` varchar(255) NOT NULL,
+ PRIMARY KEY (`REPO_ID`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
+
+
+--
+-- Definition of table `stratos_foundation`.`SERVICE`
+--
+DROP TABLE IF EXISTS `stratos_foundation`.`SERVICE`;
+CREATE TABLE `stratos_foundation`.`SERVICE` (
+ `SERVICE_ID` int NOT NULL AUTO_INCREMENT,
+ `TYPE` varchar(255) NOT NULL,
+ `AUTOSCALING_POLICY` varchar(255) NOT NULL,
+ `DEPLOYMENT_POLICY` varchar(255) NOT NULL,
+ `TENANT_RANGE` varchar(255) NOT NULL,
+ `CLUSTER_ID` varchar(255) NOT NULL,
+ `HOST_NAME` varchar(255) NOT NULL,
+ `SUBSCRIPTION_KEY` varchar(255) NOT NULL,
+ PRIMARY KEY (`SERVICE_ID`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
+
+
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/249e1290/products/stratos-manager/dbscripts/wso2_rss.sql
----------------------------------------------------------------------
diff --git a/products/stratos-manager/dbscripts/wso2_rss.sql b/products/stratos-manager/dbscripts/wso2_rss.sql
new file mode 100755
index 0000000..4a2348f
--- /dev/null
+++ b/products/stratos-manager/dbscripts/wso2_rss.sql
@@ -0,0 +1,99 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF 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.
+*/
+
+CREATE TABLE RSS_INSTANCE (
+ rss_instance_id INTEGER AUTO_INCREMENT,
+ name VARCHAR(128) NOT NULL,
+ server_url VARCHAR(1024) NOT NULL,
+ dbms_type VARCHAR(128) NOT NULL,
+ instance_type VARCHAR(128) NOT NULL,
+ server_category VARCHAR(128) NOT NULL,
+ admin_username VARCHAR(128),
+ admin_password VARCHAR(128),
+ tenant_id INTEGER NOT NULL,
+ UNIQUE (name, tenant_id),
+ PRIMARY KEY (rss_instance_id)
+) ENGINE="InnoDB";
+
+CREATE TABLE DATABASE_INSTANCE (
+ database_instance_id INTEGER AUTO_INCREMENT,
+ name VARCHAR(128) NOT NULL,
+ rss_instance_id INTEGER,
+ tenant_id INTEGER,
+ UNIQUE (name, rss_instance_id),
+ PRIMARY KEY (database_instance_id),
+ FOREIGN KEY (rss_instance_id) REFERENCES RSS_INSTANCE (rss_instance_id)
+) ENGINE="InnoDB";
+
+CREATE TABLE DATABASE_USER (
+ user_id INTEGER AUTO_INCREMENT,
+ db_username VARCHAR(128) NOT NULL,
+ rss_instance_id INTEGER,
+ user_tenant_id INTEGER,
+ UNIQUE (db_username, rss_instance_id, user_tenant_id),
+ PRIMARY KEY (user_id),
+ FOREIGN KEY (rss_instance_id) REFERENCES RSS_INSTANCE (rss_instance_id)
+) ENGINE="InnoDB";
+
+CREATE TABLE DATABASE_INSTANCE_PROPERTY (
+ db_property_id INTEGER AUTO_INCREMENT,
+ prop_name VARCHAR(128) NOT NULL,
+ prop_value TEXT,
+ database_instance_id INTEGER,
+ UNIQUE (prop_name, database_instance_id),
+ PRIMARY KEY (db_property_id),
+ FOREIGN KEY (database_instance_id) REFERENCES DATABASE_INSTANCE (database_instance_id)
+) ENGINE="InnoDB";
+
+CREATE TABLE USER_DATABASE_ENTRY (
+ user_id INTEGER,
+ database_instance_id INTEGER,
+ PRIMARY KEY (user_id, database_instance_id),
+ FOREIGN KEY (user_id) REFERENCES DATABASE_USER (user_id),
+ FOREIGN KEY (database_instance_id) REFERENCES DATABASE_INSTANCE (database_instance_id)
+) ENGINE="InnoDB";
+
+CREATE TABLE USER_DATABASE_PERMISSION (
+ user_id INTEGER,
+ database_instance_id INTEGER,
+ perm_name VARCHAR(128) NOT NULL,
+ perm_value VARCHAR(128),
+ PRIMARY KEY (user_id, database_instance_id, perm_name),
+ FOREIGN KEY (user_id) REFERENCES DATABASE_USER (user_id),
+ FOREIGN KEY (database_instance_id) REFERENCES DATABASE_INSTANCE (database_instance_id)
+) ENGINE="InnoDB";
+
+CREATE TABLE WSO2_RSS_DATABASE_INSTANCE_COUNT (
+ instance_count INTEGER NOT NULL DEFAULT 0
+) ENGINE="InnoDB";
+
+CREATE TABLE USER_PRIVILEGE_GROUP (
+ priv_group_id INTEGER AUTO_INCREMENT,
+ priv_group_name VARCHAR(128),
+ tenant_id INTEGER,
+ PRIMARY KEY (priv_group_id, priv_group_name, tenant_id)
+) ENGINE="InnoDB";
+
+CREATE TABLE USER_PRIVILEGE_GROUP_ENTRY (
+ priv_group_id INTEGER,
+ perm_name VARCHAR(128),
+ perm_value CHAR(1),
+ PRIMARY KEY (priv_group_id, perm_name),
+ FOREIGN KEY (priv_group_id) REFERENCES USER_PRIVILEGE_GROUP (priv_group_id)
+) ENGINE="InnoDB";
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/249e1290/products/stratos-manager/modules/cloud-service-mgt/pom.xml
----------------------------------------------------------------------
diff --git a/products/stratos-manager/modules/cloud-service-mgt/pom.xml b/products/stratos-manager/modules/cloud-service-mgt/pom.xml
new file mode 100644
index 0000000..aa69f7c
--- /dev/null
+++ b/products/stratos-manager/modules/cloud-service-mgt/pom.xml
@@ -0,0 +1,98 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.apache.stratos</groupId>
+ <artifactId>stratos-manager-parent</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>org.apache.stratos.manager.services.mgt</artifactId>
+ <packaging>bundle</packaging>
+ <name>Apache Stratos - Cloud Manager Cloud Services Management</name>
+
+ <build>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+ <Bundle-Name>${project.artifactId}</Bundle-Name>
+ <Private-Package>
+ org.apache.stratos.manager.services.mgt.*,
+ </Private-Package>
+ <Import-Package>
+ org.wso2.carbon.registry.core.*;version=1.0.1,
+ !javax.xml.namespace,
+ javax.xml.namespace; version=0.0.0,
+ javax.servlet; version=2.4.0,
+ javax.servlet.http; version=2.4.0,
+ org.apache.axiom.*; version="${axiom.osgi.version.range}",
+ *;resolution:=optional
+ </Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.wso2.carbon</groupId>
+ <artifactId>org.wso2.carbon.registry.core</artifactId>
+ <version>${wso2carbon.version}</version>
+ </dependency>
+ <!--<dependency>-->
+ <!--<groupId>org.wso2.carbon</groupId>-->
+ <!--<artifactId>org.wso2.carbon.registry.extensions</artifactId>-->
+ <!--<version>${registry-component.version}</version>-->
+ <!--</dependency>-->
+ <dependency>
+ <groupId>org.wso2.carbon</groupId>
+ <artifactId>org.wso2.carbon.registry.resource</artifactId>
+ <version>${wso2carbon.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.stratos</groupId>
+ <artifactId>org.apache.stratos.common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.stratos</groupId>
+ <artifactId>org.apache.stratos.tenant.mgt</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/249e1290/products/stratos-manager/modules/cloud-service-mgt/src/main/java/org/apache/stratos/manager/services/mgt/beans/CloudService.java
----------------------------------------------------------------------
diff --git a/products/stratos-manager/modules/cloud-service-mgt/src/main/java/org/apache/stratos/manager/services/mgt/beans/CloudService.java b/products/stratos-manager/modules/cloud-service-mgt/src/main/java/org/apache/stratos/manager/services/mgt/beans/CloudService.java
new file mode 100644
index 0000000..7648280
--- /dev/null
+++ b/products/stratos-manager/modules/cloud-service-mgt/src/main/java/org/apache/stratos/manager/services/mgt/beans/CloudService.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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.apache.stratos.manager.services.mgt.beans;
+
+public class CloudService {
+ private String name;
+ private String label;
+ private String link;
+ private String icon;
+ private String description;
+ private boolean active;
+ private String productPageURL;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ public String getLink() {
+ return link;
+ }
+
+ public void setLink(String link) {
+ this.link = link;
+ }
+
+ public String getIcon() {
+ return icon;
+ }
+
+ public void setIcon(String icon) {
+ this.icon = icon;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public boolean isActive() {
+ return active;
+ }
+
+ public void setActive(boolean active) {
+ this.active = active;
+ }
+
+ public String getProductPageURL() {
+ return productPageURL;
+ }
+
+ public void setProductPageURL(String productPageURL) {
+ this.productPageURL = productPageURL;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/249e1290/products/stratos-manager/modules/cloud-service-mgt/src/main/java/org/apache/stratos/manager/services/mgt/internal/CloudServiceMgtServiceComponent.java
----------------------------------------------------------------------
diff --git a/products/stratos-manager/modules/cloud-service-mgt/src/main/java/org/apache/stratos/manager/services/mgt/internal/CloudServiceMgtServiceComponent.java b/products/stratos-manager/modules/cloud-service-mgt/src/main/java/org/apache/stratos/manager/services/mgt/internal/CloudServiceMgtServiceComponent.java
new file mode 100644
index 0000000..770a47d
--- /dev/null
+++ b/products/stratos-manager/modules/cloud-service-mgt/src/main/java/org/apache/stratos/manager/services/mgt/internal/CloudServiceMgtServiceComponent.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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.apache.stratos.manager.services.mgt.internal;
+
+import org.apache.stratos.manager.services.mgt.util.Util;
+import org.wso2.carbon.registry.core.service.RegistryService;
+import org.wso2.carbon.user.core.service.RealmService;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.osgi.service.component.ComponentContext;
+
+/**
+ * @scr.component name="org.apache.stratos.manager.services.mgt"
+ * immediate="true"
+ * @scr.reference name="registry.service"
+ * interface="org.wso2.carbon.registry.core.service.RegistryService" cardinality="1..1"
+ * policy="dynamic" bind="setRegistryService" unbind="unsetRegistryService"
+ * @scr.reference name="user.realmservice.default"
+ * interface="org.wso2.carbon.user.core.service.RealmService"
+ * cardinality="1..1" policy="dynamic" bind="setRealmService"
+ * unbind="unsetRealmService"
+ */
+public class CloudServiceMgtServiceComponent {
+ private static Log log = LogFactory.getLog(CloudServiceMgtServiceComponent.class);
+
+ protected void activate(ComponentContext context) {
+ try {
+ Util.loadCloudServicesConfiguration();
+ Util.loadServiceIcons();
+ log.debug("******* Cloud Manager Service Manager bundle is activated ******* ");
+ } catch (Throwable e) {
+ String msg = "******* Cloud Manager Service Manager bundle activation failed. ******* ";
+ log.error(msg, e);
+ }
+ }
+
+ protected void deactivate(ComponentContext context) {
+ log.debug("******* Cloud Manager Service Manager bundle is deactivated ******* ");
+ }
+ protected void setRegistryService(RegistryService registryService) {
+ Util.setRegistryService(registryService);
+ }
+
+ protected void unsetRegistryService(RegistryService registryService) {
+ Util.setRegistryService(null);
+ }
+
+ protected void setRealmService(RealmService realmService) {
+ Util.setRealmService(realmService);
+ }
+
+ protected void unsetRealmService(RealmService realmService) {
+ Util.setRealmService(null);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/249e1290/products/stratos-manager/modules/cloud-service-mgt/src/main/java/org/apache/stratos/manager/services/mgt/services/CloudManagerService.java
----------------------------------------------------------------------
diff --git a/products/stratos-manager/modules/cloud-service-mgt/src/main/java/org/apache/stratos/manager/services/mgt/services/CloudManagerService.java b/products/stratos-manager/modules/cloud-service-mgt/src/main/java/org/apache/stratos/manager/services/mgt/services/CloudManagerService.java
new file mode 100644
index 0000000..f12a4bb
--- /dev/null
+++ b/products/stratos-manager/modules/cloud-service-mgt/src/main/java/org/apache/stratos/manager/services/mgt/services/CloudManagerService.java
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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.apache.stratos.manager.services.mgt.services;
+
+import org.wso2.carbon.core.AbstractAdmin;
+import org.wso2.carbon.registry.core.session.UserRegistry;
+import org.apache.stratos.common.config.CloudServiceConfig;
+import org.apache.stratos.common.config.CloudServicesDescConfig;
+import org.apache.stratos.common.constants.StratosConstants;
+import org.apache.stratos.manager.services.mgt.beans.CloudService;
+import org.apache.stratos.manager.services.mgt.util.Util;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class CloudManagerService extends AbstractAdmin {
+
+ public CloudService[] retrieveCloudServiceInfo() throws Exception {
+ UserRegistry registry = (UserRegistry)getConfigUserRegistry();
+ int tenantId = registry.getTenantId();
+
+ CloudServicesDescConfig cloudServicesDesc = Util.getCloudServicesDescConfig();
+ Map<String, CloudServiceConfig> cloudServiceConfigs =
+ cloudServicesDesc.getCloudServiceConfigs();
+ List<CloudService> cloudServices = new ArrayList<CloudService>();
+ if (cloudServiceConfigs != null) {
+ Set<String> configKeys = cloudServiceConfigs.keySet();
+ for (String configKey : configKeys) {
+ CloudServiceConfig cloudServiceConfig = cloudServiceConfigs.get(configKey);
+ String label = cloudServiceConfig.getLabel();
+ if (label == null) {
+ // we are only returning display-able services
+ continue;
+ }
+ CloudService cloudService = new CloudService();
+ String name = cloudServiceConfig.getName();
+ cloudService.setName(name);
+ cloudService.setLabel(label);
+ cloudService.setLink(cloudServiceConfig.getLink());
+ cloudService.setIcon(cloudServiceConfig.getIcon());
+ cloudService.setDescription(cloudServiceConfig.getDescription());
+ cloudService.setProductPageURL(cloudServiceConfig.getProductPageURL());
+ boolean active = Util.isCloudServiceActive(name, tenantId);
+ cloudService.setActive(tenantId == 0 || active);
+
+ cloudServices.add(cloudService);
+ }
+ }
+ return cloudServices.toArray(new CloudService[cloudServices.size()]);
+ }
+
+ public void saveCloudServicesActivity(String[] activeServiceNames) throws Exception {
+ UserRegistry registry = (UserRegistry)getConfigUserRegistry();
+ int tenantId = registry.getTenantId();
+
+ CloudServicesDescConfig cloudServicesDesc = Util.getCloudServicesDescConfig();
+ Map<String, CloudServiceConfig> cloudServiceConfigMap =
+ cloudServicesDesc.getCloudServiceConfigs();
+
+ List<String> activeServiceNamesList = Arrays.asList(activeServiceNames);
+ if (cloudServiceConfigMap != null) {
+ for (String cloudServiceName : cloudServiceConfigMap.keySet()) {
+ if (activeServiceNamesList.contains(cloudServiceName)) {
+ // this should be made active
+ if (!Util.isCloudServiceActive(cloudServiceName, tenantId)) {
+ Util.setCloudServiceActive(true, cloudServiceName, tenantId);
+ }
+ } else {
+ // this should be made inactive
+ if (Util.isCloudServiceActive(cloudServiceName, tenantId)) {
+ Util.setCloudServiceActive(false, cloudServiceName, tenantId);
+ }
+
+ }
+ }
+ }
+ Util.setCloudServiceActive(true, StratosConstants.CLOUD_IDENTITY_SERVICE, tenantId);
+ Util.setCloudServiceActive(true, StratosConstants.CLOUD_GOVERNANCE_SERVICE, tenantId);
+ }
+
+ public void activate(String cloudServiceName) throws Exception {
+ UserRegistry registry = (UserRegistry) getConfigUserRegistry();
+ int tenantId = registry.getTenantId();
+ if (!Util.isCloudServiceActive(cloudServiceName, tenantId)) {
+ Util.setCloudServiceActive(true, cloudServiceName, tenantId);
+ }
+ }
+
+ public void deactivate(String cloudServiceName) throws Exception {
+ if (StratosConstants.CLOUD_IDENTITY_SERVICE.equals(cloudServiceName) ||
+ StratosConstants.CLOUD_GOVERNANCE_SERVICE.equals(cloudServiceName)) {
+ // cloud identity and governance services cannot be deactivated..
+ return;
+ }
+ UserRegistry registry = (UserRegistry) getConfigUserRegistry();
+ int tenantId = registry.getTenantId();
+ if (Util.isCloudServiceActive(cloudServiceName, tenantId)) {
+ Util.setCloudServiceActive(false, cloudServiceName, tenantId);
+ }
+ }
+}
+
+
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/249e1290/products/stratos-manager/modules/cloud-service-mgt/src/main/java/org/apache/stratos/manager/services/mgt/util/Constants.java
----------------------------------------------------------------------
diff --git a/products/stratos-manager/modules/cloud-service-mgt/src/main/java/org/apache/stratos/manager/services/mgt/util/Constants.java b/products/stratos-manager/modules/cloud-service-mgt/src/main/java/org/apache/stratos/manager/services/mgt/util/Constants.java
new file mode 100644
index 0000000..0f91d7e
--- /dev/null
+++ b/products/stratos-manager/modules/cloud-service-mgt/src/main/java/org/apache/stratos/manager/services/mgt/util/Constants.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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.apache.stratos.manager.services.mgt.util;
+
+public class Constants {
+ public static final String CLOUD_SERVICE_INFO_STORE_PATH =
+ "/repository/components/org.apache.stratos/cloud-manager/cloud-services";
+ public static final String CLOUD_SERVICE_ICONS_STORE_PATH =
+ "/repository/components/org.apache.stratos/cloud-manager/" +
+ "cloud-services-icons";
+
+ public static final String CLOUD_SERVICE_IS_ACTIVE_PROP_KEY = "active";
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/249e1290/products/stratos-manager/modules/cloud-service-mgt/src/main/java/org/apache/stratos/manager/services/mgt/util/Util.java
----------------------------------------------------------------------
diff --git a/products/stratos-manager/modules/cloud-service-mgt/src/main/java/org/apache/stratos/manager/services/mgt/util/Util.java b/products/stratos-manager/modules/cloud-service-mgt/src/main/java/org/apache/stratos/manager/services/mgt/util/Util.java
new file mode 100644
index 0000000..904537f
--- /dev/null
+++ b/products/stratos-manager/modules/cloud-service-mgt/src/main/java/org/apache/stratos/manager/services/mgt/util/Util.java
@@ -0,0 +1,264 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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.apache.stratos.manager.services.mgt.util;
+
+import org.wso2.carbon.registry.core.Collection;
+import org.wso2.carbon.registry.core.RegistryConstants;
+import org.wso2.carbon.registry.core.Resource;
+import org.wso2.carbon.registry.core.exceptions.RegistryException;
+import org.wso2.carbon.registry.core.service.RegistryService;
+import org.wso2.carbon.registry.core.session.UserRegistry;
+import org.apache.stratos.common.config.CloudServiceConfig;
+import org.apache.stratos.common.config.CloudServicesDescConfig;
+import org.apache.stratos.common.config.PermissionConfig;
+import org.apache.stratos.common.constants.StratosConstants;
+import org.apache.stratos.common.util.CommonUtil;
+import org.wso2.carbon.user.api.RealmConfiguration;
+import org.wso2.carbon.user.core.service.RealmService;
+import org.wso2.carbon.user.core.tenant.TenantManager;
+import org.wso2.carbon.user.mgt.UserMgtConstants;
+import org.wso2.carbon.utils.CarbonUtils;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.activation.MimetypesFileTypeMap;
+
+public class Util {
+
+ private static final Log log = LogFactory.getLog(Util.class);
+
+ private static final String CONFIG_FILENAME = "cloud-services-desc.xml";
+
+ private static RegistryService registryService;
+ private static RealmService realmService;
+ private static CloudServicesDescConfig cloudServicesDescConfig = null;
+
+ public static synchronized void setRegistryService(RegistryService service) {
+ if ((registryService == null) || (service == null)) {
+ registryService = service;
+ }
+ }
+
+ public static RegistryService getRegistryService() {
+ return registryService;
+ }
+
+ public static synchronized void setRealmService(RealmService service) {
+ if ((realmService == null) || (service == null)) {
+ realmService = service;
+ }
+ }
+
+ public static RealmService getRealmService() {
+ return realmService;
+ }
+
+ public static TenantManager getTenantManager() {
+ return realmService.getTenantManager();
+ }
+
+ public static RealmConfiguration getBootstrapRealmConfiguration() {
+ return realmService.getBootstrapRealmConfiguration();
+ }
+
+ public static UserRegistry getTenantZeroSystemGovernanceRegistry() throws RegistryException {
+ return registryService.getGovernanceSystemRegistry();
+ }
+
+ public static UserRegistry getSystemGovernanceRegistry(int tenantId) throws RegistryException {
+ return registryService.getGovernanceSystemRegistry(tenantId);
+ }
+
+ public static UserRegistry getSystemConfigRegistry(int tenantId) throws RegistryException {
+ return registryService.getConfigSystemRegistry(tenantId);
+ }
+
+ public static void loadCloudServicesConfiguration() throws Exception {
+ // now load the cloud services configuration
+ String configFileName =
+ CarbonUtils.getCarbonConfigDirPath() + File.separator + StratosConstants.MULTITENANCY_CONFIG_FOLDER +
+ File.separator+ CONFIG_FILENAME;
+ OMElement configElement;
+ try {
+ configElement = CommonUtil.buildOMElement(new FileInputStream(configFileName));
+ } catch (Exception e) {
+ String msg = "Error in building the cloud service configuration. config filename: " +
+ configFileName + ".";
+ log.error(msg, e);
+ throw new Exception(msg, e);
+ }
+ cloudServicesDescConfig = new CloudServicesDescConfig(configElement);
+ }
+
+ public static CloudServicesDescConfig getCloudServicesDescConfig() {
+ return cloudServicesDescConfig;
+ }
+
+ public static CloudServiceConfig getCloudServiceConfig(String cloudServiceName) {
+ Map<String, CloudServiceConfig> cloudServiceConfigs =
+ cloudServicesDescConfig.getCloudServiceConfigs();
+ return cloudServiceConfigs.get(cloudServiceName);
+ }
+
+ public static void setCloudServiceActive(boolean active, String cloudServiceName,
+ int tenantId)throws Exception {
+ CloudServiceConfig cloudServiceConfig = getCloudServiceConfig(cloudServiceName);
+ if (cloudServiceConfig.getLabel() == null) {
+ // for the non-labeled services, we are not setting/unsetting the service active
+ return;
+ }
+
+ UserRegistry tenantZeroSystemGovernanceRegistry;
+ UserRegistry systemConfigRegistry;
+ try {
+ tenantZeroSystemGovernanceRegistry = Util.getTenantZeroSystemGovernanceRegistry();
+ systemConfigRegistry = Util.getSystemConfigRegistry(tenantId);
+ } catch (RegistryException e) {
+ String msg = "Error in getting the tenant 0 system config registry";
+ log.error(msg, e);
+ throw new Exception(msg, e);
+ }
+
+ String cloudServiceInfoPath =
+ Constants.CLOUD_SERVICE_INFO_STORE_PATH + RegistryConstants.PATH_SEPARATOR +
+ tenantId + RegistryConstants.PATH_SEPARATOR + cloudServiceName;
+ Resource cloudServiceInfoResource;
+ if (tenantZeroSystemGovernanceRegistry.resourceExists(cloudServiceInfoPath)) {
+ cloudServiceInfoResource = tenantZeroSystemGovernanceRegistry.get(cloudServiceInfoPath);
+ } else {
+ cloudServiceInfoResource = tenantZeroSystemGovernanceRegistry.newCollection();
+ }
+ cloudServiceInfoResource.setProperty(Constants.CLOUD_SERVICE_IS_ACTIVE_PROP_KEY,
+ active ? "true" : "false");
+ tenantZeroSystemGovernanceRegistry.put(cloudServiceInfoPath, cloudServiceInfoResource);
+
+ // then we will copy the permissions
+ List<PermissionConfig> permissionConfigs = cloudServiceConfig.getPermissionConfigs();
+ for (PermissionConfig permissionConfig : permissionConfigs) {
+ String path = permissionConfig.getPath();
+ String name = permissionConfig.getName();
+ if (active) {
+ if (!systemConfigRegistry.resourceExists(path)) {
+ Collection collection = systemConfigRegistry.newCollection();
+ collection.setProperty(UserMgtConstants.DISPLAY_NAME, name);
+ systemConfigRegistry.put(path, collection);
+ }
+ } else {
+ if (systemConfigRegistry.resourceExists(path)) {
+ systemConfigRegistry.delete(path);
+ }
+ }
+ }
+ }
+
+ public static boolean isCloudServiceActive(String cloudServiceName,
+ int tenantId)throws Exception {
+ UserRegistry systemGovernanceRegistry;
+ try {
+ systemGovernanceRegistry = Util.getTenantZeroSystemGovernanceRegistry();
+ } catch (RegistryException e) {
+ String msg = "Error in getting the tenant 0 system config registry";
+ log.error(msg, e);
+ throw new Exception(msg, e);
+ }
+
+ String cloudServiceInfoPath =
+ Constants.CLOUD_SERVICE_INFO_STORE_PATH + RegistryConstants.PATH_SEPARATOR +
+ tenantId + RegistryConstants.PATH_SEPARATOR + cloudServiceName;
+
+ if (systemGovernanceRegistry.resourceExists(cloudServiceInfoPath)) {
+ Resource cloudServiceInfoResource = systemGovernanceRegistry.get(cloudServiceInfoPath);
+ String isActiveStr = cloudServiceInfoResource.getProperty(
+ Constants.CLOUD_SERVICE_IS_ACTIVE_PROP_KEY);
+ return "true".equals(isActiveStr);
+ }
+
+ return false;
+ }
+
+ /**
+ * Currently this is not used, as the icons are loaded from the webapps
+ *
+ * @throws Exception
+ */
+ public static void loadServiceIcons() throws Exception {
+ String serviceIconDirLocation =
+ CarbonUtils.getCarbonHome() + "/resources/cloud-service-icons";
+ File serviceIconDirDir = new File(serviceIconDirLocation);
+ UserRegistry registry = getTenantZeroSystemGovernanceRegistry();
+ try {
+ // adding the common media types
+ Map<String, String> extensionToMediaTypeMap = new HashMap<String, String>();
+ extensionToMediaTypeMap.put("gif", "img/gif");
+ extensionToMediaTypeMap.put("jpg", "img/gif");
+ extensionToMediaTypeMap.put("png", "img/png");
+
+ File[] filesAndDirs = serviceIconDirDir.listFiles();
+ if (filesAndDirs == null) {
+ return;
+ }
+ List<File> filesDirs = Arrays.asList(filesAndDirs);
+
+ for (File file : filesDirs) {
+ String filename = file.getName();
+ String fileRegistryPath = Constants.CLOUD_SERVICE_ICONS_STORE_PATH +
+ RegistryConstants.PATH_SEPARATOR + filename;
+
+ // Add the file to registry
+ Resource newResource = registry.newResource();
+ String mediaType = null;
+ if (filename.contains(".")) {
+ String fileExt = filename.substring(filename.lastIndexOf(".") + 1);
+ mediaType = extensionToMediaTypeMap.get(fileExt.toLowerCase());
+ }
+ if (mediaType == null) {
+ mediaType = new MimetypesFileTypeMap().getContentType(file);
+ }
+ newResource.setMediaType(mediaType);
+ newResource.setContentStream(new FileInputStream(file));
+ registry.put(fileRegistryPath, newResource);
+ }
+ } catch (Exception e) {
+ String msg = "Error loading icons to the system registry for registry path: " +
+ Constants.CLOUD_SERVICE_ICONS_STORE_PATH;
+ log.error(msg, e);
+ throw new Exception(msg, e);
+ }
+
+ try {
+ CommonUtil.setAnonAuthorization(RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH +
+ Constants.CLOUD_SERVICE_ICONS_STORE_PATH, registry.getUserRealm());
+ } catch (RegistryException e) {
+ String msg = "Setting the annon access enabled for the services icons paths.";
+ log.error(msg, e);
+ throw new Exception(msg, e);
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/249e1290/products/stratos-manager/modules/cloud-service-mgt/src/main/resources/META-INF/component.xml
----------------------------------------------------------------------
diff --git a/products/stratos-manager/modules/cloud-service-mgt/src/main/resources/META-INF/component.xml b/products/stratos-manager/modules/cloud-service-mgt/src/main/resources/META-INF/component.xml
new file mode 100644
index 0000000..29bdc6b
--- /dev/null
+++ b/products/stratos-manager/modules/cloud-service-mgt/src/main/resources/META-INF/component.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ # Licensed to the Apache Software Foundation (ASF) under one
+ # or more contributor license agreements. See the NOTICE file
+ # distributed with this work for additional information
+ # regarding copyright ownership. The ASF 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.
+ -->
+
+<component xmlns="http://products.wso2.org/carbon">
+ <ManagementPermissions>
+ <ManagementPermission>
+ <DisplayName>Configure</DisplayName>
+ <ResourceId>/permission/admin/configure</ResourceId>
+ </ManagementPermission>
+ <ManagementPermission>
+ <DisplayName>Cloud-Services</DisplayName>
+ <ResourceId>/permission/admin/configure/cloud-services</ResourceId>
+ </ManagementPermission>
+ </ManagementPermissions>
+</component>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/249e1290/products/stratos-manager/modules/cloud-service-mgt/src/main/resources/META-INF/services.xml
----------------------------------------------------------------------
diff --git a/products/stratos-manager/modules/cloud-service-mgt/src/main/resources/META-INF/services.xml b/products/stratos-manager/modules/cloud-service-mgt/src/main/resources/META-INF/services.xml
new file mode 100644
index 0000000..efc772e
--- /dev/null
+++ b/products/stratos-manager/modules/cloud-service-mgt/src/main/resources/META-INF/services.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ # Licensed to the Apache Software Foundation (ASF) under one
+ # or more contributor license agreements. See the NOTICE file
+ # distributed with this work for additional information
+ # regarding copyright ownership. The ASF 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.
+ -->
+<serviceGroup>
+ <service name="CloudManagerService" scope="transportsession">
+ <transports>
+ <transport>https</transport>
+ </transports>
+ <parameter name="ServiceClass" locked="false">
+ org.apache.stratos.manager.services.mgt.services.CloudManagerService
+ </parameter>
+ <operation name="retrieveCloudServiceInfo">
+ <parameter name="AuthorizationAction" locked="true">/permission/admin/login</parameter>
+ </operation>
+ <operation name="saveCloudServicesActivity">
+ <parameter name="AuthorizationAction" locked="true">/permission/admin/configure/cloud-services</parameter>
+ </operation>
+ <operation name="activate">
+ <parameter name="AuthorizationAction" locked="true">/permission/admin/configure/cloud-services</parameter>
+ </operation>
+ <operation name="deactivate">
+ <parameter name="AuthorizationAction" locked="true">/permission/admin/configure/cloud-services</parameter>
+ </operation>
+ </service>
+ <parameter name="adminService" locked="true">true</parameter>
+ <parameter name="hiddenService" locked="true">true</parameter>
+</serviceGroup>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/249e1290/products/stratos-manager/modules/dashboard/pom.xml
----------------------------------------------------------------------
diff --git a/products/stratos-manager/modules/dashboard/pom.xml b/products/stratos-manager/modules/dashboard/pom.xml
new file mode 100644
index 0000000..665378c
--- /dev/null
+++ b/products/stratos-manager/modules/dashboard/pom.xml
@@ -0,0 +1,144 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.apache.stratos</groupId>
+ <artifactId>stratos-manager-parent</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>org.apache.stratos.manager.dashboard.ui</artifactId>
+ <packaging>bundle</packaging>
+ <name>Apache Stratos - Cloud Manager Dashboard User Interface</name>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+ <Bundle-Name>${project.artifactId}</Bundle-Name>
+ <Export-Package>
+ org.apache.stratos.manager.dashboard.ui.*,
+ </Export-Package>
+ <Import-Package>
+ org.wso2.carbon.ui.servlets.*,
+ javax.servlet; version=2.4.0,
+ javax.servlet.http; version=2.4.0,
+ org.apache.lucene.*,
+ *;resolution:=optional
+ </Import-Package>
+ <Carbon-Component>UIBundle</Carbon-Component>
+ </instructions>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
+
+ <dependencies>
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.wso2.carbon</groupId>
+ <artifactId>org.wso2.carbon.registry.common.ui</artifactId>
+ <version>${wso2carbon.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.wso2.carbon</groupId>
+ <artifactId>org.wso2.carbon.registry.core</artifactId>
+ <version>${wso2carbon.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.axis2.wso2</groupId>
+ <artifactId>axis2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom.wso2</groupId>
+ <artifactId>axiom</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.wso2.carbon</groupId>
+ <artifactId>org.wso2.carbon.ui</artifactId>
+ <version>${wso2carbon.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.wso2.carbon</groupId>
+ <artifactId>org.wso2.carbon.core</artifactId>
+ <version>${wso2carbon.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.wso2.carbon</groupId>
+ <artifactId>org.wso2.carbon.registry.profiles.ui</artifactId>
+ <version>${registry-component.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.wso2.carbon</groupId>
+ <artifactId>org.wso2.carbon.registry.resource.ui</artifactId>
+ <version>${governance-component.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.stratos</groupId>
+ <artifactId>org.apache.stratos.account.mgt.ui</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.stratos</groupId>
+ <artifactId>org.apache.stratos.common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.stratos</groupId>
+ <artifactId>org.apache.stratos.manager.dashboard.stub</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <properties>
+ <eclipse.version>3.2.0</eclipse.version>
+ <!-- Component versions == Carbon version, if not, please change the properties below. -->
+ <registry-component.version>4.2.0</registry-component.version>
+ <governance-component.version>4.2.0</governance-component.version>
+ </properties>
+
+
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/249e1290/products/stratos-manager/modules/dashboard/src/main/java/org/apache/stratos/manager/dashboard/ui/clients/CloudManagerServiceClient.java
----------------------------------------------------------------------
diff --git a/products/stratos-manager/modules/dashboard/src/main/java/org/apache/stratos/manager/dashboard/ui/clients/CloudManagerServiceClient.java b/products/stratos-manager/modules/dashboard/src/main/java/org/apache/stratos/manager/dashboard/ui/clients/CloudManagerServiceClient.java
new file mode 100644
index 0000000..cdd9b16
--- /dev/null
+++ b/products/stratos-manager/modules/dashboard/src/main/java/org/apache/stratos/manager/dashboard/ui/clients/CloudManagerServiceClient.java
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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.apache.stratos.manager.dashboard.ui.clients;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.CarbonConstants;
+import org.wso2.carbon.context.CarbonContext;
+import org.wso2.carbon.registry.core.exceptions.RegistryException;
+import org.wso2.carbon.ui.CarbonUIUtil;
+import org.wso2.carbon.utils.ServerConstants;
+import org.apache.stratos.manager.dashboard.stub.CloudManagerServiceStub;
+import org.apache.stratos.manager.dashboard.stub.xsd.CloudService;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletRequest;
+import javax.servlet.http.HttpSession;
+
+public class CloudManagerServiceClient {
+ private static final Log log = LogFactory.getLog(CloudManagerServiceClient.class);
+
+ private CloudManagerServiceStub stub;
+ private String epr;
+ public static final String CLOUD_SERVICE = "cloudService";
+
+ public CloudManagerServiceClient(
+ String cookie, String backendServerURL, ConfigurationContext configContext)
+ throws RegistryException {
+
+ epr = backendServerURL + "CloudManagerService";
+
+ try {
+ stub = new CloudManagerServiceStub(configContext, epr);
+
+ ServiceClient client = stub._getServiceClient();
+ Options option = client.getOptions();
+ option.setManageSession(true);
+ option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
+
+ } catch (AxisFault axisFault) {
+ String msg = "Failed to initiate AddServices service client. " + axisFault.getMessage();
+ log.error(msg, axisFault);
+ throw new RegistryException(msg, axisFault);
+ }
+ }
+
+ public CloudManagerServiceClient(ServletRequest request, ServletConfig config, HttpSession session)
+ throws RegistryException {
+
+ String cookie = (String)session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);
+ String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session);
+ ConfigurationContext configContext = (ConfigurationContext) config.
+ getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
+ epr = backendServerURL + "CloudManagerService";
+
+ try {
+ stub = new CloudManagerServiceStub(configContext, epr);
+
+ ServiceClient client = stub._getServiceClient();
+ Options option = client.getOptions();
+ option.setManageSession(true);
+ option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
+
+ } catch (AxisFault axisFault) {
+ String msg = "Failed to initiate Add Services service client. " + axisFault.getMessage();
+ log.error(msg, axisFault);
+ throw new RegistryException(msg, axisFault);
+ }
+ }
+
+ public CloudService[] retrieveCloudServiceInfo() throws Exception {
+ /*try {
+ if (CarbonContext.getCurrentContext().getCache(null).containsKey(CLOUD_SERVICE)) {
+ return (CloudService[]) CarbonContext.getCurrentContext()
+ .getCache(null).get(CLOUD_SERVICE);
+ }
+ } catch (Exception ignored) {
+ // TODO: this exception needs not be handled, but the situation which leads to this
+ // exception needs to be.
+ }
+ CloudService[] cloudServices = stub.retrieveCloudServiceInfo();
+ CarbonContext.getCurrentContext().getCache(null).put(CLOUD_SERVICE, cloudServices);
+ return cloudServices;*/
+ return null;
+ }
+
+
+ public void saveCloudServicesActivity(String[] activeServiceNames) throws Exception {
+ /* CloudService[] cloudServices =
+ (CloudService[]) CarbonContext.getCurrentContext().getCache(null).get(CLOUD_SERVICE);
+
+ for (CloudService cloudService : cloudServices) {
+ for (String activeService : activeServiceNames) {
+ if (cloudService.getName().equals(activeService)) {
+ cloudService.setActive(true);
+ break;
+ } else {
+ cloudService.setActive(false);
+ }
+ }
+ }
+
+ stub.saveCloudServicesActivity(activeServiceNames);*/
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/249e1290/products/stratos-manager/modules/dashboard/src/main/java/org/apache/stratos/manager/dashboard/ui/utils/Util.java
----------------------------------------------------------------------
diff --git a/products/stratos-manager/modules/dashboard/src/main/java/org/apache/stratos/manager/dashboard/ui/utils/Util.java b/products/stratos-manager/modules/dashboard/src/main/java/org/apache/stratos/manager/dashboard/ui/utils/Util.java
new file mode 100644
index 0000000..9d3e1a1
--- /dev/null
+++ b/products/stratos-manager/modules/dashboard/src/main/java/org/apache/stratos/manager/dashboard/ui/utils/Util.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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.apache.stratos.manager.dashboard.ui.utils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Util {
+ public static List<String> getNewlyActivatedServices(List<String> oldActivateServices,
+ List<String> newActivateServices) {
+ List<String> newlyActivatedServices = new ArrayList<String>();
+ for (String service: newActivateServices) {
+ if (!oldActivateServices.contains(service)) {
+ newlyActivatedServices.add(service);
+ }
+ }
+ return newlyActivatedServices;
+ }
+ public static List<String> getNewlyDeactivatedServices(List<String> oldActivateServices,
+ List<String> newActivateServices) {
+ List<String> newlyDeactivatedServices = new ArrayList<String>();
+ for (String service: oldActivateServices) {
+ if (!newActivateServices.contains(service)) {
+ newlyDeactivatedServices.add(service);
+ }
+ }
+ return newlyDeactivatedServices;
+ }
+
+
+}
+