You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by la...@apache.org on 2013/07/12 09:53:01 UTC
[08/18] applying 0001-Refactor-throttling-module.patch
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/767082e3/components/stratos/throttling/org.wso2.carbon.throttling.agent/2.1.0/src/main/java/org/wso2/carbon/throttling/agent/listeners/WebAppRequestListener.java
----------------------------------------------------------------------
diff --git a/components/stratos/throttling/org.wso2.carbon.throttling.agent/2.1.0/src/main/java/org/wso2/carbon/throttling/agent/listeners/WebAppRequestListener.java b/components/stratos/throttling/org.wso2.carbon.throttling.agent/2.1.0/src/main/java/org/wso2/carbon/throttling/agent/listeners/WebAppRequestListener.java
deleted file mode 100644
index ba48f55..0000000
--- a/components/stratos/throttling/org.wso2.carbon.throttling.agent/2.1.0/src/main/java/org/wso2/carbon/throttling/agent/listeners/WebAppRequestListener.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
-* 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.
-*/
-package org.wso2.carbon.throttling.agent.listeners;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.base.MultitenantConstants;
-import org.wso2.carbon.context.CarbonContext;
-import org.wso2.carbon.stratos.common.constants.StratosConstants;
-import org.wso2.carbon.throttling.agent.ThrottlingAgent;
-import org.wso2.carbon.throttling.agent.cache.TenantThrottlingInfo;
-import org.wso2.carbon.throttling.agent.cache.ThrottlingActionInfo;
-import org.wso2.carbon.tomcat.ext.valves.CarbonTomcatValve;
-import org.wso2.carbon.user.api.UserStoreException;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class WebAppRequestListener implements CarbonTomcatValve {
-
- private static final Log log = LogFactory.getLog(WebAppRequestListener.class);
-
- private static final Pattern servicesURLPattern = Pattern.compile("\\/services\\/t\\/(.*?)\\/");
- private static final Pattern webAppsURLPattern = Pattern.compile("\\/t\\/(.*?)\\/webapps\\/");
-
- private static final String CONTEXT_SERVICES = "services";
- private static final String CONTEXT_WEBAPPS = "webapps";
-
- private ThrottlingAgent throttlingAgent;
-
- public WebAppRequestListener(ThrottlingAgent throttlingAgent) {
- this.throttlingAgent = throttlingAgent;
- }
-
- public void invoke(HttpServletRequest request, HttpServletResponse response) {
- String requestURI = request.getRequestURI();
- String tenantDomainName = CarbonContext.getCurrentContext().
- getTenantDomain();
- String urlContext = getContext(requestURI);
- if (tenantDomainName != null && urlContext != null) {
- try {
- int tenantId = throttlingAgent.getRealmService().getTenantManager().
- getTenantId(tenantDomainName);
- if (tenantId <= 0) {
- //Allow to proceed
- } else {
- if (!throttlingAgent.getRealmService().getTenantManager().getTenant(tenantId).
- isActive()) {
- //Check weather activated tenant or not
- String msg = "You are sending request to a deactivated tenant. for Domain: "
- + tenantDomainName;
- log.error(msg);
- try {
- response.sendError(403, msg);
- } catch (IOException e) {
- String message = "Error in sending throttling rule violation message by an inactive tenant." +
- " Tenant Domain: " + tenantDomainName;
- log.error(message, e);
- }
- } else {
- //check weather request come to webapps
- if (CONTEXT_WEBAPPS.equals(urlContext)) {
- //if tenant is active we will throttle other parameters such as bandwidth in/out
- try {
- TenantThrottlingInfo throttlingInfo =
- throttlingAgent.getThrottlingInfoCache().
- getTenantThrottlingInfo(tenantId);
- if (throttlingInfo != null) {
- String[] actions =
- new String[]{StratosConstants.THROTTLING_WEBAPP_IN_BANDWIDTH_ACTION,
- StratosConstants.THROTTLING_WEBAPP_OUT_BANDWIDTH_ACTION};
- ThrottlingActionInfo actionInfo;
-
- actionInfo = throttlingInfo.getThrottlingActionInfo(actions);
- if (actionInfo != null && actionInfo.isBlocked()) {
- String blockedMsg = actionInfo.getMessage();
- String msg = "This action is blocked. Reason: "
- + blockedMsg;
- log.error(msg);
- response.sendError(509, msg);
- }
- }
- } catch (Exception ex) {
- String msg = "Error in sending throttling rule violation message." +
- " Tenant Domain: " + tenantDomainName;
- log.error(msg, ex);
- return;
- }
- } else if (CONTEXT_SERVICES.equals(urlContext)) {
- try {
- TenantThrottlingInfo throttlingInfo =
- throttlingAgent.getThrottlingInfoCache().
- getTenantThrottlingInfo(tenantId);
- if (throttlingInfo != null) {
- String[] actions =
- new String[]{StratosConstants.THROTTLING_SERVICE_IN_BANDWIDTH_ACTION,
- StratosConstants.THROTTLING_SERVICE_OUT_BANDWIDTH_ACTION};
- ThrottlingActionInfo actionInfo;
-
- actionInfo = throttlingInfo.getThrottlingActionInfo(actions);
- if (actionInfo != null && actionInfo.isBlocked()) {
- String blockedMsg = actionInfo.getMessage();
- String msg = "This action is blocked. Reason: " +
- blockedMsg;
- log.error(msg);
- response.sendError(509, msg);
- }
- }
- } catch (Exception ex) {
- String msg = "Error in sending throttling rule violation message." +
- " Tenant Domain: " + tenantDomainName;
- log.error(msg, ex);
- }
- }
-
- }
- }
- } catch (UserStoreException e) {
- String msg = "Error in getting tenant id to evaluate throttling rule. " +
- "Tenant Domain: " + tenantDomainName;
- log.error(msg, e);
- }
-
- }
- }
-
- /**
- * Extract tenant domain from request url
- *
- * @return tenant domain
- */
- public String getTenantName(String requestUrl) {
- Matcher matcher = servicesURLPattern.matcher(requestUrl);
- if (matcher.find()) {
- return matcher.group(1);
- }
-
- matcher = webAppsURLPattern.matcher(requestUrl);
- if (matcher.find()) {
- return matcher.group(1);
- }
-
- return MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
- }
-
- /**
- * Extract context from the request url
- *
- * @return context string
- */
- public String getContext(String requestUrl) {
- if (requestUrl.contains("/services") && requestUrl.contains("/t")) {
- return CONTEXT_SERVICES;
- }
-
- if (requestUrl.contains("/t") && requestUrl.contains("/webapps")) {
- return CONTEXT_WEBAPPS;
- }
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/767082e3/components/stratos/throttling/org.wso2.carbon.throttling.agent/2.1.0/src/main/java/org/wso2/carbon/throttling/agent/validation/ValidationException.java
----------------------------------------------------------------------
diff --git a/components/stratos/throttling/org.wso2.carbon.throttling.agent/2.1.0/src/main/java/org/wso2/carbon/throttling/agent/validation/ValidationException.java b/components/stratos/throttling/org.wso2.carbon.throttling.agent/2.1.0/src/main/java/org/wso2/carbon/throttling/agent/validation/ValidationException.java
deleted file mode 100644
index 9d6be14..0000000
--- a/components/stratos/throttling/org.wso2.carbon.throttling.agent/2.1.0/src/main/java/org/wso2/carbon/throttling/agent/validation/ValidationException.java
+++ /dev/null
@@ -1,25 +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.throttling.agent.validation;
-
-public class ValidationException extends Exception {
- public ValidationException(String msg, Exception e) {
- super(msg, e);
- }
- public ValidationException(String msg) {
- super(msg);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/767082e3/components/stratos/throttling/org.wso2.carbon.throttling.agent/2.1.0/src/main/java/org/wso2/carbon/throttling/agent/validation/ValidationInfo.java
----------------------------------------------------------------------
diff --git a/components/stratos/throttling/org.wso2.carbon.throttling.agent/2.1.0/src/main/java/org/wso2/carbon/throttling/agent/validation/ValidationInfo.java b/components/stratos/throttling/org.wso2.carbon.throttling.agent/2.1.0/src/main/java/org/wso2/carbon/throttling/agent/validation/ValidationInfo.java
deleted file mode 100644
index 1f2de60..0000000
--- a/components/stratos/throttling/org.wso2.carbon.throttling.agent/2.1.0/src/main/java/org/wso2/carbon/throttling/agent/validation/ValidationInfo.java
+++ /dev/null
@@ -1,39 +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.throttling.agent.validation;
-
-public class ValidationInfo {
- boolean isActionBlocked;
- String blockedActionMsg;
-
- public ValidationInfo(){
- isActionBlocked = false;
- }
-
- public boolean isActionBlocked() {
- return isActionBlocked;
- }
- public void setActionBlocked(boolean isBlocked) {
- this.isActionBlocked = isBlocked;
- }
- public String getBlockedActionMsg() {
- return blockedActionMsg;
- }
- public void setBlockedActionMsg(String blockedMsg) {
- this.blockedActionMsg = blockedMsg;
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/767082e3/components/stratos/throttling/org.wso2.carbon.throttling.agent/2.1.0/src/main/java/org/wso2/carbon/throttling/agent/validation/ValidationInfoRetriever.java
----------------------------------------------------------------------
diff --git a/components/stratos/throttling/org.wso2.carbon.throttling.agent/2.1.0/src/main/java/org/wso2/carbon/throttling/agent/validation/ValidationInfoRetriever.java b/components/stratos/throttling/org.wso2.carbon.throttling.agent/2.1.0/src/main/java/org/wso2/carbon/throttling/agent/validation/ValidationInfoRetriever.java
deleted file mode 100644
index 0fc5066..0000000
--- a/components/stratos/throttling/org.wso2.carbon.throttling.agent/2.1.0/src/main/java/org/wso2/carbon/throttling/agent/validation/ValidationInfoRetriever.java
+++ /dev/null
@@ -1,109 +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.throttling.agent.validation;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-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.stratos.common.constants.StratosConstants;
-import org.wso2.carbon.stratos.common.util.MeteringAccessValidationUtils;
-
-public class ValidationInfoRetriever {
- private static final Log log = LogFactory.getLog(ValidationInfoRetriever.class);
- UserRegistry governanceSystemRegistry;
-
- public ValidationInfoRetriever(UserRegistry governanceSystemRegistry) {
- this.governanceSystemRegistry = governanceSystemRegistry;
- }
-
- public ValidationInfo getValidationInfo(String action, int tenantId) throws ValidationException {
- ValidationInfo validationInfo = new ValidationInfo();
- Resource validationInfoResource = getResource(tenantId);
- if(validationInfoResource == null){
- //this means, the user is allowed to proceed
- return validationInfo;
- }
-
- // first get the validation info for all actions
- checkAction(StratosConstants.THROTTLING_ALL_ACTION, validationInfoResource, validationInfo);
- if (validationInfo.isActionBlocked()) {
- return validationInfo;
- }
- checkAction(action, validationInfoResource, validationInfo);
- return validationInfo;
- }
-
- public ValidationInfo getValidationInfo(String[] actions, int tenantId) throws ValidationException {
- ValidationInfo validationInfo = new ValidationInfo();
- Resource validationInfoResource = getResource(tenantId);
- if(validationInfoResource == null){
- //this means, the user is allowed to proceed
- return validationInfo;
- }
-
- // first get the validation info for all actions
- checkAction(StratosConstants.THROTTLING_ALL_ACTION, validationInfoResource, validationInfo);
- if (validationInfo.isActionBlocked()) {
- return validationInfo;
- }
-
- for(String action : actions){
- checkAction(action, validationInfoResource, validationInfo);
- if (validationInfo.isActionBlocked()) {
- return validationInfo;
- }
- }
- return validationInfo;
- }
-
- private Resource getResource (int tenantId) throws ValidationException{
- // first retrieve validation info for the tenant
- String tenantValidationInfoResourcePath =
- StratosConstants.TENANT_USER_VALIDATION_STORE_PATH +
- RegistryConstants.PATH_SEPARATOR + tenantId;
- Resource tenantValidationInfoResource = null;
- try {
- if (governanceSystemRegistry.resourceExists(tenantValidationInfoResourcePath)) {
- tenantValidationInfoResource =
- governanceSystemRegistry.get(tenantValidationInfoResourcePath);
- }
- } catch (RegistryException e) {
- String msg = "Error in getting the tenant validation info for tenant:" + tenantId;
- log.error(msg, e);
- throw new ValidationException(msg, e);
- }
- return tenantValidationInfoResource;
- }
-
- private void checkAction(String action, Resource tenantValidationInfoResource,
- ValidationInfo validationInfo){
- String blockActionStr =
- tenantValidationInfoResource.getProperty(
- MeteringAccessValidationUtils.generateIsBlockedPropertyKey(action));
-
- if ("true".equals(blockActionStr)) {
- validationInfo.setActionBlocked(true);
-
- String blockActionMsg =
- tenantValidationInfoResource.getProperty(
- MeteringAccessValidationUtils.generateErrorMsgPropertyKey(action));
- validationInfo.setBlockedActionMsg(blockActionMsg);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/767082e3/components/stratos/throttling/org.wso2.carbon.throttling.agent/2.1.0/src/main/resources/META-INF/module.xml
----------------------------------------------------------------------
diff --git a/components/stratos/throttling/org.wso2.carbon.throttling.agent/2.1.0/src/main/resources/META-INF/module.xml b/components/stratos/throttling/org.wso2.carbon.throttling.agent/2.1.0/src/main/resources/META-INF/module.xml
deleted file mode 100644
index 145d965..0000000
--- a/components/stratos/throttling/org.wso2.carbon.throttling.agent/2.1.0/src/main/resources/META-INF/module.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<!--
- ~ 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.
- -->
-<module name="usagethrottling" class="org.wso2.carbon.throttling.agent.listeners.ThrottlingModule">
- <InFlow>
- <handler name="InFlowUsageThrottlingHandler"
- class="org.wso2.carbon.throttling.agent.listeners.ServiceRequestListener">
- <order phase="OpPhase" after="AuthorizationHandler"/>
- </handler>
- </InFlow>
-
- <InFaultFlow>
- <handler name="FaultInFlowUsageThrottlingHandler"
- class="org.wso2.carbon.throttling.agent.listeners.ServiceRequestListener">
- <order phase="OpPhase" after="AuthorizationHandler"/>
- </handler>
- </InFaultFlow>
- <parameter name="adminModule" locked="true">true</parameter>
-</module>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/767082e3/components/stratos/throttling/org.wso2.carbon.throttling.agent/2.1.0/src/main/resources/MultitenancyThrottlingService.wsdl
----------------------------------------------------------------------
diff --git a/components/stratos/throttling/org.wso2.carbon.throttling.agent/2.1.0/src/main/resources/MultitenancyThrottlingService.wsdl b/components/stratos/throttling/org.wso2.carbon.throttling.agent/2.1.0/src/main/resources/MultitenancyThrottlingService.wsdl
deleted file mode 100644
index a652030..0000000
--- a/components/stratos/throttling/org.wso2.carbon.throttling.agent/2.1.0/src/main/resources/MultitenancyThrottlingService.wsdl
+++ /dev/null
@@ -1,82 +0,0 @@
-<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://services.manager.throttling.carbon.wso2.org" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://services.manager.throttling.carbon.wso2.org">
- <wsdl:documentation>MultitenancyThrottlingService</wsdl:documentation>
- <wsdl:types>
- <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://services.manager.throttling.carbon.wso2.org">
- <xs:element name="executeThrottlingRulesException">
- <xs:complexType>
- <xs:sequence>
- <xs:element minOccurs="0" name="executeThrottlingRulesException" nillable="true" type="ns:Exception" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- <xs:complexType name="Exception">
- <xs:sequence>
- <xs:element minOccurs="0" name="Message" nillable="true" type="xs:string" />
- </xs:sequence>
- </xs:complexType>
- <xs:element name="executeThrottlingRules">
- <xs:complexType>
- <xs:sequence>
- <xs:element minOccurs="0" name="tenantId" type="xs:int" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:schema>
- </wsdl:types>
- <wsdl:message name="executeThrottlingRulesRequest">
- <wsdl:part name="parameters" element="ns:executeThrottlingRules" />
- </wsdl:message>
- <wsdl:message name="executeThrottlingRulesException">
- <wsdl:part name="parameters" element="ns:executeThrottlingRulesException" />
- </wsdl:message>
- <wsdl:portType name="MultitenancyThrottlingServicePortType">
- <wsdl:operation name="executeThrottlingRules">
- <wsdl:input message="ns:executeThrottlingRulesRequest" wsaw:Action="urn:executeThrottlingRules" />
- <wsdl:fault message="ns:executeThrottlingRulesException" name="executeThrottlingRulesException" wsaw:Action="urn:executeThrottlingRulesexecuteThrottlingRulesException" />
- </wsdl:operation>
- </wsdl:portType>
- <wsdl:binding name="MultitenancyThrottlingServiceSoap11Binding" type="ns:MultitenancyThrottlingServicePortType">
- <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
- <wsdl:operation name="executeThrottlingRules">
- <soap:operation soapAction="urn:executeThrottlingRules" style="document" />
- <wsdl:input>
- <soap:body use="literal" />
- </wsdl:input>
- <wsdl:fault name="executeThrottlingRulesException">
- <soap:fault use="literal" name="executeThrottlingRulesException" />
- </wsdl:fault>
- </wsdl:operation>
- </wsdl:binding>
- <wsdl:binding name="MultitenancyThrottlingServiceSoap12Binding" type="ns:MultitenancyThrottlingServicePortType">
- <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
- <wsdl:operation name="executeThrottlingRules">
- <soap12:operation soapAction="urn:executeThrottlingRules" style="document" />
- <wsdl:input>
- <soap12:body use="literal" />
- </wsdl:input>
- <wsdl:fault name="executeThrottlingRulesException">
- <soap12:fault use="literal" name="executeThrottlingRulesException" />
- </wsdl:fault>
- </wsdl:operation>
- </wsdl:binding>
- <wsdl:binding name="MultitenancyThrottlingServiceHttpBinding" type="ns:MultitenancyThrottlingServicePortType">
- <http:binding verb="POST" />
- <wsdl:operation name="executeThrottlingRules">
- <http:operation location="executeThrottlingRules" />
- <wsdl:input>
- <mime:content type="text/xml" part="parameters" />
- </wsdl:input>
- </wsdl:operation>
- </wsdl:binding>
- <wsdl:service name="MultitenancyThrottlingService">
- <wsdl:port name="MultitenancyThrottlingServiceHttpsSoap11Endpoint" binding="ns:MultitenancyThrottlingServiceSoap11Binding">
- <soap:address location="https://192.168.1.100:9443/services/MultitenancyThrottlingService.MultitenancyThrottlingServiceHttpsSoap11Endpoint/" />
- </wsdl:port>
- <wsdl:port name="MultitenancyThrottlingServiceHttpsSoap12Endpoint" binding="ns:MultitenancyThrottlingServiceSoap12Binding">
- <soap12:address location="https://192.168.1.100:9443/services/MultitenancyThrottlingService.MultitenancyThrottlingServiceHttpsSoap12Endpoint/" />
- </wsdl:port>
- <wsdl:port name="MultitenancyThrottlingServiceHttpsEndpoint" binding="ns:MultitenancyThrottlingServiceHttpBinding">
- <http:address location="https://192.168.1.100:9443/services/MultitenancyThrottlingService.MultitenancyThrottlingServiceHttpsEndpoint/" />
- </wsdl:port>
- </wsdl:service>
-</wsdl:definitions>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/767082e3/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/pom.xml
----------------------------------------------------------------------
diff --git a/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/pom.xml b/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/pom.xml
deleted file mode 100644
index 9fb038f..0000000
--- a/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/pom.xml
+++ /dev/null
@@ -1,170 +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>throttling-parent</artifactId>
- <version>2.1.0</version>
-<relativePath>../../pom.xml</relativePath>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <artifactId>org.wso2.carbon.throttling.manager</artifactId>
- <version>2.1.0</version>
- <packaging>bundle</packaging>
- <name>WSO2 Stratos - Throttling Manager</name>
-
- <build>
-
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-scr-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <excludes>
- <exclude>**/BaseTestCase.java</exclude>
- <exclude>**/ThrottlingTest.java</exclude>
- </excludes>
- </configuration>
- </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.throttling.manager.dataobjects,
- </Export-Package>
- <Private-Package>
- !org.wso2.carbon.throttling.manager.dataobjects,
- org.wso2.carbon.throttling.manager.*,
- </Private-Package>
- <!--<Require-Bundle>
- drools;visibility:=reexport
- </Require-Bundle>-->
- <Import-Package>
- org.wso2.carbon.rule.*,
- org.wso2.carbon.stratos.common.*,
- org.wso2.carbon.throttling.agent.*,
- org.wso2.carbon.billing.mgt.*,
- org.wso2.carbon.registry.core.*;version=1.0.1,
- org.wso2.carbon.registry.resource.*,
- org.quartz.*; version=2.1.1,
- !javax.xml.namespace,
- javax.xml.namespace; version=0.0.0,
- 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>
- <DynamicImport-Package>*</DynamicImport-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
-
- <dependency>
- <groupId>org.apache.axis2.wso2</groupId>
- <artifactId>axis2</artifactId>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </dependency>
- <dependency>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.registry.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.utils</artifactId>
- <version>4.1.0</version>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </dependency>
- <dependency>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.registry.extensions</artifactId>
- <version>${carbon.platform.version}</version>
- </dependency>
- <dependency>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.registry.resource</artifactId>
- <version>${carbon.platform.version}</version>
- </dependency>
- <dependency>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.stratos.common</artifactId>
- </dependency>
- <dependency>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.usage</artifactId>
- </dependency>
- <dependency>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.billing.mgt</artifactId>
- </dependency>
- <dependency>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.rule.kernel</artifactId>
- <version>${carbon.platform.version}</version>
- </dependency>
- <dependency>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.rule.common</artifactId>
- <version>${carbon.platform.version}</version>
- </dependency>
- <dependency>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.rule.backend</artifactId>
- <version>${carbon.platform.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.synapse</groupId>
- <artifactId>synapse-tasks</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.synapse</groupId>
- <artifactId>synapse-commons</artifactId>
- </dependency>
- <dependency>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.throttling.agent</artifactId>
- <version>2.1.0</version>
- </dependency>
- <dependency>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.usage.agent</artifactId>
- </dependency>
- </dependencies>
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/767082e3/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/conf/ThrottlingConfiguration.java
----------------------------------------------------------------------
diff --git a/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/conf/ThrottlingConfiguration.java b/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/conf/ThrottlingConfiguration.java
deleted file mode 100644
index e2b5ca1..0000000
--- a/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/conf/ThrottlingConfiguration.java
+++ /dev/null
@@ -1,104 +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.throttling.manager.conf;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.xml.namespace.QName;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.stratos.common.util.CommonUtil;
-import org.wso2.carbon.throttling.manager.exception.ThrottlingException;
-import org.wso2.carbon.throttling.manager.tasks.Task;
-
-public class ThrottlingConfiguration {
- private static final Log log = LogFactory.getLog(ThrottlingConfiguration.class);
- private static final String CONFIG_NS = "http://wso2.com/carbon/multitenancy/usage-throttling-agent/config";
- List<ThrottlingTaskConfiguration> throttlingTaskConfigs;
- List<Task> tasks;
-
- public ThrottlingConfiguration(String throttlingConfigFile) throws ThrottlingException {
- try {
- OMElement throttlingConfig =
- CommonUtil.buildOMElement(new FileInputStream(throttlingConfigFile));
- deserialize(throttlingConfig);
- } catch (FileNotFoundException e) {
- String msg = "Unable to find the file: " + throttlingConfigFile + ".";
- log.error(msg, e);
- throw new ThrottlingException(msg, e);
- } catch (Exception e) {
- String msg = "Error in building the throttling config, config file: " +
- throttlingConfigFile + ".";
- log.error(msg, e);
- throw new ThrottlingException(msg, e);
- }
- }
-
- public void deserialize(OMElement throttlingConfigEle) throws ThrottlingException {
- OMElement throttlingManagerConfigs=null;
- Iterator childElements = throttlingConfigEle.getChildElements();
- while (childElements.hasNext()) {
- Object configChildElement = childElements.next();
-
- if (!(configChildElement instanceof OMElement)) {
- continue;
- }
- OMElement configChildOMElement = (OMElement) configChildElement;
- if (new QName(CONFIG_NS, "ThrottlingManagerTask", "").equals(configChildOMElement.getQName())) {
- throttlingManagerConfigs=(OMElement)configChildElement;
- }
- }
- // Iterator throttlingConfigChildIt = throttlingConfigEle.getChildElements();
- Iterator throttlingConfigChildIt = throttlingManagerConfigs.getChildElements();
- while (throttlingConfigChildIt.hasNext()) {
- Object throttlingConfigChild = throttlingConfigChildIt.next();
- if (!(throttlingConfigChild instanceof OMElement)) {
- continue;
- }
- OMElement throttlingConfigChildEle = (OMElement) throttlingConfigChild;
-
- if (new QName(CONFIG_NS, "tasks", "").equals(throttlingConfigChildEle.getQName())) {
- throttlingTaskConfigs = new ArrayList<ThrottlingTaskConfiguration>();
- tasks = new ArrayList<Task>();
- Iterator tasksConfigChildIt = throttlingConfigChildEle.getChildElements();
- while (tasksConfigChildIt.hasNext()) {
- Object taskConfigChild = tasksConfigChildIt.next();
- if (!(taskConfigChild instanceof OMElement)) {
- continue;
- }
- ThrottlingTaskConfiguration taskConfiguration =
- new ThrottlingTaskConfiguration((OMElement) taskConfigChild);
- throttlingTaskConfigs.add(taskConfiguration);
- tasks.add(taskConfiguration.getTask());
- }
- }
- }
- }
-
- public List<ThrottlingTaskConfiguration> getThrottlingTaskConfigs() {
- return throttlingTaskConfigs;
- }
-
- public List<Task> getThrottlingTasks() {
- return tasks;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/767082e3/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/conf/ThrottlingTaskConfiguration.java
----------------------------------------------------------------------
diff --git a/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/conf/ThrottlingTaskConfiguration.java b/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/conf/ThrottlingTaskConfiguration.java
deleted file mode 100644
index d60a8fb..0000000
--- a/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/conf/ThrottlingTaskConfiguration.java
+++ /dev/null
@@ -1,117 +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.throttling.manager.conf;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.throttling.manager.exception.ThrottlingException;
-import org.wso2.carbon.throttling.manager.tasks.Task;
-
-import javax.xml.namespace.QName;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-public class ThrottlingTaskConfiguration {
- private static final Log log =
- LogFactory.getLog(ThrottlingTaskConfiguration.class);
-
- private static final String CONFIG_NS =
- "http://wso2.com/carbon/multitenancy/usage-throttling-agent/config";
- private static final String TASK_CONF_PARAMERTERS = "parameters";
- private static final String TASK_CONF_DATA_PROVIDERS = "dataProviders";
- private static final String TASK_CONF_PARAM_KEY = "parameter";
- private static final String TASK_CONF_PARAM_NAME_KEY = "name";
-
- public static final String INTERVAL_PARAM_KEY = "interval";
- public static final String DELAY_PARAM_KEY = "delay";
-
- Task task;
- List<ThrottlingTaskDataProviderConfiguration> dataProviderConfigs;
- Map<String, String> taskParameters;
-
- public ThrottlingTaskConfiguration(OMElement taskConfigEle) throws ThrottlingException {
- dataProviderConfigs = new ArrayList<ThrottlingTaskDataProviderConfiguration>();
- serialize(taskConfigEle);
- }
-
- private void serialize(OMElement taskConfigEle) throws ThrottlingException {
- Iterator taskConfigChildIt = taskConfigEle.getChildElements();
-
- while (taskConfigChildIt.hasNext()) {
- Object taskConfigChildObj = taskConfigChildIt.next();
- if (!(taskConfigChildObj instanceof OMElement)) {
- continue;
- }
- OMElement taskConfigChildEle = (OMElement) taskConfigChildObj;
- if (taskConfigChildEle.getQName().equals(new QName(CONFIG_NS, TASK_CONF_PARAMERTERS))) {
- Iterator parametersIt = taskConfigChildEle.getChildElements();
-
- taskParameters = extractTaskParameters(parametersIt);
- } else if (taskConfigChildEle.getQName().equals(
- new QName(CONFIG_NS, TASK_CONF_DATA_PROVIDERS))) {
- Iterator handlerConfigIt = taskConfigChildEle.getChildElements();
- while (handlerConfigIt.hasNext()) {
- Object handlerConfigObj = handlerConfigIt.next();
- if (!(handlerConfigObj instanceof OMElement)) {
- continue;
- }
- OMElement handlerConfigEle = (OMElement) handlerConfigObj;
- ThrottlingTaskDataProviderConfiguration handlerConfig =
- new ThrottlingTaskDataProviderConfiguration(handlerConfigEle);
- dataProviderConfigs.add(handlerConfig);
- }
- }
- }
-
- // create the task instance
- task = new Task(taskParameters, dataProviderConfigs);
-
- }
-
- private static Map<String, String> extractTaskParameters(
- Iterator parameterIt) throws ThrottlingException {
- Map<String, String> parameters = new HashMap<String, String>();
- while (parameterIt.hasNext()) {
- Object parameterObj = parameterIt.next();
- if (!(parameterObj instanceof OMElement)) {
- continue;
- }
- OMElement configChildEle = (OMElement) parameterObj;
- if (!new QName(CONFIG_NS, TASK_CONF_PARAM_KEY, "")
- .equals(configChildEle.getQName())) {
- continue;
- }
- String paramName =
- configChildEle.getAttributeValue(new QName(
- TASK_CONF_PARAM_NAME_KEY));
- String paramValue = configChildEle.getText();
- parameters.put(paramName, paramValue);
- }
- return parameters;
- }
-
- public List<ThrottlingTaskDataProviderConfiguration> getDataProviderConfigs() {
- return dataProviderConfigs;
- }
-
- public Task getTask() {
- return task;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/767082e3/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/conf/ThrottlingTaskDataProviderConfiguration.java
----------------------------------------------------------------------
diff --git a/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/conf/ThrottlingTaskDataProviderConfiguration.java b/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/conf/ThrottlingTaskDataProviderConfiguration.java
deleted file mode 100644
index d7573aa..0000000
--- a/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/conf/ThrottlingTaskDataProviderConfiguration.java
+++ /dev/null
@@ -1,114 +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.throttling.manager.conf;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.throttling.manager.dataproviders.DataProvider;
-import org.wso2.carbon.throttling.manager.exception.ThrottlingException;
-import org.wso2.carbon.throttling.manager.utils.Util;
-
-import javax.xml.namespace.QName;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-public class ThrottlingTaskDataProviderConfiguration {
- private static final Log log =
- LogFactory.getLog(ThrottlingTaskDataProviderConfiguration.class);
-
- private static final String CONFIG_NS =
- "http://wso2.com/carbon/multitenancy/throttling/config";
- private static final String HANDLER_CONF_PARAM_KEY = "parameter";
- private static final String HANDLER_CLASS_ATTR = "class";
- private static final String HANDLER_CONF_PARAM_NAME_KEY = "name";
- private static final String HANDLER_SERVICE_ATTR = "service";
-
- private String dataProviderServiceName;
- private Map<String, String> dataProviderParameters;
- private DataProvider dataProvider;
- // to keep the task class that are available.
- private Map<String, DataProvider> dataProviders;
-
- public ThrottlingTaskDataProviderConfiguration(OMElement handlerConfigEle)
- throws ThrottlingException {
- serialize(handlerConfigEle);
- dataProviders = new HashMap<String, DataProvider>();
- }
-
- private void serialize(OMElement handlerConfigEle) throws ThrottlingException {
- Iterator handlerParameterChildIt = handlerConfigEle.getChildElements();
- Map<String, String> parameters = extractParameters(handlerParameterChildIt);
- // get the task class
- String handlerClassName = handlerConfigEle.getAttributeValue(new QName(HANDLER_CLASS_ATTR));
-
- if (handlerClassName == null) {
- dataProviderServiceName =
- handlerConfigEle.getAttributeValue(new QName(HANDLER_SERVICE_ATTR));
- dataProviderParameters = parameters;
- } else {
- dataProvider = (DataProvider) Util.constructObject(handlerClassName);
- dataProvider.init(parameters);
- }
- }
-
- private static Map<String, String> extractParameters(Iterator parameterIt)
- throws ThrottlingException {
- Map<String, String> parameters = new HashMap<String, String>();
- while (parameterIt.hasNext()) {
- Object parameterObj = parameterIt.next();
- if (!(parameterObj instanceof OMElement)) {
- continue;
- }
- OMElement configChildEle = (OMElement) parameterObj;
- if (!new QName(CONFIG_NS, HANDLER_CONF_PARAM_KEY, "").equals(configChildEle.getQName())) {
- continue;
- }
- String paramName =
- configChildEle.getAttributeValue(new QName(HANDLER_CONF_PARAM_NAME_KEY));
- String paramValue = configChildEle.getText();
- parameters.put(paramName, paramValue);
- }
- return parameters;
- }
-
- // get task have to be called to initialize tasks which are registered as
- // OSGI services
- public DataProvider getDataProvider() throws ThrottlingException {
- if (dataProvider == null && dataProviderServiceName != null) {
- dataProvider = dataProviders.get(dataProviderServiceName);
- if (dataProvider == null) {
- String msg =
- "The scheduler helper service: " +
- dataProviderServiceName + " is not loaded.";
- log.error(msg);
- throw new ThrottlingException(msg);
- }
- dataProvider.init(dataProviderParameters);
- }
- return dataProvider;
- }
-
- public void loadDataProviderService() throws ThrottlingException {
- if (dataProvider == null && dataProviderServiceName != null) {
- dataProvider = dataProviders.get(dataProviderServiceName);
- if (dataProvider != null) {
- dataProvider.init(dataProviderParameters);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/767082e3/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/dataobjects/ThrottlingAccessValidation.java
----------------------------------------------------------------------
diff --git a/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/dataobjects/ThrottlingAccessValidation.java b/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/dataobjects/ThrottlingAccessValidation.java
deleted file mode 100644
index 5ec0120..0000000
--- a/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/dataobjects/ThrottlingAccessValidation.java
+++ /dev/null
@@ -1,70 +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.throttling.manager.dataobjects;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-public class ThrottlingAccessValidation {
-
- Map<String, Boolean> userBlockedActions = new HashMap<String, Boolean>();
- Map<String, Boolean> tenantBlockedActions = new HashMap<String, Boolean>();
- Map<String, String> userBlockedMsgs = new HashMap<String, String>();
- Map<String, String> tenantBlockedMsgs = new HashMap<String, String>();
-
- boolean persistValidationInfo = true;
-
- public boolean isPersistValidationInfo() {
- return persistValidationInfo;
- }
-
- public void setPersistValidationInfo(boolean persistValidationInfo) {
- this.persistValidationInfo = persistValidationInfo;
- }
-
- public boolean isUserBlocked(String action) {
- Boolean result = userBlockedActions.get(action);
- return result == null? false: result;
- }
-
- public String getUserBlockedMsg(String action) {
- return userBlockedMsgs.get(action);
- }
-
- public void setUserBlocked(String action, boolean block, String msg) {
- userBlockedActions.put(action, block);
- userBlockedMsgs.put(action, msg);
- }
-
- public boolean isTenantBlocked(String action) {
- Boolean result = tenantBlockedActions.get(action);
- return result == null? false: result;
- }
-
- public String getTenantBlockedMsg(String action) {
- return tenantBlockedMsgs.get(action);
- }
-
- public void setTenantBlocked(String action, boolean block, String msg) {
- tenantBlockedActions.put(action, block);
- tenantBlockedMsgs.put(action, msg);
- }
-
- public Set<String> getActions() {
- return tenantBlockedActions.keySet();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/767082e3/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/dataobjects/ThrottlingDataContext.java
----------------------------------------------------------------------
diff --git a/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/dataobjects/ThrottlingDataContext.java b/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/dataobjects/ThrottlingDataContext.java
deleted file mode 100644
index b8b1b2b..0000000
--- a/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/dataobjects/ThrottlingDataContext.java
+++ /dev/null
@@ -1,145 +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.throttling.manager.dataobjects;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-public class ThrottlingDataContext {
- int tenantId;
- String userName;
- Map<String, ThrottlingDataEntry> data;
- boolean async = false;
- String taskName = null;
-
- private ThrottlingAccessValidation accessValidation;
- boolean processingComplete;
-
- public ThrottlingDataContext(int tenantId) {
- this.tenantId = tenantId;
- this.data = new HashMap<String, ThrottlingDataEntry>();
- }
-
- public int getTenantId() {
- return tenantId;
- }
-
- public void setTenantId(int tenantId) {
- this.tenantId = tenantId;
- }
-
- public String getUserName() {
- return userName;
- }
-
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
-
- public ThrottlingAccessValidation getAccessValidation() {
- return accessValidation;
- }
-
- public void setAccessValidation(ThrottlingAccessValidation accessValidation) {
- this.accessValidation = accessValidation;
- }
-
- public boolean isProcessingComplete() {
- return processingComplete;
- }
-
- public void setProcessingComplete(boolean processingComplete) {
- this.processingComplete = processingComplete;
- }
-
- public Collection<ThrottlingDataEntry> getData() {
- return data.values();
- }
-
- public void addDataString(String key, String value) {
- ThrottlingDataEntry dataEntry = new ThrottlingDataEntry(key);
- dataEntry.setStringValue(value);
- data.put(key, dataEntry);
- }
-
- public void addDataLong(String key, long value) {
- ThrottlingDataEntry dataEntry = new ThrottlingDataEntry(key);
- dataEntry.setLongValue(value);
- data.put(key, dataEntry);
- }
-
- public void addDataInt(String key, int value) {
- ThrottlingDataEntry dataEntry = new ThrottlingDataEntry(key);
- dataEntry.setIntValue(value);
- data.put(key, dataEntry);
- }
-
- public void addDataObject(String key, Object value) {
- ThrottlingDataEntry dataEntry = new ThrottlingDataEntry(key);
- dataEntry.setObjectValue(value);
- data.put(key, dataEntry);
- }
-
- public String getDataString(String key) {
- ThrottlingDataEntry dataEntry = data.get(key);
- if (dataEntry == null) {
- return null;
- }
- return dataEntry.getStringValue();
- }
-
- public long getDataLong(String key) {
- ThrottlingDataEntry dataEntry = data.get(key);
- if (dataEntry == null) {
- return 0;
- }
- return dataEntry.getLongValue();
- }
-
- public int getDataInt(String key) {
- ThrottlingDataEntry dataEntry = data.get(key);
- if (dataEntry == null) {
- return 0;
- }
- return dataEntry.getIntValue();
- }
-
- public Object getDataObject(String key) {
- ThrottlingDataEntry dataEntry = data.get(key);
- if (dataEntry == null) {
- return null;
- }
- return dataEntry.getObjectValue();
- }
-
- public boolean isAsync() {
- return async;
- }
-
- public void setAsync(boolean async) {
- this.async = async;
- }
-
- public String getTaskName() {
- return taskName;
- }
-
- public void setTaskName(String taskName) {
- this.taskName = taskName;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/767082e3/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/dataobjects/ThrottlingDataEntry.java
----------------------------------------------------------------------
diff --git a/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/dataobjects/ThrottlingDataEntry.java b/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/dataobjects/ThrottlingDataEntry.java
deleted file mode 100644
index 3427dfd..0000000
--- a/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/dataobjects/ThrottlingDataEntry.java
+++ /dev/null
@@ -1,84 +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.throttling.manager.dataobjects;
-
-public class ThrottlingDataEntry {
- String key;
- String stringValue;
- int intValue;
- long longValue;
- Object objectValue;
-
- // here we are not using enums, as pojo services may not support that.
- // 1 - String, 2 - Int, 3 - long, 4 - object
- int valueType;
-
- public ThrottlingDataEntry(String key) {
- this.key = key;
- }
-
- public String getKey() {
- return key;
- }
-
- public void setKey(String key) {
- this.key = key;
- }
-
- public String getStringValue() {
- return stringValue;
- }
-
- public void setStringValue(String stringValue) {
- this.stringValue = stringValue;
- valueType = 1;
- }
-
- public int getIntValue() {
- return intValue;
- }
-
- public void setIntValue(int intValue) {
- this.intValue = intValue;
- valueType = 2;
- }
-
- public long getLongValue() {
- return longValue;
- }
-
- public void setLongValue(long longValue) {
- this.longValue = longValue;
- valueType = 3;
- }
-
- public Object getObjectValue() {
- return objectValue;
- }
-
- public void setObjectValue(Object objectValue) {
- this.objectValue = objectValue;
- valueType = 4;
- }
-
- public int getValueType() {
- return valueType;
- }
-
- public void setValueType(int valueType) {
- this.valueType = valueType;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/767082e3/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/dataobjects/ThrottlingDataEntryConstants.java
----------------------------------------------------------------------
diff --git a/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/dataobjects/ThrottlingDataEntryConstants.java b/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/dataobjects/ThrottlingDataEntryConstants.java
deleted file mode 100644
index 090bc15..0000000
--- a/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/dataobjects/ThrottlingDataEntryConstants.java
+++ /dev/null
@@ -1,41 +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.throttling.manager.dataobjects;
-
-public class ThrottlingDataEntryConstants {
-
- final public static String TENANT_INCOMING_BANDWIDTH = "tenantIncomingBandwidth";
- final public static String TENANT_OUTGOING_BANDWIDTH = "tenantOutgoingBandwidth";
-
- final public static String TENANT_CAPACITY = "tenantCapacity";
- final public static String TENANT_HISTORY_CAPACITY = "tenantHistoryCapacity";
-
- final public static String USERS_COUNT = "usersCount";
-
- // some custom objects
- final public static String CUSTOMER = "customer";
- final public static String PACKAGE = "package";
- final public static String USER_MANAGER = "userManager";
- final public static String REGISTRY_INCOMING_BANDWIDTH = "registryIncomingBandwidth";
- final public static String REGISTRY_OUTGOING_BANDWIDTH = "registryOutgoingBandwidth";
- final public static String SERVICE_INCOMING_BANDWIDTH = "serviceIncomingBandwidth";
- final public static String SERVICE_OUTGOING_BANDWIDTH = "serviceOutgoingBandwidth";
- final public static String WEBAPP_INCOMING_BANDWIDTH = "webappIncomingBandwidth";
- final public static String WEBAPP_OUTGOING_BANDWIDTH = "webappOutgoingBandwidth";
- final public static String SERVICE_REQUEST_COUNT = "serviceRequestCount";
- final public static String SERVICE_RESPONSE_COUNT = "serviceResponseCount";
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/767082e3/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/dataproviders/BillingDataProvider.java
----------------------------------------------------------------------
diff --git a/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/dataproviders/BillingDataProvider.java b/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/dataproviders/BillingDataProvider.java
deleted file mode 100644
index 6966a6d..0000000
--- a/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/dataproviders/BillingDataProvider.java
+++ /dev/null
@@ -1,52 +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.throttling.manager.dataproviders;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.billing.core.dataobjects.Customer;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.billing.mgt.dataobjects.MultitenancyPackage;
-import org.wso2.carbon.throttling.manager.dataobjects.ThrottlingDataContext;
-import org.wso2.carbon.throttling.manager.dataobjects.ThrottlingDataEntryConstants;
-import org.wso2.carbon.throttling.manager.exception.ThrottlingException;
-import org.wso2.carbon.throttling.manager.utils.Util;
-
-public class BillingDataProvider extends DataProvider {
- private static Log log = LogFactory.getLog(BillingDataProvider.class);
-
-
- public void invoke(ThrottlingDataContext dataContext) throws ThrottlingException {
- int tenantId = dataContext.getTenantId();
- try {
- Customer customer = Util.getCurrentBillingCustomer(tenantId);
- dataContext.addDataObject(ThrottlingDataEntryConstants.CUSTOMER, customer);
- } catch (RegistryException e) {
- String msg = "Error in getting the current customer. tenant id: " + tenantId + ".";
- log.error(msg, e);
- throw new ThrottlingException(msg, e);
- }
- // getting the package
- try {
- MultitenancyPackage mtPackage = Util.getCurrentBillingPackage(tenantId);
- dataContext.addDataObject(ThrottlingDataEntryConstants.PACKAGE, mtPackage);
- } catch (RegistryException e) {
- String msg = "Error in getting the multi-tenancy package. tenant id: " + tenantId + ".";
- log.error(msg, e);
- throw new ThrottlingException(msg, e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/767082e3/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/dataproviders/DataProvider.java
----------------------------------------------------------------------
diff --git a/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/dataproviders/DataProvider.java b/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/dataproviders/DataProvider.java
deleted file mode 100644
index 313c97f..0000000
--- a/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/dataproviders/DataProvider.java
+++ /dev/null
@@ -1,35 +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.throttling.manager.dataproviders;
-
-import org.wso2.carbon.throttling.manager.dataobjects.ThrottlingDataContext;
-import org.wso2.carbon.throttling.manager.exception.ThrottlingException;
-
-import java.util.Map;
-
-public abstract class DataProvider {
- Map<String, String> parameters;
-
- public void init(Map<String, String> parameters) throws ThrottlingException {
- this.parameters = parameters;
- }
-
- public Map<String, String> getParameters() {
- return parameters;
- }
-
- public abstract void invoke(ThrottlingDataContext dataContext) throws ThrottlingException;
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/767082e3/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/dataproviders/UsageDataProvider.java
----------------------------------------------------------------------
diff --git a/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/dataproviders/UsageDataProvider.java b/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/dataproviders/UsageDataProvider.java
deleted file mode 100644
index fdb54d9..0000000
--- a/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/dataproviders/UsageDataProvider.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/**
- * Copyright (c) 2010, 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.throttling.manager.dataproviders;
-
-import java.util.Calendar;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.throttling.manager.dataobjects.ThrottlingDataContext;
-import org.wso2.carbon.throttling.manager.dataobjects.ThrottlingDataEntryConstants;
-import org.wso2.carbon.throttling.manager.exception.ThrottlingException;
-import org.wso2.carbon.throttling.manager.utils.Util;
-import org.wso2.carbon.usage.beans.BandwidthStatistics;
-import org.wso2.carbon.usage.beans.RequestStatistics;
-import org.wso2.carbon.usage.api.TenantUsageRetriever;
-import org.wso2.carbon.usage.beans.TenantUsage;
-
-/**
- *
- */
-public class UsageDataProvider extends DataProvider {
- private static final Log log = LogFactory.getLog(UsageDataProvider.class);
-
- @Override
- public void invoke(ThrottlingDataContext dataContext) throws ThrottlingException {
- int tenantId = dataContext.getTenantId();
- String userName = dataContext.getUserName();
- String yearMonth = Util.getCurrentMonthString(Calendar.getInstance());
- TenantUsageRetriever tenantUsageRetriever = Util.getTenantUsageRetriever();
-
- try {
- TenantUsage usage = tenantUsageRetriever.getTenantUsage(tenantId, yearMonth);
-
- //Bandwidth usages
- long tenantIncomingBandwidth = usage.getTotalIncomingBandwidth();
- long tenantOutgoingBandwidth = usage.getTotalOutgoingBandwidth();
- dataContext.addDataLong(ThrottlingDataEntryConstants.TENANT_INCOMING_BANDWIDTH,
- tenantIncomingBandwidth);
- dataContext.addDataLong(ThrottlingDataEntryConstants.TENANT_OUTGOING_BANDWIDTH,
- tenantOutgoingBandwidth);
-
- //Registry space capacity
- long currentTenantCapacity = usage.getRegistryContentCapacity();
- long historyTenantCapacity = usage.getRegistryContentHistoryCapacity();
- dataContext.addDataLong(ThrottlingDataEntryConstants.TENANT_CAPACITY,
- currentTenantCapacity);
- dataContext.addDataLong(ThrottlingDataEntryConstants.TENANT_HISTORY_CAPACITY,
- historyTenantCapacity);
- //Assigning registry bandwidths
- BandwidthStatistics totalRgistryBW=usage.getTotalRegistryBandwidth();
- dataContext.addDataLong(ThrottlingDataEntryConstants.REGISTRY_INCOMING_BANDWIDTH,
- totalRgistryBW.getIncomingBandwidth());
- dataContext.addDataLong(ThrottlingDataEntryConstants.REGISTRY_OUTGOING_BANDWIDTH,
- totalRgistryBW.getOutgoingBandwidth());
-
- //Assigning service bandwidths
- BandwidthStatistics serviceBWStatistic=usage.getTotalServiceBandwidth();
- dataContext.addDataLong(ThrottlingDataEntryConstants.SERVICE_INCOMING_BANDWIDTH,
- serviceBWStatistic.getIncomingBandwidth());
- dataContext.addDataLong(ThrottlingDataEntryConstants.SERVICE_OUTGOING_BANDWIDTH,
- serviceBWStatistic.getOutgoingBandwidth());
-
- //Assigning webapp bandwidths
- BandwidthStatistics webappBWStatistic = usage.getTotalWebappBandwidth();
- dataContext.addDataLong(ThrottlingDataEntryConstants.WEBAPP_INCOMING_BANDWIDTH,
- webappBWStatistic.getIncomingBandwidth());
- dataContext.addDataLong(ThrottlingDataEntryConstants.WEBAPP_OUTGOING_BANDWIDTH,
- webappBWStatistic.getOutgoingBandwidth());
-
- //Assigning service requests and response
- RequestStatistics requestStat = usage.getTotalRequestStatistics();
- dataContext.addDataLong(ThrottlingDataEntryConstants.SERVICE_REQUEST_COUNT,
- requestStat.getRequestCount());
- dataContext.addDataLong(ThrottlingDataEntryConstants.SERVICE_RESPONSE_COUNT,
- requestStat.getResponseCount());
-
- //Get number of users
- int usersCount = usage.getNumberOfUsers();
- dataContext.addDataInt(ThrottlingDataEntryConstants.USERS_COUNT, usersCount);
-
- } catch (Exception e) {
- String msg = "Error in retrieving Usage information. " + "tenant id: " + tenantId
- + ", user name: " + userName + ".";
- log.error(msg, e);
- throw new ThrottlingException(msg, e);
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/767082e3/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/exception/ThrottlingException.java
----------------------------------------------------------------------
diff --git a/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/exception/ThrottlingException.java b/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/exception/ThrottlingException.java
deleted file mode 100644
index 39a695c..0000000
--- a/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/exception/ThrottlingException.java
+++ /dev/null
@@ -1,25 +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.throttling.manager.exception;
-
-public class ThrottlingException extends Exception{
- public ThrottlingException(String msg, Exception e) {
- super(msg, e);
- }
- public ThrottlingException(String msg) {
- super(msg);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/767082e3/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/internal/ThrottlingManagerServiceComponent.java
----------------------------------------------------------------------
diff --git a/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/internal/ThrottlingManagerServiceComponent.java b/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/internal/ThrottlingManagerServiceComponent.java
deleted file mode 100644
index 7f0b6b5..0000000
--- a/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/internal/ThrottlingManagerServiceComponent.java
+++ /dev/null
@@ -1,129 +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.throttling.manager.internal;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.osgi.service.component.ComponentContext;
-import org.wso2.carbon.billing.core.BillingManager;
-import org.wso2.carbon.registry.core.service.RegistryService;
-import org.wso2.carbon.rule.kernel.config.RuleEngineConfigService;
-import org.wso2.carbon.user.core.service.RealmService;
-import org.wso2.carbon.billing.mgt.api.MultitenancyBillingInfo;
-import org.wso2.carbon.throttling.manager.utils.Util;
-import org.wso2.carbon.usage.api.TenantUsageRetriever;
-
-/**
- * @scr.component name="org.wso2.carbon.throttling.manager"
- * 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"
- * @scr.reference name="billingManager.service"
- * interface="org.wso2.carbon.billing.core.BillingManager" cardinality="1..1"
- * policy="dynamic" bind="setBillingManager" unbind="unsetBillingManager"
- * @scr.reference name="rule.engine.config.server.component"
- * interface="org.wso2.carbon.rule.kernel.config.RuleEngineConfigService"
- * cardinality="1..1"
- * policy="dynamic" bind="setRuleEngineConfigService"
- * unbind="unsetRuleEngineConfigService"
- * @scr.reference name="metering.service"
- * interface="org.wso2.carbon.usage.api.TenantUsageRetriever" cardinality="1..1"
- * policy="dynamic" bind="setTenantUsageRetriever" unbind="unsetTenantUsageRetriever"
- * @scr.reference name="org.wso2.carbon.billing.mgt.api.MultitenancyBillingInfo"
- * interface="org.wso2.carbon.billing.mgt.api.MultitenancyBillingInfo" cardinality="1..1"
- * policy="dynamic" bind="setMultitenancyBillingInfo" unbind="unsetMultitenancyBillingInfo"
- */
-public class ThrottlingManagerServiceComponent {
- private static Log log = LogFactory.getLog(ThrottlingManagerServiceComponent.class);
-
- protected void activate(ComponentContext context) {
- try {
- Util.setBundleContext(context.getBundleContext());
- Util.loadThrottlingRules();
- Util.registerThrottlingRuleInvoker();
- Util.initializeThrottling();
- log.debug(" Multitenancy Throttling Manager bundle is activated ");
- } catch (Throwable e) {
- log.error(" Multitenancy Throttling Manager bundle failed activating ", e);
- }
- }
-
- protected void deactivate(ComponentContext context) {
- log.debug("******* Multitenancy Throttling 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);
- }
-
- protected void setBillingManager(BillingManager billingManager) {
- log.debug("Receiving billingManager service");
- Util.setBillingManager(billingManager);
- }
-
- protected void unsetBillingManager(BillingManager billingManager) {
- log.debug("Halting billingManager service");
- Util.setBillingManager(null);
- }
-
- protected void setRuleEngineConfigService(RuleEngineConfigService ruleEngineConfigService) {
- Util.setRuleEngineConfigService(ruleEngineConfigService);
- }
-
- protected void unsetRuleEngineConfigService(RuleEngineConfigService ruleEngineConfigService) {
- // we are not dynamically removing schedule helpers
- }
-
- protected void setTenantUsageRetriever(TenantUsageRetriever tenantUsageRetriever) {
- log.debug("Setting Tenant Usage Retriever service");
- Util.setTenantUsageRetriever(tenantUsageRetriever);
- }
-
- protected void unsetTenantUsageRetriever(TenantUsageRetriever tenantUsageRetriever) {
- log.debug("Unsetting Tenant Usage Retriever service");
- Util.setBillingManager(null);
- }
-
- protected void setMultitenancyBillingInfo(MultitenancyBillingInfo mtBillingInfo) {
- log.debug("Setting MT billing info service");
- Util.setMultitenancyBillingInfo(mtBillingInfo);
- }
-
- protected void unsetMultitenancyBillingInfo(MultitenancyBillingInfo mtBillingInfo) {
- log.debug("Unsetting MT billing info service");
- Util.setMultitenancyBillingInfo(null);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/767082e3/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/rules/KnowledgeBaseManager.java
----------------------------------------------------------------------
diff --git a/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/rules/KnowledgeBaseManager.java b/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/rules/KnowledgeBaseManager.java
deleted file mode 100644
index a7d0c40..0000000
--- a/components/stratos/throttling/org.wso2.carbon.throttling.manager/2.1.0/src/main/java/org/wso2/carbon/throttling/manager/rules/KnowledgeBaseManager.java
+++ /dev/null
@@ -1,70 +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.throttling.manager.rules;
-
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.throttling.manager.dataobjects.ThrottlingDataContext;
-import org.wso2.carbon.throttling.manager.dataobjects.ThrottlingDataEntry;
-import org.wso2.carbon.throttling.manager.exception.ThrottlingException;
-import org.wso2.carbon.throttling.manager.tasks.Task;
-import org.wso2.carbon.throttling.manager.validation.ValidationInfoManager;
-
-public class KnowledgeBaseManager {
- private static final Log log = LogFactory.getLog(KnowledgeBaseManager.class);
-
- public static ThrottlingDataContext feedKnowledgeBase(int tenantId, Task task,
- List<Object> knowledgeBase) throws ThrottlingException {
- // initialize the throttling context
- ThrottlingDataContext throttlingDataContext = new ThrottlingDataContext(tenantId);
-
- // prepare data from data providers
- try {
- task.prepareData(throttlingDataContext);
- } catch (ThrottlingException e) {
- String msg = "Error in preparing throttling data for tenant: " + tenantId + ".";
- log.error(msg, e);
- throw new ThrottlingException(msg, e);
- }
-
- // add data entries with object types separately
- for (ThrottlingDataEntry dataEntry : throttlingDataContext.getData()) {
- if (dataEntry.getValueType() == 4) {
- Object object = dataEntry.getObjectValue();
- if (object != null) {
- knowledgeBase.add(object);
- }
- }
- }
- // load the access validation data
- try {
- ValidationInfoManager.loadValidationDetails(throttlingDataContext);
- } catch (ThrottlingException e) {
- String msg = "Error in loading validation details. tenant id: " + tenantId + ".";
- log.error(msg, e);
- throw new ThrottlingException(msg, e);
- }
-
- // add metering data context
- knowledgeBase.add(throttlingDataContext);
- // add access validation information
- knowledgeBase.add(throttlingDataContext.getAccessValidation());
-
- return throttlingDataContext;
- }
-}