From: <jbo...@li...> - 2006-07-07 14:57:20
|
Author: unibrew Date: 2006-07-07 10:39:39 -0400 (Fri, 07 Jul 2006) New Revision: 4943 Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadsDescriptor.java Log: [JBLAB-682] Clearing the code. Modified: 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 2006-07-07 13:50:53 UTC (rev 4942) +++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadsDescriptor.java 2006-07-07 14:39:39 UTC (rev 4943) @@ -30,7 +30,6 @@ import java.util.Map; import java.util.Set; -import org.apache.xerces.parsers.DOMParser; import org.jboss.forge.common.ForgeHelper; import org.jboss.forge.common.projects.XmlInputFactory.XmlNotFoundException; import org.jboss.forge.common.projects.elements.BindingsHandlerIterSingleKey; @@ -45,7 +44,6 @@ import org.jboss.forge.common.projects.permissions.NullPermissionsChecker; import org.jboss.forge.common.projects.permissions.PermissionsChecker; import org.jboss.portal.common.context.DelegateContext; -import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; @@ -89,13 +87,6 @@ * @throws IOException * @throws XmlNotFoundException */ - /*public DownloadsDescriptor(XmlInputFactory isf, DomToXmlTransformer xht, - String componentDir, String componentDesc, String portalName, - String projectId) throws SAXException, IOException, - XmlNotFoundException { - this(isf, xht, "", "", componentDir, componentDesc, portalName, - projectId, null); - }*/ public DownloadsDescriptor(XmlInputFactory isf, DomToXmlTransformer xht, Node node, String componentDir, String componentDesc, String portalName, String projectId) throws SAXException, IOException, @@ -131,35 +122,15 @@ ElementsDescriptor filesDesc = null; Node n; - NodeList nodes = node.getChildNodes(); - - System.out.println("---------------------"); - System.out.println("ENTERING PARSING OF NODE"); - System.out.println("ROOT NODENAME: "+node.getNodeName() +" NODEVALUE: "+node.getNodeValue()); - for (int i =0; i<nodes.getLength();i++) { - if (nodes.item(i).getNodeType() == Node.ELEMENT_NODE) - System.out.println("SUBNODE NAME: "+nodes.item(i).getNodeName()+" NODEVALUE: "+nodes.item(i).getNodeValue()); - } - System.out.println("---------------------"); - - - - - - - + NodeList nodes = node.getChildNodes(); + // Parsing the descriptor // If there's no parent category info, we look for a "root-category" // tag. - System.out.println("BEFORE NODENAME: "+node.getNodeName()); if (thisCategory == null) { - System.out.println("IN IF"); if (node.getNodeType() == Node.ELEMENT_NODE) { - System.out.println("IN ELEMENT"); thisCategory = new ElementDescriptor(node, xht, new PropertiesHandlerDefault()); categoryNameContext = thisCategory.getProperty("name"); - System.out.println("CATEGORY NAME: "+categoryNameContext); - // categoryDescription = thisCategory.getProperty("description"); } } @@ -168,16 +139,13 @@ n = nodes.item(i); if (n.getNodeType() == Node.ELEMENT_NODE) { - System.out.println("PARSING ZA NODETYPE: "+n.getNodeName()); if (n.getNodeName().equals("categories")) { - System.out.println("W KATEGORIACH"); categoriesDesc = new ElementsDescriptor(n, xht, "category", getCategoriesPropertiesHandler(isf,xht,n, categoryContext,categoryNameContext, componentDir, componentDesc, portalName, projectId )); } else if (n.getNodeName().equals("files")) { - System.out.println("W PLIKACH"); filesDesc = new ElementsDescriptor(n, xht, "file", getFilesPropertiesHandler(isf, projectId, downloadPrefix, pathCategoryContext, @@ -251,138 +219,7 @@ * @throws IOException * @throws XmlNotFoundException */ - /* private DownloadsDescriptor(XmlInputFactory isf, DomToXmlTransformer xht, - String categoryContext, String categoryNameContext, - String componentDir, String componentDesc, String portalName, - String projectId, ElementDescriptor thisCategory) - throws SAXException, IOException, XmlNotFoundException { - this.categoryContext = categoryContext; - categories = new HashMap<String, DownloadsDescriptor>(); - context = new DelegateContext(); - - // File name components separator - String separator = "/"; - - // Prefix to prepend to each file path to make a component link - String downloadPrefix = separator + ForgeHelper.FILE_ACCESS_DIR - + separator + portalName + separator - + ProjectsHelper.MEMBERS_DIR + separator + projectId - + separator + componentDir; - - // Getting the category which has a path-like structure, not the - // web-address-like structure - String pathCategoryContext = categoryContext.replaceAll("[" - + CAT_ID_SEPARATOR + "]", separator); - - // The isf is already suffixed with the members directory, so we just - // need to add <project id>/<path prefix = component type>/<category - // context> - String isfPathPrefix = separator + projectId + separator + componentDir - + separator + pathCategoryContext; - - // Descriptors of categories and files that are contained in this - // category. - ElementsDescriptor categoriesDesc = null; - ElementsDescriptor filesDesc = null; - - // Getting the categories and files descriptors - DOMParser parser = new DOMParser(); - parser.parse(isf.getInputSource(isfPathPrefix + separator - + componentDesc)); - Document doc = parser.getDocument(); - - Node n; - NodeList nodes = doc.getDocumentElement().getChildNodes(); - - - - //TODO: BECOMES OUTDATED - - - // Parsing the descriptor - // If there's no parent category info, we look for a "root-category" - // tag. - if (thisCategory == null) - for (int i = 0; i < nodes.getLength(); i++) { - n = nodes.item(i); - - if (n.getNodeType() == Node.ELEMENT_NODE) { - if (n.getNodeName().equals("root-category")) { - thisCategory = new ElementDescriptor(n, xht, - new PropertiesHandlerDefault()); - categoryNameContext = thisCategory.getProperty("name"); - } - } - } - - // If there's still no root category info, we throw an exception. - if (thisCategory == null) - throw new SAXException(); - - //TODO: BECOMES OUTDATED - - - - // 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, - portalName, projectId, categoryContext, - categoryNameContext,componentDir, componentDesc)); - } else if (n.getNodeName().equals("files")) { - filesDesc = new ElementsDescriptor(n, xht, "file", - getFilesPropertiesHandler(isf, projectId, - downloadPrefix, pathCategoryContext, - separator,componentDir), - getFilesExtendedPropertiesMap(downloadPrefix, - pathCategoryContext, separator, portalName, - projectId), - new OutsidePropertiesMap()); - } - } - } - - - //TODO: BECOMES OUTDATED - if (thisCategory != null) - thisCategory.fillContext(context, new NullPermissionsChecker()); - //TODO: BECOMES OUTDATED - - - - if (categoriesDesc != null) - categoriesDesc.fillContext(context.next("hasCategories"), "categories", - new NullPermissionsChecker()); - if (filesDesc != null) - filesDesc.fillContext(context.next("hasFiles"), "files", - 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]); - } - }*/ - - private PropertiesHandler getCategoriesPropertiesHandler( + private PropertiesHandler getCategoriesPropertiesHandler( final XmlInputFactory isf, final DomToXmlTransformer xht, final Node node, final String categoryContext, final String categoryNameContext, final String componentDir, final String componentDesc, @@ -516,7 +353,7 @@ + pathCategoryContext + separator + id; boolean outsideFile = false; - System.out.println("PUTTING IN CONTEXT FILE: "+id); + /* * 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 @@ -545,9 +382,9 @@ context.put("release", properties.get("release").getFirstValue()); else /* - * If this is an outside file, then we cannot determine its - * release date. - */ + * If this is an outside file, then we cannot determine its + * release date. + */ if (!outsideFile) context.put("release", DateFormat.getDateInstance( DateFormat.SHORT).format( |