http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.theme.mgt.ui/src/main/resources/web/tenant-theme/theme_mgt.jsp ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.theme.mgt.ui/src/main/resources/web/tenant-theme/theme_mgt.jsp b/components/org.apache.stratos.theme.mgt.ui/src/main/resources/web/tenant-theme/theme_mgt.jsp deleted file mode 100644 index a089ea1..0000000 --- a/components/org.apache.stratos.theme.mgt.ui/src/main/resources/web/tenant-theme/theme_mgt.jsp +++ /dev/null @@ -1,240 +0,0 @@ -<%-- - ~ Licensed to the Apache Software Foundation (ASF) under one - ~ or more contributor license agreements. See the NOTICE file - ~ distributed with this work for additional information - ~ regarding copyright ownership. The ASF licenses this file - ~ to you under the Apache License, Version 2.0 (the - ~ "License"); you may not use this file except in compliance - ~ with the License. You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, - ~ software distributed under the License is distributed on an - ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~ KIND, either express or implied. See the License for the - ~ specific language governing permissions and limitations - ~ under the License. - --%> -<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> -<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %> -<%@ page import="org.apache.stratos.theme.mgt.ui.clients.ThemeMgtServiceClient" %> -<%@ page import="org.apache.stratos.theme.mgt.ui.utils.ThemeUtil" %> -<%@ page contentType="text/html;charset=UTF-8" language="java" %> -<% -response.setHeader("Pragma", "no-cache"); -%> - -<jsp:include page="../dialog/display_messages.jsp"/> - -<!-- YUI inculudes for rich text editor --> -<link rel="stylesheet" type="text/css" - href="../yui/build/editor/assets/skins/sam/simpleeditor.css"/> -<link type="text/css" href="css/tenent-theme.css" rel="stylesheet" /> -<link rel="stylesheet" type="text/css" href="../yui/assets/yui.css" > -<link rel="stylesheet" type="text/css" href="../yui/build/menu/assets/skins/sam/menu.css" /> -<link rel="stylesheet" type="text/css" href="../yui/build/button/assets/skins/sam/button.css" /> -<link rel="stylesheet" type="text/css" href="../yui/build/container/assets/skins/sam/container.css" /> -<link rel="stylesheet" type="text/css" href="../yui/build/autocomplete/assets/skins/sam/autocomplete.css" /> -<link rel="stylesheet" type="text/css" href="../yui/build/editor/assets/skins/sam/editor.css" /> - -<script type="text/javascript" src="../yui/build/yahoo-dom-event/yahoo-dom-event.js"></script> -<script type="text/javascript" src="../yui/build/element/element-beta-min.js"></script> -<script type="text/javascript" src="../yui/build/container/container_core-min.js"></script> -<script type="text/javascript" src="../yui/build/editor/simpleeditor-min.js"></script> - -<script type="text/javascript" src="../admin/js/jquery.js"></script> -<script type="text/javascript" src="../admin/js/jquery.form.js"></script> -<script type="text/javascript" src="../dialog/js/jqueryui/jquery-ui.min.js"></script> - -<!-- other includes --> -<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="../tenant-theme/js/theme_resource_util.js"></script> -<jsp:include page="../resources/resources-i18n-ajaxprocessor.jsp"/> -<script type="text/javascript" src="../resources/js/resource_util.js"></script> -<script type="text/javascript" src="../tenant-theme/js/theme_resource_util.js"></script> -<link rel="stylesheet" type="text/css" href="../resources/css/registry.css"/> -<link rel="stylesheet" type="text/css" href="../tenant-theme/css/tenant.css"/> -<link rel="stylesheet" type="text/css" href="../tenant-theme/css/theme-mgt.css"/> - -<script language="javascript" type="text/javascript"> -function setChecked(value,id){ - var itemLength = document.forms['ThemeMgtForm'].elements['theme'].length; - setCheckedValue(document.forms['ThemeMgtForm'].elements['theme'], value); - for(var i=0;i<=itemLength;i++){ - YAHOO.util.Dom.removeClass('themeObj'+i,'sel-box'); - YAHOO.util.Dom.addClass('themeObj'+i,'nor-box'); - } - YAHOO.util.Dom.removeClass('themeObj'+id,'nor-box'); - YAHOO.util.Dom.addClass('themeObj'+id,'sel-box'); - -} -function setCheckedValue(radioObj, newValue) { - if(!radioObj) - return; - var radioLength = radioObj.length; - if(radioLength == undefined) { - radioObj.checked = (radioObj.value == newValue.toString()); - return; - } - for(var i = 0; i < radioLength; i++) { - radioObj[i].checked = false; - if(radioObj[i].value == newValue.toString()) { - radioObj[i].checked = true; - } - } -} - -</script> -<%--Syntax hylighter include--%> -<script language="javascript" type="text/javascript" src="../tenant-theme/js/editarea/edit_area/edit_area_full.js"></script> - -<% - // the redirectWithStr will be used in the following operations - String redirectWithStr = request.getParameter("redirectWith"); - if (redirectWithStr == null) { - redirectWithStr = ""; - } -%> - -<fmt:bundle basename="org.apache.stratos.theme.mgt.ui.i18n.Resources"> - -<% - - String updateThemeVal = request.getParameter("updateTheme"); - if("Failed".equals(updateThemeVal)){ -%> - - <script type="text/javascript"> - jQuery(document).ready(function() { - CARBON.showErrorDialog('Error in updating the theme, Please try again setting the theme again.'); - }); - </script> -<% - } - - String onceMessageShowed = (String)session.getAttribute("once-message-showed"); - if ("Success".equals(updateThemeVal) && !"true".equals(onceMessageShowed)) { -%> - <script type="text/javascript"> - // we need to refresh the page to load the theme - jQuery(document).ready(function() { - CARBON.showWarningDialog('The theme successfully updated. Please refresh the page to load the theme.'); - }); - </script> -<% - session.setAttribute("once-message-showed", "true"); - } - if ("Success".equals(updateThemeVal) && "true".equals(onceMessageShowed)) { - session.setAttribute("once-message-showed", "false"); -%> - <script type="text/javascript"> - // we need to refresh the page to load the theme - window.location.href="theme_mgt.jsp?redirectWith=<%=redirectWithStr%>"; - </script> -<% - } - - - ThemeMgtServiceClient client; - String[] allThemes; - try { - client = new ThemeMgtServiceClient(config, session); - - allThemes = client.getAllThemes(redirectWithStr); - } catch (Exception e) { -%> -<jsp:forward page="../admin/error.jsp?<%=e.getMessage()%>"/> -<% - return; - } - String parentPathToUpload = "/"; - String logoFilename = "logo.gif"; - - if (allThemes.length < 2) { - return; - } - - // to derive the thumbnail url - //Customization of UI theming per tenant - - -%> - - -<carbon:breadcrumb label="resources" - resourceBundle="org.wso2.carbon.registry.resource.ui.i18n.Resources" - topPage="true" request="<%=request%>"/> -<div id="middle"> - -<h2> Theme Management </h2> - -<div id="workArea"> - -<div class="subtopic">Select a Theme</div> -<div class="subcontent"> -<form id="ThemeMgtForm" name="ThemeMgtForm" action="theme_mgt_ajaxprocessor.jsp?redirectWith=<%=redirectWithStr%>" method="post"> - -<% -String selectedTheme = allThemes[0]; - -for (int i = 1; i < allThemes.length; i ++) { - String theme = allThemes[i]; - String checkedStr = ""; - String thumbUrl = ThemeUtil.getThumbUrl(request, theme); - if (theme.equals(selectedTheme)) { - checkedStr = "checked"; - } -%> -<a onclick="setChecked('<%=theme%>','<%=i%>')"> -<div <%if (theme.equals(selectedTheme)) {%>class="sel-box"<% } else { %>class="nor-box"<%}%> id="themeObj<%=i%>"> - <span><%=theme%></span> - <div> - <input style="display:none" type="radio" name="theme" checked="<%=checkedStr%>" value="<%=theme%>"/> - <div><img src="<%=thumbUrl%>"/></div> - </div> -</div> -</a> -<% -} -%> -<div style="clear:both;"></div> -<p> -<% - if (redirectWithStr.equals("")) { - // mean the user is logged in -%> -<input type="submit" value="Update"/> -<% - } else { -%> -<input type="submit" value="Apply theme"/> -<input type="button" value="Skip" onclick="javascript:location.href='../admin/login.jsp'"/> -<% - } -%> -</p> -</form> -</div> - -<% - if (redirectWithStr.equals("")) { - // mean the user is logged in -%> - -<div class="subtopic">Customize the theme</div> -<div class="subcontent"> -<a href="theme_advanced.jsp">Click here</a> to customize the current theme -</div> -</div> - -<% - } -%> - -</div> - -</fmt:bundle>
http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.theme.mgt.ui/src/main/resources/web/tenant-theme/theme_mgt_ajaxprocessor.jsp ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.theme.mgt.ui/src/main/resources/web/tenant-theme/theme_mgt_ajaxprocessor.jsp b/components/org.apache.stratos.theme.mgt.ui/src/main/resources/web/tenant-theme/theme_mgt_ajaxprocessor.jsp deleted file mode 100644 index 4b1b881..0000000 --- a/components/org.apache.stratos.theme.mgt.ui/src/main/resources/web/tenant-theme/theme_mgt_ajaxprocessor.jsp +++ /dev/null @@ -1,49 +0,0 @@ -<%-- - ~ Licensed to the Apache Software Foundation (ASF) under one - ~ or more contributor license agreements. See the NOTICE file - ~ distributed with this work for additional information - ~ regarding copyright ownership. The ASF licenses this file - ~ to you under the Apache License, Version 2.0 (the - ~ "License"); you may not use this file except in compliance - ~ with the License. You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, - ~ software distributed under the License is distributed on an - ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~ KIND, either express or implied. See the License for the - ~ specific language governing permissions and limitations - ~ under the License. - --%> -<%@ page import="org.wso2.carbon.CarbonConstants" %> -<%@ page import="org.wso2.carbon.registry.common.ui.UIException" %> -<%@ page import="org.apache.stratos.theme.mgt.ui.clients.ThemeMgtServiceClient" %> -<%@ page import="java.util.UUID" %> -<%@ 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.apache.stratos.theme.mgt.ui.i18n.JSResources" - request="<%=request%>" /> -<% - - String redirectWithStr = request.getParameter("redirectWith"); - if (redirectWithStr == null) { - redirectWithStr = ""; - } - try { - ThemeMgtServiceClient client = new ThemeMgtServiceClient(config, session); - String themeName = request.getParameter("theme"); - request.getSession().setAttribute( - CarbonConstants.THEME_URL_RANDOM_SUFFIX_SESSION_KEY, UUID.randomUUID().toString()); - client.applyTheme(themeName, redirectWithStr); - if (redirectWithStr.equals("")) { - response.sendRedirect("../tenant-theme/theme_mgt.jsp?updateTheme=Success&redirectWith=" + redirectWithStr); - } else { - response.sendRedirect("../admin/login.jsp"); - } - } catch (UIException e) { - response.sendRedirect("../tenant-theme/theme_mgt.jsp?updateTheme=Failed&redirectWith=" + redirectWithStr); - } -%> http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.theme.mgt.ui/src/main/resources/web/tenant-theme/update_text_content.jsp ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.theme.mgt.ui/src/main/resources/web/tenant-theme/update_text_content.jsp b/components/org.apache.stratos.theme.mgt.ui/src/main/resources/web/tenant-theme/update_text_content.jsp deleted file mode 100644 index aa8929e..0000000 --- a/components/org.apache.stratos.theme.mgt.ui/src/main/resources/web/tenant-theme/update_text_content.jsp +++ /dev/null @@ -1,52 +0,0 @@ -<%-- - ~ Licensed to the Apache Software Foundation (ASF) under one - ~ or more contributor license agreements. See the NOTICE file - ~ distributed with this work for additional information - ~ regarding copyright ownership. The ASF licenses this file - ~ to you under the Apache License, Version 2.0 (the - ~ "License"); you may not use this file except in compliance - ~ with the License. You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, - ~ software distributed under the License is distributed on an - ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~ KIND, either express or implied. See the License for the - ~ specific language governing permissions and limitations - ~ under the License. - --%> -<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> - -<%@ page import="org.wso2.carbon.registry.common.ui.UIException" %> -<%@ page import="org.wso2.carbon.utils.ServerConstants" %> -<%@ page import="org.apache.stratos.theme.mgt.ui.clients.ThemeMgtServiceClient" %> -<%@ page contentType="text/html;charset=UTF-8" language="java" %> -<fmt:bundle basename="org.wso2.carbon.registry.resource.ui.i18n.Resources"> - - <% - try { - String resourcePath = request.getParameter("resourcePath"); - String contentText = request.getParameter("contentText"); - - String cookie = (String) request. - getSession().getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE); - - try { - ThemeMgtServiceClient client = - new ThemeMgtServiceClient(cookie, config, request.getSession()); - client.updateTextContent(resourcePath, contentText); - - } catch (Exception e) { - String msg = "Failed to update text content of the resource " + - resourcePath + ". " + e.getMessage(); - throw new UIException(msg, e); - } - } catch (UIException e) { - response.setStatus(500); - %><fmt:message key="error.updating.text.message"/>.<br/><%=e.getMessage()%><% - return; - } -%> - -</fmt:bundle> http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.theme.mgt/pom.xml ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.theme.mgt/pom.xml b/components/org.apache.stratos.theme.mgt/pom.xml deleted file mode 100644 index df0dee7..0000000 --- a/components/org.apache.stratos.theme.mgt/pom.xml +++ /dev/null @@ -1,105 +0,0 @@ -<!-- - ~ Licensed to the Apache Software Foundation (ASF) under one - ~ or more contributor license agreements. See the NOTICE file - ~ distributed with this work for additional information - ~ regarding copyright ownership. The ASF licenses this file - ~ to you under the Apache License, Version 2.0 (the - ~ "License"); you may not use this file except in compliance - ~ with the License. You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, - ~ software distributed under the License is distributed on an - ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~ KIND, either express or implied. See the License for the - ~ specific language governing permissions and limitations - ~ under the License. - ~ - --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <parent> - <groupId>org.apache.stratos</groupId> - <artifactId>stratos-components-parent</artifactId> - <version>4.1.0-SNAPSHOT</version> - <relativePath>../pom.xml</relativePath> - </parent> - - <modelVersion>4.0.0</modelVersion> - <artifactId>org.apache.stratos.theme.mgt</artifactId> - <packaging>bundle</packaging> - <name>Apache Stratos - Tenant Theme Configurations</name> - - <build> - - <plugins> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-scr-plugin</artifactId> - </plugin> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - - <extensions>true</extensions> - <configuration> - <instructions> - <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> - <Bundle-Name>${project.artifactId}</Bundle-Name> - <Axis2Module>${project.artifactId}-${project.version}</Axis2Module> - <Private-Package> - org.apache.stratos.theme.mgt.internal.*, - org.apache.stratos.theme.mgt.services.*, - </Private-Package> - <Export-Package> - org.apache.stratos.theme.mgt.util.*, - org.apache.stratos.theme.mgt.module.*, - org.apache.stratos.theme.mgt.handler.*, - </Export-Package> - <Import-Package> - org.wso2.carbon.registry.core.*;version=1.0.1, - org.wso2.carbon.registry.resource.*, - !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>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - </dependency> - <dependency> - <groupId>org.wso2.carbon</groupId> - <artifactId>org.wso2.carbon.registry.resource</artifactId> - <version>4.2.0</version> - </dependency> - <dependency> - <groupId>org.apache.stratos</groupId> - <artifactId>org.apache.stratos.common</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> -</project> http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.theme.mgt/src/main/java/org/apache/stratos/theme/mgt/internal/TenantThemeMgtServiceComponent.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.theme.mgt/src/main/java/org/apache/stratos/theme/mgt/internal/TenantThemeMgtServiceComponent.java b/components/org.apache.stratos.theme.mgt/src/main/java/org/apache/stratos/theme/mgt/internal/TenantThemeMgtServiceComponent.java deleted file mode 100644 index 6603a6f..0000000 --- a/components/org.apache.stratos.theme.mgt/src/main/java/org/apache/stratos/theme/mgt/internal/TenantThemeMgtServiceComponent.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - - * http://www.apache.org/licenses/LICENSE-2.0 - - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.stratos.theme.mgt.internal; - -import org.apache.stratos.common.listeners.TenantMgtListener; -import org.apache.stratos.theme.mgt.util.ThemeLoadingListener; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osgi.service.component.ComponentContext; -import org.osgi.framework.BundleContext; -import org.wso2.carbon.registry.core.service.RegistryService; -import org.apache.stratos.theme.mgt.util.ThemeUtil; -import org.wso2.carbon.user.core.service.RealmService; -import org.wso2.carbon.utils.ConfigurationContextService; - -import java.util.Hashtable; - -/** - * @scr.component name="org.wso2.carbon.governance.theme.tenant" 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="config.context.service" - * interface="org.wso2.carbon.utils.ConfigurationContextService" cardinality="1..1" - * policy="dynamic" bind="setConfigurationContextService" - * unbind="unsetConfigurationContextService" - * - */ -public class TenantThemeMgtServiceComponent { - private static Log log = LogFactory.getLog(TenantThemeMgtServiceComponent.class); - private static ConfigurationContextService configContextService = null; - - protected void activate(ComponentContext context) { - try { - ThemeUtil.loadResourceThemes(); - - // registering the Theme Logding Listener - BundleContext bundleContext = context.getBundleContext(); - bundleContext.registerService(TenantMgtListener.class.getName(), - new ThemeLoadingListener(), new Hashtable()); - - log.debug("******* Multitenancy Theme Config bundle is activated ******* "); - } catch (Exception e) { - log.error("******* Multitenancy Theme Config bundle failed activating ****", e); - } - } - - protected void deactivate(ComponentContext context) { - log.debug("******* Multitenancy Theme Config bundle is deactivated ******* "); - } - - protected void setRegistryService(RegistryService registryService) { - ThemeUtil.setRegistryService(registryService); - } - - protected void unsetRegistryService(RegistryService registryService) { - ThemeUtil.setRegistryService(null); - } - - protected void setRealmService(RealmService realmService) { - ThemeUtil.setRealmService(realmService); - } - - protected void unsetRealmService(RealmService realmService) { - ThemeUtil.setRealmService(null); - } - - protected void setConfigurationContextService(ConfigurationContextService contextService) { - if (log.isDebugEnabled()) { - log.debug("Setting the ConfigurationContext"); - } - configContextService = contextService; - } - - protected void unsetConfigurationContextService(ConfigurationContextService contextService) { - if (log.isDebugEnabled()) { - log.debug("Unsetting the ConfigurationContext"); - } - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.theme.mgt/src/main/java/org/apache/stratos/theme/mgt/services/ThemeMgtService.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.theme.mgt/src/main/java/org/apache/stratos/theme/mgt/services/ThemeMgtService.java b/components/org.apache.stratos.theme.mgt/src/main/java/org/apache/stratos/theme/mgt/services/ThemeMgtService.java deleted file mode 100644 index 05a3d36..0000000 --- a/components/org.apache.stratos.theme.mgt/src/main/java/org/apache/stratos/theme/mgt/services/ThemeMgtService.java +++ /dev/null @@ -1,196 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - - * http://www.apache.org/licenses/LICENSE-2.0 - - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.stratos.theme.mgt.services; - -import org.wso2.carbon.core.AbstractAdmin; -import org.wso2.carbon.registry.core.Registry; -import org.wso2.carbon.registry.core.session.UserRegistry; -import org.wso2.carbon.registry.core.Collection; -import org.wso2.carbon.registry.core.Resource; -import org.apache.stratos.theme.mgt.util.ThemeUtil; -import org.wso2.carbon.registry.resource.beans.*; -import org.wso2.carbon.registry.resource.services.utils.*; -import org.wso2.carbon.registry.common.ResourceData; -import org.wso2.carbon.registry.common.utils.RegistryUtil; - -import javax.activation.DataHandler; -import java.util.ArrayList; -import java.util.Stack; - -public class ThemeMgtService extends AbstractAdmin { - public ResourceTreeEntryBean getResourceTreeEntry(String resourcePath) throws Exception { - UserRegistry themeRegistry = ThemeUtil.getThemeRegistry(getGovernanceSystemRegistry()); - return GetResourceTreeEntryUtil.getResourceTreeEntry(resourcePath, themeRegistry); - } - - public ContentBean getContentBean(String path) throws Exception { - UserRegistry themeRegistry = ThemeUtil.getThemeRegistry(getGovernanceSystemRegistry()); - return ContentUtil.getContent(path, themeRegistry); - } - - - public CollectionContentBean getCollectionContent(String path) throws Exception { - UserRegistry themeRegistry = ThemeUtil.getThemeRegistry(getGovernanceSystemRegistry()); - return ContentUtil.getCollectionContent(path, themeRegistry); - } - - public ResourceData[] getResourceData(String[] paths) throws Exception { - UserRegistry themeRegistry = ThemeUtil.getThemeRegistry(getGovernanceSystemRegistry()); - return ContentUtil.getResourceData(paths, themeRegistry); - } - - public String addCollection( - String parentPath, String collectionName, String mediaType, String description) - throws Exception { - UserRegistry registry = ThemeUtil.getThemeRegistry(getGovernanceSystemRegistry()); - return AddCollectionUtil.process(parentPath, collectionName, mediaType, description, registry); - } - - public void addResource(String path, String mediaType, String description, DataHandler content, - String symlinkLocation, String tenantPass) - throws Exception { - UserRegistry registry = ThemeUtil.getThemeRegistry(getGovernanceSystemRegistry()); - if (registry == null) { - registry = ThemeUtil.getThemeRegistryFromTenantPass(tenantPass); - } - AddResourceUtil.addResource(path, mediaType, description, content, symlinkLocation, registry,new String[0][0]); - } - - public void importResource( - String parentPath, - String resourceName, - String mediaType, - String description, - String fetchURL, - String symlinkLocation, - String tenantPass) throws Exception { - - UserRegistry registry = ThemeUtil.getThemeRegistry(getGovernanceSystemRegistry()); - if (registry == null) { - registry = ThemeUtil.getThemeRegistryFromTenantPass(tenantPass); - } - ImportResourceUtil.importResource(parentPath, resourceName, mediaType, description, fetchURL, - symlinkLocation, registry,new String[0][0]); - } - - public void addTextResource( - String parentPath, - String fileName, - String mediaType, - String description, - String content) throws Exception { - UserRegistry registry = ThemeUtil.getThemeRegistry(getGovernanceSystemRegistry()); - AddTextResourceUtil.addTextResource(parentPath, fileName, mediaType, description, content, registry); - } - - public MetadataBean getMetadata(String path) throws Exception { - RegistryUtil.setSessionResourcePath(path); - UserRegistry registry = ThemeUtil.getThemeRegistry(getGovernanceSystemRegistry()); - return MetadataPopulator.populate(path, registry); - } - - public String getSessionResourcePath() throws Exception { - return RegistryUtil.getSessionResourcePath(); - } - - public String getTextContent(String path) throws Exception { - UserRegistry registry = ThemeUtil.getThemeRegistry(getGovernanceSystemRegistry()); - return GetTextContentUtil.getTextContent(path, registry); - } - - public void updateTextContent(String resourcePath, String contentText) throws Exception { - UserRegistry registry = ThemeUtil.getThemeRegistry(getGovernanceSystemRegistry()); - UpdateTextContentUtil.updateTextContent(resourcePath, contentText, registry); - } - - public ContentDownloadBean getContentDownloadBean(String path) throws Exception { - UserRegistry registry = ThemeUtil.getThemeRegistry(getGovernanceSystemRegistry()); - return GetDownloadContentUtil.getContentDownloadBean(path, registry); - } - - public void renameResource( - String parentPath, String oldResourcePath, String newResourceName) - throws Exception { - UserRegistry registry = ThemeUtil.getThemeRegistry(getGovernanceSystemRegistry()); - RenameResourceUtil.renameResource(parentPath, oldResourcePath, newResourceName, registry); - } - - public void delete(String pathToDelete) throws Exception { - UserRegistry registry = ThemeUtil.getThemeRegistry(getGovernanceSystemRegistry()); - DeleteUtil.process(pathToDelete, registry); - } - - public String[] getAllPaths() throws Exception { - UserRegistry registry = ThemeUtil.getThemeRegistry(getGovernanceSystemRegistry()); - // will use a stack in place of calling recurssion - - - ArrayList<String> paths = new ArrayList<String>(); - Stack<Collection> parentCollections = new Stack<Collection>(); - Collection rootCollection = (Collection)registry.get("/"); - parentCollections.push(rootCollection); - while (!parentCollections.empty()) { - Collection parentCollection = parentCollections.pop(); - String[] childs = parentCollection.getChildren(); - for (String childPath: childs) { - String pathToAdd = childPath.substring(1); - paths.add(pathToAdd); - Resource resource = registry.get(childPath); - if (resource instanceof Collection) { - Collection c = (Collection)resource; - parentCollections.push(c); - } - } - } - return paths.toArray(new String[paths.size()]); - } - - public String[] getAllThemes(String tenantPass) throws Exception { - String[] allThemes = ThemeUtil.getAvailableThemes(); - //we are readding the selected theme as the first element - String currentTheme = ThemeUtil.getCurrentTheme(tenantPass, (UserRegistry) getGovernanceSystemRegistryIfLoggedIn()); - String[] returnVal = new String[allThemes.length + 1]; - returnVal[0] = currentTheme; - for (int i = 0; i < allThemes.length; i ++) { - returnVal[i + 1] = allThemes[i]; - } - return returnVal; - } - - public void applyTheme(String themeName, String tenantPass) throws Exception { - ThemeUtil.applyTheme(themeName, tenantPass, (UserRegistry) getGovernanceSystemRegistryIfLoggedIn()); - ThemeUtil.removeTheUUID(tenantPass); - } - - private Registry getGovernanceSystemRegistryIfLoggedIn() { - UserRegistry tempRegistry = (UserRegistry)getConfigUserRegistry(); - if (tempRegistry != null) { - try { - return ThemeUtil.getRegistryService().getGovernanceSystemRegistry( - tempRegistry.getTenantId()); - } catch (Exception ignored) { - // The Registry service should not fail if the above if condition holds. - return null; - } - } - return null; - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.theme.mgt/src/main/java/org/apache/stratos/theme/mgt/util/ThemeLoadingListener.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.theme.mgt/src/main/java/org/apache/stratos/theme/mgt/util/ThemeLoadingListener.java b/components/org.apache.stratos.theme.mgt/src/main/java/org/apache/stratos/theme/mgt/util/ThemeLoadingListener.java deleted file mode 100644 index f6f6deb..0000000 --- a/components/org.apache.stratos.theme.mgt/src/main/java/org/apache/stratos/theme/mgt/util/ThemeLoadingListener.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - - * http://www.apache.org/licenses/LICENSE-2.0 - - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.stratos.theme.mgt.util; - -import org.wso2.carbon.registry.core.exceptions.RegistryException; -import org.apache.stratos.common.beans.TenantInfoBean; -import org.apache.stratos.common.exception.ApacheStratosException; -import org.apache.stratos.common.listeners.TenantMgtListener; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -public class ThemeLoadingListener implements TenantMgtListener { - private static final Log log = LogFactory.getLog(ThemeLoadingListener.class); - private static final int EXEC_ORDER = 10; - public void onTenantCreate(TenantInfoBean tenantInfo) throws ApacheStratosException { - try { - ThemeUtil.loadTheme(tenantInfo.getTenantId()); - } catch (RegistryException e) { - String msg = "Error in loading the theme for the tenant: " - + tenantInfo.getTenantDomain() + "."; - log.error(msg, e); - throw new ApacheStratosException(msg, e); - } - } - - public void onTenantUpdate(TenantInfoBean tenantInfo) throws ApacheStratosException { - // do nothing - } - - public void onTenantDelete(int tenantId) { - // do nothing - } - - public void onTenantRename(int tenantId, String oldDomainName, - String newDomainName) throws ApacheStratosException { - // do nothing - } - - public int getListenerOrder() { - return EXEC_ORDER; - } - - public void onTenantInitialActivation(int tenantId) throws ApacheStratosException { - // do nothing - } - - public void onTenantActivation(int tenantId) throws ApacheStratosException { - // do nothing - - } - - public void onTenantDeactivation(int tenantId) throws ApacheStratosException { - // do nothing - - } - - public void onSubscriptionPlanChange(int tenentId, String oldPlan, - String newPlan) throws ApacheStratosException { - // do nothing - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.theme.mgt/src/main/java/org/apache/stratos/theme/mgt/util/ThemeUtil.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.theme.mgt/src/main/java/org/apache/stratos/theme/mgt/util/ThemeUtil.java b/components/org.apache.stratos.theme.mgt/src/main/java/org/apache/stratos/theme/mgt/util/ThemeUtil.java deleted file mode 100644 index 6c78474..0000000 --- a/components/org.apache.stratos.theme.mgt/src/main/java/org/apache/stratos/theme/mgt/util/ThemeUtil.java +++ /dev/null @@ -1,306 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - - * http://www.apache.org/licenses/LICENSE-2.0 - - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.stratos.theme.mgt.util; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.registry.core.Collection; -import org.wso2.carbon.registry.core.Registry; -import org.wso2.carbon.registry.core.RegistryConstants; -import org.wso2.carbon.registry.core.Resource; -import org.wso2.carbon.registry.core.exceptions.RegistryException; -import org.wso2.carbon.registry.core.service.RegistryService; -import org.wso2.carbon.registry.core.session.UserRegistry; -import org.wso2.carbon.registry.core.utils.RegistryUtils; -import org.apache.stratos.common.constants.StratosConstants; -import org.apache.stratos.common.util.CommonUtil; -import org.wso2.carbon.user.core.service.RealmService; -import org.wso2.carbon.utils.ServerConstants; - -import javax.activation.MimetypesFileTypeMap; -import java.io.File; -import java.io.FileInputStream; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class ThemeUtil { - - private static final Log log = LogFactory.getLog(ThemeUtil.class); - - private static RegistryService registryService; - private static RealmService realmService; - private static final String CURRENT_THEME_KEY = "current-theme"; - private static final String THEME_PATH = "/repository/theme"; - private static final String THEME_ADMIN_PATH = THEME_PATH + "/admin"; - - public static synchronized void setRegistryService(RegistryService service) { - if (registryService == null) { - registryService = service; - } - } - public static RegistryService getRegistryService() { - return registryService; - } - - public static synchronized void setRealmService(RealmService service) { - if (realmService == null) { - realmService = service; - } - } - - public static RealmService getRealmService() { - return realmService; - } - - public static UserRegistry getThemeMgtSystemRegistry(String tenantPass) throws RegistryException { - if (tenantPass != null && !tenantPass.equals("")) { - // tenant 0th system registry - UserRegistry systemRegistry = registryService.getGovernanceSystemRegistry(); - Resource resource = systemRegistry.get( - StratosConstants.TENANT_CREATION_THEME_PAGE_TOKEN + "/" + tenantPass); - String tenantIdStr = resource.getProperty("tenantId"); - int tenantId = Integer.parseInt(tenantIdStr); - - return registryService.getGovernanceSystemRegistry(tenantId); - } - - return null; - } - - public static void removeTheUUID(String tenantPass) throws RegistryException { - if (tenantPass != null && !tenantPass.equals("")) { - // tenant 0th system registry - UserRegistry systemRegistry = registryService.getGovernanceSystemRegistry(); - if(systemRegistry.resourceExists( - StratosConstants.TENANT_CREATION_THEME_PAGE_TOKEN + "/" + tenantPass)) { - systemRegistry.delete( - StratosConstants.TENANT_CREATION_THEME_PAGE_TOKEN + "/" + tenantPass); - } - } - } - - public static void transferAllThemesToRegistry(File rootDirectory, Registry registry, - String registryPath) - throws RegistryException { - try { - // adding the common media types - Map<String, String> extensionToMediaTypeMap = new HashMap<String, String>(); - extensionToMediaTypeMap.put("gif", "image/gif"); - extensionToMediaTypeMap.put("jpg", "image/jpeg"); - extensionToMediaTypeMap.put("jpe", "image/jpeg"); - extensionToMediaTypeMap.put("jpeg", "image/jpeg"); - extensionToMediaTypeMap.put("png", "image/png"); - extensionToMediaTypeMap.put("css", "text/css"); - - File[] filesAndDirs = rootDirectory.listFiles(); - if (filesAndDirs == null) { - return; - } - List<File> filesDirs = Arrays.asList(filesAndDirs); - - for (File file : filesDirs) { - String filename = file.getName(); - String fileRegistryPath = registryPath + RegistryConstants.PATH_SEPARATOR + filename; - if (!file.isFile()) { - // This is a Directory add a new collection - // This path is used to store the file resource under registry - Collection newCollection = registry.newCollection(); - registry.put(fileRegistryPath, newCollection); - - // recur - transferAllThemesToRegistry(file, registry, fileRegistryPath); - } else { - // Add the file to registry - Resource newResource = registry.newResource(); - String mediaType = null; - if (filename.contains(".")) { - String fileExt = filename.substring(filename.lastIndexOf(".") + 1); - mediaType = extensionToMediaTypeMap.get(fileExt.toLowerCase()); - } - if (mediaType == null) { - mediaType = new MimetypesFileTypeMap().getContentType(file); - } - newResource.setMediaType(mediaType); - newResource.setContentStream(new FileInputStream(file)); - registry.put(fileRegistryPath, newResource); - } - } - } catch (Exception e) { - String msg = "Error loading theme to the sytem registry for registry path: " + registryPath; - log.error(msg, e); - throw new RegistryException(msg, e); - } - - } - - public static UserRegistry getThemeRegistryFromTenantPass(String tenantPass) throws RegistryException { - UserRegistry themeMgtSystemRegistry = getThemeMgtSystemRegistry(tenantPass); - if (themeMgtSystemRegistry != null) { - return themeMgtSystemRegistry.getChrootedRegistry(THEME_ADMIN_PATH); - } else { - return null; - } - } - - public static UserRegistry getThemeRegistry(Registry registry) throws RegistryException { - if (registry == null) { - return null; - } - return ((UserRegistry)registry).getChrootedRegistry(THEME_ADMIN_PATH); - } - - public static void loadResourceThemes() throws RegistryException { - // loads the tenant0's system registry - UserRegistry systemRegistry = registryService.getGovernanceSystemRegistry(); - // we are not checking whether the theme resources already exists to make sure, the newly - // added themes can be loaded just at the activation of the component - String themeRootFileName = System.getProperty(ServerConstants.CARBON_HOME) + File - .separator + "resources" + File.separator + "allthemes"; - // we are always making this accessible from anyware - File themeRootFile = new File(themeRootFileName); - ThemeUtil.transferAllThemesToRegistry(themeRootFile, systemRegistry, StratosConstants.ALL_THEMES_PATH); - - CommonUtil.setAnonAuthorization(RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH + StratosConstants.ALL_THEMES_PATH, - systemRegistry.getUserRealm()); - } - - public static String[] getAvailableThemes() throws RegistryException { - Registry systemRegistry = registryService.getGovernanceSystemRegistry(); - if (!systemRegistry.resourceExists(StratosConstants.ALL_THEMES_PATH)) { - log.info("The theme root path: " + StratosConstants.ALL_THEMES_PATH + " doesn't exist."); - return new String[0]; - } - Collection c = (Collection)systemRegistry.get(StratosConstants.ALL_THEMES_PATH); - String[] childPaths = c.getChildren(); - for (int i = 0; i < childPaths.length; i ++) { - childPaths[i] = RegistryUtils.getResourceName(childPaths[i]); - } - return childPaths; - } - - - public static void loadTheme(int tenantId) throws RegistryException { - // get the util functions from the theme - // this is always the 0th system reigstry - UserRegistry systemRegistry = registryService.getGovernanceSystemRegistry(tenantId); - String[] allThemes = getAvailableThemes(); - if (allThemes.length == 0) { - log.info("No themes found."); - return; - } - int randomNumber = (int)(Math.random() * allThemes.length); - String ourLuckyTheme = allThemes[randomNumber]; - // anway now we are hard coding the default theme to be loaded here, - ourLuckyTheme = "Default"; - applyThemeForDomain(ourLuckyTheme, systemRegistry); - } - - public static void applyTheme(String themeName, String tenantPass, UserRegistry systemTenantRegistry) throws Exception { - if (systemTenantRegistry == null) { - systemTenantRegistry = getThemeMgtSystemRegistry(tenantPass); - } - applyThemeForDomain(themeName, systemTenantRegistry); - } - - public static void applyThemeForDomain(String themeName, UserRegistry systemTenantRegistry) - throws RegistryException { - String sourcePath = StratosConstants.ALL_THEMES_PATH + "/" + themeName; // tenant 0s path - String targetPath = THEME_PATH; - - UserRegistry systemZeroRegistry = registryService.getGovernanceSystemRegistry(); - - // if the themes doesn't exist we would exclude applying it - if (!systemZeroRegistry.resourceExists(sourcePath)) { - log.info("The theme source path: " + sourcePath + " doesn't exist."); - return; - } - - // first delete the old one, or we can backup it if required - // we are anyway getting a backup of the logo - Resource logoR = null; - String logoPath = targetPath + "/admin/" + "logo.gif"; - if (systemTenantRegistry.resourceExists(targetPath)) { - if (systemTenantRegistry.resourceExists(logoPath)) { - logoR = systemTenantRegistry.get(logoPath); - } - if (logoR != null) { - logoR.getContent(); // we will load the content as well. - } - systemTenantRegistry.delete(targetPath); - } - - // copy theme resources to tenant's registry - addResourcesRecursively(sourcePath, targetPath, systemZeroRegistry, systemTenantRegistry); - - // replace the logo - if (logoR != null) { - systemTenantRegistry.put(logoPath, logoR); - } - - // remember the theme name - Resource tenantThemeCollection = systemTenantRegistry.get(targetPath); - tenantThemeCollection.setProperty(CURRENT_THEME_KEY, themeName); - systemTenantRegistry.put(targetPath, tenantThemeCollection); - - try { - CommonUtil.setAnonAuthorization(RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH + targetPath, - systemTenantRegistry.getUserRealm()); - CommonUtil.setAnonAuthorization(RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH + - StratosConstants.ALL_THEMES_PATH, - systemTenantRegistry.getUserRealm()); - } catch (RegistryException e) { - String msg = "Error in giving authorizations of the " + targetPath + - " to the anonymous user and everyone role."; - log.error(msg, e); - throw new RegistryException(msg, e); - } - } - - private static void addResourcesRecursively(String sourcePath, String targetPath, - Registry superRegistry, Registry tenantRegistry) - throws RegistryException { - Resource resource = superRegistry.get(sourcePath); - tenantRegistry.put(targetPath, resource); - - if (resource instanceof Collection) { - String[] children = ((Collection) resource).getChildren(); - for (String child : children) { - String childName = child.substring(child.lastIndexOf("/"), child.length()); - addResourcesRecursively(child, targetPath + childName, superRegistry, tenantRegistry); - } - } - } - - public static String getCurrentTheme(String tenantPass, UserRegistry registry) throws Exception { - if (registry == null) { - registry = getThemeMgtSystemRegistry(tenantPass); - } - String targetPath = THEME_PATH; - - // remember the theme name - Resource tenantThemeCollection = registry.get(targetPath); - if (tenantThemeCollection == null) { - return null; - } - return tenantThemeCollection.getProperty(CURRENT_THEME_KEY); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.theme.mgt/src/main/resources/META-INF/component.xml ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.theme.mgt/src/main/resources/META-INF/component.xml b/components/org.apache.stratos.theme.mgt/src/main/resources/META-INF/component.xml deleted file mode 100644 index 8ae7806..0000000 --- a/components/org.apache.stratos.theme.mgt/src/main/resources/META-INF/component.xml +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - # Licensed to the Apache Software Foundation (ASF) under one - # or more contributor license agreements. See the NOTICE file - # distributed with this work for additional information - # regarding copyright ownership. The ASF licenses this file - # to you under the Apache License, Version 2.0 (the - # "License"); you may not use this file except in compliance - # with the License. You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, - # software distributed under the License is distributed on an - # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - # KIND, either express or implied. See the License for the - # specific language governing permissions and limitations - # under the License. - --> -<component xmlns="http://products.wso2.org/carbon"> - <ManagementPermissions> - <ManagementPermission> - <DisplayName>Configure</DisplayName> - <ResourceId>/permission/admin/configure</ResourceId> - </ManagementPermission> - <ManagementPermission> - <DisplayName>Theme</DisplayName> - <ResourceId>/permission/admin/configure/theme</ResourceId> - </ManagementPermission> - </ManagementPermissions> -</component> http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.theme.mgt/src/main/resources/META-INF/services.xml ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.theme.mgt/src/main/resources/META-INF/services.xml b/components/org.apache.stratos.theme.mgt/src/main/resources/META-INF/services.xml deleted file mode 100644 index f455be7..0000000 --- a/components/org.apache.stratos.theme.mgt/src/main/resources/META-INF/services.xml +++ /dev/null @@ -1,105 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - # Licensed to the Apache Software Foundation (ASF) under one - # or more contributor license agreements. See the NOTICE file - # distributed with this work for additional information - # regarding copyright ownership. The ASF licenses this file - # to you under the Apache License, Version 2.0 (the - # "License"); you may not use this file except in compliance - # with the License. You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, - # software distributed under the License is distributed on an - # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - # KIND, either express or implied. See the License for the - # specific language governing permissions and limitations - # under the License. - --> -<serviceGroup> - <service name="ThemeMgtService" scope="transportsession"> - <transports> - <transport>https</transport> - </transports> - <parameter name="ServiceClass" locked="false"> - org.apache.stratos.theme.mgt.services.ThemeMgtService - </parameter> - - <operation name="getResourceTreeEntry"> - <parameter name="AuthorizationAction" locked="true">/permission/admin/configure/theme</parameter> - </operation> - - <operation name="getContentBean"> - <parameter name="AuthorizationAction" locked="true">/permission/admin/configure/theme</parameter> - </operation> - - <operation name="getCollectionContent"> - <parameter name="AuthorizationAction" locked="true">/permission/admin/configure/theme</parameter> - </operation> - - <operation name="getResourceData"> - <parameter name="AuthorizationAction" locked="true">/permission/admin/configure/theme</parameter> - </operation> - - <operation name="addCollection"> - <parameter name="AuthorizationAction" locked="true">/permission/admin/configure/theme</parameter> - </operation> - - <operation name="addResource"> - <parameter name="AuthorizationAction" locked="true">/permission/admin/configure/theme</parameter> - </operation> - - <operation name="importResource"> - <parameter name="AuthorizationAction" locked="true">/permission/admin/configure/theme</parameter> - </operation> - - <operation name="addTextResource"> - <parameter name="AuthorizationAction" locked="true">/permission/admin/configure/theme</parameter> - </operation> - - <operation name="getMetadata"> - <parameter name="AuthorizationAction" locked="true">/permission/admin/configure/theme</parameter> - </operation> - - <operation name="getSessionResourcePath"> - <parameter name="AuthorizationAction" locked="true">/permission/admin/configure/theme</parameter> - </operation> - - <operation name="getTextContent"> - <parameter name="AuthorizationAction" locked="true">/permission/admin/configure/theme</parameter> - </operation> - - <operation name="updateTextContent"> - <parameter name="AuthorizationAction" locked="true">/permission/admin/configure/theme</parameter> - </operation> - - <operation name="getContentDownloadBean"> - <parameter name="AuthorizationAction" locked="true">/permission/admin/configure/theme</parameter> - </operation> - - <operation name="renameResource"> - <parameter name="AuthorizationAction" locked="true">/permission/admin/configure/theme</parameter> - </operation> - - <operation name="delete"> - <parameter name="AuthorizationAction" locked="true">/permission/admin/configure/theme</parameter> - </operation> - - <operation name="getAllPaths"> - <parameter name="AuthorizationAction" locked="true">/permission/admin/configure/theme</parameter> - </operation> - <operation name="getAllThemes"> - <parameter name="AuthorizationAction" locked="true">/permission/admin/configure/theme</parameter> - </operation> - - <operation name="applyTheme"> - <parameter name="AuthorizationAction" locked="true">/permission/admin/configure/theme</parameter> - </operation> - - - <parameter name="enableMTOM" locked="true">false</parameter> - </service> - <parameter name="adminService" locked="true">true</parameter> - <parameter name="hiddenService" locked="true">true</parameter> -</serviceGroup> http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.throttling.agent/pom.xml ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.throttling.agent/pom.xml b/components/org.apache.stratos.throttling.agent/pom.xml deleted file mode 100644 index ccad292..0000000 --- a/components/org.apache.stratos.throttling.agent/pom.xml +++ /dev/null @@ -1,138 +0,0 @@ -<!-- - # Licensed to the Apache Software Foundation (ASF) under one - # or more contributor license agreements. See the NOTICE file - # distributed with this work for additional information - # regarding copyright ownership. The ASF licenses this file - # to you under the Apache License, Version 2.0 (the - # "License"); you may not use this file except in compliance - # with the License. You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, - # software distributed under the License is distributed on an - # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - # KIND, either express or implied. See the License for the - # specific language governing permissions and limitations - # under the License. - --> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <parent> - <groupId>org.apache.stratos</groupId> - <artifactId>stratos-components-parent</artifactId> - <version>4.0.0-SNAPSHOT</version> - </parent> - - <modelVersion>4.0.0</modelVersion> - <artifactId>org.apache.stratos.throttling.agent</artifactId> - <packaging>bundle</packaging> - <name>Apache Stratos - Throttling Agent</name> - - <build> - - <plugins> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-scr-plugin</artifactId> - </plugin> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - - <extensions>true</extensions> - <configuration> - <instructions> - <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> - <Bundle-Name>${project.artifactId}</Bundle-Name> - <Axis2Module>${project.artifactId}-${project.version}</Axis2Module> - <ListenerManager-RequiredServices> - org.apache.stratos.throttling.agent.ThrottlingAgent - </ListenerManager-RequiredServices> - <Export-Package> - org.apache.stratos.throttling.agent.client, - org.apache.stratos.throttling.agent.*, - </Export-Package> - <Private-Package> - !org.apache.stratos.throttling.agent.client, - org.apache.stratos.throttling.agent.*, - </Private-Package> - <Import-Package> - org.apache.stratos.throttling.agent.stub.*; - version="${carbon.platform.package.import.version.range}", - org.apache.stratos.common.*, - org.wso2.carbon.server.*, - org.wso2.carbon.registry.core.*;version=1.0.1, - org.wso2.carbon.registry.resource.*, - !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.utils</artifactId> - <version>${wso2carbon.version}</version> - </dependency> - <dependency> - <groupId>org.wso2.carbon</groupId> - <artifactId>org.wso2.carbon.registry.core</artifactId> - <version>${wso2carbon.version}</version> - </dependency> - <dependency> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - </dependency> - <dependency> - <groupId>org.wso2.carbon</groupId> - <artifactId>org.wso2.carbon.registry.extensions</artifactId> - <version>${wso2carbon.version}</version> - </dependency> - <dependency> - <groupId>org.wso2.carbon</groupId> - <artifactId>org.wso2.carbon.registry.resource</artifactId> - <version>${wso2carbon.version}</version> - </dependency> - <dependency> - <groupId>org.apache.stratos</groupId> - <artifactId>org.apache.stratos.common</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.stratos</groupId> - <artifactId>org.apache.stratos.throttling.agent.stub</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.wso2.carbon</groupId> - <artifactId>org.wso2.carbon.server</artifactId> - <version>${wso2carbon.version}</version> - </dependency> - <dependency> - <groupId>org.wso2.carbon</groupId> - <artifactId>org.wso2.carbon.tomcat.ext</artifactId> - <version>${wso2carbon.version}</version> - </dependency> - </dependencies> - -</project> http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.throttling.agent/src/main/java/org/apache/stratos/throttling/agent/ThrottlingAgent.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.throttling.agent/src/main/java/org/apache/stratos/throttling/agent/ThrottlingAgent.java b/components/org.apache.stratos.throttling.agent/src/main/java/org/apache/stratos/throttling/agent/ThrottlingAgent.java deleted file mode 100644 index b8665e9..0000000 --- a/components/org.apache.stratos.throttling.agent/src/main/java/org/apache/stratos/throttling/agent/ThrottlingAgent.java +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.stratos.throttling.agent; - -import org.apache.stratos.throttling.agent.cache.TenantThrottlingInfo; -import org.apache.stratos.throttling.agent.cache.ThrottlingActionInfo; -import org.apache.stratos.throttling.agent.cache.ThrottlingInfoCache; -import org.apache.stratos.throttling.agent.cache.ThrottlingInfoCacheUpdaterTask; -import org.apache.stratos.throttling.agent.client.MultitenancyThrottlingServiceClient; -import org.apache.stratos.throttling.agent.client.ThrottlingRuleInvoker; -import org.apache.stratos.throttling.agent.conf.ThrottlingAgentConfiguration; -import org.apache.stratos.throttling.agent.listeners.PerRegistryRequestListener; -import org.apache.stratos.throttling.agent.listeners.PerUserAddListener; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osgi.framework.BundleContext; -import org.osgi.util.tracker.ServiceTracker; -import org.wso2.carbon.base.ServerConfiguration; -import org.wso2.carbon.context.CarbonContext; -import org.wso2.carbon.registry.core.RegistryConstants; -import org.wso2.carbon.registry.core.Resource; -import org.wso2.carbon.registry.core.config.RegistryContext; -import org.wso2.carbon.registry.core.exceptions.RegistryException; -import org.wso2.carbon.registry.core.service.RegistryService; -import org.wso2.carbon.registry.core.session.UserRegistry; -import org.apache.stratos.common.constants.StratosConstants; -import org.apache.stratos.common.util.MeteringAccessValidationUtils; -import org.apache.stratos.common.util.StratosConfiguration; -import org.wso2.carbon.user.core.listener.UserStoreManagerListener; -import org.wso2.carbon.user.core.service.RealmService; -import org.wso2.carbon.utils.CarbonUtils; -import org.wso2.carbon.utils.ConfigurationContextService; - -import java.io.File; -import java.util.Properties; -import java.util.Set; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.TimeUnit; - -public class ThrottlingAgent { - private static final Log log = LogFactory.getLog(ThrottlingAgent.class); - - private static final String CONFIG_FILE = "throttling-agent-config.xml"; - private static final String MANAGER_SERVER_URL_PARAM_NAME = "managerServiceUrl"; - private static final String USERNAME_PARAM_NAME = "userName"; - private static final String PASSWORD_PARAM_NAME = "password"; - - private ThrottlingAgentConfiguration configuration; - - private RegistryService registryService; - - private RealmService realmService; - - private ConfigurationContextService configurationContextService; - - private ThrottlingInfoCache throttlingInfoCache; - - private ServiceTracker throttlingRuleInvokerTracker = null; - - private ScheduledExecutorService scheduler; - - private BundleContext bundleContext; - private StratosConfiguration stratosConfiguration=null; - - public StratosConfiguration getStratosConfiguration() { - return stratosConfiguration; - } - - public void setStratosConfiguration(StratosConfiguration stratosConfiguration) { - this.stratosConfiguration = stratosConfiguration; - } - - public ThrottlingAgent(BundleContext bundleContext) throws Exception { - this.scheduler = Executors.newScheduledThreadPool(1, new ThrottlingAgentThreadFactory()); - this.throttlingInfoCache = new ThrottlingInfoCache(); - this.bundleContext = bundleContext; - } - - public void init() throws RegistryException { - - if("true".equals(ServerConfiguration.getInstance().getFirstProperty("EnableMetering"))){ - - UserRegistry superTenantGovernanceRegistry = registryService.getGovernanceSystemRegistry(); - - scheduler.scheduleAtFixedRate( - new ThrottlingInfoCacheUpdaterTask(throttlingInfoCache, superTenantGovernanceRegistry), 2, 15, - TimeUnit.MINUTES); - - PerRegistryRequestListener.registerPerRegistryRequestListener(RegistryContext.getBaseInstance()); - if (bundleContext != null) { - bundleContext.registerService(UserStoreManagerListener.class.getName(), - new PerUserAddListener(), null); - } - - } - throttlingRuleInvokerTracker = new ServiceTracker(bundleContext, ThrottlingRuleInvoker.class.getName(), - null); - throttlingRuleInvokerTracker.open(); - } - - public ThrottlingInfoCache getThrottlingInfoCache() { - return throttlingInfoCache; - } - - public void setRegistryService(RegistryService registryService) { - this.registryService = registryService; - } - - public RegistryService getRegistryService(){ - return this.registryService; - } - - public void setRealmService(RealmService realmService) { - this.realmService = realmService; - } - - public RealmService getRealmService() { - return realmService; - } - - public void setConfigurationContextService(ConfigurationContextService configurationContextService) { - this.configurationContextService = configurationContextService; - } - - public ConfigurationContextService getConfigurationContextService() { - return configurationContextService; - } - - public void updateThrottlingCacheForTenant() throws Exception { - // TODO: Need to refactor this and updater task - - int tenantId = CarbonContext.getCurrentContext().getTenantId(); - - String tenantValidationInfoResourcePath = - StratosConstants.TENANT_USER_VALIDATION_STORE_PATH + - RegistryConstants.PATH_SEPARATOR + tenantId; - try { - if (registryService.getGovernanceSystemRegistry().resourceExists(tenantValidationInfoResourcePath)) { - Resource tenantValidationInfoResource = - registryService.getGovernanceSystemRegistry().get(tenantValidationInfoResourcePath); - Properties properties = tenantValidationInfoResource.getProperties(); - Set<String> actions = MeteringAccessValidationUtils.getAvailableActions(properties); - for (String action : actions) { - String blocked = - tenantValidationInfoResource.getProperty(MeteringAccessValidationUtils - .generateIsBlockedPropertyKey(action)); - - String blockMessage = - tenantValidationInfoResource.getProperty(MeteringAccessValidationUtils - .generateErrorMsgPropertyKey(action)); - TenantThrottlingInfo tenantThrottlingInfo = throttlingInfoCache.getTenantThrottlingInfo(tenantId); - if (tenantThrottlingInfo == null) { - throttlingInfoCache.addTenant(tenantId); - tenantThrottlingInfo = throttlingInfoCache.getTenantThrottlingInfo(tenantId); - } - tenantThrottlingInfo.updateThrottlingActionInfo(action, - new ThrottlingActionInfo("true".equals(blocked), blockMessage)); - } - } - } catch (RegistryException re) { - String msg = - "Error while getting throttling info for tenant " + tenantId + "."; - log.error(msg, re); - } - } - - private ThrottlingAgentConfiguration loadThrottlingConfiguration() throws Exception { - // it is acceptable that throttling agent file is not present, when the - // embedded rule invoker is in use. - ThrottlingAgentConfiguration throttlingAgentConfig = null; - String configFileName = CarbonUtils.getCarbonConfigDirPath() + File.separator + - StratosConstants.MULTITENANCY_CONFIG_FOLDER + File.separator + CONFIG_FILE; - if (new File(configFileName).exists()) { - throttlingAgentConfig = new ThrottlingAgentConfiguration(configFileName); - } else { - log.warn("Throttling agent config file is not present. File name: " + configFileName + "."); - } - - return throttlingAgentConfig; - } - - public ThrottlingRuleInvoker getThrottlingRuleInvoker() throws Exception { - // first check the OSGi service exists, if so return it - ThrottlingRuleInvoker embeddedRuleInvoker = - (ThrottlingRuleInvoker) throttlingRuleInvokerTracker.getService(); - if (embeddedRuleInvoker != null) { - return embeddedRuleInvoker; - } - - - if (stratosConfiguration == null) { - String msg = - "Neither embedded nor web service implementation of throttling rule invoker found."; - log.error(msg); - throw new Exception(msg); - } - String serverUrl = stratosConfiguration.getManagerServiceUrl(); - String userName =stratosConfiguration.getAdminUserName() ; - String password = stratosConfiguration.getAdminPassword(); - - return new MultitenancyThrottlingServiceClient(serverUrl, userName, password); - } - - public void executeManagerThrottlingRules(int tenantId) throws Exception { - ThrottlingRuleInvoker client = getThrottlingRuleInvoker(); - client.executeThrottlingRules(tenantId); - } - - - class ThrottlingAgentThreadFactory implements ThreadFactory { - private int counter = 0; - - public Thread newThread(Runnable r) { - return new Thread(r, "ThrottlingAgentThreadFactory-" + counter++); - } - } - - public void executeThrottlingRules(int tenantId) { - try { - executeManagerThrottlingRules(tenantId); - updateThrottlingCacheForTenant(); - } catch (Exception e) { - log.error("Error in executing throttling rules"); - } - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.throttling.agent/src/main/java/org/apache/stratos/throttling/agent/cache/Axis2ConfigurationContextObserverImpl.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.throttling.agent/src/main/java/org/apache/stratos/throttling/agent/cache/Axis2ConfigurationContextObserverImpl.java b/components/org.apache.stratos.throttling.agent/src/main/java/org/apache/stratos/throttling/agent/cache/Axis2ConfigurationContextObserverImpl.java deleted file mode 100644 index 9467b61..0000000 --- a/components/org.apache.stratos.throttling.agent/src/main/java/org/apache/stratos/throttling/agent/cache/Axis2ConfigurationContextObserverImpl.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.stratos.throttling.agent.cache; - -import org.apache.axis2.context.ConfigurationContext; -import org.wso2.carbon.utils.AbstractAxis2ConfigurationContextObserver; -import org.wso2.carbon.utils.multitenancy.MultitenantUtils; - -/** - * Axis configuration context observer which add and remove lazy loaded/unloaded tenants to throttling information - * cache. - */ -public class Axis2ConfigurationContextObserverImpl extends AbstractAxis2ConfigurationContextObserver{ - - private ThrottlingInfoCache throttlingInfoCache; - - public Axis2ConfigurationContextObserverImpl(ThrottlingInfoCache throttlingInfoCache){ - this.throttlingInfoCache = throttlingInfoCache; - } - - public void createdConfigurationContext(ConfigurationContext configContext) { - throttlingInfoCache.addTenant(MultitenantUtils.getTenantId(configContext)); - } - - public void terminatedConfigurationContext(ConfigurationContext configCtx) { - throttlingInfoCache.deleteTenant(MultitenantUtils.getTenantId(configCtx)); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.throttling.agent/src/main/java/org/apache/stratos/throttling/agent/cache/TenantThrottlingInfo.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.throttling.agent/src/main/java/org/apache/stratos/throttling/agent/cache/TenantThrottlingInfo.java b/components/org.apache.stratos.throttling.agent/src/main/java/org/apache/stratos/throttling/agent/cache/TenantThrottlingInfo.java deleted file mode 100644 index 6ea5db6..0000000 --- a/components/org.apache.stratos.throttling.agent/src/main/java/org/apache/stratos/throttling/agent/cache/TenantThrottlingInfo.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.stratos.throttling.agent.cache; - -import org.apache.stratos.common.constants.StratosConstants; - -import java.util.HashMap; -import java.util.Map; - -public class TenantThrottlingInfo { - private Map<String, ThrottlingActionInfo> throttlingActionInfoMap = new HashMap<String, ThrottlingActionInfo>(); - - public ThrottlingActionInfo getThrottlingActionInfo(String action) { - if(throttlingActionInfoMap.get(action) != null){ - return throttlingActionInfoMap.get(action); - } - return new ThrottlingActionInfo(false, ""); - } - - public ThrottlingActionInfo getThrottlingActionInfo(String[] actions) { - ThrottlingActionInfo actionInfo = throttlingActionInfoMap.get(StratosConstants.THROTTLING_ALL_ACTION); - if (actionInfo != null && actionInfo.isBlocked()) { - return actionInfo; - } - - for (String action : actions) { - actionInfo = throttlingActionInfoMap.get(action); - if (actionInfo != null && actionInfo.isBlocked()) { - return actionInfo; - } - } - - return new ThrottlingActionInfo(false, ""); - } - - public void updateThrottlingActionInfo(String action, ThrottlingActionInfo throttlingActionInfo) { - throttlingActionInfoMap.put(action, throttlingActionInfo); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.throttling.agent/src/main/java/org/apache/stratos/throttling/agent/cache/ThrottlingActionInfo.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.throttling.agent/src/main/java/org/apache/stratos/throttling/agent/cache/ThrottlingActionInfo.java b/components/org.apache.stratos.throttling.agent/src/main/java/org/apache/stratos/throttling/agent/cache/ThrottlingActionInfo.java deleted file mode 100644 index 9a09f06..0000000 --- a/components/org.apache.stratos.throttling.agent/src/main/java/org/apache/stratos/throttling/agent/cache/ThrottlingActionInfo.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.stratos.throttling.agent.cache; - -public class ThrottlingActionInfo { - private boolean blocked = false; - - private String message = ""; - - public ThrottlingActionInfo(boolean blocked, String message) { - this.blocked = blocked; - this.message = message; - } - - public boolean isBlocked() { - return blocked; - } - - public String getMessage() { - return message; - } -} -
