You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by pr...@apache.org on 2014/04/17 04:43:25 UTC

[45/52] [partial] forking carbon ui bundle in to stratos code base and removing license incompatible JS and packing the new module to carbon runtime, through dropins

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6b1dba58/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/taglibs/Report.java
----------------------------------------------------------------------
diff --git a/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/taglibs/Report.java b/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/taglibs/Report.java
new file mode 100644
index 0000000..efcb8e8
--- /dev/null
+++ b/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/taglibs/Report.java
@@ -0,0 +1,131 @@
+/*
+*  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.ui.taglibs;
+
+import org.wso2.carbon.ui.CarbonUIUtil;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.JspWriter;
+import javax.servlet.jsp.tagext.BodyTagSupport;
+import java.io.IOException;
+
+/**
+ * used to generate reporting UI
+ */
+public class Report extends BodyTagSupport {
+
+    private String component;
+    private String template;
+    private boolean pdfReport;
+    private boolean htmlReport;
+    private boolean excelReport;
+    private String reportDataSession;
+
+    public String getReportDataSession() {
+        return reportDataSession;
+    }
+
+    public void setReportDataSession(String reportDataSession) {
+        this.reportDataSession = reportDataSession;
+    }
+
+
+
+
+    public String getComponent() {
+        return component;
+    }
+
+    public void setComponent(String component) {
+        this.component = component;
+    }
+
+    public String getTemplate() {
+        return template;
+    }
+
+    public void setTemplate(String template) {
+        this.template = template;
+    }
+
+    public boolean isPdfReport() {
+        return pdfReport;
+    }
+
+    public void setPdfReport(boolean pdfReport) {
+        this.pdfReport = pdfReport;
+    }
+
+    public boolean isHtmlReport() {
+        return htmlReport;
+    }
+
+    public void setHtmlReport(boolean htmlReport) {
+        this.htmlReport = htmlReport;
+    }
+
+    public boolean isExcelReport() {
+        return excelReport;
+    }
+
+    public void setExcelReport(boolean excelReport) {
+        this.excelReport = excelReport;
+    }
+
+
+    public int doStartTag() throws JspException {
+        //check permission.
+        HttpServletRequest req = (HttpServletRequest)
+                pageContext.getRequest();
+        if(!CarbonUIUtil.isUserAuthorized(req, "/permission/admin/manage/report")){
+          return EVAL_PAGE;
+        }
+        JspWriter writer = pageContext.getOut();
+
+        String context = "<div style='float:right;padding-bottom:5px;padding-right:15px;'>";
+
+        if(pdfReport){
+           context  = context+ "<a target='_blank' class='icon-link' style='background-image:url(../admin/images/pdficon.gif);' href=\"../report" + "?" +"reportDataSession="+ reportDataSession + "&component=" + component + "&template=" + template + "&type=pdf" +  "\">Generate Pdf Report</a>";
+        }
+        if(htmlReport){
+            context  = context+ "<a target='_blank' class='icon-link' style='background-image:url(../admin/images/htmlicon.gif);' href=\"../report" + "?" + "reportDataSession="+ reportDataSession + "&component=" + component + "&template=" + template + "&type=html" + "\">Generate Html Report</a>";
+
+        }
+        if(excelReport){
+            context  = context+ "<a target='_blank' class='icon-link' style='background-image:url(../admin/images/excelicon.gif);' href=\"../report" + "?" + "reportDataSession="+ reportDataSession + "&component=" + component + "&template=" + template + "&type=excel" +"\">Generate Excel Report</a>";
+
+        }
+        context  = context + "</div><div style='clear:both;'></div>";
+
+        try {
+            writer.write(context);
+        } catch (IOException e) {
+            String msg = "Cannot write reporting tag content";
+
+            throw new JspException(msg, e);
+        }
+        return EVAL_PAGE;
+
+
+    }
+}
+
+
+
+

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6b1dba58/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/taglibs/ResourcePaginator.java
----------------------------------------------------------------------
diff --git a/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/taglibs/ResourcePaginator.java b/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/taglibs/ResourcePaginator.java
new file mode 100644
index 0000000..efa19b1
--- /dev/null
+++ b/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/taglibs/ResourcePaginator.java
@@ -0,0 +1,202 @@
+/*
+ *  Copyright (c) 2005-2009, 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.ui.taglibs;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.ui.CarbonUIUtil;
+
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.JspWriter;
+import java.io.IOException;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+public class ResourcePaginator extends Paginator {
+
+    private static final String END = "end";
+
+	private static final String MIDDLE = "middle";
+
+	private static final String START = "start";
+
+	private static final Log log = LogFactory.getLog(ResourcePaginator.class);
+
+    private String paginationFunction = null;
+    private int tdColSpan = 0;
+
+    public String getPaginationFunction() {
+        return paginationFunction;
+    }
+
+    public void setPaginationFunction(String paginationFunction) {
+        this.paginationFunction = paginationFunction;
+    }
+
+    public int getTdColSpan() {
+        return tdColSpan;
+    }
+
+    public void setTdColSpan(int tdColSpan) {
+        this.tdColSpan = tdColSpan;
+    }
+
+    public int doEndTag() throws JspException {
+        if (getNumberOfPages() < 2) {
+            // Pagination is not required.
+            return 0;
+        }
+        String next = "Next";
+        String prev = "Prev";
+        String pageName = "Page {0}";
+        if (getResourceBundle() != null) {
+            try {
+                Locale locale = JSi18n.getLocaleFromPageContext(pageContext);
+                ResourceBundle bundle = ResourceBundle.getBundle(getResourceBundle(),locale);
+                next = bundle.getString(getNextKey());
+                prev = bundle.getString(getPrevKey());
+            } catch (Exception e) {
+                log.warn("Error while i18ning paginator", e);
+            }
+        }
+
+        JspWriter writer = pageContext.getOut();
+
+        StringBuffer content = new StringBuffer("<tr><td ");
+        if (tdColSpan > 0) {
+            content.append("colspan=\"").append(tdColSpan).append("\" ");
+        }
+        content.append("class=\"pagingRow\" style=\"text-align:center;padding-top:10px; padding-bottom:10px;\">");
+
+        if (getPageNumber() == 1) {
+            content.append("<span class=\"disableLink\">< ").append(prev).append("</span>");
+        } else {
+            content.append("<a class=\"pageLinks\" title=\"").append(pageName.replace("{0}",
+                    Integer.toString(getPageNumber() - 1))).append("\"");
+            if (getPaginationFunction() != null) {
+                content.append("onclick=\"").append(getPaginationFunction().replace("{0}",
+                        Integer.toString(getPageNumber() - 1))).append("\"");
+            }
+            content.append(">< ").append(prev).append("</a>");
+        }
+        if (getNumberOfPages() <= 10) {
+            for (int pageItem = 1; pageItem <= getNumberOfPages(); pageItem++) {
+                content.append("<a title=\"").append(pageName.replace("{0}",
+                    Integer.toString(pageItem))).append("\" class=\"");
+                if (getPageNumber()==pageItem) {
+                    content.append("pageLinks-selected\"");
+                } else {
+                    content.append("pageLinks\"");
+                }
+                if (getPaginationFunction() != null) {
+                    content.append("onclick=\"").append(getPaginationFunction().replace("{0}",
+                            Integer.toString(pageItem))).append("\"");
+                }
+                content.append(">").append(pageItem).append("</a>");
+            }
+        } else {
+            // FIXME: The equals comparisons below looks buggy. Need to test whether the desired
+            // behaviour is met, when there are more than ten pages.
+            String place = MIDDLE;
+            int pageItemFrom = getPageNumber() - 2;
+            int pageItemTo = getPageNumber() + 2;
+
+            if (getNumberOfPages() - getPageNumber() <= 5) {
+            	place = END;
+            }
+            if (getPageNumber() <= 5) {
+            	place = START;
+            }
+
+            if (START.equals(place)) {
+                pageItemFrom = 1;
+                pageItemTo = 7;
+            }
+            if (END.equals(place)) {
+                pageItemFrom = getNumberOfPages() - 7;
+                pageItemTo = getNumberOfPages();
+            }
+
+            if (END.equals(place)  || MIDDLE.equals(place)) {
+                for (int pageItem = 1; pageItem <= 2; pageItem++) {
+                    content.append("<a title=\"").append(pageName.replace("{0}",
+                            Integer.toString(pageItem))).append("\" class=\"pageLinks\"");
+                    if (getPaginationFunction() != null) {
+                        content.append("onclick=\"").append(getPaginationFunction().replace("{0}",
+                                Integer.toString(pageItem))).append("\"");
+                    }
+                    content.append(">").append(pageItem).append("</a>");
+                }
+                content.append("...");
+            }
+
+            for (int pageItem = pageItemFrom; pageItem <= pageItemTo; pageItem++) {
+                content.append("<a title=\"").append(pageName.replace("{0}",
+                    Integer.toString(pageItem))).append("\" class=\"");
+                if (getPageNumber()==pageItem) {
+                    content.append("pageLinks-selected\"");
+                } else {
+                    content.append("pageLinks\"");
+                }
+                if (getPaginationFunction() != null) {
+                    content.append("onclick=\"").append(getPaginationFunction().replace("{0}",
+                            Integer.toString(pageItem))).append("\"");
+                }
+                content.append(">").append(pageItem).append("</a>");
+            }
+
+            if (START.equals(place) || MIDDLE.equals(place)) {
+                content.append("...");
+                for (int pageItem = (getNumberOfPages() - 1); pageItem <= getNumberOfPages(); pageItem++) {
+
+                    content.append("<a title=\"").append(pageName.replace("{0}",
+                            Integer.toString(pageItem))).append("\" class=\"pageLinks\"");
+                    if (getPaginationFunction() != null) {
+                        content.append("onclick=\"").append(getPaginationFunction().replace("{0}",
+                                Integer.toString(pageItem))).append("\"");
+                    }
+                    content.append("style=\"margin-left:5px;margin-right:5px;\">").append(
+                            pageItem).append("</a>");
+                }
+            }
+        }
+        if (getPageNumber() == getNumberOfPages()) {
+           content.append("<span class=\"disableLink\">").append(next).append(" ></span>");
+        } else {
+            content.append("<a class=\"pageLinks\" title=\"").append(pageName.replace("{0}",
+                    Integer.toString(getPageNumber() + 1))).append("\"");
+            if (getPaginationFunction() != null) {
+                content.append("onclick=\"").append(getPaginationFunction().replace("{0}",
+                        Integer.toString(getPageNumber() + 1))).append("\"");
+            }
+            content.append(">").append(next).append(" ></a>");
+        }
+        content.append("<span id=\"xx").append(getPageNumber()).append(
+                "\" style=\"display:none\" /></td></tr>");
+        try {
+            writer.write(content.toString());
+        } catch (IOException e) {
+            String msg = "Cannot write paginator tag content";
+            log.error(msg, e);
+            throw new JspException(msg, e);
+        }
+        return 0;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6b1dba58/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/taglibs/SimpleItemGroupSelector.java
----------------------------------------------------------------------
diff --git a/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/taglibs/SimpleItemGroupSelector.java b/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/taglibs/SimpleItemGroupSelector.java
new file mode 100644
index 0000000..0ec97f7
--- /dev/null
+++ b/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/taglibs/SimpleItemGroupSelector.java
@@ -0,0 +1,113 @@
+/*                                                                             
+ * Copyright 2004,2005 The Apache Software Foundation.                         
+ *                                                                             
+ * 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.ui.taglibs;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.ui.CarbonUIUtil;
+
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.JspWriter;
+import javax.servlet.jsp.tagext.BodyTagSupport;
+import java.io.IOException;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+/**
+ * A tag for selecting & deselecting a group of items. This does not have any fancy functionality
+ * like {@link org.wso2.carbon.ui.taglibs.ItemGroupSelector}. It simply select & deselect a group
+ * of items.
+ */
+public class SimpleItemGroupSelector extends BodyTagSupport {
+
+    private static final Log log = LogFactory.getLog(SimpleItemGroupSelector.class);
+    protected String selectAllFunction;
+    protected String selectNoneFunction;
+    protected String selectAllKey;
+    protected String selectNoneKey;
+    protected String resourceBundle;
+
+    public String getResourceBundle() {
+        return resourceBundle;
+    }
+
+    public void setResourceBundle(String resourceBundle) {
+        this.resourceBundle = resourceBundle;
+    }
+
+    public String getSelectAllFunction() {
+        return selectAllFunction;
+    }
+
+    public void setSelectAllFunction(String selectAllFunction) {
+        this.selectAllFunction = selectAllFunction;
+    }
+
+    public String getSelectNoneFunction() {
+        return selectNoneFunction;
+    }
+
+    public void setSelectNoneFunction(String selectNoneFunction) {
+        this.selectNoneFunction = selectNoneFunction;
+    }
+
+    public String getSelectAllKey() {
+        return selectAllKey;
+    }
+
+    public void setSelectAllKey(String selectAllKey) {
+        this.selectAllKey = selectAllKey;
+    }
+
+    public String getSelectNoneKey() {
+        return selectNoneKey;
+    }
+
+    public void setSelectNoneKey(String selectNoneKey) {
+        this.selectNoneKey = selectNoneKey;
+    }
+
+    public int doEndTag() throws JspException {
+        String selectAll = "Select all in all pages";
+        String selectNone = "Select none";
+        if (resourceBundle != null) {
+            try {
+                Locale locale = JSi18n.getLocaleFromPageContext(pageContext);
+                ResourceBundle bundle = ResourceBundle.getBundle(resourceBundle,locale);
+                selectAll = bundle.getString(selectAllKey);
+                selectNone = bundle.getString(selectNoneKey);
+            } catch (Exception e) {
+                log.warn("Error while i18ning SimpleItemGroupSelector", e);
+            }
+        }
+
+        JspWriter writer = pageContext.getOut();
+
+        String content = "<a href=\"#\" onclick=\"" +
+                         selectAllFunction + ";return false;\"  " +
+                         "style=\"cursor:pointer\">" + selectAll + "</a>&nbsp<b>|</b>&nbsp;" +
+                         "<a href=\"#\" onclick=\"" + selectNoneFunction + ";return false;\"  " +
+                         "style=\"cursor:pointer\">" + selectNone + "</a>";
+        try {
+            writer.write(content);
+        } catch (IOException e) {
+            String msg = "Cannot write SimpleItemGroupSelector tag content";
+            log.error(msg, e);
+            throw new JspException(msg, e);
+        }
+        return 0;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6b1dba58/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/taglibs/TooltipsGenerator.java
----------------------------------------------------------------------
diff --git a/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/taglibs/TooltipsGenerator.java b/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/taglibs/TooltipsGenerator.java
new file mode 100644
index 0000000..59a28a9
--- /dev/null
+++ b/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/taglibs/TooltipsGenerator.java
@@ -0,0 +1,214 @@
+/*
+*  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.ui.taglibs;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.taglibs.standard.tag.common.fmt.BundleSupport;
+import org.wso2.carbon.ui.CarbonUIUtil;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.JspWriter;
+import javax.servlet.jsp.jstl.fmt.LocalizationContext;
+import javax.servlet.jsp.tagext.BodyTagSupport;
+import javax.servlet.jsp.tagext.Tag;
+import java.io.IOException;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+/**
+ * This Tag Handler class is used to add a tooltips for a image.
+ */
+public class TooltipsGenerator extends BodyTagSupport {
+
+    private static final Log log = LogFactory.getLog(TooltipsGenerator.class);
+    //image location. tooltips appears when mouse over on this image.
+    private String image;
+
+    //tooltips body content.
+    private String description;
+
+    //no of words in a single line. this use to design the tooltips body. default value has set to 10.
+    private int noOfWordsPerLine = 10;
+
+    //resource bundle name.
+    private String resourceBundle;
+
+    //element in resource file.
+    private String key;
+
+    public String getImage() {
+        return image;
+    }
+
+    public void setImage(String image) {
+        this.image = image;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public int getNoOfWordsPerLine() {
+        return noOfWordsPerLine;
+    }
+
+    public void setNoOfWordsPerLine(int noOfWordsPerLine) {
+        this.noOfWordsPerLine = noOfWordsPerLine;
+    }
+
+    public String getResourceBundle() {
+        return this.resourceBundle;
+    }
+
+    public void setResourceBundle(String resourceBundle) {
+        this.resourceBundle = resourceBundle;
+    }
+
+    public String getKey() {
+        return this.key;
+    }
+
+    public void setKey(String key) {
+        this.key = key;
+    }
+
+    /**
+     * This method is invoked when the custom end tag is encountered.
+     * The main function of this method is to add a image and display a tooltips when mouse over
+     * that image. This is done by calling the 'showTooltips' method in ../admin/js/widgets.js
+     * java script file.
+     * @return return EVAL_PAGE - continue processing the page.
+     * @throws JspException
+     */
+    public int doEndTag() throws JspException {
+        JspWriter writer = pageContext.getOut();
+        String context = "<link rel='stylesheet' type='text/css' " +
+                        "href='../yui/build/container/assets/skins/sam/container.css'>\n" +
+                        "<script type=\"text/javascript\" " +
+                        "src=\"../yui/build/yahoo-dom-event/yahoo-dom-event.js\"></script>\n" +
+                        "<script type=\"text/javascript\" " +
+                        "src=\"../yui/build/container/container-min.js\"></script>\n" +
+                        "<script type=\"text/javascript\" " +
+                        "src=\"../yui/build/element/element-min.js\"></script>\n" +
+                        "<script type=\"text/javascript\" src=\"../admin/js/widgets.js\"></script>\n";
+
+
+        if((getResourceBundle()!= null && getKey() != null) ||
+                (getResourceBundle() == null && getKey() != null)) { //create tooltips content from resource bundle.
+            context = context + "<a target='_blank' class='icon-link' " +
+                            "onmouseover=\"showTooltip(this,'" + getTooltipsContentFromKey() + "')\" " +
+                            "style='background-image:url(\"" + getImage() + "\")' ></a>";
+        }
+        else if(this.description != null) { //create the tooltips content from user given text.
+            context = context + "<a target='_blank' class='icon-link' " +
+                            "onmouseover=\"showTooltip(this,'" + createTooltipsBody(getNoOfWordsPerLine()) +
+                    "')\" " +"style='background-image:url(\"" + getImage() + "\")' ></a>";
+        }
+         
+        try {
+            writer.write(context);
+        } catch (IOException e) {
+            String msg = "Cannot write tag content";
+            throw new JspException(msg, e);
+        }
+        return EVAL_PAGE;
+    }
+
+
+
+    /**
+     * This method is used to design the tooltips content display window size.
+     * This takes the no of words that should contains in a single line as a argument.
+     * So when we create tooltips body, its size vary accordingly.
+     *
+     * @param noOfWordsPerLine no of words that should contain in single line of tooltips body.
+     * @return return the tooltips body content in displayable way in tooltips.
+     */
+    public String createTooltipsBody(int noOfWordsPerLine) {
+        String toolTipContent = getDescription();
+        if (toolTipContent != null) {
+            String[] words = toolTipContent.split(" ");
+            if (words.length > noOfWordsPerLine) {
+                int countWords = 0;
+                String descriptionNew = "";
+                for (String word : words) {
+                    if (countWords != noOfWordsPerLine) {
+                        descriptionNew = descriptionNew + " " + word;
+                        countWords++;
+                    } else {
+                        descriptionNew = descriptionNew + "<br>" + word;
+                        countWords = 0;
+                    }
+                }
+                setDescription(descriptionNew);
+            }
+        }
+        return getDescription();
+    }
+
+    /**
+     * This method is used to get the tooltips content from resource file.
+     * @return return the tooltips body content in displayable way in tooltips.
+     * @throws javax.servlet.jsp.JspException
+     */
+    public String getTooltipsContentFromKey() throws JspException {
+        String toolTipsContent;
+        ResourceBundle bundle = null;
+        try {
+            Locale locale = JSi18n.getLocaleFromPageContext(pageContext);
+            if (getResourceBundle() != null && getKey() != null) {
+                    bundle = ResourceBundle.getBundle(getResourceBundle(),locale);
+            }
+            //get the default bundle define in jsp page when only key is provided.
+            else if (getResourceBundle() == null && getKey() != null) {
+                    bundle = getCommonResourceBundleForJspPage();
+            }
+        } catch (Exception e) {
+                log.warn("Error while i18ning.", e);
+        }
+        if (bundle != null) {
+            toolTipsContent = bundle.getString(getKey());
+            setDescription(toolTipsContent);
+        }
+        return createTooltipsBody(getNoOfWordsPerLine());
+    }
+
+    /**
+     * This method is used to get the resource bundle define in a jsp page.
+     * @return return the resource bundle
+     */
+    public ResourceBundle getCommonResourceBundleForJspPage() {
+        Tag t = findAncestorWithClass(this, BundleSupport.class);
+        LocalizationContext localizationContext;
+        if (t != null) {
+            // use resource bundle from parent <bundle> tag
+            BundleSupport parent = (BundleSupport) t;
+            localizationContext = parent.getLocalizationContext();
+
+	    }  else {
+            localizationContext = BundleSupport.getLocalizationContext(pageContext);
+        }
+        return localizationContext.getResourceBundle();
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6b1dba58/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/tracker/AuthenticatorComparator.java
----------------------------------------------------------------------
diff --git a/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/tracker/AuthenticatorComparator.java b/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/tracker/AuthenticatorComparator.java
new file mode 100644
index 0000000..0d64b45
--- /dev/null
+++ b/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/tracker/AuthenticatorComparator.java
@@ -0,0 +1,32 @@
+/*
+*  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.ui.tracker;
+
+import org.wso2.carbon.ui.CarbonUIAuthenticator;
+
+import java.util.Comparator;
+
+public class AuthenticatorComparator implements Comparator<CarbonUIAuthenticator>{
+
+    public int compare(CarbonUIAuthenticator o1, CarbonUIAuthenticator o2) {
+        return o2.getPriority()-o1.getPriority();
+    }
+    
+    
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6b1dba58/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/tracker/AuthenticatorRegistry.java
----------------------------------------------------------------------
diff --git a/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/tracker/AuthenticatorRegistry.java b/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/tracker/AuthenticatorRegistry.java
new file mode 100644
index 0000000..19e3570
--- /dev/null
+++ b/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/tracker/AuthenticatorRegistry.java
@@ -0,0 +1,89 @@
+/*
+ *  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.ui.tracker;
+
+import java.util.Arrays;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+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.ui.CarbonSecuredHttpContext;
+import org.wso2.carbon.ui.CarbonUIAuthenticator;
+
+public class AuthenticatorRegistry {
+
+    private static Log log = LogFactory.getLog(AuthenticatorRegistry.class);
+    private static ServiceTracker authTracker;
+    private static CarbonUIAuthenticator[] authenticators;
+    private static Object lock = new Object();
+
+    public static final String AUTHENTICATOR_TYPE = "authenticator.type";
+
+    public static void init(BundleContext bc) throws Exception {
+        try {
+            authTracker = new ServiceTracker(bc, CarbonUIAuthenticator.class.getName(), null);
+            authTracker.open();
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            throw e;
+        }
+    }
+
+    // At the time getCarbonAuthenticator() method been invoked, all the authenticators should be
+    // registered.
+    public static CarbonUIAuthenticator getCarbonAuthenticator(HttpServletRequest request) {
+
+        HttpSession session = request.getSession();
+        CarbonUIAuthenticator authenticator;
+
+        if ((authenticator = (CarbonUIAuthenticator) session
+                .getAttribute(CarbonSecuredHttpContext.CARBON_AUTHNETICATOR)) != null) {
+            return authenticator;
+        }
+
+        if (authenticators == null || authenticators.length == 0 || authenticators[0] == null) {
+            synchronized (lock) {
+                if (authenticators == null || authenticators.length == 0
+                        || authenticators[0] == null) {
+                    Object[] objects = authTracker.getServices();
+                    // cast each object - cannot cast object array
+                    authenticators = new CarbonUIAuthenticator[objects.length];
+                    int i = 0;
+                    for (Object obj : objects) {
+                        authenticators[i] = (CarbonUIAuthenticator) obj;
+                        i++;
+                    }
+                    Arrays.sort(authenticators, new AuthenticatorComparator());
+                }
+            }
+        }
+
+        for (CarbonUIAuthenticator auth : authenticators) {
+            if (!auth.isDisabled() && auth.canHandle(request)) {
+                session.setAttribute(CarbonSecuredHttpContext.CARBON_AUTHNETICATOR, auth);
+                return auth;
+            }
+        }
+
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6b1dba58/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/transports/FileDownloadServlet.java
----------------------------------------------------------------------
diff --git a/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/transports/FileDownloadServlet.java b/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/transports/FileDownloadServlet.java
new file mode 100644
index 0000000..f1f1035
--- /dev/null
+++ b/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/transports/FileDownloadServlet.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2005-2007 WSO2, Inc. (http://wso2.com)
+ *
+ * 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.ui.transports;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.osgi.framework.BundleContext;
+import org.wso2.carbon.CarbonException;
+import org.wso2.carbon.ui.util.FileDownloadUtil;
+import org.wso2.carbon.utils.ConfigurationContextService;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+public class FileDownloadServlet extends javax.servlet.http.HttpServlet {
+    private static final Log log = LogFactory.getLog(org.wso2.carbon.ui.transports.FileDownloadServlet.class);
+
+    private static final long serialVersionUID = 6074514253507510250L;
+
+    private FileDownloadUtil fileDownloadUtil;
+
+    private BundleContext context;
+
+    private ConfigurationContextService configContextService;
+
+    private ServletConfig servletConfig;
+
+    public FileDownloadServlet(BundleContext context, ConfigurationContextService configContextService) {
+        this.context = context;
+        this.configContextService = configContextService;
+    }
+
+    protected void doPost(HttpServletRequest req, HttpServletResponse res)
+            throws ServletException, IOException {
+        res.setStatus(HttpServletResponse.SC_NOT_ACCEPTABLE);
+    }
+
+    protected void doGet(HttpServletRequest req, HttpServletResponse res)
+            throws ServletException, IOException {
+        try {
+            fileDownloadUtil.acquireResource(configContextService, req, res);
+        } catch (CarbonException e) {
+            String msg = "Cannot download file";
+            log.error(msg, e);
+            throw new ServletException(e);
+        }
+    }
+
+    public void init(ServletConfig servletConfig) throws ServletException {
+        this.servletConfig = servletConfig;
+        fileDownloadUtil = new FileDownloadUtil(context);
+    }
+
+    public ServletConfig getServletConfig() {
+        return this.servletConfig;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6b1dba58/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/transports/FileUploadServlet.java
----------------------------------------------------------------------
diff --git a/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/transports/FileUploadServlet.java b/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/transports/FileUploadServlet.java
new file mode 100644
index 0000000..f616ea5
--- /dev/null
+++ b/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/transports/FileUploadServlet.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2005-2007 WSO2, Inc. (http://wso2.com)
+ *
+ * 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.ui.transports;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.osgi.framework.BundleContext;
+import org.wso2.carbon.CarbonException;
+import org.wso2.carbon.ui.transports.fileupload.FileUploadExecutorManager;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+public class FileUploadServlet extends javax.servlet.http.HttpServlet {
+    private static final Log log = LogFactory.getLog(org.wso2.carbon.ui.transports.FileUploadServlet.class);
+
+    private static final long serialVersionUID = 8089568022124816379L;
+
+    private FileUploadExecutorManager fileUploadExecutorManager;
+
+    private BundleContext bundleContext;
+
+    private ConfigurationContext configContext;
+
+    private String webContext;
+
+    private ServletConfig servletConfig;
+
+    public FileUploadServlet(BundleContext context, ConfigurationContext configCtx, String webContext) {
+        this.bundleContext = context;
+        this.configContext = configCtx;
+        this.webContext = webContext;
+    }
+
+    protected void doPost(HttpServletRequest request,
+                          HttpServletResponse response) throws ServletException, IOException {
+
+        try {
+            fileUploadExecutorManager.execute(request, response);
+        } catch (Exception e) {
+            String msg = "File upload failed ";
+            log.error(msg, e);
+            throw new ServletException(e);
+        }
+    }
+
+    protected void doGet(HttpServletRequest req, HttpServletResponse res)
+            throws ServletException, IOException {
+        res.setStatus(HttpServletResponse.SC_NOT_ACCEPTABLE);
+    }
+
+
+    public void init(ServletConfig servletConfig) throws ServletException {
+        this.servletConfig = servletConfig;
+        try {
+            fileUploadExecutorManager = new FileUploadExecutorManager(bundleContext, configContext, webContext);
+            //Registering FileUploadExecutor Manager as an OSGi service
+            bundleContext.registerService(FileUploadExecutorManager.class.getName(), fileUploadExecutorManager, null);
+        } catch (CarbonException e) {
+            log.error("Exception occurred while trying to initialize FileUploadServlet", e);
+            throw new ServletException(e);
+        }
+    }
+
+    public ServletConfig getServletConfig() {
+        return this.servletConfig;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6b1dba58/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/transports/fileupload/AbstractFileUploadExecutor.java
----------------------------------------------------------------------
diff --git a/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/transports/fileupload/AbstractFileUploadExecutor.java b/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/transports/fileupload/AbstractFileUploadExecutor.java
new file mode 100644
index 0000000..7514fac
--- /dev/null
+++ b/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/transports/fileupload/AbstractFileUploadExecutor.java
@@ -0,0 +1,552 @@
+/*
+ * Copyright 2005-2007 WSO2, Inc. (http://wso2.com)
+ *
+ * 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.ui.transports.fileupload;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.fileupload.FileItemFactory;
+import org.apache.commons.fileupload.FileUploadException;
+import org.apache.commons.fileupload.disk.DiskFileItemFactory;
+import org.apache.commons.fileupload.servlet.ServletFileUpload;
+import org.apache.commons.fileupload.servlet.ServletRequestContext;
+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.base.ServerConfiguration;
+import org.wso2.carbon.core.common.UploadedFileItem;
+import org.wso2.carbon.ui.CarbonUIMessage;
+import org.wso2.carbon.ui.clients.FileUploadServiceClient;
+import org.wso2.carbon.ui.internal.CarbonUIServiceComponent;
+import org.wso2.carbon.utils.CarbonUtils;
+import org.wso2.carbon.utils.FileItemData;
+import org.wso2.carbon.utils.FileManipulator;
+import org.wso2.carbon.utils.ServerConstants;
+import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
+
+import javax.activation.DataHandler;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import java.io.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * This class is responsible for handling File uploads of specific file types in Carbon. The file
+ * type is decided depending on the file extensio.
+ * 
+ * This class should be extended by all FileUploadExecutors
+ *
+ * @see FileUploadExecutorManager
+ */
+public abstract class AbstractFileUploadExecutor {
+
+    protected static final Log log = LogFactory.getLog(AbstractFileUploadExecutor.class);
+
+    protected ConfigurationContext configurationContext;
+
+    private ThreadLocal<Map<String, ArrayList<FileItemData>>> fileItemsMap =
+            new ThreadLocal<Map<String, ArrayList<FileItemData>>>();
+
+    private ThreadLocal<Map<String, ArrayList<String>>> formFieldsMap =
+            new ThreadLocal<Map<String, ArrayList<String>>>();
+    
+    private static final int DEFAULT_TOTAL_FILE_SIZE_LIMIT_IN_MB = 100;
+
+    public abstract boolean execute(HttpServletRequest request,
+                                    HttpServletResponse response) throws CarbonException,
+                                                                         IOException;
+
+    /**
+     * Total allowed file upload size in bytes
+     */
+    private long totalFileUploadSizeLimit;
+
+    protected AbstractFileUploadExecutor() {
+        totalFileUploadSizeLimit = getFileSizeLimit();
+    }
+
+    private long getFileSizeLimit() {
+        String totalFileSizeLimitInBytes =
+                CarbonUIServiceComponent.getServerConfiguration().
+                        getFirstProperty("FileUploadConfig.TotalFileSizeLimit");
+        return totalFileSizeLimitInBytes != null ?
+               Long.parseLong(totalFileSizeLimitInBytes) * 1024 * 1024 :
+               DEFAULT_TOTAL_FILE_SIZE_LIMIT_IN_MB * 1024 * 1024;
+    }
+
+    boolean executeGeneric(HttpServletRequest request,
+                           HttpServletResponse response,
+                           ConfigurationContext configurationContext) throws IOException {//,
+        //    CarbonException {
+        this.configurationContext = configurationContext;
+        try {
+            parseRequest(request);
+            return execute(request, response);
+        } catch (FileUploadFailedException e) {
+            sendErrorRedirect(request, response, e);
+        } catch (FileSizeLimitExceededException e) {
+            sendErrorRedirect(request, response, e);
+        } catch (CarbonException e) {
+            sendErrorRedirect(request, response, e);
+        }
+        return false;
+    }
+
+    private void sendErrorRedirect(HttpServletRequest request,
+                                   HttpServletResponse response,
+                                   Exception e) throws IOException {
+        String errorRedirectionPage = getErrorRedirectionPage();
+        if (errorRedirectionPage != null) {
+            CarbonUIMessage.sendCarbonUIMessage(e.getMessage(), CarbonUIMessage.ERROR, request,
+                                                response, errorRedirectionPage);        //TODO: error msg i18n
+        } else {
+            throw new IOException("Could not send error. " +
+                                  "Please define the errorRedirectionPage in your UI page. " +
+                                  e.getMessage());
+        }
+    }
+
+
+    protected String getErrorRedirectionPage() {
+        List<String> errRedirValues = getFormFieldValue("errorRedirectionPage");
+        String errorRedirectionPage = null;
+        if (errRedirValues != null && !errRedirValues.isEmpty()) {
+            errorRedirectionPage = errRedirValues.get(0);
+        }
+        return errorRedirectionPage;
+    }
+
+    protected void parseRequest(HttpServletRequest request) throws FileUploadFailedException,
+                                                                 FileSizeLimitExceededException {
+        fileItemsMap.set(new HashMap<String, ArrayList<FileItemData>>());
+        formFieldsMap.set(new HashMap<String, ArrayList<String>>());
+
+        ServletRequestContext servletRequestContext = new ServletRequestContext(request);
+        boolean isMultipart = ServletFileUpload.isMultipartContent(servletRequestContext);
+        Long totalFileSize = 0L;
+
+        if (isMultipart) {
+
+            List items;
+            try {
+                items = parseRequest(servletRequestContext);
+            } catch (FileUploadException e) {
+                String msg = "File upload failed";
+                log.error(msg, e);
+                throw new FileUploadFailedException(msg, e);
+            }
+            boolean multiItems = false;
+            if (items.size() > 1) {
+                multiItems = true;
+            }
+
+            // Add the uploaded items to the corresponding maps.
+            for (Iterator iter = items.iterator(); iter.hasNext();) {
+                FileItem item = (FileItem) iter.next();
+                String fieldName = item.getFieldName().trim();
+                if (item.isFormField()) {
+                    if (formFieldsMap.get().get(fieldName) == null) {
+                        formFieldsMap.get().put(fieldName, new ArrayList<String>());
+                    }
+                    try {
+                        formFieldsMap.get().get(fieldName).add(new String(item.get(), "UTF-8"));
+                    } catch (UnsupportedEncodingException ignore) {
+                    }
+                } else {
+                    String fileName = item.getName();
+                    if ((fileName == null || fileName.length() == 0) && multiItems) {
+                        continue;
+                    }
+                    if (fileItemsMap.get().get(fieldName) == null) {
+                        fileItemsMap.get().put(fieldName, new ArrayList<FileItemData>());
+                    }
+                    totalFileSize += item.getSize();
+                    if (totalFileSize < totalFileUploadSizeLimit) {
+                        fileItemsMap.get().get(fieldName).add(new FileItemData(item));
+                    } else {
+                        throw new FileSizeLimitExceededException(getFileSizeLimit() / 1024 / 1024);
+                    }
+                }
+            }
+        }
+    }
+
+    protected String getWorkingDir() {
+        return (String) configurationContext.getProperty(ServerConstants.WORK_DIR);
+    }
+
+    protected String generateUUID() {
+        return String.valueOf(System.currentTimeMillis() + Math.random());
+    }
+
+    protected String getFileName(String fileName) {
+        String fileNameOnly;
+        if (fileName.indexOf("\\") < 0) {
+            fileNameOnly = fileName.substring(fileName.lastIndexOf('/') + 1,
+                                              fileName.length());
+        } else {
+            fileNameOnly = fileName.substring(fileName.lastIndexOf("\\") + 1,
+                                              fileName.length());
+        }
+        return fileNameOnly;
+    }
+
+    protected List parseRequest(ServletRequestContext requestContext) throws FileUploadException {
+        // Create a factory for disk-based file items
+        FileItemFactory factory = new DiskFileItemFactory();
+        // Create a new file upload handler
+        ServletFileUpload upload = new ServletFileUpload(factory);
+        // Parse the request
+        return upload.parseRequest(requestContext);
+    }
+
+    //Old methods, these should be refactored.
+
+    protected void checkServiceFileExtensionValidity(String fileExtension,
+                                                     String[] allowedExtensions)
+            throws FileUploadException {
+        boolean isExtensionValid = false;
+        StringBuffer allowedExtensionsStr = new StringBuffer();
+        for (String allowedExtension : allowedExtensions) {
+            allowedExtensionsStr.append(allowedExtension).append(",");
+            if (fileExtension.endsWith(allowedExtension)) {
+                isExtensionValid = true;
+                break;
+            }
+        }
+        if (!isExtensionValid) {
+            throw new FileUploadException(" Illegal file type." +
+                                          " Allowed file extensions are " + allowedExtensionsStr);
+        }
+    }
+
+    protected File uploadFile(HttpServletRequest request,
+                              String repoDir,
+                              HttpServletResponse response,
+                              String extension) throws FileUploadException {
+
+        response.setContentType("text/html; charset=utf-8");
+        ServletRequestContext servletRequestContext = new ServletRequestContext(request);
+        boolean isMultipart =
+                ServletFileUpload.isMultipartContent(servletRequestContext);
+        File uploadedFile = null;
+        if (isMultipart) {
+            try {
+                // Create a new file upload handler
+                List items = parseRequest(servletRequestContext);
+
+                // Process the uploaded items
+                for (Iterator iter = items.iterator(); iter.hasNext();) {
+                    FileItem item = (FileItem) iter.next();
+                    if (!item.isFormField()) {
+                        String fileName = item.getName();
+                        String fileExtension = fileName;
+                        fileExtension = fileExtension.toLowerCase();
+                        if (extension != null && !fileExtension.endsWith(extension)) {
+                            throw new Exception(" Illegal file type. Only " +
+                                                extension + " files can be uploaded");
+
+                        }
+                        String fileNameOnly = getFileName(fileName);
+                        uploadedFile = new File(repoDir, fileNameOnly);
+                        item.write(uploadedFile);
+                    }
+                }
+            } catch (Exception e) {
+                String msg = "File upload failed";
+                log.error(msg, e);
+                throw new FileUploadException(msg, e);
+            }
+        }
+        return uploadedFile;
+    }
+
+    /**
+     * This is the common method that can be used for Fileupload.
+     * extraStoreDirUUID is the name of the javascript that's going to
+     * execute on the client side at the secound run.
+     *
+     * @param request
+     * @param response
+     * @return Status true/fase.
+     * @throws org.apache.commons.fileupload.FileUploadException
+     *
+     */
+    protected boolean executeCommon(HttpServletRequest request, HttpServletResponse response)
+            throws FileUploadException {
+
+        String serverURL = (String) request.getAttribute(CarbonConstants.SERVER_URL);
+        HttpSession session = request.getSession();
+        String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);
+
+        PrintWriter out = null;
+        try {
+            out = response.getWriter();
+            FileUploadServiceClient client =
+                    new FileUploadServiceClient(configurationContext, serverURL, cookie);
+
+            response.setContentType("text/plain; charset=utf-8");
+            Set<String> keys = fileItemsMap.get().keySet();
+            boolean multiItems = false;
+            if (fileItemsMap.get().size() > 1) {
+                multiItems = true;
+            }
+            // Process the uploaded items
+            UploadedFileItem[] uploadedFileItems = new UploadedFileItem[fileItemsMap.get().size()];
+            Iterator<String> iterator = keys.iterator();
+            int i = 0;
+            while (iterator.hasNext()) {
+                String fieldName = iterator.next();
+                String fileName = fileItemsMap.get().get(fieldName).get(0).getFileItem().getName();
+                if ((fileName == null || fileName.length() == 0) && multiItems) {
+                    continue;
+                }
+                FileItemData fileItemData = fileItemsMap.get().get(fieldName).get(0);
+                UploadedFileItem uploadedFileItem = new UploadedFileItem();
+                uploadedFileItem.setDataHandler(fileItemData.getDataHandler());
+                uploadedFileItem.setFileName(fileName);
+                uploadedFileItem.setFileType("");
+                uploadedFileItems[i] = uploadedFileItem;
+                i++;
+            }
+            String[] uuidArray = client.uploadFiles(uploadedFileItems);
+            StringBuffer uuids = new StringBuffer();
+            for (String uuid : uuidArray) {
+                uuids.append(uuid).append(",");
+            }
+            out.write(uuids.toString().substring(0, uuids.length() - 1));
+            out.flush();
+        } catch (Exception e) {
+            String msg = "File upload FAILED. File may be non-existent or invalid.";
+            log.error(msg, e);
+            throw new FileUploadException(msg, e);
+        } finally {
+            if (out != null) {
+                out.close();
+            }
+        }
+        return true;
+    }
+
+
+    /**
+     * This is a helper method that will be used upload main entity (ex: wsdd, jar, class etc) and
+     * its resources to a given deployer.
+     *
+     * @param request
+     * @param response
+     * @param uploadDirName
+     * @param extensions
+     * @param utilityString
+     * @return boolean
+     * @throws IOException
+     */
+    protected boolean uploadArtifacts(HttpServletRequest request,
+                                      HttpServletResponse response,
+                                      String uploadDirName,
+                                      String[] extensions,
+                                      String utilityString)
+            throws FileUploadException, IOException {
+        String axis2Repo = ServerConfiguration.getInstance().
+                getFirstProperty(ServerConfiguration.AXIS2_CONFIG_REPO_LOCATION);
+        if (CarbonUtils.isURL(axis2Repo)) {
+            String msg = "You are not permitted to upload jars to URL repository";
+            throw new FileUploadException(msg);
+        }
+
+        String tmpDir = (String) configurationContext.getProperty(ServerConstants.WORK_DIR);
+        String uuid = String.valueOf(System.currentTimeMillis() + Math.random());
+        tmpDir = tmpDir + File.separator + "artifacts" + File.separator + uuid + File.separator;
+        File tmpDirFile = new File(tmpDir);
+        if (!tmpDirFile.exists() && !tmpDirFile.mkdirs()) {
+            log.warn("Could not create " + tmpDirFile.getAbsolutePath());
+        }
+
+        response.setContentType("text/html; charset=utf-8");
+
+        ServletRequestContext servletRequestContext = new ServletRequestContext(request);
+        boolean isMultipart =
+                ServletFileUpload.isMultipartContent(servletRequestContext);
+        if (isMultipart) {
+            PrintWriter out = null;
+            try {
+                out = response.getWriter();
+                // Create a new file upload handler
+                List items = parseRequest(servletRequestContext);
+                // Process the uploaded items
+                for (Iterator iter = items.iterator(); iter.hasNext();) {
+                    FileItem item = (FileItem) iter.next();
+                    if (!item.isFormField()) {
+                        String fileName = item.getName();
+                        String fileExtension = fileName;
+                        fileExtension = fileExtension.toLowerCase();
+
+                        String fileNameOnly = getFileName(fileName);
+                        File uploadedFile;
+
+                        String fieldName = item.getFieldName();
+
+                        if (fieldName != null && fieldName.equals("jarResource")) {
+                            if (fileExtension.endsWith(".jar")) {
+                                File servicesDir =
+                                        new File(tmpDir + File.separator + uploadDirName, "lib");
+                                if (!servicesDir.exists() && !servicesDir.mkdirs()){
+                                    log.warn("Could not create " + servicesDir.getAbsolutePath());
+                                }
+                                uploadedFile = new File(servicesDir, fileNameOnly);
+                                item.write(uploadedFile);
+                            }
+                        } else {
+                            File servicesDir = new File(tmpDir, uploadDirName);
+                            if (!servicesDir.exists() && !servicesDir.mkdirs()) {
+                                log.warn("Could not create " + servicesDir.getAbsolutePath());
+                            }
+                            uploadedFile = new File(servicesDir, fileNameOnly);
+                            item.write(uploadedFile);
+                        }
+                    }
+                }
+
+                //First lets filter for jar resources
+                String repo = configurationContext.getAxisConfiguration().getRepository().getPath();
+
+                //Writing the artifacts to the proper location
+                String parent = repo + File.separator + uploadDirName;
+                File mainDir = new File(tmpDir + File.separator + uploadDirName);
+                File libDir = new File(mainDir, "lib");
+                File[] resourceLibFile =
+                        FileManipulator.getMatchingFiles(libDir.getAbsolutePath(), null, "jar");
+
+
+                for (File src : resourceLibFile) {
+                    File dst = new File(parent, "lib");
+                    String[] files = libDir.list();
+                    for (String file : files) {
+                        copyFile(src, new File(dst, file));
+                    }
+                }
+
+                for (String extension : extensions) {
+                    File[] mainFiles =
+                            FileManipulator.getMatchingFiles(mainDir.getAbsolutePath(), null, extension);
+                    for (File mainFile : mainFiles) {
+                        File dst = new File(parent);
+                        String[] files = mainDir.list();
+                        for (String file : files) {
+                            File f = new File(dst, file);
+                            if (!f.isDirectory()) {
+                                copyFile(mainFile, f);
+                            }
+                        }
+
+                    }
+                }
+                response.sendRedirect(getContextRoot(request) + "/carbon/service-mgt/index.jsp?message=Files have been uploaded "
+                                      + "successfully. This page will be auto refreshed shortly with "
+                                      + "the status of the created " + utilityString + " service"); //TODO: why do we redirect to service-mgt ???
+                return true;
+            } catch (RuntimeException e) {
+                throw e;
+            } catch (Exception e) {
+                String msg = "File upload failed";
+                log.error(msg, e);
+                throw new FileUploadException(msg, e);
+            } finally {
+                if (out != null) {
+                    out.close();
+                }
+            }
+        }
+        return false;
+    }
+
+    private void copyFile(File src, File dst) throws IOException {
+        String dstAbsPath = dst.getAbsolutePath();
+        String dstDir = dstAbsPath.substring(0, dstAbsPath.lastIndexOf(File.separator));
+        File dir = new File(dstDir);
+        if (!dir.exists() && !dir.mkdirs()) {
+            log.warn("Could not create " + dir.getAbsolutePath());
+        }
+        DataHandler dh = new DataHandler(src.toURL());
+        FileOutputStream out = null;
+        try {
+            out = new FileOutputStream(dst);
+            dh.writeTo(out);
+            out.flush();
+        } finally {
+            if (out != null) {
+                out.close();
+            }
+        }
+    }
+
+    protected List<FileItemData> getAllFileItems() {
+        Collection<ArrayList<FileItemData>> listCollection = fileItemsMap.get().values();
+        List<FileItemData> fileItems = new ArrayList<FileItemData>();
+        for (ArrayList<FileItemData> fileItemData : listCollection) {
+            fileItems.addAll(fileItemData);
+        }
+        return fileItems;
+    }
+
+    protected String getContextRoot(HttpServletRequest request) {
+        String contextPath = (request.getContextPath().equals("")) ? "" : request.getContextPath();
+        int index;
+        if (contextPath.equals("/fileupload")) {
+            contextPath = "";
+        } else {
+            if ((index = contextPath.indexOf("/fileupload")) > -1) {
+                contextPath = contextPath.substring(0, index);
+            }
+        }
+        // Make the context root tenant aware, eg: /t/wso2.com in a multi-tenant scenario
+        String tenantDomain = (String)request.getSession().getAttribute(MultitenantConstants.TENANT_DOMAIN);
+        if(!contextPath.startsWith("/" + MultitenantConstants.TENANT_AWARE_URL_PREFIX + "/")
+                && (tenantDomain != null &&
+                !MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) ){
+            contextPath = contextPath + "/" + MultitenantConstants.TENANT_AWARE_URL_PREFIX + "/" +
+                          tenantDomain;
+            // replace the possible '//' with '/ '
+            contextPath = contextPath.replaceAll("//", "/");
+        }
+        return contextPath;
+    }
+
+    /**
+     * Retrieve the form field values of the provided form field with name <code>formFieldName</code>
+     *
+     * @param formFieldName Name of the form field to be retrieved
+     * @return List of form field values
+     */
+    public List<String> getFormFieldValue(String formFieldName) {
+        return formFieldsMap.get().get(formFieldName);
+    }
+
+    protected Map<String, ArrayList<FileItemData>> getFileItemsMap() {
+        return fileItemsMap.get();
+    }
+
+    protected Map<String, ArrayList<String>> getFormFieldsMap() {
+        return formFieldsMap.get();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6b1dba58/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/transports/fileupload/AnyFileUploadExecutor.java
----------------------------------------------------------------------
diff --git a/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/transports/fileupload/AnyFileUploadExecutor.java b/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/transports/fileupload/AnyFileUploadExecutor.java
new file mode 100644
index 0000000..da941a1
--- /dev/null
+++ b/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/transports/fileupload/AnyFileUploadExecutor.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2005-2007 WSO2, Inc. (http://wso2.com)
+ *
+ * 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.ui.transports.fileupload;
+
+import org.apache.commons.fileupload.FileUploadException;
+import org.wso2.carbon.CarbonException;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/*
+ * 
+ */
+public class AnyFileUploadExecutor extends AbstractFileUploadExecutor {
+
+    public boolean execute(HttpServletRequest request, HttpServletResponse response)
+            throws CarbonException, IOException {
+
+        try {
+            return super.executeCommon(request, response);
+        } catch (FileUploadException e) {
+            e.printStackTrace();  //Todo: change body of catch statement use File | Settings | File Templates.
+        }
+        return false;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6b1dba58/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/transports/fileupload/DBSFileUploadExecutor.java
----------------------------------------------------------------------
diff --git a/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/transports/fileupload/DBSFileUploadExecutor.java b/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/transports/fileupload/DBSFileUploadExecutor.java
new file mode 100644
index 0000000..38e73d6
--- /dev/null
+++ b/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/transports/fileupload/DBSFileUploadExecutor.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2005-2007 WSO2, Inc. (http://wso2.com)
+ *
+ * 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.ui.transports.fileupload;
+
+import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.fileupload.servlet.ServletFileUpload;
+import org.apache.commons.fileupload.servlet.ServletRequestContext;
+import org.wso2.carbon.CarbonException;
+import org.wso2.carbon.base.ServerConfiguration;
+import org.wso2.carbon.utils.CarbonUtils;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Iterator;
+import java.util.List;
+/*
+ *
+ */
+
+public class DBSFileUploadExecutor extends org.wso2.carbon.ui.transports.fileupload.AbstractFileUploadExecutor {
+
+    private static final String[] ALLOWED_FILE_EXTENSIONS = new String[]{".dbs"};
+
+    public boolean execute(HttpServletRequest request,
+                           HttpServletResponse response) throws CarbonException, IOException {
+        String axis2Repo = ServerConfiguration.getInstance().
+                getFirstProperty(ServerConfiguration.AXIS2_CONFIG_REPO_LOCATION);
+        PrintWriter out = response.getWriter();
+        if (CarbonUtils.isURL(axis2Repo)) {
+            out.write("<script type=\"text/javascript\">" +
+                      "alert('You are not permitted to upload services to URL repository " +
+                      axis2Repo + "');" +
+                      "</script>");
+            out.flush();
+            return false;
+        }
+        response.setContentType("text/html; charset=utf-8");
+        ServletRequestContext servletRequestContext = new ServletRequestContext(request);
+        boolean isMultipart =
+                ServletFileUpload.isMultipartContent(servletRequestContext);
+        if (isMultipart) {
+            try {
+                // Create a new file upload handler
+                List items = parseRequest(servletRequestContext);
+
+                // Process the uploaded items
+                for (Iterator iter = items.iterator(); iter.hasNext();) {
+                    FileItem item = (FileItem) iter.next();
+                    if (!item.isFormField()) {
+                        String fileName = item.getName();
+                        String fileExtension = fileName;
+                        fileExtension = fileExtension.toLowerCase();
+
+                        // check whether extension is valid
+                        checkServiceFileExtensionValidity(fileExtension, ALLOWED_FILE_EXTENSIONS);
+
+                        String fileNameOnly = getFileName(fileName);
+                        File uploadedFile;
+                        if (fileExtension.endsWith(".dbs")) {
+                            String repo =
+                                    configurationContext.getAxisConfiguration().
+                                            getRepository().getPath();
+                            String finalFolderName;
+                            if (fileExtension.endsWith(".dbs")) {
+                                finalFolderName = "dataservices";
+                            } else {
+                                throw new CarbonException(
+                                        "File with extension " + fileExtension + " is not supported!");
+                            }
+
+                            File servicesDir = new File(repo, finalFolderName);
+                            if (!servicesDir.exists()) {
+                                servicesDir.mkdir();
+                            }
+                            uploadedFile = new File(servicesDir, fileNameOnly);
+                            item.write(uploadedFile);
+                            //TODO: fix them
+                            out.write("<script type=\"text/javascript\" src=\"../main/admin/js/main.js\"></script>");
+                            out.write("<script type=\"text/javascript\">" +
+                                      "alert('File uploaded successfully');" +
+                                      "loadServiceListingPage();" +
+                                      "</script>");
+                        }
+                    }
+                return true;
+                }
+            } catch (Exception e) {
+                log.error("File upload failed", e);                
+                out.write("<script type=\"text/javascript\" src=\"../ds/extensions/core/js/data_service.js\"></script>");                
+                out.write("<script type=\"text/javascript\">" +
+                          "alert('Service file upload FAILED. You will be redirected to file upload screen. Reason :" +
+                          e.getMessage().replaceFirst(",","") + "');" +
+                          "loadDBSFileUploadPage();"+ //available in data_service.js
+                          "</script>");
+            }
+        }
+        return false;
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6b1dba58/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/transports/fileupload/FileSizeLimitExceededException.java
----------------------------------------------------------------------
diff --git a/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/transports/fileupload/FileSizeLimitExceededException.java b/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/transports/fileupload/FileSizeLimitExceededException.java
new file mode 100644
index 0000000..d82aaf0
--- /dev/null
+++ b/dependencies/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/transports/fileupload/FileSizeLimitExceededException.java
@@ -0,0 +1,24 @@
+package org.wso2.carbon.ui.transports.fileupload;
+
+/**
+ * This exception will be thrown when the maximum allowed file size limit is exceeded. This can
+ * be applicable to a single file or a collection of files.
+ */
+public class FileSizeLimitExceededException extends Exception {
+
+    public FileSizeLimitExceededException(long fileSizeLimitInMB) {
+        super("File size limit of " + fileSizeLimitInMB + " MB has been exceeded");
+    }
+
+    public FileSizeLimitExceededException(String msg, long fileSizeLimitInMB) {
+        super("File size limit of " + fileSizeLimitInMB + " MB has been exceeded. " + msg);
+    }
+
+    public FileSizeLimitExceededException(String msg, long fileSizeLimitInMB, Throwable throwable) {
+        super("File size limit of " + fileSizeLimitInMB + " MB has been exceeded. " + msg, throwable);
+    }
+
+    public FileSizeLimitExceededException(Throwable throwable, long fileSizeLimitInMB) {
+        super("File size limit of " + fileSizeLimitInMB + " MB has been exceeded", throwable);
+    }
+}