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/11 07:17:59 UTC
[08/27] aplying 0001-Refactor-usage-module-to-apache-stratos.patch
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/tenant_usage.jsp
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/tenant_usage.jsp b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/tenant_usage.jsp
deleted file mode 100644
index bbf56e4..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/tenant_usage.jsp
+++ /dev/null
@@ -1,427 +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.
--->
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.BandwidthStatistics" %>
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.RequestStatistics" %>
-<%@ page import="org.wso2.carbon.usage.ui.report.UsageReport" %>
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.TenantUsage" %>
-<%@ page import="java.util.List" %>
-<%@ page import="org.wso2.carbon.usage.ui.utils.UsageUtil" %>
-<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
-<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %>
-
-<carbon:jsi18n
- resourceBundle="org.wso2.carbon.usage.ui.i18n.JSResources"
- request="<%=request%>"/>
-
-
-<fmt:bundle basename="org.wso2.carbon.usage.ui.i18n.Resources">
-<carbon:breadcrumb
- label="tenant.menu"
- resourceBundle="org.wso2.carbon.usage.ui.i18n.Resources"
- topPage="true"
- request="<%=request%>"/>
-<jsp:include page="../registry_common/registry_common-i18n-ajaxprocessor.jsp"/>
-<script type="text/javascript" src="../registry_common/js/registry_validation.js"></script>
-<script type="text/javascript" src="../registry_common/js/registry_common.js"></script>
-<script type="text/javascript" src="../ajax/js/prototype.js"></script>
-<script type="text/javascript" src="js/register_config.js"></script>
-<script type="text/javascript" src="js/usage-report.js"></script>
-<%
-
- TenantUsage usage = UsageUtil.retrieveCurrentTenantUsage(request, config, session);
- int numberOfUsers = usage.getNumberOfUsers();
- String yearMonth = request.getParameter("year-month");
- session.setAttribute("year-month", yearMonth);
-
-
- if (yearMonth == null) {
- // get the current year month
- yearMonth = UsageUtil.getCurrentYearMonth();
- }
- String username = (String) request.getSession().getAttribute("logged-user");
- String tenantName = usage.getDomain();
- int tenantId = usage.getTenantId();
- String currentYearMonth = UsageUtil.getCurrentYearMonth();
-%>
-
-<%
-
- UsageReport usageReport = new UsageReport(config, session, request);
- List<String> reportDataArray = usageReport.getUsageReportData();
- request.getSession().setAttribute("usage_data", reportDataArray);
-%>
-
-<div id="middle">
-
-<h2><fmt:message key="tenant.usage.report"/> for the Month - <%=yearMonth%> (Tenant: <%=tenantName%>
- )</h2>
-
-<%--<div id="report_ui">
- <carbon:report
- component="org.wso2.carbon.usage"
- template="usage_report"
- pdfReport="true"
- htmlReport="true"
- excelReport="true"
- reportDataSession="usage_data"
- />
-</div>--%>
-<div id="workArea">
-
-<form id="usageForm" action="tenant_usage.jsp" method="post">
-
-<table class="styledLeft">
-<thead>
-<tr>
- <th>
- <fmt:message key="report.duration"/>
- </th>
-</tr>
-</thead>
-<tbody>
-<tr>
-<td class="nopadding">
-<table class="normal-nopadding" cellspacing="0">
-<tbody>
-<tr>
- <td><fmt:message key="year.month"/></td>
- <td colspan="3">
- <select onchange="this.form.submit()" name="year-month" id="year-month" style="width:200px">
- <%
- for (String ym : UsageUtil.getYearMonths()) {
- String selectedStr = "";
- if (ym.equals(yearMonth)) {
- selectedStr = "selected=\"true\" ";
- }
- %>
- <option <%=selectedStr%> value="<%=ym%>"><%=ym%>
- </option>
- <%
- }
- %>
- </select>
- </td>
-</tr>
-<%
- if (currentYearMonth.equals(yearMonth)) {
-%>
-<tr>
- <td colspan="4" class="middle-header"><fmt:message key="users"/></td>
-</tr>
-<tr>
- <td><fmt:message key="number.of.users"/></td>
- <td colspan="3">
- <input readonly="1" type="text" name="userCount" id="userCount" style="width:200px"
- value="<%=numberOfUsers%>"/>
- </td>
-</tr>
-
-<tr>
- <td colspan="4" class="middle-header"><fmt:message key="storage.usage"/></td>
-</tr>
-
-<tr>
- <td><fmt:message key="data.storage.name"/></td>
- <td><fmt:message key="current.data.storage"/></td>
- <td><fmt:message key="history.data.storage"/></td>
- <td><fmt:message key="total.data.storage"/></td>
-</tr>
-<%
- String totalDataStorage = UsageUtil.getTotalDataStorage(usage);
- String currentDataStorage = UsageUtil.getCurrentDataStorage(usage);
- String historyDataStorage = UsageUtil.getHistoryDataStorage(usage);
-%>
-<tr>
- <td><fmt:message key="registry.content.storage.name"/></td>
- <td colspan="1">
- <input readonly="1" type="text" name="currentData" id="currentData" style="width:200px"
- value="<%=currentDataStorage%>"/>
- </td>
- <td colspan="1">
- <input readonly="1" type="text" name="historyData" id="historyData" style="width:200px"
- value="<%=historyDataStorage%>"/>
- </td>
- <td colspan="1">
- <input readonly="1" type="text" name="totalData" id="totalData" style="width:200px"
- value="<%=totalDataStorage%>"/>
- </td>
-</tr>
-<%
- }
-%>
-
-<tr>
- <td colspan="4" class="middle-header"><fmt:message key="api.usage"/></td>
-</tr>
-<tr>
- <td><fmt:message key="server.name"/></td>
- <td><fmt:message key="number.of.api.calls"/></td>
-</tr>
-<%
- String apiCallCount = UsageUtil.getAPIUsage(usage);
-%>
-
-<tr>
- <td><fmt:message key="all.server.name"/></td>
- <td>
- <input readonly="1" type="text" name="totalAPICalls" id="APICalls"
- style="width:200px" value="<%=apiCallCount%>"/>
- </td>
-</tr>
-
-<%--<tr>
- <td colspan="4" class="middle-header"><fmt:message key="registry.bandwidth.usage"/></td>
-</tr>
-<tr>
- <td><fmt:message key="server.name"/></td>
- <td><fmt:message key="incoming.bandwidth"/></td>
- <td><fmt:message key="outgoing.bandwidth"/></td>
- <td><fmt:message key="total.bandwidth"/></td>
-</tr>
-<%
- String totRegInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalRegistryBandwidth());
- String totRegOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalRegistryBandwidth());
- String totRegBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalRegistryBandwidth());
- BandwidthStatistics[] regBWStats = usage.getRegistryBandwidthStatistics();
- if (regBWStats != null && regBWStats.length > 0 && regBWStats[0] != null) {
- for (BandwidthStatistics stat : regBWStats) {
- String regInBandwidth = UsageUtil.getIncomingBandwidth(stat);
- String regOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
- String regBandwidth = UsageUtil.getTotalBandwidth(stat);
-%>
-<tr>
- <td><%=stat.getKey()%>
- </td>
- <td>
- <input readonly="1" type="text" name="registryIncomingBW" id="registryIncomingBW"
- style="width:200px" value="<%=regInBandwidth%>"/>
- </td>
- <td>
- <input readonly="1" type="text" name="registryOutgoingBW" id="registryOutgoingBW"
- style="width:200px" value="<%=regOutBandwidth%>"/>
- </td>
- <td>
- <input readonly="1" type="text" name="registryTotalBW" id="registryTotalBW"
- style="width:200px" value="<%=regBandwidth%>"/>
- </td>
-</tr>
-<%
- }
- }
-%>
-<tr>
- <td><fmt:message key="all.server.name"/></td>
- <td>
- <input readonly="1" type="text" name="totRegistryIncomingBW" id="totRegistryIncomingBW"
- style="width:200px" value="<%=totRegInBandwidth%>"/>
- </td>
- <td>
- <input readonly="1" type="text" name="totRegistryOutgoingBW" id="totRegistryOutgoingBW"
- style="width:200px" value="<%=totRegOutBandwidth%>"/>
- </td>
- <td>
- <input readonly="1" type="text" name="totRegistryTotalBW" id="totRegistryTotalBW"
- style="width:200px" value="<%=totRegBandwidth%>"/>
- </td>
-</tr>
---%>
-
-<tr>
- <td colspan="4" class="middle-header"><fmt:message key="service.bandwidth.usage"/></td>
-</tr>
-<tr>
- <td><fmt:message key="server.name"/></td>
- <td><fmt:message key="incoming.bandwidth"/></td>
- <td><fmt:message key="outgoing.bandwidth"/></td>
- <td><fmt:message key="total.bandwidth"/></td>
-</tr>
-<%
- String totSvcInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalServiceBandwidth());
- String totSvcOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalServiceBandwidth());
- String totSvcBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalServiceBandwidth());
- BandwidthStatistics[] svcBWStats = usage.getServiceBandwidthStatistics();
- if (svcBWStats != null && svcBWStats.length > 0 && svcBWStats[0] != null) {
- for (BandwidthStatistics stat : svcBWStats) {
- String svcInBandwidth = UsageUtil.getIncomingBandwidth(stat);
- String svcOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
- String svcBandwidth = UsageUtil.getTotalBandwidth(stat);
-%>
-<tr>
- <td><%=stat.getKey()%>
- </td>
- <td>
- <input readonly="1" type="text" name="serviceIncomingBW" id="serviceIncomingBW"
- style="width:200px" value="<%=svcInBandwidth%>"/>
- </td>
- <td>
- <input readonly="1" type="text" name="serviceOutgoingBW" id="serviceOutgoingBW"
- style="width:200px" value="<%=svcOutBandwidth%>"/>
- </td>
- <td>
- <input readonly="1" type="text" name="serviceTotalBW" id="serviceTotalBW"
- style="width:200px" value="<%=svcBandwidth%>"/>
- </td>
-</tr>
-<%
- }
- }
-%>
-<tr>
- <td><fmt:message key="all.server.name"/></td>
- <td>
- <input readonly="1" type="text" name="totServiceIncomingBW" id="totServiceIncomingBW"
- style="width:200px" value="<%=totSvcInBandwidth%>"/>
- </td>
- <td>
- <input readonly="1" type="text" name="totServiceOutgoingBW" id="totServiceOutgoingBW"
- style="width:200px" value="<%=totSvcOutBandwidth%>"/>
- </td>
- <td>
- <input readonly="1" type="text" name="totServiceTotalBW" id="totServiceTotalBW"
- style="width:200px" value="<%=totSvcBandwidth%>"/>
- </td>
-</tr>
-
-
-<tr>
- <td colspan="4" class="middle-header"><fmt:message key="webapp.bandwidth.usage"/></td>
-</tr>
-<tr>
- <td><fmt:message key="server.name"/></td>
- <td><fmt:message key="incoming.bandwidth"/></td>
- <td><fmt:message key="outgoing.bandwidth"/></td>
- <td><fmt:message key="total.bandwidth"/></td>
-</tr>
-<%
- String totWebappInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalWebappBandwidth());
- String totWebappOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalWebappBandwidth());
- String totWebappBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalWebappBandwidth());
- BandwidthStatistics[] webappBWStats = usage.getWebappBandwidthStatistics();
- if (webappBWStats != null && webappBWStats.length > 0 && webappBWStats[0] != null) {
- for (BandwidthStatistics stat : webappBWStats) {
- String webappInBandwidth = UsageUtil.getIncomingBandwidth(stat);
- String webappOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
- String webappBandwidth = UsageUtil.getTotalBandwidth(stat);
-%>
-<tr>
- <td><%=stat.getKey()%>
- </td>
- <td>
- <input readonly="1" type="text" name="webappIncomingBW" id="webappIncomingBW"
- style="width:200px" value="<%=webappInBandwidth%>"/>
- </td>
- <td>
- <input readonly="1" type="text" name="webappOutgoingBW" id="webappOutgoingBW"
- style="width:200px" value="<%=webappOutBandwidth%>"/>
- </td>
- <td>
- <input readonly="1" type="text" name="webappTotalBW" id="webappTotalBW" style="width:200px"
- value="<%=webappBandwidth%>"/>
- </td>
-</tr>
-<%
- }
- }
-%>
-<tr>
- <td><fmt:message key="all.server.name"/></td>
- <td>
- <input readonly="1" type="text" name="totWebappIncomingBW" id="totWebappIncomingBW"
- style="width:200px" value="<%=totWebappInBandwidth%>"/>
- </td>
- <td>
- <input readonly="1" type="text" name="totWebappOutgoingBW" id="totWebappOutgoingBW"
- style="width:200px" value="<%=totWebappOutBandwidth%>"/>
- </td>
- <td>
- <input readonly="1" type="text" name="totWebappTotalBW" id="totWebappTotalBW"
- style="width:200px" value="<%=totWebappBandwidth%>"/>
- </td>
-</tr>
-
-
-<tr>
- <td colspan="4" class="middle-header"><fmt:message key="service.usage.stat"/></td>
-</tr>
-<tr>
- <td><fmt:message key="server.name"/></td>
- <td><fmt:message key="service.usage.request"/></td>
- <td><fmt:message key="service.usage.response"/></td>
- <td><fmt:message key="service.usage.fault"/></td>
-</tr>
-<%
- long totSvcReqCount = usage.getTotalRequestStatistics().getRequestCount();
- long totSvcRespCount = usage.getTotalRequestStatistics().getResponseCount();
- long totSvcFaultCount = usage.getTotalRequestStatistics().getFaultCount();
- RequestStatistics[] svcStats = usage.getRequestStatistics();
- if (svcStats != null && svcStats.length > 0 && svcStats[0] != null) {
- for (RequestStatistics stat : svcStats) {
- long svcReqCount = stat.getRequestCount();
- long svcResCount = stat.getResponseCount();
- long svcFaultCount = stat.getFaultCount();
-%>
-<tr>
- <td><%=stat.getKey()%>
- </td>
- <td>
- <input readonly="1" type="text" name="serviceRequestCount" id="serviceRequestCount"
- style="width:200px" value="<%=svcReqCount%>"/>
- </td>
- <td>
- <input readonly="1" type="text" name="serviceResponseCount" id="serviceResponseCount"
- style="width:200px" value="<%=svcResCount%>"/>
- </td>
- <td>
- <input readonly="1" type="text" name="serviceFaultCount" id="serviceFaultCount"
- style="width:200px" value="<%=svcFaultCount%>"/>
- </td>
-</tr>
-<%
- }
- }
-%>
-<tr>
- <td><fmt:message key="all.server.name"/></td>
- <td>
- <input readonly="1" type="text" name="totServiceRequestCount" id="totServiceRequestCount"
- style="width:200px" value="<%=totSvcReqCount%>"/>
- </td>
- <td>
- <input readonly="1" type="text" name="totServiceResponseCount" id="totServiceResponseCount"
- style="width:200px" value="<%=totSvcRespCount%>"/>
- </td>
- <td>
- <input readonly="1" type="text" name="totServiceFaultCount" id="totServiceFaultCount"
- style="width:200px" value="<%=totSvcFaultCount%>"/>
- </td>
-</tr>
-
-
-</tbody>
-</table>
-</td>
-</tr>
-</tbody>
-</table>
-</form>
-<br/>
-</div>
-</div>
-</fmt:bundle>
-
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/usage_report.jsp
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/usage_report.jsp b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/usage_report.jsp
deleted file mode 100644
index cb6a28d..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/usage_report.jsp
+++ /dev/null
@@ -1,28 +0,0 @@
-<%@ page import="org.wso2.carbon.usage.ui.report.UsageReport" %>
-<!--
-~ 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.
--->
-<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<carbon:jsi18n
-resourceBundle="org.wso2.carbon.usage.ui.i18n.JSResources"
-request="<%=request%>" />
-<%
-
- UsageReport usageReport = new UsageReport(config, session, request);
- String[] reportDataArray = usageReport.getUsageReportData();
- request.getSession().setAttribute("usage_data", reportDataArray);
-%>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/pom.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/pom.xml b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/pom.xml
deleted file mode 100644
index 8522cfa..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/pom.xml
+++ /dev/null
@@ -1,131 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-# 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>usage-parent</artifactId>
- <version>2.1.0</version>
-<relativePath>../../pom.xml</relativePath>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <artifactId>org.wso2.carbon.usage.ui</artifactId>
- <version>2.1.3</version>
- <packaging>bundle</packaging>
- <name>WSO2 Stratos - Usage - User Interface</name>
-
- <build>
-
- <plugins>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </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.usage.ui.*,
- </Export-Package>
- <Import-Package>
- org.wso2.carbon.usage.stub.*; version="${carbon.platform.package.import.version.range}",
- javax.servlet;version="${imp.pkg.version.javax.servlet}",
- javax.servlet.http;version="${imp.pkg.version.javax.servlet}",
- !javax.xml.namespace,
- javax.xml.namespace; version=0.0.0,
- org.apache.lucene.*,
- *;resolution:=optional
- </Import-Package>
- <Carbon-Component>UIBundle</Carbon-Component>
- </instructions>
- </configuration>
- </plugin>
-
- </plugins>
- </build>
-
- <dependencies>
-
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-codec.wso2</groupId>
- <artifactId>commons-codec</artifactId>
- </dependency>
- <dependency>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.registry.common.ui</artifactId>
- </dependency>
- <dependency>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.registry.core</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </dependency>
- <dependency>
- <groupId>org.eclipse.equinox</groupId>
- <artifactId>javax.servlet</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.axis2.wso2</groupId>
- <artifactId>axis2</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.ws.commons.axiom.wso2</groupId>
- <artifactId>axiom</artifactId>
- </dependency>
- <dependency>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.ui</artifactId>
- </dependency>
- <dependency>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.stratos.common</artifactId>
- <version>2.1.2</version>
- </dependency>
- <dependency>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.usage.stub</artifactId>
- <version>4.1.3</version>
- </dependency>
- </dependencies>
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/clients/UsageServiceClient.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/clients/UsageServiceClient.java b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/clients/UsageServiceClient.java
deleted file mode 100644
index 64ee922..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/clients/UsageServiceClient.java
+++ /dev/null
@@ -1,115 +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.usage.ui.clients;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.client.Options;
-import org.apache.axis2.client.ServiceClient;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.CarbonConstants;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.ui.CarbonUIUtil;
-import org.wso2.carbon.usage.stub.beans.xsd.InstanceUsageStatics;
-import org.wso2.carbon.usage.stub.beans.xsd.PaginatedInstanceUsage;
-import org.wso2.carbon.usage.stub.beans.xsd.PaginatedTenantUsageInfo;
-import org.wso2.carbon.usage.stub.beans.xsd.TenantUsage;
-import org.wso2.carbon.usage.stub.services.UsageServiceStub;
-import org.wso2.carbon.utils.ServerConstants;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.http.HttpSession;
-
-public class UsageServiceClient {
- private static final Log log = LogFactory.getLog(UsageServiceClient.class);
-
- private UsageServiceStub stub;
- private String epr;
-
- public UsageServiceClient(
- String cookie, String backendServerURL, ConfigurationContext configContext)
- throws RegistryException {
-
- epr = backendServerURL + "UsageService";
-
- try {
- stub = new UsageServiceStub(configContext, epr);
-
- ServiceClient client = stub._getServiceClient();
- Options option = client.getOptions();
- option.setManageSession(true);
- option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
-
- } catch (AxisFault axisFault) {
- String msg = "Failed to initiate UsageService service client. " + axisFault.getMessage();
- log.error(msg, axisFault);
- throw new RegistryException(msg, axisFault);
- }
- }
-
- public UsageServiceClient(ServletConfig config, HttpSession session)
- throws RegistryException {
-
- String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);
- String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session);
- ConfigurationContext configContext = (ConfigurationContext) config.
- getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
- epr = backendServerURL + "UsageService";
-
- try {
- stub = new UsageServiceStub(configContext, epr);
-
- ServiceClient client = stub._getServiceClient();
- Options option = client.getOptions();
- option.setManageSession(true);
- option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
-
- } catch (AxisFault axisFault) {
- String msg = "Failed to initiate UsageService service client. " + axisFault.getMessage();
- log.error(msg, axisFault);
- throw new RegistryException(msg, axisFault);
- }
- }
-
- public TenantUsage retrieveCurrentTenantUsage(String yearMonth) throws Exception {
- return stub.retrieveCurrentTenantUsage(yearMonth);
- }
-
- public TenantUsage[] retrieveTenantUsages(String yearMonth) throws Exception {
- return stub.retrieveTenantUsages(yearMonth);
- }
-
- public PaginatedTenantUsageInfo retrievePaginatedTenantUsages(String yearMonth, int pageNumber,
- int entriesPerPage) throws Exception {
- return stub.retrievePaginatedTenantUsages(yearMonth, pageNumber, entriesPerPage);
- }
-
- public TenantUsage retrieveTenantUsage(String yearMonth, int tenantId) throws Exception {
- return stub.retrieveTenantUsage(yearMonth, tenantId);
- }
-
- public InstanceUsageStatics[] retrieveInstanceUsage() throws Exception{
- return stub.retrieveInstanceUsage();
- }
-
- public PaginatedInstanceUsage retrievePaginatedInstanceUsage (
- String yearMonth, int pageNumber, int numbersPerPage) throws Exception {
- return stub.retrievePaginatedInstanceUsage(yearMonth, pageNumber, numbersPerPage);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageData.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageData.java b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageData.java
deleted file mode 100755
index 38ff46b..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageData.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package org.wso2.carbon.usage.ui.report;
-
-/**
- * Copyright (c) 2009, 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.
- */
-public class AllTenantUsageData {
-
- public AllTenantUsageData() {
- }
-
- String yearMonth;
-
- String tenantName;
-
- String numberOfUsers;
-
- String currentDataStorage;
-
- String regBandwidth;
-
- String svcBandwidth;
-
- String svcTotalRequest;
-
- public String getYearMonth() {
- return yearMonth;
- }
-
- public void setYearMonth(String yearMonth) {
- this.yearMonth = yearMonth;
- }
-
- public String getTenantName() {
- return tenantName;
- }
-
- public void setTenantName(String tenantName) {
- this.tenantName = tenantName;
- }
-
- public String getNumberOfUsers() {
- return numberOfUsers;
- }
-
- public void setNumberOfUsers(String numberOfUsers) {
- this.numberOfUsers = numberOfUsers;
- }
-
- public String getCurrentDataStorage() {
- return currentDataStorage;
- }
-
- public void setCurrentDataStorage(String currentDataStorage) {
- this.currentDataStorage = currentDataStorage;
- }
-
- public String getRegBandwidth() {
- return regBandwidth;
- }
-
- public void setRegBandwidth(String regBandwidth) {
- this.regBandwidth = regBandwidth;
- }
-
- public String getSvcBandwidth() {
- return svcBandwidth;
- }
-
- public void setSvcBandwidth(String svcBandwidth) {
- this.svcBandwidth = svcBandwidth;
- }
-
- public String getSvcTotalRequest() {
- return svcTotalRequest;
- }
-
- public void setSvcTotalRequest(String svcTotalRequest) {
- this.svcTotalRequest = svcTotalRequest;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageReport.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageReport.java b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageReport.java
deleted file mode 100644
index 00d03b3..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageReport.java
+++ /dev/null
@@ -1,110 +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.usage.ui.report;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.usage.stub.beans.xsd.PaginatedTenantUsageInfo;
-import org.wso2.carbon.usage.stub.beans.xsd.TenantUsage;
-import org.wso2.carbon.usage.ui.utils.UsageUtil;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-import java.util.ArrayList;
-import java.util.List;
-
-
-/**
- * this class is used to generate reports of all tenant usages
- */
-public class AllTenantUsageReport {
-
- private TenantUsage[] tenantUsages;
- private String yearMonth;
-
- /**
- * @param config
- * @param session
- * @param request
- * @throws Exception
- */
- private static final Log log = LogFactory.getLog(AllTenantUsageReport.class);
-
- public AllTenantUsageReport(ServletConfig config, HttpSession session, HttpServletRequest request)
- throws Exception {
- tenantUsages = UsageUtil.retrieveTenantUsages(request, config, session);
-
-
- yearMonth = (String) request.getSession().getAttribute("year-month");
- }
-
- public List<AllTenantUsageData> getUsageReportData() {
-
- List<AllTenantUsageData> reportData = new ArrayList<AllTenantUsageData>(); // all the strings need to be passed to
- // generate the report are added to this list
-
- if (yearMonth == null) {
- // get the current year month
- yearMonth = UsageUtil.getCurrentYearMonth();
- }
- String currentYearMonth = UsageUtil.getCurrentYearMonth();
-
- // add all the usage data to the list
- try {
- for (TenantUsage usage : tenantUsages) {
- AllTenantUsageData usageData = new AllTenantUsageData();
- usageData.setYearMonth(yearMonth);
- String currentDataStorage = UsageUtil.getTotalDataStorage(usage);
- String regBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalRegistryBandwidth());
- String svcBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalServiceBandwidth());
- long svcTotalRequest = usage.getTotalRequestStatistics().getRequestCount();
- int numberOfUsers = usage.getNumberOfUsers();
-
- // String username = (String) request.getSession().getAttribute("logged-user");
- String tenantName = usage.getDomain();
- int tenantId = usage.getTenantId();
- String fullReportLink = "any_tenant_usage.jsp?tenant-id=" + tenantId + "&year-month=" + yearMonth;
-
- usageData.setTenantName(tenantName);
- if (yearMonth.equals(currentYearMonth)) {
- usageData.setNumberOfUsers(Integer.toString(numberOfUsers));
- usageData.setCurrentDataStorage(currentDataStorage);
- }
- // if the yearMonth is not current, number of users coloumn and storage usage coloumn are empty
- else {
- usageData.setNumberOfUsers("-");
- usageData.setCurrentDataStorage("-");
- }
- usageData.setRegBandwidth(regBandwidth);
- usageData.setSvcBandwidth(svcBandwidth);
- usageData.setSvcTotalRequest(Long.toString(svcTotalRequest));
- reportData.add(usageData);
- }
- }
- catch (Exception e) {
- String msg = "Error while retrieving tenant usages for month : " + yearMonth;
- log.error(msg, e);
- }
- return reportData; // return as an array
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/report/UsageReport.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/report/UsageReport.java b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/report/UsageReport.java
deleted file mode 100644
index 6c0ad50..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/report/UsageReport.java
+++ /dev/null
@@ -1,194 +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.usage.ui.report;
-
-import org.wso2.carbon.usage.stub.beans.xsd.BandwidthStatistics;
-import org.wso2.carbon.usage.stub.beans.xsd.RequestStatistics;
-import org.wso2.carbon.usage.stub.beans.xsd.TenantUsage;
-import org.wso2.carbon.usage.ui.utils.UsageUtil;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * This class is used to generate tenant usage report
- */
-public class UsageReport {
- private TenantUsage usage;
- private String yearMonth;
-
- public UsageReport(ServletConfig config, HttpSession session, HttpServletRequest request)
- throws Exception {
- usage = UsageUtil.retrieveCurrentTenantUsage(request, config, session);
- yearMonth = (String) request.getSession().getAttribute("year-month");
-
- }
-
-
- public List<String> getUsageReportData() {
-
- int numberOfUsers = usage.getNumberOfUsers();
- if (yearMonth == null) {
-
- yearMonth = UsageUtil.getCurrentYearMonth();
- }
-
- String tenantName = usage.getDomain();
- String currentYearMonth = UsageUtil.getCurrentYearMonth();
- List<String> reportData = new ArrayList<String>();
- reportData.add("Basic Tenant Details");
- reportData.add("");
- reportData.add("Duration");
- reportData.add("Tenant Name");
- reportData.add("Number of users");
- reportData.add("Basic Tenant Details");
- reportData.add("");
- reportData.add(yearMonth);
- reportData.add(tenantName);
- reportData.add(String.valueOf(numberOfUsers));
-
-
- if (currentYearMonth.equals(yearMonth)) {
- reportData.add("Storage Usage");
- reportData.add("Data Storage");
- reportData.add("Current Data Storage");
- reportData.add("Historical Data Storage");
- reportData.add("Total Data Storage");
- String totalDataStorage = UsageUtil.getTotalDataStorage(usage);
- String currentDataStorage = UsageUtil.getCurrentDataStorage(usage);
- String historyDataStorage = UsageUtil.getHistoryDataStorage(usage);
- reportData.add("Storage Usage");
- reportData.add("Registry Content");
- reportData.add(totalDataStorage);
- reportData.add(currentDataStorage);
- reportData.add(historyDataStorage);
- }
-
- String totRegInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalRegistryBandwidth());
- String totRegOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalRegistryBandwidth());
- String totRegBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalRegistryBandwidth());
- reportData.add("Registry Bandwidth Usage");
- reportData.add("Server Name");
- reportData.add("Incoming Bandwidth");
- reportData.add("Outgoing Bandwidth");
- reportData.add("Total Bandwidth");
- BandwidthStatistics[] regBWStats = usage.getRegistryBandwidthStatistics();
- if (regBWStats != null) {
- for (BandwidthStatistics stat : regBWStats) {
- String regInBandwidth = UsageUtil.getIncomingBandwidth(stat);
- String regOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
- String regBandwidth = UsageUtil.getTotalBandwidth(stat);
- reportData.add("Server Name****");
- reportData.add(regInBandwidth);
- reportData.add(regOutBandwidth);
- reportData.add(regBandwidth);
-
- }
- }
- reportData.add("Registry Bandwidth Usage");
- reportData.add("All Server Total");
- reportData.add(totRegInBandwidth);
- reportData.add(totRegOutBandwidth);
- reportData.add(totRegBandwidth);
-
- String totSvcInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalServiceBandwidth());
- String totSvcOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalServiceBandwidth());
- String totSvcBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalServiceBandwidth());
- reportData.add("Service Bandwidth Usage");
- reportData.add("Server Name");
- reportData.add("Incoming Bandwidth");
- reportData.add("Outgoing Bandwidth");
- reportData.add("Total Bandwidth");
- BandwidthStatistics[] svcBWStats = usage.getServiceBandwidthStatistics();
- if (svcBWStats != null) {
- for (BandwidthStatistics stat : svcBWStats) {
- String svcInBandwidth = UsageUtil.getIncomingBandwidth(stat);
- String svcOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
- String svcBandwidth = UsageUtil.getTotalBandwidth(stat);
- reportData.add("Server Name****");
- reportData.add(svcInBandwidth);
- reportData.add(svcOutBandwidth);
- reportData.add(svcBandwidth);
-
- }
- }
- reportData.add("Service Bandwidth Usage");
- reportData.add("All Server Total");
- reportData.add(totSvcInBandwidth);
- reportData.add(totSvcOutBandwidth);
- reportData.add(totSvcBandwidth);
-
- String totWebappInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalWebappBandwidth());
- String totWebappOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalWebappBandwidth());
- String totWebappBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalWebappBandwidth());
- BandwidthStatistics[] webappBWStats = usage.getWebappBandwidthStatistics();
- reportData.add("Webapp Bandwidth Usage");
- reportData.add("Server Name");
- reportData.add("Incoming Bandwidth");
- reportData.add("Outgoing Bandwidth");
- reportData.add("Total Bandwidth");
- if (webappBWStats != null) {
- for (BandwidthStatistics stat : webappBWStats) {
- String webappInBandwidth = UsageUtil.getIncomingBandwidth(stat);
- String webappOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
- String webappBandwidth = UsageUtil.getTotalBandwidth(stat);
- reportData.add("Server Name****");
- reportData.add(webappInBandwidth);
- reportData.add(webappOutBandwidth);
- reportData.add(webappBandwidth);
- }
- }
- reportData.add("Webapp Bandwidth Usage");
- reportData.add("All Server Total");
- reportData.add(totWebappInBandwidth);
- reportData.add(totWebappOutBandwidth);
- reportData.add(totWebappBandwidth);
-
-
- long totSvcReqCount = usage.getTotalRequestStatistics().getRequestCount();
- long totSvcRespCount = usage.getTotalRequestStatistics().getResponseCount();
- long totSvcFaultCount = usage.getTotalRequestStatistics().getFaultCount();
- RequestStatistics[] svcStats = usage.getRequestStatistics();
- reportData.add("Service Usage Statistic");
- reportData.add("Server Name");
- reportData.add("Request Count");
- reportData.add("Response Count");
- reportData.add("Fault Count");
- if (svcStats != null && svcStats.length>0 && svcStats[0]!=null) {
- for (RequestStatistics stat : svcStats) {
- long svcReqCount = stat.getRequestCount();
- long svcResCount = stat.getResponseCount();
- long svcFaultCount = stat.getFaultCount();
- reportData.add("Server Name****");
- reportData.add(String.valueOf(svcReqCount));
- reportData.add(String.valueOf(svcResCount));
- reportData.add(String.valueOf(svcFaultCount));
- }
- }
- reportData.add("Service Usage Statistic");
- reportData.add("All Server Total");
- reportData.add(String.valueOf(totSvcReqCount));
- reportData.add(String.valueOf(totSvcRespCount));
- reportData.add(String.valueOf(totSvcFaultCount));
-
- return reportData;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/utils/UsageUtil.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/utils/UsageUtil.java b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/utils/UsageUtil.java
deleted file mode 100644
index 401342d..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/utils/UsageUtil.java
+++ /dev/null
@@ -1,251 +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.usage.ui.utils;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.stratos.common.util.CommonUtil;
-import org.wso2.carbon.registry.common.ui.UIException;
-import org.wso2.carbon.usage.stub.beans.xsd.*;
-import org.wso2.carbon.usage.ui.clients.UsageServiceClient;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletRequest;
-import javax.servlet.http.HttpSession;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.List;
-
-public class UsageUtil {
- private static final Log log = LogFactory.getLog(UsageUtil.class);
-
- private static long KB_LIMIT = 1024;
- private static long MB_LIMIT = 1024 * 1024;
- private static long GB_LIMIT = 1024 * 1024 * 1024;
- private static long TB_LIMIT = (long) 1024 * 1024 * 1024 * 1024;
-
- public static TenantUsage retrieveCurrentTenantUsage(ServletRequest request,
- ServletConfig config, HttpSession session) throws Exception {
- try {
- UsageServiceClient serviceClient = new UsageServiceClient(config, session);
- String yearMonth = request.getParameter("year-month");
- if (yearMonth == null) {
- // get the current year month
- yearMonth = getCurrentYearMonth();
- }
- return serviceClient.retrieveCurrentTenantUsage(yearMonth);
- } catch (Exception e) {
- String msg = "Failed to get current tenant usage.";
- log.error(msg, e);
- throw new UIException(msg, e);
- }
- }
-
- public static TenantUsage[] retrieveTenantUsages(ServletRequest request,
- ServletConfig config, HttpSession session) throws Exception {
- try {
- UsageServiceClient serviceClient = new UsageServiceClient(config, session);
- String yearMonth = request.getParameter("year-month");
- if (yearMonth == null) {
- // get the current year month
- yearMonth = getCurrentYearMonth();
- }
- return serviceClient.retrieveTenantUsages(yearMonth);
- } catch (Exception e) {
- String msg = "Failed to get all tenants usages.";
- log.error(msg, e);
- throw new UIException(msg, e);
- }
- }
-
- public static PaginatedTenantUsageInfo retrievePaginatedTenantUsages(ServletRequest request,
- ServletConfig config, HttpSession session) throws Exception {
- String requestedPage = request.getParameter("requestedPage");
- int pageNumber = 1;
- int numberOfPages = 1;
- int entriesPerPage = 15;
- if (requestedPage != null && requestedPage.length() > 0) {
- pageNumber = new Integer(requestedPage);
- }
-
- try {
- UsageServiceClient serviceClient = new UsageServiceClient(config, session);
- String yearMonth = request.getParameter("year-month");
- if (yearMonth == null) {
- // get the current year month
- yearMonth = getCurrentYearMonth();
- }
- return serviceClient.retrievePaginatedTenantUsages(yearMonth, pageNumber, entriesPerPage);
- } catch (Exception e) {
- String msg = "Failed to get all tenants usages.";
- log.error(msg, e);
- throw new UIException(msg, e);
- }
- }
-
- public static TenantUsage retrieveTenantUsage(ServletRequest request,
- ServletConfig config, HttpSession session) throws Exception {
- try {
- UsageServiceClient serviceClient = new UsageServiceClient(config, session);
- String yearMonth = request.getParameter("year-month");
- if (yearMonth == null) {
- // get the current year month
- yearMonth = getCurrentYearMonth();
- }
- String tenantIdStr = request.getParameter("tenant-id");
- if (tenantIdStr == null) {
- tenantIdStr = "0";
- }
- return serviceClient.retrieveTenantUsage(yearMonth, Integer.parseInt(tenantIdStr));
- } catch (Exception e) {
- String msg = "Failed to get tenant usages.";
- log.error(msg, e);
- throw new UIException(msg, e);
- }
- }
-
-
- public static String convertBytesToString(long storage) {
- if (storage < KB_LIMIT) {
- return storage + " Byte(s)";
- } else if (storage < MB_LIMIT) {
- return storage / KB_LIMIT + " KByte(s)";
- } else if (storage < GB_LIMIT) {
- return storage / MB_LIMIT + " MByte(s)";
- } else if (storage < TB_LIMIT) {
- return storage / GB_LIMIT + " GByte(s)";
- } else {
- return storage / TB_LIMIT + " TByte(s)";
- }
- }
-
- public static String getCurrentYearMonth() {
- Calendar calendar = Calendar.getInstance();
- return CommonUtil.getMonthString(calendar);
- }
-
- public static String[] getYearMonths() {
- // we will list 100 months for now
- List<String> yearMonths = new ArrayList<String>();
- for (int i = 0; i > -100; i--) {
- String yearMonth = CommonUtil.getMonthString(i);
- yearMonths.add(yearMonth);
- }
- return yearMonths.toArray(new String[yearMonths.size()]);
- }
-
- public static String getCurrentDataStorage(TenantUsage usage) {
- TenantDataCapacity regData = usage.getRegistryCapacity();
- long currentData = 0;
- if (regData != null) {
- currentData = regData.getRegistryContentCapacity();
- }
- return convertBytesToString(currentData);
- }
-
- public static String getHistoryDataStorage(TenantUsage usage) {
- TenantDataCapacity historyData = usage.getRegistryCapacity();
- long currentData = 0;
- if (historyData != null) {
- currentData = historyData.getRegistryContentHistoryCapacity();
- }
- return convertBytesToString(currentData);
- }
-
- public static String getTotalDataStorage(TenantUsage usage) {
- TenantDataCapacity regData = usage.getRegistryCapacity();
- long totalDataStorage = 0;
- if (regData != null) {
- totalDataStorage =
- regData.getRegistryContentCapacity() + regData.getRegistryContentHistoryCapacity();
- }
- return convertBytesToString(totalDataStorage);
- }
-
- public static String getIncomingBandwidth(BandwidthStatistics bandwidth) {
- long totalBW = 0;
- if (bandwidth != null) {
- totalBW = bandwidth.getIncomingBandwidth();
- }
- return convertBytesToString(totalBW);
- }
-
- public static String getOutgoingBandwidth(BandwidthStatistics bandwidth) {
- long totalBW = 0;
- if (bandwidth != null) {
- totalBW = bandwidth.getOutgoingBandwidth();
- }
- return convertBytesToString(totalBW);
- }
-
- public static String getTotalBandwidth(BandwidthStatistics bandwidth) {
- long totalBW = 0;
- if (bandwidth != null) {
- totalBW = bandwidth.getIncomingBandwidth() + bandwidth.getOutgoingBandwidth();
- }
- return convertBytesToString(totalBW);
- }
-
- public static InstanceUsageStatics[] retrieveInstanceUsage(ServletRequest request,
- ServletConfig config, HttpSession session)
- throws Exception {
-
- try {
- UsageServiceClient serviceClient = new UsageServiceClient(config, session);
- InstanceUsageStatics[] returnInstanceUsage = serviceClient.retrieveInstanceUsage();
- return returnInstanceUsage;
- } catch (Exception e) {
- String msg = "Failed to get current instance usage.";
- log.error(msg, e);
- throw new UIException(msg, e);
- }
- }
-
- public static PaginatedInstanceUsage retrievePaginatedInstanceUsages(ServletRequest request,
- ServletConfig config, HttpSession session) throws Exception {
- String requestedPage = request.getParameter("requestedPage");
- int pageNumber = 1;
- int numberOfPages = 1;
- int entriesPerPage = 15;
- if (requestedPage != null && requestedPage.length() > 0) {
- pageNumber = new Integer(requestedPage);
- }
- try {
- UsageServiceClient serviceClient = new UsageServiceClient(config, session);
- String yearMonth = request.getParameter("year-month");
- if (yearMonth == null) {
- // get the current year month
- yearMonth = getCurrentYearMonth();
- }
- return serviceClient.retrievePaginatedInstanceUsage(yearMonth, pageNumber, entriesPerPage);
- } catch (Exception e) {
- String msg = "Failed to get paginated instance usages.";
- log.error(msg, e);
- throw new UIException(msg, e);
- }
- }
- public static String getAPIUsage(TenantUsage usage) {
- long count = 0;
-
- if (usage.getApiManagerUsageStats() != null) {
- count =usage.getApiManagerUsageStats()[0].getRequestCount();
- }
- return Long.toString(count);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/META-INF/component.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/META-INF/component.xml b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/META-INF/component.xml
deleted file mode 100644
index 19b0510..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/META-INF/component.xml
+++ /dev/null
@@ -1,73 +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.
- -->
-<component xmlns="http://products.wso2.org/carbon">
- <!-- sample menu configuration -->
- <menus>
- <menu>
- <id>usage_monitoring_menu</id>
- <i18n-key>usage.monitoring</i18n-key>
- <i18n-bundle>org.wso2.carbon.usage.ui.i18n.Resources</i18n-bundle>
- <parent-menu></parent-menu>
- <link>#</link>
- <region>region4</region>
- <style-class>home</style-class>
- <order>22</order>
- <icon>../services/images/services.gif</icon>
- </menu>
- <menu>
- <id>tenant_usage_menu</id>
- <i18n-key>tenant.usage.report</i18n-key>
- <i18n-bundle>org.wso2.carbon.usage.ui.i18n.Resources</i18n-bundle>
- <parent-menu>monitor_menu</parent-menu>
- <link>../tenant-usage/tenant_usage.jsp</link>
- <region>region4</region>
- <order>51</order>
- <style-class>manage</style-class>
- <icon>../tenant-usage/images/user-usage-report.gif</icon>
- <require-permission>/permission/admin/monitor/tenantUsage</require-permission>
- <require-not-super-tenant>true</require-not-super-tenant>
- </menu>
- <!--menu>
- <id>all_tenant_instance_usage_menu</id>
- <i18n-key>instance.usage.report</i18n-key>
- <i18n-bundle>org.wso2.carbon.usage.ui.i18n.Resources</i18n-bundle>
- <parent-menu>monitor_menu</parent-menu>
- <link>../tenant-usage/all_tenant_instance_usage.jsp</link>
- <region>region4</region>
- <order>50</order>
- <style-class>manage</style-class>
- <icon>../tenant-usage/images/instance-usage-report.gif</icon>
- <require-permission>/permission/protected/monitor/userUsage</require-permission>
- <require-super-tenant>true</require-super-tenant>
- </menu-->
- <menu>
- <id>all_tenant_usage_menu</id>
- <i18n-key>all.tenant.usage.report</i18n-key>
- <i18n-bundle>org.wso2.carbon.usage.ui.i18n.Resources</i18n-bundle>
- <parent-menu>monitor_menu</parent-menu>
- <link>../tenant-usage/all_tenant_usage.jsp</link>
- <region>region4</region>
- <order>50</order>
- <style-class>manage</style-class>
- <icon>../tenant-usage/images/tenant-usage-report.gif</icon>
- <require-permission>/permission/protected/monitor/userUsage</require-permission>
- <require-super-tenant>true</require-super-tenant>
- </menu>
- </menus>
-
-</component>