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 2013/07/06 18:53:18 UTC
[6/7] refactoring org.apache.stratos.common component
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/bff2da51/components/org.apache.stratos.common/2.1.2/src/main/java/org/apache/stratos/common/util/CloudServicesUtil.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/2.1.2/src/main/java/org/apache/stratos/common/util/CloudServicesUtil.java b/components/org.apache.stratos.common/2.1.2/src/main/java/org/apache/stratos/common/util/CloudServicesUtil.java
new file mode 100644
index 0000000..4108973
--- /dev/null
+++ b/components/org.apache.stratos.common/2.1.2/src/main/java/org/apache/stratos/common/util/CloudServicesUtil.java
@@ -0,0 +1,200 @@
+/*
+ * 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.common.util;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+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.internal.CloudCommonServiceComponent;
+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.session.UserRegistry;
+import org.wso2.carbon.user.core.UserStoreException;
+import org.wso2.carbon.user.mgt.UserMgtConstants;
+import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
+
+public class CloudServicesUtil {
+
+ private static final Log log = LogFactory.getLog(CloudServicesUtil.class);
+ // TODO protect using Java security
+
+ public static void activateAllServices(CloudServicesDescConfig cloudServicesDesc, int tenantId) throws Exception {
+
+ java.util.Collection<CloudServiceConfig> cloudServiceConfigList =
+ cloudServicesDesc.getCloudServiceConfigs().
+ values();
+ if (cloudServiceConfigList != null) {
+ for (CloudServiceConfig cloudServiceConfig : cloudServiceConfigList) {
+ if (cloudServiceConfig.isDefaultActive()) {
+ String cloudServiceName = cloudServiceConfig.getName();
+ try {
+ if (!CloudServicesUtil.isCloudServiceActive(cloudServiceName, tenantId)) {
+ CloudServicesUtil.setCloudServiceActive(true,
+ cloudServiceName,
+ tenantId,
+ cloudServicesDesc.getCloudServiceConfigs().
+ get(cloudServiceName));
+ }
+ } catch (Exception e) {
+ String msg = "Error in activating the cloud service at the tenant" +
+ "creation. tenant id: " + tenantId + ", service name: " +
+ cloudServiceName;
+ log.error(msg, e);
+ throw new UserStoreException(msg, e);
+ }
+ }
+ }
+ }
+ }
+
+ public static void activateOriginalAndCompulsoryServices(CloudServicesDescConfig cloudServicesDesc,
+ String originalService,
+ int tenantId) throws Exception {
+
+ Map<String, CloudServiceConfig> cloudServiceConfigs =
+ cloudServicesDesc.getCloudServiceConfigs();
+ if (CloudServicesUtil.isServiceNameValid(cloudServicesDesc, originalService)) {
+ if (!CloudServicesUtil.isCloudServiceActive(originalService, tenantId)) {
+ CloudServicesUtil.setCloudServiceActive(true, originalService, tenantId,
+ cloudServiceConfigs.get(originalService));
+ log.info("Successfully activated the " + originalService + " for the tenant " +
+ tenantId);
+ }
+ // register the compulsory services
+ if (!CloudServicesUtil.isCloudServiceActive(StratosConstants.CLOUD_IDENTITY_SERVICE,
+ tenantId)) {
+ CloudServicesUtil.setCloudServiceActive(true,
+ StratosConstants.CLOUD_IDENTITY_SERVICE,
+ tenantId,
+ cloudServiceConfigs.get(StratosConstants.CLOUD_IDENTITY_SERVICE));
+ }
+ if (!CloudServicesUtil.isCloudServiceActive(StratosConstants.CLOUD_GOVERNANCE_SERVICE,
+ tenantId)) {
+ CloudServicesUtil.setCloudServiceActive(true,
+ StratosConstants.CLOUD_GOVERNANCE_SERVICE,
+ tenantId,
+ cloudServiceConfigs.get(StratosConstants.CLOUD_GOVERNANCE_SERVICE));
+ }
+ } else {
+ log.warn("Unable to activate the " + originalService + " for the tenant " + tenantId);
+ }
+
+ }
+
+ public static void setCloudServiceActive(boolean active,
+ String cloudServiceName,
+ int tenantId, CloudServiceConfig cloudServiceConfig)
+ throws Exception {
+ if (cloudServiceConfig.getLabel() == null) {
+ // for the non-labled services, we are not setting/unsetting the
+ // service active
+ return;
+ }
+
+ UserRegistry govRegistry =
+ CloudCommonServiceComponent.getGovernanceSystemRegistry(
+ MultitenantConstants.SUPER_TENANT_ID);
+ UserRegistry configRegistry = CloudCommonServiceComponent.getConfigSystemRegistry(tenantId);
+ String cloudServiceInfoPath = StratosConstants.CLOUD_SERVICE_INFO_STORE_PATH +
+ RegistryConstants.PATH_SEPARATOR + tenantId +
+ RegistryConstants.PATH_SEPARATOR + cloudServiceName;
+
+ Resource cloudServiceInfoResource;
+ if (govRegistry.resourceExists(cloudServiceInfoPath)) {
+ cloudServiceInfoResource = govRegistry.get(cloudServiceInfoPath);
+ } else {
+ cloudServiceInfoResource = govRegistry.newCollection();
+ }
+ cloudServiceInfoResource.setProperty(StratosConstants.CLOUD_SERVICE_IS_ACTIVE_PROP_KEY,
+ active ? "true" : "false");
+ govRegistry.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 (!configRegistry.resourceExists(path)) {
+ Collection collection = configRegistry.newCollection();
+ collection.setProperty(UserMgtConstants.DISPLAY_NAME, name);
+ configRegistry.put(path, collection);
+ }
+ } else {
+ if (configRegistry.resourceExists(path)) {
+ configRegistry.delete(path);
+ }
+ }
+ }
+ }
+
+ public static boolean isCloudServiceActive(String cloudServiceName,
+ int tenantId) throws Exception {
+ UserRegistry govRegistry = CloudCommonServiceComponent.getGovernanceSystemRegistry(
+ MultitenantConstants.SUPER_TENANT_ID);
+ return isCloudServiceActive(cloudServiceName, tenantId, govRegistry);
+ }
+
+ public static boolean isCloudServiceActive(String cloudServiceName,
+ int tenantId, UserRegistry govRegistry)
+ throws Exception {
+ // The cloud manager is always active
+ if (StratosConstants.CLOUD_MANAGER_SERVICE.equals(cloudServiceName)) {
+ return true;
+ }
+
+ String cloudServiceInfoPath = StratosConstants.CLOUD_SERVICE_INFO_STORE_PATH +
+ RegistryConstants.PATH_SEPARATOR + tenantId +
+ RegistryConstants.PATH_SEPARATOR + cloudServiceName;
+ Resource cloudServiceInfoResource;
+ if (govRegistry.resourceExists(cloudServiceInfoPath)) {
+ cloudServiceInfoResource = govRegistry.get(cloudServiceInfoPath);
+ String isActiveStr =
+ cloudServiceInfoResource.getProperty(
+ StratosConstants.CLOUD_SERVICE_IS_ACTIVE_PROP_KEY);
+ return "true".equals(isActiveStr);
+ }
+ return false;
+ }
+
+ public static boolean isServiceNameValid(CloudServicesDescConfig cloudServicesDesc,
+ String cloudServiceName) {
+ if(cloudServiceName == null) {
+ return false;
+ }
+ java.util.Collection<CloudServiceConfig> cloudServiceConfigList =
+ cloudServicesDesc.getCloudServiceConfigs().values();
+ if (cloudServiceName.equals(StratosConstants.CLOUD_MANAGER_SERVICE)) {
+ return false;
+ }
+ for (CloudServiceConfig cloudServiceConfig : cloudServiceConfigList) {
+ if (cloudServiceConfig.getName().equals(cloudServiceName)) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/bff2da51/components/org.apache.stratos.common/2.1.2/src/main/java/org/apache/stratos/common/util/CommonUtil.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/2.1.2/src/main/java/org/apache/stratos/common/util/CommonUtil.java b/components/org.apache.stratos.common/2.1.2/src/main/java/org/apache/stratos/common/util/CommonUtil.java
new file mode 100644
index 0000000..8adf1e4
--- /dev/null
+++ b/components/org.apache.stratos.common/2.1.2/src/main/java/org/apache/stratos/common/util/CommonUtil.java
@@ -0,0 +1,623 @@
+/*
+ * 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.common.util;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.constants.StratosConstants;
+import org.apache.stratos.common.internal.CloudCommonServiceComponent;
+import org.wso2.carbon.CarbonConstants;
+import org.wso2.carbon.registry.core.ActionConstants;
+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.session.UserRegistry;
+import org.wso2.carbon.registry.core.utils.AccessControlConstants;
+import org.wso2.carbon.user.api.RealmConfiguration;
+import org.wso2.carbon.user.core.AuthorizationManager;
+import org.wso2.carbon.user.core.UserRealm;
+import org.wso2.carbon.user.core.UserStoreException;
+import org.wso2.carbon.user.core.tenant.TenantManager;
+import org.wso2.carbon.utils.CarbonUtils;
+import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.DateFormat;
+import java.text.DateFormatSymbols;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.regex.Pattern;
+
+/**
+ * Common Utility methods for Stratos.
+ * Now this class has been growing with several util methods - Should refactor accordingly.
+ */
+public class CommonUtil {
+ private static final Log log = LogFactory.getLog(CommonUtil.class);
+ private static StratosConfiguration stratosConfig;
+ private static String eula;
+
+
+ private static final String ILLEGAL_CHARACTERS_FOR_EMAIL =
+ ".*[\\(\\)\\<\\>\\,\\;\\:\\\\\\\"\\[\\]].*";
+ private static final String EMAIL_FILTER_STRING = "^[^@]+@[^@.]+\\.[^@]*\\w\\w$";
+ private static Pattern emailFilterPattern = Pattern.compile(EMAIL_FILTER_STRING);
+ private static Pattern illegalCharactersPatternForEmail = Pattern
+ .compile(ILLEGAL_CHARACTERS_FOR_EMAIL);
+
+ public static StratosConfiguration getStratosConfig() {
+ return stratosConfig;
+ }
+
+ public static void setStratosConfig(StratosConfiguration stratosConfig) {
+ CommonUtil.stratosConfig = stratosConfig;
+ }
+
+ public static String getEula() {
+ return eula;
+ }
+
+ public static void setEula(String eula) {
+ CommonUtil.eula = eula;
+ }
+
+ /**
+ * Checks whether the email validation is mandatory from the configuration file.
+ *
+ * @return true, if the email validation is mandatory to login. Default is false.
+ */
+ public static boolean isEmailValidationMandatory() {
+ boolean isEmailValidationMandatory = false; //false by default.
+ if (stratosConfig != null) { //make sure the configuration exists.
+ isEmailValidationMandatory = stratosConfig.getEmailValidationRequired();
+ }
+ return isEmailValidationMandatory;
+ }
+
+ /**
+ * Checks whether the email sending is enabled from the configuration file.
+ *
+ * @return true, if the email sending is disabled. By default, this is disabled, and tenant
+ * activation is done without any email sending.
+ */
+ public static boolean isTenantManagementEmailsDisabled() {
+ boolean isEmailsDisabled = true; //true by default.
+ if (stratosConfig != null) { //make sure the configuration exists.
+ isEmailsDisabled = stratosConfig.isEmailsDisabled();
+ }
+ return isEmailsDisabled;
+ }
+
+ public static String getSuperAdminEmail() {
+ return stratosConfig.getSuperAdminEmail();
+ }
+
+ public static String getAdminUserName() {
+ return stratosConfig.getAdminUserName();
+ }
+
+ public static String getAdminPassword() {
+ return stratosConfig.getAdminPassword();
+ }
+
+ public static boolean isTenantActivationModerated() {
+ return stratosConfig.isTenantActivationModerated();
+ }
+
+ public static boolean isChargedOnRegistration() {
+ return stratosConfig.isChargeOnRegistration();
+ }
+
+ /**
+ * Checks whether it is for the public cloud setup or Mars.
+ *
+ * @return true, if it is not for the private cloud setups. Default is true.
+ */
+ public static boolean isPublicCloudSetup() {
+ boolean isPublicCloudSetup = true; // true by default.
+ if (stratosConfig != null) { //make sure the configuration exists.
+ isPublicCloudSetup = stratosConfig.isPublicCloudSetup();
+ }
+ return isPublicCloudSetup;
+ }
+
+ /**
+ * Gets the notification email address of the admin upon the tenant creation.
+ *
+ * @return notification email address for the tenant creations.
+ */
+ public static String getNotificationEmailAddress() {
+ String notificationEmailAddress = "";
+ if (stratosConfig != null) {
+ notificationEmailAddress = stratosConfig.getNotificationEmail();
+ try {
+ validateEmail(notificationEmailAddress);
+ } catch (Exception e) {
+ if (log.isWarnEnabled()) {
+ log.warn("Invalid Email Address provided for tenant creation notification. " +
+ "Please check whether the parameter NotificationEmail" +
+ " is set properly in " +
+ StratosConstants.STRATOS_CONF_FILE, e);
+ }
+ return "";
+ }
+ }
+ return notificationEmailAddress;
+ }
+
+ public static String getMonthString(Calendar calendar) {
+ int currentMonth = calendar.get(Calendar.MONTH);
+
+ String[] monthArr = new DateFormatSymbols().getMonths();
+ String month = monthArr[currentMonth];
+ return calendar.get(Calendar.YEAR) + "-" + month;
+ }
+
+ public static String getMonthString(int relativeMonth) {
+ Calendar newCalendar = Calendar.getInstance();
+ newCalendar.add(Calendar.MONTH, relativeMonth);
+
+ return CommonUtil.getMonthString(newCalendar);
+ }
+
+ public static Date getDateFromMonthString(String yearMonth) throws ParseException {
+ DateFormat yearMonthFormat = new SimpleDateFormat("yyyy-MMM");
+ return yearMonthFormat.parse(yearMonth);
+ }
+
+ public static String getCurrentMonthString() {
+ Calendar newCalendar = Calendar.getInstance();
+
+ return CommonUtil.getMonthString(newCalendar);
+ }
+
+
+ public static void setAnonAuthorization(String path, UserRealm userRealm)
+ throws RegistryException {
+
+ if (userRealm == null) {
+ return;
+ }
+
+ try {
+ AuthorizationManager accessControlAdmin = userRealm.getAuthorizationManager();
+ String everyoneRole = CarbonConstants.REGISTRY_ANONNYMOUS_ROLE_NAME;
+
+ accessControlAdmin.authorizeRole(everyoneRole, path, ActionConstants.GET);
+ accessControlAdmin.denyRole(everyoneRole, path, ActionConstants.PUT);
+ accessControlAdmin.denyRole(everyoneRole, path, ActionConstants.DELETE);
+ accessControlAdmin.denyRole(everyoneRole, path, AccessControlConstants.AUTHORIZE);
+
+ } catch (UserStoreException e) {
+ String msg = "Could not set authorizations for the " + path + ".";
+ log.error(msg, e);
+ throw new RegistryException(msg);
+ }
+ }
+
+ public static void denyAnonAuthorization(String path, UserRealm userRealm)
+ throws RegistryException {
+ if (userRealm == null) {
+ return;
+ }
+
+ try {
+ AuthorizationManager accessControlAdmin = userRealm.getAuthorizationManager();
+ RealmConfiguration realmConfig;
+ try {
+ realmConfig = userRealm.getRealmConfiguration();
+ } catch (UserStoreException e) {
+ String msg = "Failed to retrieve realm configuration.";
+ log.error(msg, e);
+ throw new RegistryException(msg, e);
+ }
+
+ String everyoneRole = realmConfig.getEveryOneRoleName();
+
+ accessControlAdmin.denyRole(everyoneRole, path, ActionConstants.GET);
+ accessControlAdmin.denyRole(everyoneRole, path, ActionConstants.PUT);
+ accessControlAdmin.denyRole(everyoneRole, path, ActionConstants.DELETE);
+ accessControlAdmin.denyRole(everyoneRole, path, AccessControlConstants.AUTHORIZE);
+
+ } catch (UserStoreException e) {
+ String msg = "Could not clear authorizations for the " + path + ".";
+ log.error(msg, e);
+ throw new RegistryException(msg);
+ }
+ }
+
+ /**
+ * builds the OMElement from the given inputStream
+ *
+ * @param inputStream, given input - inputStream
+ * @return OMElement
+ * @throws Exception, if building OMElement from the inputStream failed.
+ */
+ public static OMElement buildOMElement(InputStream inputStream) throws Exception {
+ XMLStreamReader parser;
+ try {
+ parser = XMLInputFactory.newInstance().createXMLStreamReader(inputStream);
+ } catch (XMLStreamException e) {
+ String msg = "Error in initializing the parser to build the OMElement.";
+ log.error(msg, e);
+ throw new Exception(msg, e);
+ }
+
+ // create the builder
+ StAXOMBuilder builder = new StAXOMBuilder(parser);
+ // get the root element (in this case the envelope)
+
+ return builder.getDocumentElement();
+ }
+
+
+ /**
+ * validates the email
+ *
+ * @param email - email address
+ * @throws Exception, if validation failed
+ */
+ public static void validateEmail(String email) throws Exception {
+ if (email == null) {
+ String msg = "Provided email value is null.";
+ log.warn(msg);
+ throw new Exception(msg);
+ }
+ email = email.trim();
+ if ("".equals(email)) {
+ String msg = "Provided email value is empty.";
+ log.warn(msg);
+ throw new Exception(msg);
+ }
+ if (illegalCharactersPatternForEmail.matcher(email).matches()) {
+ String msg = "Wrong characters in the email.";
+ log.error(msg);
+ throw new Exception(msg);
+ }
+ if (!emailFilterPattern.matcher(email).matches()) {
+ String msg = "Invalid email address is provided.";
+ log.error(msg);
+ throw new Exception(msg);
+ }
+ }
+
+ /**
+ * @param name validate the name.
+ * @param variable entry name.
+ * @throws Exception if empty
+ */
+ public static void validateName(String name, String variable) throws Exception {
+ if (name.trim().equals("")) {
+ String msg = variable + " is not provided.";
+ log.error(msg);
+ throw new Exception(msg);
+ }
+ }
+
+ /**
+ * validates domain from the successkey
+ *
+ * @param governanceSystemRegistry - The governance system registry
+ * @param domain - tenant domain
+ * @param successKey - successkey
+ * @return true, if successfully validated
+ * @throws RegistryException, if validation failed
+ */
+ public static boolean validateDomainFromSuccessKey(UserRegistry governanceSystemRegistry,
+ String domain, String successKey)
+ throws RegistryException {
+ String domainValidatorInfoPath =
+ StratosConstants.DOMAIN_VALIDATOR_INFO_PATH + RegistryConstants.PATH_SEPARATOR +
+ domain + RegistryConstants.PATH_SEPARATOR +
+ StratosConstants.VALIDATION_KEY_RESOURCE_NAME;
+ if (governanceSystemRegistry.resourceExists(domainValidatorInfoPath)) {
+ Resource resource = governanceSystemRegistry.get(domainValidatorInfoPath);
+ String actualSuccessKey = resource.getProperty("successKey");
+ if (actualSuccessKey != null && successKey != null &&
+ actualSuccessKey.trim().equals(successKey.trim())) {
+ // the domain is correct
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Returns the configurations from the stratos configuration file.
+ *
+ * @return stratos configurations
+ */
+ public static StratosConfiguration loadStratosConfiguration() {
+ // gets the configuration file name from the StratosConstants.
+ String StratosConfigFileName = CarbonUtils.getCarbonConfigDirPath() + File.separator +
+ StratosConstants.MULTITENANCY_CONFIG_FOLDER + File.separator +
+ StratosConstants.STRATOS_CONF_FILE;
+ return loadStratosConfiguration(StratosConfigFileName);
+ }
+
+ /**
+ * Loads the given Stratos Configuration file.
+ *
+ * @param configFilename Name of the configuration file
+ * @return the stratos configuration data.
+ */
+ private static StratosConfiguration loadStratosConfiguration(String configFilename) {
+ StratosConfiguration config = new StratosConfiguration();
+ File configFile = new File(configFilename);
+ if (configFile.exists()) {
+ FileInputStream inputStream = null;
+ try {
+ inputStream = new FileInputStream(configFile);
+ XMLStreamReader parser =
+ XMLInputFactory.newInstance().createXMLStreamReader(inputStream);
+ StAXOMBuilder builder = new StAXOMBuilder(parser);
+ OMElement documentElement = builder.getDocumentElement();
+ Iterator it = documentElement.getChildElements();
+ while (it.hasNext()) {
+ OMElement element = (OMElement) it.next();
+
+ if ("DisableTenantManagementEmails".equals(element.getLocalName())) {
+ String disableEmails = element.getText();
+ // by default, make the email validation mandatory.
+ boolean isEmailsDisabled = true;
+ if (disableEmails.trim().equalsIgnoreCase("false")) {
+ isEmailsDisabled = false;
+ }
+ config.setEmailsDisabled(isEmailsDisabled);
+ }
+ // Checks whether Email Validation is mandatory to log in and use the registered
+ // tenants.
+ else if ("EmailValidationMandatoryForLogin".equals(element.getLocalName())) {
+ String emailValidation = element.getText();
+ //by default, make the email validation not mandatory.
+ boolean isEmailValidationRequired = false;
+ if (emailValidation.trim().equalsIgnoreCase("true")) {
+ isEmailValidationRequired = true;
+ }
+ config.setEmailValidationRequired(isEmailValidationRequired);
+ } else if ("ChargeOnRegistration".equals(element.getLocalName())) {
+ String chargeOnRegistration = element.getText();
+ boolean isChargedOnRegistration = false;
+ if (chargeOnRegistration.trim().equalsIgnoreCase("true")) {
+ isChargedOnRegistration = true;
+ }
+ config.setChargeOnRegistration(isChargedOnRegistration);
+ } else if ("NotificationEmail".equals(element.getLocalName())) {
+ config.setNotificationEmail(element.getText());
+ } else if ("SuperAdminEmail".equals(element.getLocalName())) {
+ config.setSuperAdminEmail(element.getText());
+ } else if ("TenantActivationModerated".equals(element.getLocalName())){
+ String isTenantActivationModerated = element.getText();
+ boolean tenantActivationModerated = false;
+ if (isTenantActivationModerated.trim().equalsIgnoreCase("true")) {
+ tenantActivationModerated = true;
+ }
+ config.setTenantActivationModerated(tenantActivationModerated);
+ }
+ //Checks whether it is public cloud deployment.
+ else if ("StratosPublicCloudSetup".equals(element.getLocalName())) {
+ String cloudSetup = element.getText();
+ //by default, make the email validation mandatory.
+ boolean isStratosPublicCloudSetup = true;
+ if (cloudSetup.trim().equalsIgnoreCase("false")) {
+ isStratosPublicCloudSetup = false;
+ }
+ config.setPublicCloudSetup(isStratosPublicCloudSetup);
+ //Setting the paypal url
+ } else if ("PaypalUrl".equals(element.getLocalName())) {
+ String paypalUrl = element.getText();
+ config.setPaypalUrl(paypalUrl);
+ } else if ("SkipSummaryGenerator".equals(element.getLocalName())) {
+ String summaryGenerator = element.getText();
+ boolean skipSummaryGenerator = false;
+ if (summaryGenerator.trim().equalsIgnoreCase("true")) {
+ skipSummaryGenerator = true;
+ }
+ config.setSkipSummaryGenerator(skipSummaryGenerator);
+ }
+ else if ("PaypalAPIUsername".equals(element.getLocalName())) {
+ config.setPaypalAPIUsername(element.getText());
+ } else if ("PaypalAPIPassword".equals(element.getLocalName())) {
+ config.setPaypalAPIPassword(element.getText());
+ } else if ("PaypalAPISignature".equals(element.getLocalName())) {
+ config.setPaypalAPISignature(element.getText());
+ }else if ("PaypalEnvironment".equals(element.getLocalName())){
+ config.setPaypalEnvironment(element.getText());
+ }else if("FinanceNotificationEmail".equals(element.getLocalName())){
+ config.setFinanceNotificationEmail(element.getText());
+ }else if("UsagePlanUrl".equals(element.getLocalName())){
+ config.setUsagePlanURL(element.getText());
+ }else if("PaidJIRAUrl".equals(element.getLocalName())) {
+ config.setPaidJIRAUrl(element.getText());
+ }else if("PaidJIRAProject".equals(element.getLocalName())) {
+ config.setPaidJIRAProject(element.getText());
+ }else if("ForumUrl".equals(element.getLocalName())) {
+ config.setForumUrl(element.getText());
+ }else if("PaidUserGroup".equals(element.getLocalName())) {
+ config.setPaidUserGroup(element.getText());
+ }else if("NonpaidUserGroup".equals(element.getLocalName())) {
+ config.setNonpaidUserGroup(element.getText());
+ } else if("SupportInfoUrl".equals(element.getLocalName())) {
+ config.setSupportInfoUrl(element.getText());
+ }else if("IncidentCustomFieldId".equals(element.getLocalName())) {
+ config.setIncidentCustomFieldId(element.getText());
+ } else if("IncidentImpactCustomFieldId".equals(element.getLocalName())) {
+ config.setIncidentImpactCustomFieldId(element.getText());
+ } else if ("GoogleAnalyticsURL".equals(element.getLocalName())) {
+ config.setGoogleAnalyticsURL(element.getText());
+ } else if("StratosEventListener".equals(element.getLocalName())) {
+ populateEventListenerProperties(config, element);
+ } else if ("managerServiceUrl".equals(element.getLocalName())) {
+ config.setManagerServiceUrl(element.getText());
+ } else if ("adminUserName".equals(element.getLocalName())) {
+ config.setAdminUserName(element.getText());
+ } else if ("adminPassword".equals(element.getLocalName())) {
+ config.setAdminPassword(element.getText());
+ } else if("SSOLoadingMessage".equals(element.getLocalName())){
+ config.setSsoLoadingMessage(element.getText());
+ }
+ }
+ return config;
+ } catch (Exception e) {
+ String msg = "Error in loading Stratos Configurations File: " + configFilename + ".";
+ log.error(msg, e);
+ return config; //returns the default configurations, if the file could not be loaded.
+ } finally {
+ if (inputStream != null) {
+ try {
+ inputStream.close();
+ } catch (IOException e) {
+ log.error("Could not close the Configuration File " + configFilename);
+ }
+ }
+ }
+ }
+ log.error("Unable to locate the stratos configurations file. " +
+ "Default Settings will be used.");
+ return config; // return the default configuratiosn, if the file not found.
+ }
+
+
+ private static void populateEventListenerProperties(StratosConfiguration config,
+ OMElement element) throws RegistryException {
+ config.setStratosEventListenerName(element.getAttributeValue(new QName("class")));
+ Iterator<?> ite =
+ element.getChildrenWithName(new QName("Property"));
+ while (ite.hasNext()) {
+ OMElement propElem = (OMElement) ite.next();
+ String propName = propElem.getAttributeValue(new QName("name"));
+ String propValue = propElem.getText();
+ config.setStratosEventListenerProperty(propName, propValue);
+ }
+ }
+
+ /**
+ * Loading the EULA.
+ * ultimately we shall be loading the eula from the web page itself.
+ * But loading from file should be there to customize the EULA based on the private deployments,
+ * etc.
+ *
+ * @return eula
+ */
+ public static String loadTermsOfUsage() {
+ // currently loads from the file; gets the eula file name from the StratosConstants.
+ String StratosEULAFileName = CarbonUtils.getCarbonConfigDirPath() + File.separator +
+ StratosConstants.MULTITENANCY_CONFIG_FOLDER + File.separator +
+ StratosConstants.STRATOS_EULA;
+ return loadTermsOfUsage(StratosEULAFileName);
+ }
+
+ private static String loadTermsOfUsage(String eulaFile) {
+ String eula = StratosConstants.STRATOS_EULA_DEFAULT_TEXT;
+ File configFile = new File(eulaFile);
+ if (configFile.exists()) {
+ FileInputStream inputStream = null;
+ try {
+ inputStream = new FileInputStream(configFile);
+ XMLStreamReader parser =
+ XMLInputFactory.newInstance().createXMLStreamReader(inputStream);
+ StAXOMBuilder builder = new StAXOMBuilder(parser);
+ OMElement documentElement = builder.getDocumentElement();
+ Iterator it = documentElement.getChildElements();
+ while (it.hasNext()) {
+ OMElement element = (OMElement) it.next();
+
+ //Checks whether Email Validation is mandatory for tenant registration complete.
+ if ("EULA".equalsIgnoreCase(element.getLocalName())) {
+ eula = element.getText();
+ }
+ }
+ return eula;
+ } catch (Exception e) {
+ String msg = "Error in loading Stratos Terms and Conditions File.";
+ log.error(msg, e);
+ return eula; //returns the default text, if the file could not be loaded.
+ } finally {
+ if (inputStream != null) {
+ try {
+ inputStream.close();
+ } catch (IOException e) {
+ log.error("Could not close the EULA File " + eulaFile);
+ }
+ }
+ }
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Unable to locate the stratos EULA file. Default value will be used.");
+ }
+ return eula; // return the default, if the file not found.
+ }
+
+
+ /**
+ * method to check whether a domain name is available to register given a domain name
+ * @param tenantDomain, domain name
+ * @return true, if the domain is available to register
+ * @throws Exception, if checking the existence of the tenant is failed.
+ */
+ public static boolean isDomainNameAvailable(String tenantDomain) throws Exception {
+
+ TenantManager tenantManager = CloudCommonServiceComponent.getTenantManager();
+ // The registry reserved words are checked first.
+ if (tenantDomain.equals("atom") || tenantDomain.equals("registry")
+ || tenantDomain.equals("resource")) {
+ String msg = "You can not use a registry reserved word:" + tenantDomain +
+ ":as a tenant domain. Please choose a different one.";
+ log.error(msg);
+ throw new Exception(msg);
+ }
+
+ int tenantId;
+ try {
+ tenantId = tenantManager.getTenantId(tenantDomain);
+ } catch (UserStoreException e) {
+ String msg = "Error in getting the tenant id for the given domain " +
+ tenantDomain + ".";
+ log.error(msg);
+ throw new Exception(msg, e);
+ }
+
+ // check a tenant with same domain exist.
+ if ((tenantId != MultitenantConstants.INVALID_TENANT_ID && tenantId != MultitenantConstants.SUPER_TENANT_ID) ||
+ tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) {
+ String msg =
+ "A tenant with same domain already exist. " +
+ "Please use a different domain name. tenant domain: " +
+ tenantDomain + ".";
+ log.info(msg);
+ return false;
+ }
+ return true;
+ }
+}
+
+
+
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/bff2da51/components/org.apache.stratos.common/2.1.2/src/main/java/org/apache/stratos/common/util/MeteringAccessValidationUtils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/2.1.2/src/main/java/org/apache/stratos/common/util/MeteringAccessValidationUtils.java b/components/org.apache.stratos.common/2.1.2/src/main/java/org/apache/stratos/common/util/MeteringAccessValidationUtils.java
new file mode 100644
index 0000000..4dc269e
--- /dev/null
+++ b/components/org.apache.stratos.common/2.1.2/src/main/java/org/apache/stratos/common/util/MeteringAccessValidationUtils.java
@@ -0,0 +1,53 @@
+/*
+ * 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.common.util;
+
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+
+public class MeteringAccessValidationUtils {
+
+ public static final String ERROR_MSG_PROPERTY_KEY_POST_FIX = "error_msg";
+ public static final String IS_BLOCKED_PROPERTY_KEY_POST_FIX = "is_blocked";
+
+ public static String generateIsBlockedPropertyKey(String action) {
+ return action + "_" + IS_BLOCKED_PROPERTY_KEY_POST_FIX;
+ }
+
+ public static String generateErrorMsgPropertyKey(String action) {
+ return action + "_" + ERROR_MSG_PROPERTY_KEY_POST_FIX;
+ }
+
+ public static Set<String> getAvailableActions(Properties properties) {
+ Set propertyKeys = properties.keySet();
+ Set<String> actions = new HashSet<String>();
+ for (Object propertyKeyObj : propertyKeys) {
+ String propertyKey = (String) propertyKeyObj;
+ if (propertyKey.endsWith(IS_BLOCKED_PROPERTY_KEY_POST_FIX)) {
+ // -1 for the length of the '_'
+ String action =
+ propertyKey.substring(0, propertyKey.length() -
+ IS_BLOCKED_PROPERTY_KEY_POST_FIX.length() - 1);
+ actions.add(action);
+ }
+ }
+ return actions;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/bff2da51/components/org.apache.stratos.common/2.1.2/src/main/java/org/apache/stratos/common/util/StratosConfiguration.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/2.1.2/src/main/java/org/apache/stratos/common/util/StratosConfiguration.java b/components/org.apache.stratos.common/2.1.2/src/main/java/org/apache/stratos/common/util/StratosConfiguration.java
new file mode 100644
index 0000000..2226593
--- /dev/null
+++ b/components/org.apache.stratos.common/2.1.2/src/main/java/org/apache/stratos/common/util/StratosConfiguration.java
@@ -0,0 +1,319 @@
+/*
+ * 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.common.util;
+
+import java.lang.String;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Class for the stratos specific parameters configuration
+ */
+public class StratosConfiguration {
+
+ // By default email sending is disabled. Changed according to the configuration file.
+ private boolean emailsDisabled = true;
+
+ private boolean emailValidationRequired = false;
+ private boolean isPublicCloudSetup = true;
+ private boolean isTenantActivationModerated = false;
+ private boolean chargeOnRegistration = false;
+ private String SuperAdminEmail = "";
+ private String paypalUrl = "";
+ private String paypalAPIUsername = "";
+ private String paypalAPIPassword = "";
+ private String paypalAPISignature = "";
+ private String paypalEnvironment="";
+ private String usagePlanURL = "";
+ private String paidJIRAUrl = "";
+ private String paidJIRAProject = "";
+ private String forumUrl = "";
+ private String paidUserGroup = "";
+ private String nonpaidUserGroup = "";
+ private String supportInfoUrl = "";
+ private String incidentCustomFieldId = ""; // todo this is a custom field id of JIRA, this need to be dynamically get in jira reporting component
+ private String incidentImpactCustomFieldId = "";
+ private String stratosEventListenerName ="";
+ private Map<String, String> stratosEventProperties = new HashMap<String, String>();
+ private String googleAnalyticsURL;
+ private String managerServiceUrl = "";
+ private String adminUserName = "";
+ private String adminPassword = "";
+ private String ssoLoadingMessage="";
+
+ /**
+ * @return Stratos Manager service url
+ */
+ public String getManagerServiceUrl() {
+ return managerServiceUrl;
+ }
+
+ public void setManagerServiceUrl(String managerServiceUrl) {
+ this.managerServiceUrl = managerServiceUrl;
+ }
+
+ /**
+ * @return Super admin User name
+ */
+ public String getAdminUserName() {
+ return adminUserName;
+ }
+
+ public void setAdminUserName(String adminUserName) {
+ this.adminUserName = adminUserName;
+ }
+
+ /**
+ * @return super admin password
+ */
+ public String getAdminPassword() {
+ return adminPassword;
+ }
+
+ public void setAdminPassword(String adminPassword) {
+ this.adminPassword = adminPassword;
+ }
+
+ //This parameter used to skip usage summary generator
+ private boolean skipSummaryGenerator = false;
+
+ public boolean isSkipSummaryGenerator() {
+ return skipSummaryGenerator;
+ }
+
+ public void setSkipSummaryGenerator(boolean skipSummaryGenerator) {
+ this.skipSummaryGenerator = skipSummaryGenerator;
+ }
+ //This is the url that we pointed users when they need to aware about usage plans
+
+ public String getUsagePlanURL() {
+ return usagePlanURL;
+ }
+
+ public void setUsagePlanURL(String usagePlanURL) {
+ this.usagePlanURL = usagePlanURL;
+ }
+
+ //Email address for general notifications
+ private String notificationEmail = "";
+ //Email address for finance related notifications
+ private String financeNotificationEmail = "";
+
+ public boolean isTenantActivationModerated() {
+ return isTenantActivationModerated;
+ }
+
+ public void setTenantActivationModerated(boolean tenantActivationModerated) {
+ isTenantActivationModerated = tenantActivationModerated;
+ }
+
+ public String getSuperAdminEmail() {
+ return SuperAdminEmail;
+ }
+
+ public void setSuperAdminEmail(String superAdminEmail) {
+ SuperAdminEmail = superAdminEmail;
+ }
+
+ public boolean getEmailValidationRequired() {
+ return emailValidationRequired;
+ }
+
+ public String getPaypalUrl() {
+ return paypalUrl;
+ }
+
+ public void setPaypalUrl(String paypalUrl) {
+ this.paypalUrl = paypalUrl;
+ }
+
+ public void setEmailValidationRequired(boolean emailValidationRequired) {
+ this.emailValidationRequired = emailValidationRequired;
+ }
+
+ public boolean isPublicCloudSetup() {
+ return isPublicCloudSetup;
+ }
+
+ public void setPublicCloudSetup(boolean publicCloudSetup) {
+ isPublicCloudSetup = publicCloudSetup;
+ }
+
+ public String getNotificationEmail() {
+ return notificationEmail;
+ }
+
+ public void setNotificationEmail(String notificationEmail) {
+ this.notificationEmail = notificationEmail;
+ }
+
+ public String getPaypalAPIUsername() {
+ return paypalAPIUsername;
+ }
+
+ public void setPaypalAPIUsername(String paypalAPIUsername) {
+ this.paypalAPIUsername = paypalAPIUsername;
+ }
+
+ public String getPaypalAPIPassword() {
+ return paypalAPIPassword;
+ }
+
+ public void setPaypalAPIPassword(String paypalAPIPassword) {
+ this.paypalAPIPassword = paypalAPIPassword;
+ }
+
+ public String getPaypalAPISignature() {
+ return paypalAPISignature;
+ }
+
+ public void setPaypalAPISignature(String paypalAPISignature) {
+ this.paypalAPISignature = paypalAPISignature;
+ }
+
+ public String getFinanceNotificationEmail() {
+ return financeNotificationEmail;
+ }
+
+ public void setFinanceNotificationEmail(String financeNotificationEmail) {
+ this.financeNotificationEmail = financeNotificationEmail;
+ }
+
+ public String getPaidJIRAUrl() {
+ return paidJIRAUrl;
+ }
+
+ public void setPaidJIRAUrl(String paidJIRAUrl) {
+ this.paidJIRAUrl = paidJIRAUrl;
+ }
+
+ public String getPaidJIRAProject() {
+ return paidJIRAProject;
+ }
+
+ public void setPaidJIRAProject(String paidJIRAProject) {
+ this.paidJIRAProject = paidJIRAProject;
+ }
+
+ public String getForumUrl() {
+ return forumUrl;
+ }
+
+ public void setForumUrl(String forumUrl) {
+ this.forumUrl = forumUrl;
+ }
+
+ public String getPaidUserGroup() {
+ return paidUserGroup;
+ }
+
+ public void setPaidUserGroup(String paidUserGroup) {
+ this.paidUserGroup = paidUserGroup;
+ }
+
+ public String getNonpaidUserGroup() {
+ return nonpaidUserGroup;
+ }
+
+ public void setNonpaidUserGroup(String nonpaidUserGroup) {
+ this.nonpaidUserGroup = nonpaidUserGroup;
+ }
+
+ public String getSupportInfoUrl() {
+ return supportInfoUrl;
+ }
+
+ public void setSupportInfoUrl(String supportInfoUrl) {
+ this.supportInfoUrl = supportInfoUrl;
+ }
+
+ public String getIncidentCustomFieldId() {
+ return incidentCustomFieldId;
+ }
+
+ public void setIncidentCustomFieldId(String incidentCustomFieldId) {
+ this.incidentCustomFieldId = incidentCustomFieldId;
+ }
+
+ public String getIncidentImpactCustomFieldId() {
+ return incidentImpactCustomFieldId;
+ }
+
+ public void setIncidentImpactCustomFieldId(String incidentImpactCustomFieldId) {
+ this.incidentImpactCustomFieldId = incidentImpactCustomFieldId;
+ }
+
+ public String getStratosEventListenerName() {
+ return stratosEventListenerName;
+ }
+
+ public void setStratosEventListenerName(String stratosEventListenerName) {
+ this.stratosEventListenerName = stratosEventListenerName;
+ }
+
+ public String getStratosEventListenerPropertyValue(String key) {
+ return stratosEventProperties.get(key);
+ }
+
+ public void setStratosEventListenerProperty(String key, String value) {
+ stratosEventProperties.put(key, value);
+ }
+
+ public String getPaypalEnvironment() {
+ return paypalEnvironment;
+ }
+
+ public void setPaypalEnvironment(String paypalEnvironment) {
+ this.paypalEnvironment = paypalEnvironment;
+ }
+
+ public String getGoogleAnalyticsURL() {
+ return googleAnalyticsURL;
+ }
+
+ public void setGoogleAnalyticsURL(String googleAnalyticsURL) {
+ this.googleAnalyticsURL = googleAnalyticsURL;
+ }
+
+ public boolean isEmailsDisabled() {
+ return emailsDisabled;
+ }
+
+ public void setEmailsDisabled(boolean emailsDisabled) {
+ this.emailsDisabled = emailsDisabled;
+ }
+
+ public boolean isChargeOnRegistration() {
+ return chargeOnRegistration;
+ }
+
+ public void setChargeOnRegistration(boolean chargeOnRegistration) {
+ this.chargeOnRegistration = chargeOnRegistration;
+ }
+
+ public String getSsoLoadingMessage() {
+ return ssoLoadingMessage;
+ }
+
+ public void setSsoLoadingMessage(String ssoLoadingMessage) {
+ this.ssoLoadingMessage = ssoLoadingMessage;
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/bff2da51/components/org.apache.stratos.common/2.1.2/src/main/resources/META-INF/services.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/2.1.2/src/main/resources/META-INF/services.xml b/components/org.apache.stratos.common/2.1.2/src/main/resources/META-INF/services.xml
new file mode 100644
index 0000000..7f0bcf3
--- /dev/null
+++ b/components/org.apache.stratos.common/2.1.2/src/main/resources/META-INF/services.xml
@@ -0,0 +1,34 @@
+<?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="PackageInfoService" scope="transportsession">
+ <transports>
+ <transport>https</transport>
+ </transports>
+ <parameter name="ServiceClass" locked="false">
+ org.apache.stratos.common.services.PackageInfoService
+ </parameter>
+ <parameter name="adminService" locked="ture">false</parameter>
+ </service>
+
+ <parameter name="hiddenService" locked="ture">true</parameter>
+
+</serviceGroup>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/bff2da51/components/org.apache.stratos.common/2.1.2/src/main/resources/cloud-services-desc.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/2.1.2/src/main/resources/cloud-services-desc.xml b/components/org.apache.stratos.common/2.1.2/src/main/resources/cloud-services-desc.xml
new file mode 100644
index 0000000..15fb4b9
--- /dev/null
+++ b/components/org.apache.stratos.common/2.1.2/src/main/resources/cloud-services-desc.xml
@@ -0,0 +1,109 @@
+<!--
+ ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ ~
+ ~ WSO2 Inc. licenses this file to you under the Apache License,
+ ~ Version 2.0 (the "License"); you may not use this file except
+ ~ in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<cloudServices xmlns="http://wso2.com/carbon/cloud/mgt/services">
+ <cloudService name="WSO2 Stratos Manager">
+ </cloudService>
+ <cloudService name="WSO2 Enterprise Service Bus" default="true">
+ <label>Enterprise Service Bus</label>
+ <link>https://esb.stratoslive.wso2.com</link>
+ <icon>
+ https://localhost:9443/cloud-services-icons/esb.gif
+ </icon>
+ <description>Enterprise Service Bus in the cloud.</description>
+ </cloudService>
+ <cloudService name="WSO2 Application Server" default="true">
+ <label>Application Server</label>
+ <link>https://appserver.stratoslive.wso2.com</link>
+ <icon>
+ https://localhost:9443/cloud-services-icons/appserver.gif
+ </icon>
+ <description>Application Server in the cloud.</description>
+ </cloudService>
+ <cloudService name="WSO2 Data Services Server" default="true">
+ <label>Data Services Server</label>
+ <link>https://dss.stratoslive.wso2.com</link>
+ <icon>
+ https://localhost:9443/cloud-services-icons/ds.gif
+ </icon>
+ <description>Data Services Server in the cloud.</description>
+ </cloudService>
+ <cloudService name="WSO2 Governance" default="true">
+ <label>Governance</label>
+ <link>https://governance.stratoslive.wso2.com</link>
+ <description>Governance in the cloud.</description>
+ <icon>
+ https://localhost:9443/cloud-services-icons/governance.gif
+ </icon>
+ </cloudService>
+ <cloudService name="WSO2 Identity" default="true">
+ <label>Identity</label>
+ <link>https://identity.stratoslive.wso2.com</link>
+ <icon>
+ https://localhost:9443/cloud-services-icons/identity.gif
+ </icon>
+ <description>Identity in the cloud.</description>
+ </cloudService>
+ <cloudService name="WSO2 Business Activity Monitor" default="true">
+ <label>Business Activity Monitor</label>
+ <link>https://bam.stratoslive.wso2.com</link>
+ <icon>
+ https://localhost:9443/cloud-services-icons/bam.gif
+ </icon>
+ <description>Business Activity Monitor in the cloud.</description>
+ </cloudService>
+ <cloudService name="WSO2 Business Process Server" default="true">
+ <label>Business Process Server</label>
+ <link>https://bps.stratoslive.wso2.com</link>
+ <icon>
+ https://localhost:9443/cloud-services-icons/bps.gif
+ </icon>
+ <description>Business Process Server in the cloud.</description>
+ </cloudService>
+ <cloudService name="WSO2 Business Rule Server" default="true">
+ <label>Business Rule Server</label>
+ <link>https://brs.stratoslive.wso2.com</link>
+ <icon>
+ https://localhost:9443/cloud-services-icons/brs.gif
+ </icon>
+ <description>Business Rule Server in the cloud.</description>
+ </cloudService>
+ <cloudService name="WSO2 Mashup Server" default="true">
+ <label>Mashup Server</label>
+ <link>https://mashup.stratoslive.wso2.com</link>
+ <icon>
+ https://localhost:9443/cloud-services-icons/mashup.gif
+ </icon>
+ <description>Mashup Server in the cloud.</description>
+ </cloudService>
+ <cloudService name="WSO2 Gadgets" default="true">
+ <label>Gadgets</label>
+ <link>https://gadget.stratoslive.wso2.com</link>
+ <icon>
+ https://localhost:9443/cloud-services-icons/gadget.gif
+ </icon>
+ <description>Gadgets in the cloud.</description>
+ </cloudService>
+ <cloudService name="WSO2 Cloud Services Gateway" default="true">
+ <label>Cloud Gateway</label>
+ <link>https://csg.stratoslive.wso2.com</link>
+ <icon>
+ https://localhost:9443/cloud-services-icons/csg.gif
+ </icon>
+ <description>WSO2 Cloud Services Gateway in the cloud.</description>
+ </cloudService>
+</cloudServices>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/bff2da51/components/org.apache.stratos.common/2.1.2/src/test/java/org/apache/stratos/common/test/CommonTest.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/2.1.2/src/test/java/org/apache/stratos/common/test/CommonTest.java b/components/org.apache.stratos.common/2.1.2/src/test/java/org/apache/stratos/common/test/CommonTest.java
new file mode 100644
index 0000000..dc61fc4
--- /dev/null
+++ b/components/org.apache.stratos.common/2.1.2/src/test/java/org/apache/stratos/common/test/CommonTest.java
@@ -0,0 +1,49 @@
+/*
+ * 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.common.test;
+
+import junit.framework.TestCase;
+import org.apache.stratos.common.util.CommonUtil;
+
+public class CommonTest extends TestCase {
+ public void testEmailValidation() throws Exception {
+ try {
+ CommonUtil.validateEmail("damn@right.com");
+ assertTrue(true);
+ } catch (Exception e) {
+ assertTrue(false);
+ }
+
+ try {
+ CommonUtil.validateEmail("damn@right].com");
+ assertTrue(false);
+ } catch (Exception e) {
+ assertTrue(true);
+ assertEquals("Wrong characters in the email.", e.getMessage());
+ }
+
+ try {
+ CommonUtil.validateEmail("damn@right@wrong.com");
+ assertTrue(false);
+ } catch (Exception e) {
+ assertTrue(true);
+ assertEquals("Invalid email address is provided.", e.getMessage());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/bff2da51/components/pom.xml
----------------------------------------------------------------------
diff --git a/components/pom.xml b/components/pom.xml
index 92d256d..d316c7f 100644
--- a/components/pom.xml
+++ b/components/pom.xml
@@ -64,6 +64,8 @@
<module>org.apache.stratos.lb.common/4.1.3</module>
<module>autoscaler/org.apache.stratos.mediator.autoscale/4.1.3</module>
<module>autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0</module>
+ <!-- COMMON -->
+ <module>org.apache.stratos.common/2.1.2</module>
</modules>
<build>
@@ -164,6 +166,21 @@
<artifactId>org.wso2.carbon.base</artifactId>
<version>${carbon.platform.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.wso2.carbon</groupId>
+ <artifactId>org.wso2.carbon.registry.core</artifactId>
+ <version>${carbon.platform.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.wso2.carbon</groupId>
+ <artifactId>org.wso2.carbon.user.core</artifactId>
+ <version>${carbon.platform.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.wso2.carbon</groupId>
+ <artifactId>org.wso2.carbon.user.mgt</artifactId>
+ <version>${carbon.platform.version}</version>
+ </dependency>
<!-- Axis2 -->
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/bff2da51/components/stratos/org.wso2.carbon.stratos.common/2.1.0/pom.xml
----------------------------------------------------------------------
diff --git a/components/stratos/org.wso2.carbon.stratos.common/2.1.0/pom.xml b/components/stratos/org.wso2.carbon.stratos.common/2.1.0/pom.xml
deleted file mode 100644
index 3c31500..0000000
--- a/components/stratos/org.wso2.carbon.stratos.common/2.1.0/pom.xml
+++ /dev/null
@@ -1,87 +0,0 @@
-<!--
-# Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-#
-# Licensed 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.wso2.carbon</groupId>
- <artifactId>stratos-components</artifactId>
- <version>2.1.0</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <artifactId>org.wso2.carbon.stratos.common</artifactId>
- <version>2.1.0</version>
- <packaging>bundle</packaging>
- <name>WSO2 Stratos - Common</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>
- <Export-Package>
- org.wso2.carbon.stratos.common.*,
- </Export-Package>
- <Import-Package>
- org.wso2.carbon.registry.core.*;version=1.0.1,
- org.wso2.carbon.user.core.*,
- javax.servlet;version="${imp.pkg.version.javax.servlet}",
- javax.servlet.http;version="${imp.pkg.version.javax.servlet}",
- 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>${carbon.platform.version}</version>
- </dependency>
- <dependency>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.user.core</artifactId>
- <version>${carbon.platform.version}</version>
- </dependency>
- <dependency>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.user.mgt</artifactId>
- <version>${carbon.platform.version}</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/bff2da51/components/stratos/org.wso2.carbon.stratos.common/2.1.0/src/main/java/org/wso2/carbon/stratos/common/TenantBillingService.java
----------------------------------------------------------------------
diff --git a/components/stratos/org.wso2.carbon.stratos.common/2.1.0/src/main/java/org/wso2/carbon/stratos/common/TenantBillingService.java b/components/stratos/org.wso2.carbon.stratos.common/2.1.0/src/main/java/org/wso2/carbon/stratos/common/TenantBillingService.java
deleted file mode 100644
index e2bff75..0000000
--- a/components/stratos/org.wso2.carbon.stratos.common/2.1.0/src/main/java/org/wso2/carbon/stratos/common/TenantBillingService.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.wso2.carbon.stratos.common;
-
-import org.wso2.carbon.stratos.common.exception.StratosException;
-import org.wso2.carbon.user.api.Tenant;
-
-/**
- * The OSGI service interface that enables tenant related billing actions.
- */
-public interface TenantBillingService {
-
- public void addUsagePlan(Tenant tenant, String usagePlan) throws StratosException;
-
- public String getActiveUsagePlan(String tenantDomain) throws StratosException;
-
- public void updateUsagePlan(String tenantDomain, String usagePlan) throws StratosException;
-
- public void activateUsagePlan(String tenantDomain) throws StratosException;
-
- public void deactivateActiveUsagePlan(String tenantDomain) throws StratosException;
-
- public void deleteBillingData(int tenantId) throws StratosException;
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/bff2da51/components/stratos/org.wso2.carbon.stratos.common/2.1.0/src/main/java/org/wso2/carbon/stratos/common/beans/TenantInfoBean.java
----------------------------------------------------------------------
diff --git a/components/stratos/org.wso2.carbon.stratos.common/2.1.0/src/main/java/org/wso2/carbon/stratos/common/beans/TenantInfoBean.java b/components/stratos/org.wso2.carbon.stratos.common/2.1.0/src/main/java/org/wso2/carbon/stratos/common/beans/TenantInfoBean.java
deleted file mode 100755
index 8470a39..0000000
--- a/components/stratos/org.wso2.carbon.stratos.common/2.1.0/src/main/java/org/wso2/carbon/stratos/common/beans/TenantInfoBean.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (c) 2005-2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.wso2.carbon.stratos.common.beans;
-
-import java.util.Calendar;
-
-/**
- * Bean class for Tenant Information
- */
-public class TenantInfoBean {
-
- private String admin; //admin's user name
- private String firstname;
- private String lastname;
- private String adminPassword;
- private String tenantDomain;
- private int tenantId;
- private String email;
- private boolean active;
- private String successKey;
- Calendar createdDate;
- private String originatedService;
- private String usagePlan;
-
- public String getFirstname() {
- return firstname;
- }
-
- public void setFirstname(String firstname) {
- this.firstname = firstname;
- }
-
- public String getLastname() {
- return lastname;
- }
-
- public void setLastname(String lastname) {
- this.lastname = lastname;
- }
-
- public String getEmail() {
-
- return email;
- }
-
- public void setEmail(String email) {
- this.email = email;
- }
-
- public int getTenantId() {
- return tenantId;
- }
-
- public void setTenantId(int tenantId) {
- this.tenantId = tenantId;
- }
-
- public String getTenantDomain() {
- return tenantDomain;
- }
-
- public void setTenantDomain(String tenantDomain) {
- this.tenantDomain = tenantDomain;
- }
-
- public String getAdmin() {
- return admin;
- }
-
- public void setAdmin(String admin) {
- this.admin = admin;
- }
-
- public String getAdminPassword() {
- return adminPassword;
- }
-
- public void setAdminPassword(String adminPassword) {
- this.adminPassword = adminPassword;
- }
-
- public boolean isActive() {
- return active;
- }
-
- public void setActive(boolean active) {
- this.active = active;
- }
-
- public String getSuccessKey() {
- return successKey;
- }
-
- public void setSuccessKey(String successKey) {
- this.successKey = successKey;
- }
-
- public Calendar getCreatedDate() {
- return createdDate;
- }
-
- public void setCreatedDate(Calendar createdDate) {
- this.createdDate = createdDate;
- }
-
- public String getOriginatedService() {
- return originatedService;
- }
-
- public void setOriginatedService(String originatedService) {
- this.originatedService = originatedService;
- }
-
- public String getUsagePlan() {
- return usagePlan;
- }
-
- public void setUsagePlan(String usagePlan) {
- this.usagePlan = usagePlan;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/bff2da51/components/stratos/org.wso2.carbon.stratos.common/2.1.0/src/main/java/org/wso2/carbon/stratos/common/config/CloudServiceConfig.java
----------------------------------------------------------------------
diff --git a/components/stratos/org.wso2.carbon.stratos.common/2.1.0/src/main/java/org/wso2/carbon/stratos/common/config/CloudServiceConfig.java b/components/stratos/org.wso2.carbon.stratos.common/2.1.0/src/main/java/org/wso2/carbon/stratos/common/config/CloudServiceConfig.java
deleted file mode 100644
index a776bf2..0000000
--- a/components/stratos/org.wso2.carbon.stratos.common/2.1.0/src/main/java/org/wso2/carbon/stratos/common/config/CloudServiceConfig.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.wso2.carbon.stratos.common.config;
-
-import org.apache.axiom.om.OMElement;
-
-import javax.xml.namespace.QName;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-public class CloudServiceConfig {
- private static final String CONFIG_NS = "http://wso2.com/carbon/cloud/mgt/services";
-
- private static final String NAME_ATTR_NAME = "name";
- private static final String DEFAULT_ATTR_NAME = "default";
- private static final String LABEL_ELEMENT_NAME = "label";
- private static final String LINK_ELEMENT_NAME = "link";
- private static final String ICON_ELEMENT_NAME = "icon";
- private static final String DESCRIPTION_ELEMENT_NAME = "description";
- private static final String PERMISSIONS_ELEMENT_NAME = "permissions";
- private static final String PERMISSION_ELEMENT_NAME = "permission";
- private static final String PRODUCT_PAGE_URL_ELEMENT_NAME = "productPageURL";
-
- private String name;
- private String label;
- private String link;
- private String icon;
- private String description;
- private List<PermissionConfig> permissionConfigs;
- boolean defaultActive;
- private String productPageURL;
-
- public CloudServiceConfig(OMElement configEle) {
- permissionConfigs = new ArrayList<PermissionConfig>();
- serialize(configEle);
- }
-
- public void serialize(OMElement configEle) {
- Iterator cloudServiceChildIt = configEle.getChildElements();
- name = configEle.getAttributeValue(new QName(null, NAME_ATTR_NAME));
- defaultActive = "true".equals(configEle.
- getAttributeValue(new QName(null, DEFAULT_ATTR_NAME)));
- while (cloudServiceChildIt.hasNext()) {
- Object cloudServiceChildObj = cloudServiceChildIt.next();
- if (!(cloudServiceChildObj instanceof OMElement)) {
- continue;
- }
- OMElement cloudServiceChildEle = (OMElement) cloudServiceChildObj;
- if (new QName(CONFIG_NS, LABEL_ELEMENT_NAME, "").
- equals(cloudServiceChildEle.getQName())) {
- label = cloudServiceChildEle.getText();
- } else if (new QName(CONFIG_NS, ICON_ELEMENT_NAME, "").
- equals(cloudServiceChildEle.getQName())) {
- icon = cloudServiceChildEle.getText();
- } else if (new QName(CONFIG_NS, LINK_ELEMENT_NAME, "").
- equals(cloudServiceChildEle.getQName())) {
- link = cloudServiceChildEle.getText();
- } else if (new QName(CONFIG_NS, PRODUCT_PAGE_URL_ELEMENT_NAME, "").
- equals(cloudServiceChildEle.getQName())) {
- productPageURL = cloudServiceChildEle.getText();
- } else if (new QName(CONFIG_NS, DESCRIPTION_ELEMENT_NAME, "").
- equals(cloudServiceChildEle.getQName())) {
- description = cloudServiceChildEle.getText();
- } else if (new QName(CONFIG_NS, PERMISSIONS_ELEMENT_NAME, "").
- equals(cloudServiceChildEle.getQName())) {
- Iterator permissionChildIt = cloudServiceChildEle.getChildElements();
- while (permissionChildIt.hasNext()) {
- Object permissionChildObj = permissionChildIt.next();
- if (!(permissionChildObj instanceof OMElement)) {
- continue;
- }
- OMElement permissionChildEle = (OMElement) permissionChildObj;
-
- if (new QName(CONFIG_NS, PERMISSION_ELEMENT_NAME, "").
- equals(permissionChildEle.getQName())) {
- PermissionConfig permissionConfig =
- new PermissionConfig(permissionChildEle);
- permissionConfigs.add(permissionConfig);
- }
- }
- }
-
- }
- }
-
- 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 List<PermissionConfig> getPermissionConfigs() {
- return permissionConfigs;
- }
-
- public void setPermissionConfigs(List<PermissionConfig> permissionConfigs) {
- this.permissionConfigs = permissionConfigs;
- }
-
- public boolean isDefaultActive() {
- return defaultActive;
- }
-
- public void setDefaultActive(boolean defaultActive) {
- this.defaultActive = defaultActive;
- }
-
- public String getProductPageURL() {
- return productPageURL;
- }
-
- public void setProductPageURL(String productPageURL) {
- this.productPageURL = productPageURL;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/bff2da51/components/stratos/org.wso2.carbon.stratos.common/2.1.0/src/main/java/org/wso2/carbon/stratos/common/config/CloudServiceConfigParser.java
----------------------------------------------------------------------
diff --git a/components/stratos/org.wso2.carbon.stratos.common/2.1.0/src/main/java/org/wso2/carbon/stratos/common/config/CloudServiceConfigParser.java b/components/stratos/org.wso2.carbon.stratos.common/2.1.0/src/main/java/org/wso2/carbon/stratos/common/config/CloudServiceConfigParser.java
deleted file mode 100644
index b01a385..0000000
--- a/components/stratos/org.wso2.carbon.stratos.common/2.1.0/src/main/java/org/wso2/carbon/stratos/common/config/CloudServiceConfigParser.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.wso2.carbon.stratos.common.config;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.stratos.common.constants.StratosConstants;
-import org.wso2.carbon.stratos.common.util.CommonUtil;
-import org.wso2.carbon.utils.CarbonUtils;
-
-import java.io.File;
-import java.io.FileInputStream;
-
-public class CloudServiceConfigParser {
-
- private static Log log = LogFactory.getLog(CloudServiceConfigParser.class);
-
- private static class SynchronizingClass {
- }
-
- private static final SynchronizingClass loadlock = new SynchronizingClass();
-
- private static CloudServicesDescConfig cloudServicesDescConfig = null;
-
- private static final String CONFIG_FILENAME = "cloud-services-desc.xml";
-
- public static CloudServicesDescConfig loadCloudServicesConfiguration() throws Exception {
- if (cloudServicesDescConfig != null) {
- return cloudServicesDescConfig;
- }
-
- synchronized (loadlock) {
- if (cloudServicesDescConfig == null) {
- try {
- String configFileName = CarbonUtils.getCarbonConfigDirPath() + File.separator +
- StratosConstants.MULTITENANCY_CONFIG_FOLDER + File.separator + CONFIG_FILENAME;
- OMElement configElement = CommonUtil.buildOMElement(new FileInputStream(configFileName));
- cloudServicesDescConfig = new CloudServicesDescConfig(configElement);
- } catch (Exception e) {
- String msg = "Error in building the cloud service configuration.";
- log.error(msg, e);
- throw new Exception(msg, e);
- }
- }
- }
- return cloudServicesDescConfig;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/bff2da51/components/stratos/org.wso2.carbon.stratos.common/2.1.0/src/main/java/org/wso2/carbon/stratos/common/config/CloudServicesDescConfig.java
----------------------------------------------------------------------
diff --git a/components/stratos/org.wso2.carbon.stratos.common/2.1.0/src/main/java/org/wso2/carbon/stratos/common/config/CloudServicesDescConfig.java b/components/stratos/org.wso2.carbon.stratos.common/2.1.0/src/main/java/org/wso2/carbon/stratos/common/config/CloudServicesDescConfig.java
deleted file mode 100644
index 27d3f9e..0000000
--- a/components/stratos/org.wso2.carbon.stratos.common/2.1.0/src/main/java/org/wso2/carbon/stratos/common/config/CloudServicesDescConfig.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.wso2.carbon.stratos.common.config;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.xml.namespace.QName;
-import java.util.*;
-
-public class CloudServicesDescConfig {
- private static final Log log = LogFactory.getLog(CloudServicesDescConfig.class);
- private static final String CONFIG_NS = "http://wso2.com/carbon/cloud/mgt/services";
- private static final String CLOUD_SERVICE_ELEMENT_NAME = "cloudService";
-
- Map<String, CloudServiceConfig> cloudServiceConfigs;
-
- public CloudServicesDescConfig(OMElement configEle) {
- // as the cloud service configs are kept in an order, we use an ordered map.
- cloudServiceConfigs = new LinkedHashMap<String, CloudServiceConfig>();
- serialize(configEle);
- }
-
- public void serialize(OMElement configEle) {
- Iterator configChildIt = configEle.getChildElements();
- while (configChildIt.hasNext()) {
- Object configChildObj = configChildIt.next();
- if (!( configChildObj instanceof OMElement)) {
- continue;
- }
- OMElement configChildEle = (OMElement)configChildObj;
- if (new QName(CONFIG_NS, CLOUD_SERVICE_ELEMENT_NAME, "").
- equals(configChildEle.getQName())) {
- CloudServiceConfig cloudServiceConfig = new CloudServiceConfig(configChildEle);
- String name = cloudServiceConfig.getName();
- cloudServiceConfigs.put(name, cloudServiceConfig);
- }
- }
- }
-
- public Map<String, CloudServiceConfig> getCloudServiceConfigs() {
- return cloudServiceConfigs;
- }
-}