[jboss-svn-commits] JBL Code SVN: r10003 - in labs/jbosslabs/trunk/portal-extensions: forge-portlets/src/java/org/jboss/forge/projects/downloads and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Mar 6 19:04:39 EST 2007
Author: adamw
Date: 2007-03-06 19:04:37 -0500 (Tue, 06 Mar 2007)
New Revision: 10003
Removed:
labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadsDescriptor.java
labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/IssueTracker.java
labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Repository.java
Modified:
labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/ProjectDescriptor.java
labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Projects.java
labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/ProjectsDescriptor.java
labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/ProjectsHelper.java
labs/jbosslabs/trunk/portal-extensions/forge-portlets/src/java/org/jboss/forge/projects/downloads/Downloads.java
Log:
Cleanup
Deleted: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadsDescriptor.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadsDescriptor.java 2007-03-06 23:13:50 UTC (rev 10002)
+++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadsDescriptor.java 2007-03-07 00:04:37 UTC (rev 10003)
@@ -1,665 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.forge.common.projects;
-
-import java.io.File;
-import java.io.IOException;
-import java.text.DateFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.forge.common.ForgeHelper;
-import org.jboss.forge.common.XmlTools;
-import org.jboss.forge.common.projects.XmlInputFactory.XmlNotFoundException;
-import org.jboss.forge.common.projects.elements.BindingsHandlerIterSingleKey;
-import org.jboss.forge.common.projects.elements.ElementDescriptor;
-import org.jboss.forge.common.projects.elements.ElementsDescriptor;
-import org.jboss.forge.common.projects.elements.ExtendedPropertiesMap;
-import org.jboss.forge.common.projects.elements.OutsidePropertiesMap;
-import org.jboss.forge.common.projects.elements.PropertiesHandler;
-import org.jboss.forge.common.projects.elements.PropertiesHandlerDefault;
-import org.jboss.forge.common.projects.elements.PropertiesHandlerStack;
-import org.jboss.forge.common.projects.elements.PropertiesMap;
-import org.jboss.forge.common.projects.permissions.NullPermissionsChecker;
-import org.jboss.forge.common.projects.permissions.PermissionsChecker;
-import org.jboss.portal.core.servlet.jsp.taglib.context.DelegateContext;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-/**
- * A class for objects describing one download category.
- *
- * @author adamw
- * @author Ryszard Kozmik
- */
-public class DownloadsDescriptor extends AbstractDescriptor {
- /**
- * <code>CAT_ID_SEPARATOR</code> - a separator of category ids.
- */
- public final static String CAT_ID_SEPARATOR = "/";
-
- /**
- * Name of the XML element under which downloads are described.
- */
- public final static String DOWNLOADS_ELEMENT = "downloads";
-
- private Map<String, DownloadsDescriptor> categories;
-
- private String categoryContext;
-
- private DelegateContext context;
-
-
- // Counters Settings
- private Sorting sortOrder=Sorting.RANDOM;
-
- private Boolean visible = Boolean.TRUE;
-
- /**
- * Creates a new component descriptor that hold information about root
- * category.
- *
- * @param isf
- * A factory of XML files.
- * @param xht
- * A XML -> HTML transformer.
- * @param node
- * XML DOM node
- * @param componentDir
- * Name of the directory storing the files used (descriptors,
- * content, etc)
- * @param componentDesc
- * Name of the descriptor file of the component
- * @param portalName
- * Name of the portal to which this downloads belong to.
- * @param projectId
- * Id of the project to which this downloads belong to.
- * @throws SAXException
- * @throws IOException
- * @throws XmlNotFoundException
- */
- public DownloadsDescriptor(XmlInputFactory isf, DomToXmlTransformer xht,
- Node node, String componentDir, String componentDesc, String portalName,
- String projectId) throws SAXException, IOException,
- XmlNotFoundException {
- this(isf, xht,node, "", "", componentDir, componentDesc, portalName,
- projectId,null,null,null);
- }
-
- /**
- * Creates a new component descriptor that hold information about one
- * category.
- *
- * @param isf
- * A factory of XML files.
- * @param xht
- * A XML -> HTML transformer.
- * @param node
- * XML DOM node
- * @param categoryContext
- * Context of the category.
- * @param categoryNameContext
- * Context name category.
- * @param componentDir
- * Name of the directory storing the files used (descriptors,
- * content, etc)
- * @param componentDesc
- * Name of the descriptor file of the component
- * @param portalName
- * Name of the portal to which this downloads belong to.
- * @param projectId
- * Id of the project to which this downloads belong to.
- * @param thisCategory
- * Parent category's ElementDescriptor
- * @param parentDesc
- * Parent DownloadsDescriptor
- * @throws SAXException
- * @throws IOException
- * @throws XmlNotFoundException
- */
- private DownloadsDescriptor(XmlInputFactory isf, DomToXmlTransformer xht,Node node,
- String categoryContext, String categoryNameContext,String componentDir,
- String componentDesc, String portalName,String projectId,
- ElementDescriptor thisCategory, DownloadsDescriptor parentDesc,Map<String,Counter> counters)
- throws SAXException, IOException, XmlNotFoundException {
-
- this.categoryContext = categoryContext;
- categories = new HashMap<String, DownloadsDescriptor>();
- context = new DelegateContext();
-
- // Prefix to prepend to each file path to make a component link
- String downloadPrefix = File.separator + ForgeHelper.FILE_ACCESS_DIR
- + File.separator + portalName + File.separator
- + ProjectsHelper.MEMBERS_DIR + File.separator + projectId
- + File.separator + componentDir;
-
- // Getting the category which has a path-like structure, not the
- // web-address-like structure
- String pathCategoryContext = categoryContext.replaceAll("["
- + CAT_ID_SEPARATOR + "]", File.separator);
-
- // Descriptors of categories and files that are contained in this
- // category.
- ElementsDescriptor categoriesDesc = null;
- ElementsDescriptor filesDesc = null;
-
- Node n;
- NodeList nodes = node.getChildNodes();
-
- // Parsing the descriptor
- // If there's no parent category info
- if (thisCategory == null) {
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- thisCategory = new ElementDescriptor(node, xht, new PropertiesHandlerDefault());
- categoryNameContext = thisCategory.getProperty("name");
- }
- }
-
- // If this is root DownloadsDescriptor then counters should be null
- // so we initialize it.
- if (counters==null) {
- counters = new HashMap<String,Counter>();
- }
-
- //System.out.println("-----------------------");
- //System.out.println("JESTEM PRZED IF");
- if (parentDesc!=null){
- this.sortOrder = parentDesc.getSortOrder();
- this.visible = parentDesc.getVisible();
- //System.out.println("USTAWI??EM SORT: "+sortOrder.name()+" VISIBLE: "+visible);
- }
-
- // Iterating to find counters' settings which must be parsed first because
- // they are inherited by all underlaying nodes.
- for (int i = 0; i < nodes.getLength(); i++) {
- n = nodes.item(i);
-
- if (n.getNodeType() == Node.ELEMENT_NODE) {
- if (n.getNodeName().equals("counters")) {
- ElementDescriptor countSettings = new ElementDescriptor(n, xht,
- new PropertiesHandlerDefault());
- String visible = countSettings.getProperty("visible");
- String sort = countSettings.getProperty("sorting");
- if (visible!=null && visible.trim().length()>0) {
- this.visible= Boolean.valueOf(visible.trim());
- }
- if (sort!=null && sort.trim().length()>0) {
- this.sortOrder = Sorting.valueOf(sort.trim().toUpperCase());
- }
- }
- }
- }
-
-
- // Parsing child categories and files descriptors.
- for (int i = 0; i < nodes.getLength(); i++) {
- n = nodes.item(i);
-
- if (n.getNodeType() == Node.ELEMENT_NODE) {
- if (n.getNodeName().equals("categories")) {
- categoriesDesc = new ElementsDescriptor(n, xht, "category",
- getCategoriesPropertiesHandler(isf,xht,n,
- categoryContext,categoryNameContext,
- componentDir, componentDesc,
- portalName, projectId,this,counters ));
- } else if (n.getNodeName().equals("files")) {
- String visible = XmlTools.getAttributeValue(n,"visible");
- String sort = XmlTools.getAttributeValue(n,"sorting");
- //System.out.println("FILES NODE VISIBLE: "+visible+ " SORT: "+sort);
- if (visible!=null && visible.trim().length()>0) {
- this.visible= Boolean.valueOf(visible.trim());
- //System.out.println("FILES : W IFIE VISIBLE");
- }
- if (sort!=null && sort.trim().length()>0) {
- this.sortOrder = Sorting.valueOf(sort.trim().toUpperCase());
- //System.out.println("FILES : W IFIE SORTING");
- }
- filesDesc = new ElementsDescriptor(n, xht, "file",
- getFilesPropertiesHandler(isf, projectId,
- downloadPrefix, pathCategoryContext,
- File.separator,componentDir,counters),
- getFilesExtendedPropertiesMap(downloadPrefix,
- pathCategoryContext, File.separator, portalName,
- projectId),
- new OutsidePropertiesMap());
- }
- }
- }
-
- if (categoriesDesc != null)
- categoriesDesc.fillContext(context.next("hasCategories"), "categories",
- new NullPermissionsChecker());
- if (filesDesc != null)
- filesDesc.fillContext(context.next("hasFiles"), "files",
- new NullPermissionsChecker());
-
- if (thisCategory != null)
- thisCategory.fillContext(context, new NullPermissionsChecker());
-
- // Creating the trace (for each category, a path from from the root to
- // that category).
- String[] idTokens = categoryContext.split("[" + CAT_ID_SEPARATOR + "]");
- String[] nameTokens = categoryNameContext.split("[" + CAT_ID_SEPARATOR
- + "]");
- String idPath = "";
-
- DelegateContext rootTraceContext = context.next("trace");
- rootTraceContext.put("id", "");
- rootTraceContext.put("name", nameTokens[0]);
-
- for (int i = 1; i < idTokens.length; i++) {
- DelegateContext traceContext = context.next("trace");
-
- idPath += CAT_ID_SEPARATOR + idTokens[i];
-
- traceContext.put("id", idPath);
- traceContext.put("name", nameTokens[i]);
- }
-
- if (parentDesc==null) {
- //System.out.println("++++++++++++");
- //System.out.println("ITERACJA DOWNLOADCOUNTER??W");
- for (String path : counters.keySet()) {
- //System.out.println("COUNTER: "+path);
- }
- //System.out.println("++++++++++++");
- }
-
- //System.out.println("KONIEC SORT: "+sortOrder.name()+" VISIBLE: "+visible);
- //System.out.println("++++++++++++++++++++");
- }
-
-
- /**
- * Creates a new component descriptor that hold information about one
- * category.
- *
- * @param xht
- * A XML -> HTML transformer.
- * @param isf
- * A factory of XML files.
- * @param categoryContext
- * A CAT_ID_SEPARATOR-separated list of parent categories.
- * @param categoryNameContext
- * A CAT_ID_SEPARATOR-separated list of parent categories names.
- * @param portalName
- * Name of the portal to which this component belong to.
- * @param projectId
- * Id of the project to which this component belong to.
- * @param componentDir
- * Name of the directory storing the files used (descriptors,
- * content, etc)
- * @param componentDesc
- * Name of the descriptor file of the component
- * @throws SAXException
- * @throws IOException
- * @throws XmlNotFoundException
- */
- private PropertiesHandler getCategoriesPropertiesHandler(
- final XmlInputFactory isf, final DomToXmlTransformer xht, final Node node,
- final String categoryContext, final String categoryNameContext,
- final String componentDir, final String componentDesc,
- final String portalName, final String projectId,
- final DownloadsDescriptor parentDD, final Map<String,Counter>counters) {
- PropertiesHandlerStack stack = new PropertiesHandlerStack();
- stack.addHandler(new PropertiesHandlerDefault());
- stack.addHandler(new PropertiesHandler() {
- public void fillContext(PropertiesMap properties,
- DelegateContext context, PermissionsChecker pc) {
- context.put("fullId", categoryContext + CAT_ID_SEPARATOR
- + properties.get("id").getFirstValue());
- }
-
- public void processNode(ElementDescriptor thisElement, Node node) {
- String categoryId = thisElement.getId();
- try {
- categories.put(categoryId, new DownloadsDescriptor(isf,
- xht,node.getParentNode(), categoryContext + CAT_ID_SEPARATOR
- + categoryId, categoryNameContext
- + CAT_ID_SEPARATOR
- + thisElement.getProperty("name"),
- componentDir, componentDesc, portalName, projectId,
- thisElement,parentDD,counters));
- } catch (Exception e) {
- // In case of an exception, we just don't add a child
- // category.
- }
- }
-
- public void collect(PropertiesMap properties, Object data,
- PermissionsChecker pc) {
-
- }
- });
-
- return stack;
- }
-
- private boolean isOutsideLink(String link) {
- return link.startsWith("http://") ||
- link.startsWith("ftp://") ||
- link.startsWith("https://");
- }
-
- private ExtendedPropertiesMap getFilesExtendedPropertiesMap(
- final String downloadPrefix, final String pathCategoryContext,
- final String separator, final String portalName,
- final String projectId) {
- ExtendedPropertiesMap epm = new ExtendedPropertiesMap();
- epm.addPropertySupport("button",
- getButtonPropertiesHandler(downloadPrefix, pathCategoryContext,
- separator, portalName, projectId),
- new BindingsHandlerIterSingleKey("button", "buttons", new Boolean(true)));
-
- epm.addPropertySupport("column",
- getColumnsPropertiesHandler(downloadPrefix, pathCategoryContext,
- separator, portalName, projectId),
- new BindingsHandlerIterSingleKey("column","column",true));
-
- return epm;
- }
-
- private PropertiesHandler getColumnsPropertiesHandler (
- final String downloadPrefix, final String pathCategoryContext,
- final String separator, final String portalName,
- final String projectId) {
- return new PropertiesHandler() {
- public void fillContext(PropertiesMap properties, DelegateContext context,
- PermissionsChecker pc) {
- context.put("value", properties.get("value").getFirstValue());
- }
-
- public void processNode(ElementDescriptor thisElement, Node node) {
-
- }
-
- public void collect(PropertiesMap properties, Object data,
- PermissionsChecker pc) {
-
- }
- };
- }
-
- private PropertiesHandler getButtonPropertiesHandler(
- final String downloadPrefix, final String pathCategoryContext,
- final String separator, final String portalName,
- final String projectId) {
- return new PropertiesHandler() {
- public void fillContext(PropertiesMap properties, DelegateContext context,
- PermissionsChecker pc) {
- String id = properties.get("id").getFirstValue();
-
- if (isOutsideLink(id))
- context.put("link", id);
- else {
- if ("true".equals(properties.get("freezone").getFirstValue()))
- context.put("link",
- ProjectsHelper.createFreezonePageLink(
- portalName, projectId, id));
- else
- context.put("link", downloadPrefix + pathCategoryContext
- + separator + id);
- }
-
- context.put("name", properties.get("name").getFirstValue());
- }
-
- public void processNode(ElementDescriptor thisElement, Node node) {
-
- }
-
- public void collect(PropertiesMap properties, Object data,
- PermissionsChecker pc) {
-
- }
- };
- }
-
- private PropertiesHandler getFilesPropertiesHandler(
- final XmlInputFactory isf, final String projectId,
- final String downloadPrefix, final String pathCategoryContext,
- final String separator, final String componentDir, final Map<String,Counter>counters) {
- PropertiesHandlerStack stack = new PropertiesHandlerStack();
- stack.addHandler(new PropertiesHandlerDefault());
- stack.addHandler(new PropertiesHandler() {
-
- public void fillContext(PropertiesMap properties,
- DelegateContext context, PermissionsChecker pc) {
- String id = properties.get("id").getFirstValue();
- String pathToFile = separator + projectId
- + separator + componentDir + separator
- + pathCategoryContext + separator + id;
-
- boolean outsideFile = false;
-
- /*
- * Checking if this is the link to a file is not an absolute
- * one; if it is not, then we prepend the prefix that was
- * created earlier. Also, if the link is not absolute, we can
- * compute the file size ourselves. If it is aboslute, we read
- * it from the provided tag.
- */
- if (isOutsideLink(id)) {
- context.put("link", id);
- context.put("size", properties.get("size").getFirstValue());
- outsideFile = true;
- } else {
- context.put("link", downloadPrefix + pathCategoryContext
- + separator + id);
-
- context.put("size", getFileSize(isf, pathToFile));
- }
-
- context.put("license", properties.get("license").getFirstValue());
-
- /*
- * Adding release date information - trying to read it from the
- * properties, and if there is no such info, auto-generating it.
- */
- if (properties.hasValues("release"))
- context.put("release", properties.get("release").getFirstValue());
- else
- /*
- * If this is an outside file, then we cannot determine its
- * release date.
- */
- if (!outsideFile)
- context.put("release", DateFormat.getDateInstance(
- DateFormat.SHORT).format(
- getFileModification(isf, pathToFile)));
- }
-
- public void processNode(ElementDescriptor thisElement, Node node) {
-
- if (node.getNodeName().compareToIgnoreCase("id")==0) {
-
- String id = XmlTools.unmarshallText(node);
-
- if (id==null) return;
-
- String pathToFile = separator + projectId
- + separator + componentDir + separator
- + pathCategoryContext + separator + id.trim();
- //System.out.println("PATHTOFILE: "+pathToFile);
-
- String visible = XmlTools.getAttributeValue(node.getParentNode(),"visible");
-
- //System.out.println("----------------------");
- //System.out.println("PROCNODE: "+ node.getNodeName());
- //System.out.println("FILENODE VIS: "+visible);
-
-
- Boolean counterVis = getVisible();
- Sorting counterSort = getSortOrder();
- if (visible!=null && visible.trim().length()>0) {
- counterVis= Boolean.valueOf(visible);
- }
- //System.out.println("KONINODE VIS: "+counterVis+ " SORT: "+ counterSort.name());
- counters.put(pathToFile,new Counter(0L,projectId,counterVis,counterSort));
-
- }
- }
-
- public void collect(PropertiesMap properties, Object data,
- PermissionsChecker pc) {
-
- }
- });
-
- return stack;
- }
-
- /**
- * Computes the last modification time of the given file.
- *
- * @param isf
- * A factory of XML files.
- * @param file
- * Name of the file which last modification time should be computed.
- * @return A date holding last modification of the given file.
- */
- private Date getFileModification(XmlInputFactory isf, String file) {
- return new Date(isf.getLastModification(file));
- }
-
- /**
- * Computes the length of the given file and returns it in a short form as a
- * string with a proper suffix (MB, KB, B).
- *
- * @param isf
- * A factory of XML files.
- * @param file
- * Name of the file which size should be computed.
- * @return A string containtg a shortened representation of size of the
- * given file.
- */
- private String getFileSize(XmlInputFactory isf, String file) {
- long length = isf.getLength(file);
- String suffix = "B";
- if (length >= 1048576) {
- suffix = "MB";
- length /= 1048576;
- } else if (length >= 1024) {
- suffix = "KB";
- length /= 1024;
- }
-
- return new Long(length).toString() + " " + suffix;
- }
-
- /**
- * Gets a downloads descriptor of category with the given full-id.
- *
- * @param categoryId
- * Full id of the category to get the downloads descriptor for.
- * @return An appropriate downloads descriptor or null, if the id is
- * invalid.
- */
- public DownloadsDescriptor getDownloadsDesciptor(String categoryId) {
- if (categoryId.equals(""))
- return this;
-
- // Splitting a category name which has a structure cat1/cat2... to parts
- // describing.
- // the first category and the rest.
- String[] tokens = categoryId.split("[" + CAT_ID_SEPARATOR + "]", 2);
-
- // If the path began with a /, just parsing the rest.
- if (tokens[0].equals(""))
- return getDownloadsDesciptor(tokens[1]);
-
- // Getting the downloads descriptor that corresponds to the first path
- // fragment.
- String firstCatId = tokens[0];
- DownloadsDescriptor dd = (DownloadsDescriptor) categories
- .get(firstCatId);
- if (dd == null)
- return null;
-
- // And recursively parsing if there is a second part; if not, returning
- // the found descriptor.
- if (tokens.length == 1)
- return dd;
-
- return dd.getDownloadsDesciptor(tokens[1]);
- }
-
- public DownloadsDescriptor getThisDownloadsDescriptor() {
- return this;
- }
-
- /**
- * Gets a context for JSP pages that holds information about this category.
- *
- * @return A context with information about this category.
- */
- public DelegateContext getContext() {
- return context;
- }
-
- /**
- * Gets a sortOrder enum value.
- */
- public Sorting getSortOrder() {
- return sortOrder;
- }
-
- /**
- * Gets counters visibility state.
- */
- public Boolean getVisible() {
- return visible;
- }
-
-
- /**
- * To the given set, adds all descriptors for this category and child
- * categories. All paths are relative to the members directory.
- *
- * @param projectId
- * Id of the project to which this descriptor belongs to.
- * @param toFill
- * Set to fill.
- * @param componentDir
- * Name of the directory storing the files used (descriptors,
- * content, etc).
- * @param componentDesc
- * Name of the descriptor file of the component.
- *
- */
- public void addWatchedFiles(String projectId, Set<String> toFill,
- String componentDir, String componentDesc) {
- String pathCategoryContext = categoryContext.replaceAll("["
- + CAT_ID_SEPARATOR + "]", "/");
-
- toFill.add(projectId + "/" + componentDir + pathCategoryContext + "/"
- + componentDesc);
-
- for (Iterator iter = categories.keySet().iterator(); iter.hasNext();)
- ((DownloadsDescriptor) categories.get(iter.next()))
- .addWatchedFiles(projectId, toFill,componentDir, componentDesc);
- }
-}
Deleted: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/IssueTracker.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/IssueTracker.java 2007-03-06 23:13:50 UTC (rev 10002)
+++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/IssueTracker.java 2007-03-07 00:04:37 UTC (rev 10003)
@@ -1,69 +0,0 @@
-
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.forge.common.projects;
-
-import org.jboss.forge.common.XmlTools;
-import org.w3c.dom.Node;
-
-/**
- * @author Pawel Wrzeszcz (pawel.wrzeszcz [at] gmail.com)
- */
-
-public class IssueTracker {
-
- public static final String ISSUE_TRACKER_ELEMENT = "issue-tracker";
-
- public static final short JIRA_ISSUE_TRACKER = 0;
- public static final short OTHER_ISSUE_TRACKER = 1;
-
- private static final String TYPE_ATTRIBUTE = "type";
-
- private static final String OTHER_ISSUE_TRACKER_STRING = "other";
-
- private String location;
- private short type;
-
- public IssueTracker(Node root) {
-
- location = XmlTools.unmarshallText(root);
-
- String typeString = XmlTools.getAttributeValue(root, TYPE_ATTRIBUTE);
-
- type = JIRA_ISSUE_TRACKER;
-
- if (typeString != null ) {
- if (typeString.equalsIgnoreCase(OTHER_ISSUE_TRACKER_STRING)) {
- type = OTHER_ISSUE_TRACKER;
- }
- }
- }
-
- public short getType() {
- return type;
- }
-
- public String getLocation() {
- return location;
- }
-}
Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/ProjectDescriptor.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/ProjectDescriptor.java 2007-03-06 23:13:50 UTC (rev 10002)
+++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/ProjectDescriptor.java 2007-03-07 00:04:37 UTC (rev 10003)
@@ -57,16 +57,7 @@
private String portalName;
private ElementDescriptor thisProject;
-
- private Node repositoryNode;
- private Repository repository;
- private Node issueTrackerNode;
- private IssueTracker issueTracker;
-
- private Node downloadsNode;
- private DownloadsDescriptor downloads;
-
@Inject
private ContentManager cm;
@@ -149,27 +140,6 @@
}
//new ObjectFactory().createProject();
}*/
-
- // Trying to create a downloads descriptor.
- try {
- downloads = new DownloadsDescriptor(isf, xht,downloadsNode,
- ProjectsHelper.DOWNLOADS_DIR,
- ProjectsHelper.DOWNLOADS_DESC,
- portalName, getId());
- } catch (Exception e) {
- log.warn("Project "+getId()+", unable te parse downloads" +
- " descriptor: "+e);
- downloads = null;
- }
-
-
- if (repositoryNode != null) {
- repository = new Repository(repositoryNode);
- }
-
- if (issueTrackerNode != null) {
- issueTracker = new IssueTracker(issueTrackerNode);
- }
}
/**
@@ -230,15 +200,6 @@
}
public void processNode(ElementDescriptor thisElement, Node node) {
- if (Repository.REPOSITORY_ELEMENT.equals(node.getNodeName())) {
- setRepositoryNode(node);
- }
- if (IssueTracker.ISSUE_TRACKER_ELEMENT.equals(node.getNodeName())) {
- setIssueTrackerNode(node);
- }
- if (DownloadsDescriptor.DOWNLOADS_ELEMENT.equals(node.getNodeName())) {
- downloadsNode=node;
- }
}
public void collect(PropertiesMap properties, Object data,
@@ -250,31 +211,6 @@
return stack;
}
- /*
- private PropertiesHandler getFreezonePropertiesHandler() {
- PropertiesHandlerStack ph = new PropertiesHandlerStack();
- ph.addHandler(new PropertiesHandlerDefault());
- ph.addHandler(new PropertiesHandler() {
- public void fillContext(PropertiesMap properties,
- DelegateContext context, PermissionsChecker pc) {
- context.put("link", ProjectsHelper.createFreezonePageLink(
- portalName, getId(), properties.get("id")
- .getFirstValue()));
- }
-
- public void processNode(ElementDescriptor thisElement, Node node) {
-
- }
-
- public void collect(PropertiesMap properties, Object data,
- PermissionsChecker pc) {
-
- }
- });
-
- return ph;
- } */
-
private PropertiesHandler getAdsPropertiesHandler() {
PropertiesHandlerStack ph = new PropertiesHandlerStack();
ph.addHandler(new PropertiesHandlerDefault());
@@ -331,16 +267,6 @@
public String getId() {
return thisProject.getId();
}
-
- /**
- * Gets a downloads descriptor of this project.
- *
- * @return A component descriptor of this project or null, if the project
- * has no components.
- */
- public DownloadsDescriptor getDownloadsDescriptor() {
- return downloads;
- }
/**
* Fills the given set with names of resources from which this project
@@ -348,11 +274,6 @@
* @param toFill Set to fill.
*/
public void getAllDescriptorsNames(Set<String> toFill) {
- if (downloads != null)
- downloads.addWatchedFiles(getId(), toFill,
- ProjectsHelper.DOWNLOADS_DIR,
- ProjectsHelper.DOWNLOADS_DESC);
-
toFill.add(getId() + "/" + ProjectsHelper.PROJECT_DESC);
}
@@ -368,32 +289,6 @@
}
/**
- * Creates and returns a link to the project's main page.
- *
- * @return A link to this project's main page.
- */
- public String getProjectLink() {
- if (thisProject.hasProperty(ProjectsDescriptor.INFO_PAGE_ATTRIBUTE)) {
- String infoPage = getProperty(ProjectsDescriptor.INFO_PAGE_ATTRIBUTE);
-
- if (Tools.isOutsideLink(infoPage)) {
- return infoPage;
- }
- }
-
- return ProjectsHelper.createPageLink(portalName,
- getId(), "");
- }
-
- /**
- * Gets a name of this project's main freezone page (if it exists);
- * returns null otherwise.
- */
- public String getProjectPageFreezone() {
- return getProperty(ProjectsDescriptor.INFO_PAGE_ATTRIBUTE);
- }
-
- /**
* Checks if permission to read this project is allowed with permissions
* set represented by the given permissions checker.
*
@@ -414,30 +309,4 @@
public boolean editPermissionAllowed(PermissionsChecker pc) {
return thisProject.editPermissionAllowed(pc);
}
-
- private void setRepositoryNode(Node node) {
- repositoryNode = node;
- }
-
- private void setIssueTrackerNode(Node node) {
- issueTrackerNode = node;
- }
-
- /**
- * Gets a repository for this project.
- * @return An object representing this project's repository
- * of null if repository is not specified for this project.
- */
- public Repository getProjectRepository() {
- return repository;
- }
-
- /**
- * Gets an issue tracker for this project.
- * @return An object representing this project's issue tracker
- * or null if issue tracker is not specified for this project.
- */
- public IssueTracker getProjectIssueTracker() {
- return issueTracker;
- }
}
Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Projects.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Projects.java 2007-03-06 23:13:50 UTC (rev 10002)
+++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Projects.java 2007-03-07 00:04:37 UTC (rev 10003)
@@ -68,61 +68,6 @@
}
/**
- * Gets context of the given category.
- * @param pc Permissions checker to use.
- * @param id Id of the category to get.
- */
- public DelegateContext getCategoryContext(PermissionsChecker pc, String id) {
- return getProjectsDescriptor()
- .getOutsidePropertyContext(pc, "category", id);
- }
-
- /**
- * Gets context of the given level.
- * @param pc Permissions checker to use.
- * @param id Id of the level to get.
- */
- public DelegateContext getLevelContext(PermissionsChecker pc, String id) {
- return getProjectsDescriptor()
- .getOutsidePropertyContext(pc,
- ProjectsDescriptor.LEVEL_ATTRIBUTE, id);
- }
-
- /**
- * Gets a context describing all projects.
- *
- * @param pc Permissions checker to use.
- */
- public DelegateContext getProjectsContext(PermissionsChecker pc) {
- return getProjectsDescriptor().getContext(pc);
- }
-
- /**
- * Gets a download context for the given project and category.
- *
- * @param projectId
- * Id of the selected project.
- * @param categoryId
- * Id of the selected category.
- * @param pc Permissions checker to use.
- * @return Download context for the diven project and category or null if no
- * such context exists.
- */
- public DelegateContext getDownloadsContext(PermissionsChecker pc,
- String projectId, String categoryId) {
- ProjectDescriptor pd = getProjectsDescriptor().getProjectDescriptor(projectId);
- if (pd == null)
- return null;
-
- DownloadsDescriptor dd = pd.getDownloadsDescriptor();
-
- if (categoryId != null)
- dd = dd.getDownloadsDesciptor(categoryId);
-
- return dd == null ? null : dd.getContext();
- }
-
- /**
* Gets the name of the project with the given id.
*/
public String getProjectName(String projectId) {
@@ -133,43 +78,10 @@
* Gets a link to the project with the given id.
*/
public String getProjectLink(String projectId) {
- return getProjectsDescriptor().getProjectLink(projectId);
+ return "/" + projectId;
}
/**
- * Gets a name of this project's main freezone page (if it exists);
- * returns null otherwise.
- */
- public String getProjectPageFreezone(String projectId) {
- return getProjectsDescriptor().getProjectPageFreezone(projectId);
- }
-
- /**
- * Gets level of the given project.
- * @param projectId Id of the project.
- * @return Level of the given project.
- */
- public String getProjectLevel(String projectId) {
- ProjectDescriptor pd = getProjectsDescriptor().getProjectDescriptor(projectId);
-
- if (pd == null)
- return null;
-
- return pd.getProperty(ProjectsDescriptor.LEVEL_ATTRIBUTE);
- }
-
-
- /**
- * Gets the value of the given property of the given project.
- * @param projectId Id of the project.
- * @param propertyName Name of the property.
- * @return Value of the project property with the given name.
- */
- public String getProjectProperty(String projectId, String propertyName) {
- return getProjectsDescriptor().getProjectProperty(projectId, propertyName);
- }
-
- /**
* Checks if a project with the given id exists.
* @param projectId Id of the project to check.
* @return True iff a project with the given id exists.
@@ -203,63 +115,12 @@
}
/**
- * Searches for the given string in project's names and descriptions.
- *
- * @param pc Permissions checker to use.
- * @param searchFor
- * String to search for.
- * @return A context containing under the key "projects" contexts of found
- * projects.
- */
- public DelegateContext search(PermissionsChecker pc, String searchFor) {
- return getProjectsDescriptor().search(pc, searchFor);
- }
-
- /**
- * Gets a context which holds information about all projects categorized
- * by their level.
- */
- public DelegateContext getLevelsContext(PermissionsChecker pc) {
- return getProjectsDescriptor().getLevelsContext(pc);
- }
-
- /**
* Checks if the given project can be edited.
*/
public boolean editPermissionAllowed(PermissionsChecker pc, String projectId) {
return getProjectsDescriptor().editPermissionAllowed(pc, projectId);
}
- /**
- * Gets a link to the given level.
- * @return A link to the given level.
- */
- public String getLevelLink(String levelId) {
- return getProjectsDescriptor().getLevelLink(levelId);
- }
-
- /**
- * Gets a link to the given level.
- * @return A link to the given level.
- */
- public String getLevelName(String levelId) {
- return getProjectsDescriptor().getLevelName(levelId);
- }
-
- /**
- * For the given project id, returns project repository.
- */
- public Repository getProjectRepository(String projectId) {
- return getProjectsDescriptor().getProjectRepository(projectId);
- }
-
- /**
- * For the given project id, returns project issue tracker.
- */
- public IssueTracker getProjectIssueTracker(String projectId) {
- return getProjectsDescriptor().getProjectIssueTracker(projectId);
- }
-
public Map<String, String> getProjectsNameId() {
return getProjectsDescriptor().getProjectsNameId();
}
Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/ProjectsDescriptor.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/ProjectsDescriptor.java 2007-03-06 23:13:50 UTC (rev 10002)
+++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/ProjectsDescriptor.java 2007-03-07 00:04:37 UTC (rev 10003)
@@ -408,46 +408,6 @@
}
/**
- * Searches for the given string in project's names and descriptions.
- *
- * @param pc
- * Permissions checker to use.
- * @param searchFor
- * String to search for.
- * @return A context containing under the key "projects" contexts of found
- * projects.
- */
- public DelegateContext search(PermissionsChecker pc, String searchFor) {
- boolean found = false;
- DelegateContext context = new DelegateContext();
-
- String[] tokens = SearchTools.prepareTokens(searchFor, "+");
-
- for (String projectId : projects.keySet()) {
- if (!projectAdmissable(projectId)) {
- continue;
- }
-
- ProjectDescriptor project = projects.get(projectId);
-
- if (!project.permissionAllowed(pc)) {
- continue;
- }
-
- if ((SearchTools
- .searchInString(project.getProperty("name"), tokens)
- || (SearchTools.searchInString(project
- .getProperty("description"), tokens)) || (SearchTools
- .searchInString(project.getProperty("companyname"), tokens)))) {
- found = true;
- project.fillContextShallow(context.next("projects"), pc);
- }
- }
-
- return found ? context : null;
- }
-
- /**
* Gets a descriptor of a specified project.
*
* @param projectId
@@ -600,62 +560,6 @@
}
/**
- * Gets a link to the project witht he given id.
- *
- * @param projectId
- * Id of the project.
- * @return A link to the given project's main page.
- */
- public String getProjectLink(String projectId) {
- if (!projectAdmissable(projectId)) {
- return "";
- }
-
- ProjectDescriptor pd = projects.get(projectId);
- if (pd == null)
- return "";
-
- return pd.getProjectLink();
- }
-
- /**
- * Gets a name of this project's main freezone page (if it exists);
- * returns null otherwise.
- */
- public String getProjectPageFreezone(String projectId) {
- if (!projectAdmissable(projectId)) {
- return "";
- }
-
- ProjectDescriptor pd = projects.get(projectId);
- if (pd == null)
- return "";
-
- return pd.getProjectPageFreezone();
- }
-
- /**
- * Gets the value of a given property of the project witht the given id.
- *
- * @param projectId
- * Id of the project.
- * @param propertyName
- * Name of the property.
- * @return Value of the project property with the given name.
- */
- public String getProjectProperty(String projectId, String propertyName) {
- if (!projectAdmissable(projectId)) {
- return "";
- }
-
- ProjectDescriptor pd = projects.get(projectId);
- if (pd == null)
- return "";
-
- return pd.getProperty(propertyName);
- }
-
- /**
* Gets a set of names of resources which are descriptors of projects
* represented by this ProjectsDescriptor instance.
*/
@@ -732,76 +636,6 @@
return pd.editPermissionAllowed(transformPermissionsChecker(pc));
}
- public String getLevelLink(String levelId) {
- ElementDescriptor ed = opm.getElementsDescriptor("level").getElementWithId(levelId);
-
- if (ed == null) {
- return "";
- }
-
- String link = ForgeHelper.createLink(portalName,
- ed.getProperty(TYPE_ATTRIBUTE),
- ed.getProperty(LINK_ELEMENT));
-
- return link;
- }
-
- public String getLevelName(String levelId) {
- ElementDescriptor ed = opm.getElementsDescriptor("level").getElementWithId(levelId);
-
- if (ed == null) {
- return "";
- }
-
- return ed.getProperty("name");
- }
-
- /**
- * For the given project id, returns project repository.
- *
- * @param projectId
- * Id of the project.
- * @return project repository or null if no such project exists
- * or project repository is not specified for this project.
- */
- public Repository getProjectRepository(String projectId) {
-
- if (!projectAdmissable(projectId)) {
- return null;
- }
-
- ProjectDescriptor pd = projects.get(projectId);
-
- if (pd == null) {
- return null;
- }
-
- return pd.getProjectRepository();
- }
-
- /**
- * For the given project id, returns project issue tracker.
- *
- * @param projectId
- * Id of the project.
- * @return project issue tracker or null if no such project exists
- * or project issue tracker is not specified for this project.
- */
- public IssueTracker getProjectIssueTracker(String projectId) {
-
- if (!projectAdmissable(projectId)) {
- return null;
- }
-
- ProjectDescriptor pd = projects.get(projectId);
-
- if (pd == null) {
- return null;
- }
-
- return pd.getProjectIssueTracker();
- }
-
public Map<String, String> getProjectsNameId() {
Map<String, String> projectsNameId = new HashMap<String, String>();
Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/ProjectsHelper.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/ProjectsHelper.java 2007-03-06 23:13:50 UTC (rev 10002)
+++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/ProjectsHelper.java 2007-03-07 00:04:37 UTC (rev 10003)
@@ -92,7 +92,6 @@
protected final static String PAGES_DESC = "pages.xml";
protected final static String JEMS_DESC = "jems.xml";
protected final static String CATEGORIES_DESC = "categories.xml";
- protected final static String DOWNLOADS_DESC = "downloads.xml";
protected final static String DOWNLOADCOUNTER_DESC = "counter.xml";
protected final static String DOWNLOADCOUNTERMAIN_DESC = "counters.xml";
public final static String POLLS_DESC = "polls.xml";
Deleted: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Repository.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Repository.java 2007-03-06 23:13:50 UTC (rev 10002)
+++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Repository.java 2007-03-07 00:04:37 UTC (rev 10003)
@@ -1,90 +0,0 @@
-
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.forge.common.projects;
-
-import org.jboss.forge.common.XmlTools;
-import org.w3c.dom.Node;
-
-/**
- * @author Pawel Wrzeszcz (pawel.wrzeszcz [at] gmail.com)
- */
-
-public class Repository {
-
- public static final String REPOSITORY_ELEMENT = "repository";
-
- public static final short SVN_REPOSITORY = 0;
- public static final short CVS_REPOSITORY = 1;
- public static final short OTHER_REPOSITORY = 2;
-
- private static final String TYPE_ATTRIBUTE = "type";
- private static final String USERNAME_ATTRIBUTE = "username";
- private static final String PASSWORD_ATTRIBUTE = "password";
-
- private static final String CVS_REPOSITORY_STRING = "cvs";
- private static final String OTHER_REPOSITORY_STRING = "other";
-
- private String location;
- private String username;
- private String password;
- private short type;
-
- public Repository(Node root) {
-
- location = XmlTools.unmarshallText(root);
- username = XmlTools.getAttributeValue(root, USERNAME_ATTRIBUTE);
- password = XmlTools.getAttributeValue(root, PASSWORD_ATTRIBUTE);
-
- String typeString = XmlTools.getAttributeValue(root, TYPE_ATTRIBUTE);
-
- type = SVN_REPOSITORY; // default type is SVN
-
- if (typeString != null) {
-
- if (typeString.equalsIgnoreCase(CVS_REPOSITORY_STRING)) {
- type = SVN_REPOSITORY;
- }
- if (typeString.equalsIgnoreCase(OTHER_REPOSITORY_STRING)) {
- type = OTHER_REPOSITORY;
- }
- }
- }
-
- public short getType() {
- return type;
- }
-
- public String getLocation() {
- return location;
- }
-
- public String getUsername() {
- return username;
- }
-
- public String getPassword() {
- return password;
- }
-
-}
Modified: labs/jbosslabs/trunk/portal-extensions/forge-portlets/src/java/org/jboss/forge/projects/downloads/Downloads.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-portlets/src/java/org/jboss/forge/projects/downloads/Downloads.java 2007-03-06 23:13:50 UTC (rev 10002)
+++ labs/jbosslabs/trunk/portal-extensions/forge-portlets/src/java/org/jboss/forge/projects/downloads/Downloads.java 2007-03-07 00:04:37 UTC (rev 10003)
@@ -62,9 +62,9 @@
Constants.FREEZONE_PATH_PARAM);
// Getting the appropriate context
- DelegateContext context = projects.getDownloadsContext(
- new RenderRequestPermissionsChecker(request), projectId,
- categoryId);
+ DelegateContext context = null;//projects.getDownloadsContext(
+ //new RenderRequestPermissionsChecker(request), projectId,
+ //categoryId);
if (context == null)
throw new Exception("2");
More information about the jboss-svn-commits
mailing list