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 14:08:30 UTC
[2/2] git commit: refactoring theme-mgt components,
missing licence text replacings included
refactoring theme-mgt components, missing licence text replacings included
Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/30fae32c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/30fae32c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/30fae32c
Branch: refs/heads/master
Commit: 30fae32ce86b952a9693be24b33eff3541ba9f9f
Parents: f633083
Author: Lahiru Sandaruwan <la...@wso2.com>
Authored: Thu Jul 11 17:43:37 2013 +0530
Committer: Lahiru Sandaruwan <la...@wso2.com>
Committed: Thu Jul 11 17:43:37 2013 +0530
----------------------------------------------------------------------
.../processors/AddThemeResourceProcessor.java | 38 +-
.../mgt/ui/servlets/ThemeResourceSevelet.java | 21 +-
.../stratos/theme/mgt/ui/utils/ThemeUtil.java | 21 +-
.../mgt/ui/clients/ThemeMgtServiceClient.java | 424 -------------------
.../processors/AddThemeResourceProcessor.java | 240 -----------
.../mgt/ui/servlets/ThemeResourceSevelet.java | 124 ------
.../carbon/theme/mgt/ui/utils/ThemeUtil.java | 67 ---
.../theme/mgt/ui/i18n/JSResources.properties | 2 -
.../theme/mgt/ui/i18n/Resources.properties | 51 ---
.../TenantThemeMgtServiceComponent.java | 36 +-
.../theme/mgt/services/ThemeMgtService.java | 21 +-
.../theme/mgt/util/ThemeLoadingListener.java | 32 +-
.../stratos/theme/mgt/util/ThemeUtil.java | 32 +-
.../TenantThemeMgtServiceComponent.java | 99 -----
.../theme/mgt/services/ThemeMgtService.java | 195 ---------
.../theme/mgt/util/ThemeLoadingListener.java | 73 ----
.../wso2/carbon/theme/mgt/util/ThemeUtil.java | 302 -------------
.../src/main/resources/META-INF/component.xml | 29 +-
18 files changed, 114 insertions(+), 1693 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/30fae32c/components/org.apache.stratos.theme.mgt.ui/src/main/java/org/apache/stratos/theme/mgt/ui/processors/AddThemeResourceProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.theme.mgt.ui/src/main/java/org/apache/stratos/theme/mgt/ui/processors/AddThemeResourceProcessor.java b/components/org.apache.stratos.theme.mgt.ui/src/main/java/org/apache/stratos/theme/mgt/ui/processors/AddThemeResourceProcessor.java
index c8ac3cb..4dd68d2 100644
--- a/components/org.apache.stratos.theme.mgt.ui/src/main/java/org/apache/stratos/theme/mgt/ui/processors/AddThemeResourceProcessor.java
+++ b/components/org.apache.stratos.theme.mgt.ui/src/main/java/org/apache/stratos/theme/mgt/ui/processors/AddThemeResourceProcessor.java
@@ -1,21 +1,22 @@
-/*
- * 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
- *
+/**
+ * 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.ui.processors;
import org.apache.commons.logging.Log;
@@ -44,23 +45,6 @@ import java.util.ArrayList;
import java.util.Map;
-/*
-* Copyright (c) 2006, 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 AddThemeResourceProcessor extends AbstractFileUploadExecutor {
private static final Log log = LogFactory.getLog(AddThemeResourceProcessor.class);
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/30fae32c/components/org.apache.stratos.theme.mgt.ui/src/main/java/org/apache/stratos/theme/mgt/ui/servlets/ThemeResourceSevelet.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.theme.mgt.ui/src/main/java/org/apache/stratos/theme/mgt/ui/servlets/ThemeResourceSevelet.java b/components/org.apache.stratos.theme.mgt.ui/src/main/java/org/apache/stratos/theme/mgt/ui/servlets/ThemeResourceSevelet.java
index a79324e..0650ca3 100644
--- a/components/org.apache.stratos.theme.mgt.ui/src/main/java/org/apache/stratos/theme/mgt/ui/servlets/ThemeResourceSevelet.java
+++ b/components/org.apache.stratos.theme.mgt.ui/src/main/java/org/apache/stratos/theme/mgt/ui/servlets/ThemeResourceSevelet.java
@@ -1,21 +1,22 @@
-/*
- * 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
- *
+/**
+ * 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.ui.servlets;
import org.apache.commons.logging.Log;
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/30fae32c/components/org.apache.stratos.theme.mgt.ui/src/main/java/org/apache/stratos/theme/mgt/ui/utils/ThemeUtil.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.theme.mgt.ui/src/main/java/org/apache/stratos/theme/mgt/ui/utils/ThemeUtil.java b/components/org.apache.stratos.theme.mgt.ui/src/main/java/org/apache/stratos/theme/mgt/ui/utils/ThemeUtil.java
index c01114f..b1072fa 100644
--- a/components/org.apache.stratos.theme.mgt.ui/src/main/java/org/apache/stratos/theme/mgt/ui/utils/ThemeUtil.java
+++ b/components/org.apache.stratos.theme.mgt.ui/src/main/java/org/apache/stratos/theme/mgt/ui/utils/ThemeUtil.java
@@ -1,21 +1,22 @@
-/*
- * 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
- *
+/**
+ * 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.ui.utils;
import org.wso2.carbon.registry.core.RegistryConstants;
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/30fae32c/components/org.apache.stratos.theme.mgt.ui/src/main/java/org/wso2/carbon/theme/mgt/ui/clients/ThemeMgtServiceClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.theme.mgt.ui/src/main/java/org/wso2/carbon/theme/mgt/ui/clients/ThemeMgtServiceClient.java b/components/org.apache.stratos.theme.mgt.ui/src/main/java/org/wso2/carbon/theme/mgt/ui/clients/ThemeMgtServiceClient.java
deleted file mode 100644
index 3630e3a..0000000
--- a/components/org.apache.stratos.theme.mgt.ui/src/main/java/org/wso2/carbon/theme/mgt/ui/clients/ThemeMgtServiceClient.java
+++ /dev/null
@@ -1,424 +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.theme.mgt.ui.clients;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.Constants;
-import org.apache.axis2.client.Options;
-import org.apache.axis2.client.ServiceClient;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.MessageContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.CarbonConstants;
-import org.wso2.carbon.registry.common.utils.RegistryUtil;
-import org.wso2.carbon.registry.core.RegistryConstants;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.registry.core.exceptions.ResourceNotFoundException;
-import org.wso2.carbon.theme.mgt.stub.registry.resource.stub.beans.xsd.CollectionContentBean;
-import org.wso2.carbon.theme.mgt.stub.registry.resource.stub.beans.xsd.ContentBean;
-import org.wso2.carbon.theme.mgt.stub.registry.resource.stub.beans.xsd.ContentDownloadBean;
-import org.wso2.carbon.theme.mgt.stub.registry.resource.stub.beans.xsd.MetadataBean;
-import org.wso2.carbon.theme.mgt.stub.registry.resource.stub.beans.xsd.ResourceTreeEntryBean;
-import org.wso2.carbon.theme.mgt.stub.registry.resource.stub.common.xsd.ResourceData;
-import org.wso2.carbon.theme.mgt.stub.ThemeMgtServiceStub;
-import org.wso2.carbon.ui.CarbonUIUtil;
-import org.wso2.carbon.utils.ServerConstants;
-
-import javax.activation.DataHandler;
-import javax.servlet.ServletConfig;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-public class ThemeMgtServiceClient {
-
- private static final Log log = LogFactory.getLog(ThemeMgtServiceClient.class);
-
- private ThemeMgtServiceStub stub;
- private String epr;
-
- public ThemeMgtServiceClient (
- String cookie, String backendServerURL, ConfigurationContext configContext)
- throws RegistryException {
-
- epr = backendServerURL + "ThemeMgtService";
-
- try {
- stub = new ThemeMgtServiceStub(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 resource service client. " + axisFault.getMessage();
- log.error(msg, axisFault);
- throw new RegistryException(msg, axisFault);
- }
- }
-
-
- public ThemeMgtServiceClient(String cookie, ServletConfig config, HttpSession session)
- throws RegistryException {
-
- String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session);
- ConfigurationContext configContext = (ConfigurationContext) config.
- getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
- epr = backendServerURL + "ThemeMgtService";
-
- try {
- stub = new ThemeMgtServiceStub(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 resource service client. " + axisFault.getMessage();
- log.error(msg, axisFault);
- throw new RegistryException(msg, axisFault);
- }
- }
-
- public ThemeMgtServiceClient(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 + "ThemeMgtService";
-
- try {
- stub = new ThemeMgtServiceStub(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 resource service client. " + axisFault.getMessage();
- log.error(msg, axisFault);
- throw new RegistryException(msg, axisFault);
- }
- }
-
- public ResourceTreeEntryBean getResourceTreeEntry(String resourcePath)
- throws Exception {
-
- ResourceTreeEntryBean entryBean = null;
- try {
- Options options = stub._getServiceClient().getOptions();
- options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
- entryBean = stub.getResourceTreeEntry(resourcePath);
- } catch (Exception e) {
- String msg = "Failed to get resource tree entry for resource " +
- resourcePath + ". " + e.getMessage();
- log.error(msg, e);
- throw e;
- }
- if (entryBean == null) {
- throw new ResourceNotFoundException("The resource does not exist");
- }
- return entryBean;
- }
-
- public ContentBean getContent(HttpServletRequest request) throws Exception {
-
- String path = RegistryUtil.getPath(request);
- ContentBean bean = null;
- try {
- bean = stub.getContentBean(path);
- } catch (Exception e) {
- String msg = "Failed to get content from the resource service. " +
- e.getMessage();
- log.error(msg, e);
- throw e;
- }
-
- return bean;
- }
-
-
- public CollectionContentBean getCollectionContent(HttpServletRequest request) throws Exception {
-
- String path = RegistryUtil.getPath(request);
- CollectionContentBean bean = null;
- try {
- bean = stub.getCollectionContent(path);
-
- } catch (Exception e) {
- String msg = "Failed to get collection content from the resource service. " +
- e.getMessage();
- log.error(msg, e);
- throw e;
- }
-
- return bean;
- }
-
-
- public ResourceData[] getResourceData(String[] paths) throws Exception {
-
- ResourceData[] resourceData;
- try {
- resourceData = stub.getResourceData(paths);
- } catch (Exception e) {
- String msg = "Failed to get resource data from the resource service. " +
- e.getMessage();
- log.error(msg, e);
- throw e;
- }
-
- return resourceData;
- }
-
- public String addCollection(
- String parentPath, String collectionName, String mediaType, String description) throws Exception {
- try {
- return stub.addCollection(parentPath, collectionName, mediaType, description);
- } catch (Exception e) {
- String msg = "Failed to add collection " + collectionName + " for parent path: " + parentPath + ". " +
- e.getMessage();
- log.error(msg, e);
- throw e;
- }
- }
-
- public void addResource(String path, String mediaType, String description, DataHandler content,
- String symlinkLocation, String tenantPass)
- throws Exception {
-
- try {
- Options options = stub._getServiceClient().getOptions();
- options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
- options.setTimeOutInMilliSeconds(300000);
- stub.addResource(path, mediaType, description, content, symlinkLocation, tenantPass);
-
- } catch (Exception e) {
-
- String msg = "Failed to add resource " + path + ". " + e.getMessage();
- log.error(msg, e);
- throw e;
- }
- }
-
- public void importResource(
- String parentPath,
- String resourceName,
- String mediaType,
- String description,
- String fetchURL,
- String symlinkLocation,
- boolean isAsync,
- String tenantPass) throws Exception {
-
- try {
- // This is used by the add wsdl UI. WSDL validation takes long when there are wsdl
- // imports to prevent this we make a async call.
- if (isAsync) {
- stub._getServiceClient().getOptions().setProperty(
- MessageContext.CLIENT_API_NON_BLOCKING,Boolean.TRUE);
- }
- stub.importResource(parentPath, resourceName, mediaType, description, fetchURL, symlinkLocation, tenantPass);
- } catch (Exception e) {
- String msg = "Failed to import resource with name " + resourceName +
- " to the parent collection " + parentPath + ". " + e.getMessage();
- log.error(msg, e);
- throw new RegistryException(msg, e);
- }
- }
-
-
- public void addTextResource(
- String parentPath,
- String fileName,
- String mediaType,
- String description,
- String content) throws Exception {
-
- try {
- stub.addTextResource(parentPath, fileName, mediaType, description, content);
- } catch (Exception e) {
- String msg = "Failed to add new text resource with name " + fileName +
- " to the parent collection " + parentPath + ". " + e.getMessage();
- log.error(msg, e);
- throw new RegistryException(msg, e);
- }
- }
-
- public MetadataBean getMetadata(HttpServletRequest request) throws Exception {
-
- String path = RegistryUtil.getPath(request);
- if (path == null) {
- path = getSessionResourcePath();
- if (path == null) {
- path = RegistryConstants.ROOT_PATH;
- }
-
- request.setAttribute("path", path);
- }
-
- MetadataBean bean = null;
- try {
- bean = stub.getMetadata(path);
- } catch (Exception e) {
- String msg = "Failed to get resource metadata from the resource service. " +
- e.getMessage();
- log.error(msg, e);
- throw e;
- }
-
- return bean;
- }
-
- public MetadataBean getMetadata(HttpServletRequest request,String root) throws Exception {
-
- String path = RegistryConstants.ROOT_PATH;
- request.setAttribute("path", path);
- if (path == null) {
- path = getSessionResourcePath();
- if (path == null) {
- path = RegistryConstants.ROOT_PATH;
- }
- }
-
- MetadataBean bean = null;
- try {
- bean = stub.getMetadata(path);
- } catch (Exception e) {
- String msg = "Failed to get resource metadata from the resource service. " +
- e.getMessage();
- log.error(msg, e);
- throw e;
- }
-
- return bean;
- }
-
- public String getSessionResourcePath() throws Exception {
-
- String sessionResourcePath;
- try {
- sessionResourcePath = stub.getSessionResourcePath();
- } catch (Exception e) {
-
- String msg = "Failed to get the session resource path. " + e.getMessage();
- log.error(msg, e);
- throw e;
- }
- return sessionResourcePath;
- }
-
-
- public String getTextContent(HttpServletRequest request) throws Exception {
-
- String path = RegistryUtil.getPath(request);
-
- String textContent = null;
- try {
- textContent = stub.getTextContent(path);
- } catch (Exception e) {
-
- String msg = "Failed get text content of the resource " +
- path + ". " + e.getMessage();
- log.error(msg, e);
- throw e;
- }
- return textContent;
- }
-
- public void updateTextContent(String resourcePath, String contentText) throws Exception {
-
- try {
- stub.updateTextContent(resourcePath, contentText);
- } catch (Exception e) {
-
- String msg = "Failed to update text content of the resource " +
- resourcePath + ". " + e.getMessage();
- log.error(msg, e);
- throw e;
- }
- }
-
- public ContentDownloadBean getContentDownloadBean(String path) throws Exception {
-
- ContentDownloadBean bean = stub.getContentDownloadBean(path);
- return bean;
- }
-
- public void renameResource(
- String parentPath, String oldResourcePath, String newResourceName)
- throws Exception {
-
- try {
- stub.renameResource(parentPath, oldResourcePath, newResourceName);
- } catch (Exception e) {
- String msg = "Failed to rename resource with name " + oldResourcePath +
- " to the new name " + newResourceName + ". " + e.getMessage();
- log.error(msg, e);
- throw new RegistryException(msg, e);
- }
- }
-
- public void delete(String pathToDelete) throws Exception {
-
- try {
- stub.delete(pathToDelete);
- } catch (Exception e) {
- String msg = "Failed to delete " + pathToDelete + ". " + e.getMessage();
- log.error(msg, e);
- throw e;
- }
- }
-
- public String[] getAllPaths() throws Exception {
-
- try {
- return stub.getAllPaths();
- } catch (Exception e) {
- String msg = "Failed to getAllPaths. " + e.getMessage();
- log.error(msg, e);
- throw e;
- }
- }
-
- public String[] getAllThemes(String tenantPass) throws Exception {
- try {
- return stub.getAllThemes(tenantPass);
- } catch (Exception e) {
- String msg = "Failed to get All Themes.";
- log.error(msg, e);
- throw e;
- }
- }
-
- public void applyTheme(String themeName, String tenantPass) throws Exception {
- try {
- stub.applyTheme(themeName, tenantPass);
- } catch (Exception e) {
- String msg = "Failed to apply the theme: " + themeName;
- log.error(msg, e);
- throw e;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/30fae32c/components/org.apache.stratos.theme.mgt.ui/src/main/java/org/wso2/carbon/theme/mgt/ui/processors/AddThemeResourceProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.theme.mgt.ui/src/main/java/org/wso2/carbon/theme/mgt/ui/processors/AddThemeResourceProcessor.java b/components/org.apache.stratos.theme.mgt.ui/src/main/java/org/wso2/carbon/theme/mgt/ui/processors/AddThemeResourceProcessor.java
deleted file mode 100644
index 11b0bd6..0000000
--- a/components/org.apache.stratos.theme.mgt.ui/src/main/java/org/wso2/carbon/theme/mgt/ui/processors/AddThemeResourceProcessor.java
+++ /dev/null
@@ -1,240 +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.theme.mgt.ui.processors;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.CarbonConstants;
-import org.wso2.carbon.CarbonException;
-import org.wso2.carbon.registry.core.RegistryConstants;
-import org.wso2.carbon.theme.mgt.ui.clients.ThemeMgtServiceClient;
-import org.wso2.carbon.ui.CarbonUIMessage;
-import org.wso2.carbon.ui.transports.fileupload.AbstractFileUploadExecutor;
-import org.wso2.carbon.utils.FileItemData;
-import org.wso2.carbon.utils.ServerConstants;
-
-import javax.activation.DataHandler;
-import javax.activation.DataSource;
-import javax.imageio.ImageIO;
-import javax.mail.util.ByteArrayDataSource;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-import java.awt.*;
-import java.awt.image.BufferedImage;
-import java.io.BufferedInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Map;
-
-
-/*
-* Copyright (c) 2006, 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 AddThemeResourceProcessor extends AbstractFileUploadExecutor {
-
- private static final Log log = LogFactory.getLog(AddThemeResourceProcessor.class);
-
- public boolean execute(HttpServletRequest request, HttpServletResponse response)
- throws CarbonException, IOException {
-
- String webContext = (String) request.getAttribute(CarbonConstants.WEB_CONTEXT);
- String serverURL = (String) request.getAttribute(CarbonConstants.SERVER_URL);
- String cookie = (String) request.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);
- // HttpSession session = request.getSession();
-
- Map<String, ArrayList<FileItemData>> fileItemsMap = getFileItemsMap();
- if (fileItemsMap == null || fileItemsMap.isEmpty()) {
- String msg = "File uploading failed. Content is not set properly.";
- log.error(msg);
-
- CarbonUIMessage.sendCarbonUIMessage(msg, CarbonUIMessage.ERROR, request);
- response.sendRedirect(
- "../" + webContext + "/admin/error.jsp");
-
- return false;
- }
-
- try {
- ThemeMgtServiceClient client =
- new ThemeMgtServiceClient(cookie, serverURL, configurationContext);
-
- String parentPath = null;
- Map<String, ArrayList<java.lang.String>> formFieldsMap = getFormFieldsMap();
- if (formFieldsMap.get("path") != null) {
- parentPath = formFieldsMap.get("path").get(0);
- }
- String resourceName = null;
- if (formFieldsMap.get("filename") != null) {
- resourceName = formFieldsMap.get("filename").get(0);
- }
- String mediaType = null;
- if (formFieldsMap.get("mediaType") != null) {
- mediaType = formFieldsMap.get("mediaType").get(0);
- }
- String description = null;
- if (formFieldsMap.get("description") != null) {
- description = formFieldsMap.get("description").get(0);
- }
- String symlinkLocation = null;
- if (formFieldsMap.get("symlinkLocation") != null) {
- symlinkLocation = formFieldsMap.get("symlinkLocation").get(0);
- }
- String redirectWith = null;
- if (formFieldsMap.get("redirectWith") != null) {
- redirectWith = formFieldsMap.get("redirectWith").get(0);
- }
- /*
- // currently chroot will not work with multitenancy
- IServerAdmin adminClient =
- (IServerAdmin) CarbonUIUtil.
- getServerProxy(new ServerAdminClient(configurationContext,
- serverURL, cookie, session), IServerAdmin.class, session);
- ServerData data = adminClient.getServerData();
- String chroot = "";
- if (data.getRegistryType().equals("remote") && data.getRemoteRegistryChroot() != null &&
- !data.getRemoteRegistryChroot().equals(RegistryConstants.PATH_SEPARATOR)) {
- chroot = data.getRemoteRegistryChroot();
- if (!chroot.startsWith(RegistryConstants.PATH_SEPARATOR)) {
- chroot = RegistryConstants.PATH_SEPARATOR + chroot;
- }
- if (chroot.endsWith(RegistryConstants.PATH_SEPARATOR)) {
- chroot = chroot.substring(0, chroot.length() - RegistryConstants.PATH_SEPARATOR.length());
- }
- }
- if (symlinkLocation != null) {
- symlinkLocation = chroot + symlinkLocation;
- }
- */
-
- FileItemData fileItemData = fileItemsMap.get("upload").get(0);
-
- if ((fileItemData == null) || (fileItemData.getFileItem().getSize() == 0)) {
- String msg = "Failed add resource. Resource content is empty.";
- log.error(msg);
-
- CarbonUIMessage.sendCarbonUIMessage(msg, CarbonUIMessage.ERROR, request);
- response.sendRedirect(
- "../" + webContext + "/admin/error.jsp");
-
- return false;
- }
- DataHandler dataHandler = scaleImage(fileItemData.getDataHandler(), 48, 119);
-
- client.addResource(
- calculatePath(parentPath, resourceName), mediaType, description, dataHandler,
- symlinkLocation, redirectWith);
-
- response.setContentType("text/html; charset=utf-8");
- String msg = "The logo has been successfully updated.";
- CarbonUIMessage.sendCarbonUIMessage(msg, CarbonUIMessage.INFO, request);
-
- String redirectTo = request.getParameter("redirectto");
- if ("theme_mgt".equals(redirectTo)) {
- response.setHeader("Cache-Control", "no-cache, must-revalidate");
- response.sendRedirect("../" + webContext +
- "/tenant-theme/theme_mgt.jsp?logoChanged=true&redirectWith=" + redirectWith);
- }else if ("logo_mgt".equals(redirectTo)) {
- response.setHeader("Cache-Control", "no-cache, must-revalidate");
- response.sendRedirect("../" + webContext +
- "/tenant-theme/logo_mgt.jsp?logoChanged=true&redirectWith=" + redirectWith);
- }
- else {
- response.sendRedirect("../" + webContext + "/tenant-theme/theme_advanced.jsp?path=" + parentPath);
- }
- return true;
-
- } catch (Exception e) {
- String msg = "File upload failed. Please confirm that the chosen image is not corrupted " +
- "and retry uploading, or upload a valid image.";
- log.error(msg + " " + e.getMessage());
-
- CarbonUIMessage.sendCarbonUIMessage(msg, CarbonUIMessage.ERROR, request);
- response.sendRedirect(
- "../" + webContext + "/admin/error.jsp");
-
- return false;
- }
- }
-
- private static DataHandler scaleImage(DataHandler dataHandler, int height, int width) throws IOException {
-
- Image image = ImageIO.read(new BufferedInputStream(dataHandler.getInputStream()));
- // Check if the image has transparent pixels
- boolean hasAlpha = ((BufferedImage)image).getColorModel().hasAlpha();
-
- // Maintain Aspect ratio
- int thumbHeight = height;
- int thumbWidth = width;
- double thumbRatio = (double)width / (double)height;
- double imageRatio = (double)image.getWidth(null) / (double)image.getHeight(null);
- if (thumbRatio < imageRatio) {
- thumbHeight = (int)(thumbWidth / imageRatio);
- } else {
- thumbWidth = (int)(thumbHeight * imageRatio);
- }
-
- BufferedImage thumb;
- // Check if transparent pixels are available and set the color mode accordingly
- if (hasAlpha) {
- thumb = new BufferedImage(thumbWidth, thumbHeight, BufferedImage.TYPE_INT_ARGB);
- } else {
- thumb = new BufferedImage(thumbWidth, thumbHeight, BufferedImage.TYPE_INT_RGB);
- }
- Graphics2D graphics2D = thumb.createGraphics();
- graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
- RenderingHints.VALUE_INTERPOLATION_BILINEAR);
- graphics2D.drawImage(image, 0, 0, thumbWidth, thumbHeight, null);
-
- // Save the image as PNG so that transparent images are rendered as intended
- ByteArrayOutputStream output = new ByteArrayOutputStream();
- ImageIO.write(thumb, "PNG", output);
-
- DataSource dataSource= new ByteArrayDataSource(output.toByteArray(), "application/octet-stream");
- return new DataHandler(dataSource);
- }
-
- private static String calculatePath(String parentPath, String resourceName) {
- String resourcePath;
- if (!parentPath.startsWith(RegistryConstants.PATH_SEPARATOR)) {
- parentPath = RegistryConstants.PATH_SEPARATOR + parentPath;
- }
- if (parentPath.endsWith(RegistryConstants.PATH_SEPARATOR)) {
- resourcePath = parentPath + resourceName;
- } else {
- resourcePath = parentPath + RegistryConstants.PATH_SEPARATOR + resourceName;
- }
- return resourcePath;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/30fae32c/components/org.apache.stratos.theme.mgt.ui/src/main/java/org/wso2/carbon/theme/mgt/ui/servlets/ThemeResourceSevelet.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.theme.mgt.ui/src/main/java/org/wso2/carbon/theme/mgt/ui/servlets/ThemeResourceSevelet.java b/components/org.apache.stratos.theme.mgt.ui/src/main/java/org/wso2/carbon/theme/mgt/ui/servlets/ThemeResourceSevelet.java
deleted file mode 100644
index 6fbfb26..0000000
--- a/components/org.apache.stratos.theme.mgt.ui/src/main/java/org/wso2/carbon/theme/mgt/ui/servlets/ThemeResourceSevelet.java
+++ /dev/null
@@ -1,124 +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.theme.mgt.ui.servlets;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.theme.mgt.stub.registry.resource.stub.beans.xsd.ContentDownloadBean;
-import org.wso2.carbon.theme.mgt.ui.clients.ThemeMgtServiceClient;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.InputStream;
-
-public class ThemeResourceSevelet extends HttpServlet {
-
- private static final Log log = LogFactory.getLog(ThemeResourceSevelet.class);
-
- private ServletConfig servletConfig;
-
- public void init(ServletConfig servletConfig) throws ServletException {
- super.init(servletConfig);
- this.servletConfig = servletConfig;
- }
-
- protected void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
-
- try {
- ThemeMgtServiceClient client = new ThemeMgtServiceClient(servletConfig, request.getSession());
- String path = request.getParameter("path");
- String viewImage = request.getParameter("viewImage");
- if (path == null) {
- String msg = "Could not get the resource content. Path is not specified.";
- log.error(msg);
- response.setStatus(400);
- return;
- }
-
- ContentDownloadBean bean = client.getContentDownloadBean(path);
-
- InputStream contentStream = null;
- if (bean.getContent() != null) {
- contentStream = bean.getContent().getInputStream();
- } else {
- String msg = "The resource content was empty.";
- log.error(msg);
- response.setStatus(204);
- return;
- }
-
- response.setDateHeader("Last-Modified", bean.getLastUpdatedTime().getTime().getTime());
- String ext = "jpg";
- if (path.lastIndexOf(".") < path.length() -1 && path.lastIndexOf(".") > 0) {
- ext = path.substring(path.lastIndexOf(".") + 1);
- }
-
- if (viewImage != null && viewImage.equals("1")) {
- response.setContentType("img/" + ext);
- }
- else {
- if (bean.getMediatype() != null && bean.getMediatype().length() > 0) {
- response.setContentType(bean.getMediatype());
- } else {
- response.setContentType("application/download");
- }
-
- if (bean.getResourceName() != null) {
- response.setHeader(
- "Content-Disposition", "attachment; filename=\"" + bean.getResourceName() + "\"");
- }
- }
-
- if (contentStream != null) {
-
- ServletOutputStream servletOutputStream = null;
- try {
- servletOutputStream = response.getOutputStream();
-
- byte[] contentChunk = new byte[1024];
- int byteCount;
- while ((byteCount = contentStream.read(contentChunk)) != -1) {
- servletOutputStream.write(contentChunk, 0, byteCount);
- }
-
- response.flushBuffer();
- servletOutputStream.flush();
-
- } finally {
- contentStream.close();
-
- if (servletOutputStream != null) {
- servletOutputStream.close();
- }
- }
- }
- } catch (Exception e) {
-
- String msg = "Failed to get resource content. " + e.getMessage();
- log.error(msg, e);
- response.setStatus(500);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/30fae32c/components/org.apache.stratos.theme.mgt.ui/src/main/java/org/wso2/carbon/theme/mgt/ui/utils/ThemeUtil.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.theme.mgt.ui/src/main/java/org/wso2/carbon/theme/mgt/ui/utils/ThemeUtil.java b/components/org.apache.stratos.theme.mgt.ui/src/main/java/org/wso2/carbon/theme/mgt/ui/utils/ThemeUtil.java
deleted file mode 100644
index bca9fce..0000000
--- a/components/org.apache.stratos.theme.mgt.ui/src/main/java/org/wso2/carbon/theme/mgt/ui/utils/ThemeUtil.java
+++ /dev/null
@@ -1,67 +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.theme.mgt.ui.utils;
-
-import org.wso2.carbon.registry.core.RegistryConstants;
-import org.wso2.carbon.ui.CarbonUIUtil;
-import org.wso2.carbon.registry.core.utils.UUIDGenerator;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-import javax.servlet.ServletConfig;
-
-public class ThemeUtil {
- public static String getThemeResourceDownloadURL(String path) {
- return "../../registry/themeResourceContent?path=" + path;
- }
-
- public static String getThemeResourceViewAsImageURL(String path) {
- return "../../registry/themeResourceContent?path=" + path
- + "&viewImage=1";
- }
-
- public static String getThumbUrl(HttpServletRequest request, String themeName) {
- String serverURL = CarbonUIUtil.getAdminConsoleURL(request);
- String serverRoot = serverURL.substring(0, serverURL.length()
- - "carbon/".length());
- return serverRoot + "registry/resource"
- + RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH
- + "/repository/components/org.wso2.carbon.all-themes/"
- + themeName + "/thumb.png";
- }
-
- public static String getLogoURL(ServletConfig config, HttpSession session) {
- // this is to avoid the caching problem
- String randomUUID = UUIDGenerator.generateUUID();
- String serverURL = CarbonUIUtil.getServerURL(
- config.getServletContext(), session);
- String serverRoot = serverURL.substring(0, serverURL.length() - "services/".length());
- String tenantDomain = (String) session
- .getAttribute(MultitenantConstants.TENANT_DOMAIN);
- if (tenantDomain == null) {
- return "";
- }
-
- // Using relative path instead of the back-end server url.
- return "../../../../t/" + tenantDomain + "/registry/resource"
- + RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH
- + "/repository/theme/admin/logo.gif?thatsrnd=" + randomUUID;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/30fae32c/components/org.apache.stratos.theme.mgt.ui/src/main/resources/org/wso2/carbon/theme/mgt/ui/i18n/JSResources.properties
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.theme.mgt.ui/src/main/resources/org/wso2/carbon/theme/mgt/ui/i18n/JSResources.properties b/components/org.apache.stratos.theme.mgt.ui/src/main/resources/org/wso2/carbon/theme/mgt/ui/i18n/JSResources.properties
deleted file mode 100644
index 4282f03..0000000
--- a/components/org.apache.stratos.theme.mgt.ui/src/main/resources/org/wso2/carbon/theme/mgt/ui/i18n/JSResources.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-password.mismatched=Passwords do not match.
-current.password.should.provided=You should provide the current password inorder to change the password.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/30fae32c/components/org.apache.stratos.theme.mgt.ui/src/main/resources/org/wso2/carbon/theme/mgt/ui/i18n/Resources.properties
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.theme.mgt.ui/src/main/resources/org/wso2/carbon/theme/mgt/ui/i18n/Resources.properties b/components/org.apache.stratos.theme.mgt.ui/src/main/resources/org/wso2/carbon/theme/mgt/ui/i18n/Resources.properties
deleted file mode 100644
index edf3f48..0000000
--- a/components/org.apache.stratos.theme.mgt.ui/src/main/resources/org/wso2/carbon/theme/mgt/ui/i18n/Resources.properties
+++ /dev/null
@@ -1,51 +0,0 @@
-submit.tenant=Submit Tenant
-domain=Domain
-domain.information=Domain Information
-contact.details=Contact Details
-admin.username=Admin Username
-current.admin.password=Current Admin Password
-new.admin.password=New Admin Password
-new.admin.password.repeat=New Admin Password (Repeat)
-admin.password=Admin Password
-admin.password.repeat=Admin Password (Repeat)
-govern.add_tenants.menu=Add New Tenant
-govern.view_tenants.menu=View Tenants
-overview=Overview
-tenants.list=Tenants List
-company.organization=Company/Organization
-admin.contact=Admin Contact
-edit=Edit
-multitenancy=Multitenancy
-added.successfully=You have successfully added a new tenant with domain:
-updated.successfully=You have successfully updated the tenant with domain:
-update.added.tenant=Update the just added/updated tenant
-update.tenant=Update Tenant
-add.new.tenant=Add a new tenant
-register.new.organization=Register A New Organization
-view.all.tenants=View all tenants
-tenant.admin=Tenant Admin
-tenant.description=Tenant Description
-admin.fullname=Full Name
-admin.address=Address
-admin.email=Email
-admin.telephone=Telephone
-admin.im=IM
-admin.url=URL
-self.registration=Registry Tenant
-gaas=GaaS
-gaas.register.a.new.tenant=Register A New Tenant
-active=Active
-theme.management=Theme
-word.verification=Word Verification
-captcha.message=Type the characters you see in the picture below.
-add.image=Add an Image
-image.path.help.text=Give the path of a file to fetch a image (bmp,gif,jpg,png)
-image.url.help.text=Give the full url of the resource to fetch a image from URL (bmp,gif,jpg,png)
-upload.image.from.file=Upload an image from a file
-import.image.from.url=Import an image from a URL
-update.logo.image.from.file=Update the logo image from a file
-update.logo.image.from.url=Update the logo image from a URL
-method=Method
-logo.management=Logo Management
-change.the.logo=Change the Logo
-wait.message=Process may take some time. Please wait..
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/30fae32c/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
index ac3a785..9e8c2bd 100644
--- 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
@@ -1,20 +1,22 @@
-/*
-* 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.
-*/
+/**
+ * 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.wso2.carbon.stratos.common.listeners.TenantMgtListener;
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/30fae32c/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
index fe49867..05a3d36 100644
--- 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
@@ -1,21 +1,22 @@
-/*
- * 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
- *
+/**
+ * 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;
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/30fae32c/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
index c1f3fcf..32dcad1 100644
--- 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
@@ -1,18 +1,22 @@
-/*
- * 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.
+/**
+ * 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;
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/30fae32c/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
index d69bcea..09c5e79 100644
--- 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
@@ -1,18 +1,22 @@
-/*
- * 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.
+/**
+ * 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;
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/30fae32c/components/org.apache.stratos.theme.mgt/src/main/java/org/wso2/carbon/theme/mgt/internal/TenantThemeMgtServiceComponent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.theme.mgt/src/main/java/org/wso2/carbon/theme/mgt/internal/TenantThemeMgtServiceComponent.java b/components/org.apache.stratos.theme.mgt/src/main/java/org/wso2/carbon/theme/mgt/internal/TenantThemeMgtServiceComponent.java
deleted file mode 100644
index 4769b85..0000000
--- a/components/org.apache.stratos.theme.mgt/src/main/java/org/wso2/carbon/theme/mgt/internal/TenantThemeMgtServiceComponent.java
+++ /dev/null
@@ -1,99 +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.theme.mgt.internal;
-
-import org.wso2.carbon.stratos.common.listeners.TenantMgtListener;
-import org.wso2.carbon.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.wso2.carbon.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/incubator-stratos/blob/30fae32c/components/org.apache.stratos.theme.mgt/src/main/java/org/wso2/carbon/theme/mgt/services/ThemeMgtService.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.theme.mgt/src/main/java/org/wso2/carbon/theme/mgt/services/ThemeMgtService.java b/components/org.apache.stratos.theme.mgt/src/main/java/org/wso2/carbon/theme/mgt/services/ThemeMgtService.java
deleted file mode 100644
index ea21565..0000000
--- a/components/org.apache.stratos.theme.mgt/src/main/java/org/wso2/carbon/theme/mgt/services/ThemeMgtService.java
+++ /dev/null
@@ -1,195 +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.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.wso2.carbon.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/incubator-stratos/blob/30fae32c/components/org.apache.stratos.theme.mgt/src/main/java/org/wso2/carbon/theme/mgt/util/ThemeLoadingListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.theme.mgt/src/main/java/org/wso2/carbon/theme/mgt/util/ThemeLoadingListener.java b/components/org.apache.stratos.theme.mgt/src/main/java/org/wso2/carbon/theme/mgt/util/ThemeLoadingListener.java
deleted file mode 100644
index d6f9151..0000000
--- a/components/org.apache.stratos.theme.mgt/src/main/java/org/wso2/carbon/theme/mgt/util/ThemeLoadingListener.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.wso2.carbon.theme.mgt.util;
-
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.stratos.common.beans.TenantInfoBean;
-import org.wso2.carbon.stratos.common.exception.StratosException;
-import org.wso2.carbon.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 StratosException {
- 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 StratosException(msg, e);
- }
- }
-
- public void onTenantUpdate(TenantInfoBean tenantInfo) throws StratosException {
- // doing nothing
- }
-
- public void onTenantRename(int tenantId, String oldDomainName,
- String newDomainName) throws StratosException {
- // doing nothing
- }
-
- public int getListenerOrder() {
- return EXEC_ORDER;
- }
-
- public void onTenantInitialActivation(int tenantId) throws StratosException {
- // doing nothing
-
- }
-
- public void onTenantActivation(int tenantId) throws StratosException {
- // doing nothing
-
- }
-
- public void onTenantDeactivation(int tenantId) throws StratosException {
- // doing nothing
-
- }
-
- public void onSubscriptionPlanChange(int tenentId, String oldPlan,
- String newPlan) throws StratosException {
- // doing nothing
-
- }
-}