[jboss-svn-commits] JBL Code SVN: r10578 - in labs/jbosslabs/trunk/portal-extensions: forge-common/src/java/org/jboss/forge/common/projects/project and 3 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Mar 28 11:12:19 EDT 2007
Author: szimano
Date: 2007-03-28 11:12:18 -0400 (Wed, 28 Mar 2007)
New Revision: 10578
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/project/Categories.java
labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/project/Category.java
labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/project/Downloads.java
labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/project/Files.java
labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/project/rw/CategoriesRW.java
labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/project/rw/CategoryRW.java
labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/project/rw/DownloadsRW.java
labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/project/rw/FilesRW.java
labs/jbosslabs/trunk/portal-extensions/forge-portal-attr/src/java/org/jboss/forge/portal/DownloadsFilter.java
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/DownloadsConstants.java
Log:
project getCategory and getFile tweaks
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-28 14:06:46 UTC (rev 10577)
+++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/ProjectsDescriptor.java 2007-03-28 15:12:18 UTC (rev 10578)
@@ -35,6 +35,9 @@
import org.jboss.forge.common.projects.project.Downloads;
import org.jboss.forge.common.projects.project.File;
import org.jboss.forge.common.projects.project.Project;
+import org.jboss.forge.common.projects.project.rw.CategoryRW;
+import org.jboss.forge.common.projects.project.rw.DownloadsRW;
+import org.jboss.forge.common.projects.project.rw.FileRW;
import org.jboss.forge.common.projects.project.rw.ProjectRW;
import org.jboss.forge.common.projects.proxies.ReadOnlyProxy;
import org.jboss.forge.common.projects.proxies.SyncProxy;
@@ -44,226 +47,239 @@
/**
* Holds information about all projects.
- *
+ *
* @author <a href="mailto:adamw at aster.pl">Adam Warski</a>
* @author <a href="ryszard.kozmik at jboss.com">Ryszard Kozmik</a>
* @author Pawel Wrzeszcz (pawel . wrzeszcz [at] jboss . com)
*/
public class ProjectsDescriptor {
- private static final Logger log = Logger.getLogger(ProjectsDescriptor.class);
+ private static final Logger log = Logger
+ .getLogger(ProjectsDescriptor.class);
- /**
- * Project id --> corresponding project descriptor object
- */
- private Map<String, Project> projects;
+ /**
+ * Project id --> corresponding project descriptor object
+ */
+ private Map<String, Project> projects;
- /**
- * Configuration from projects.xml descriptor.
- */
- private Configuration configuration;
+ /**
+ * Configuration from projects.xml descriptor.
+ */
+ private Configuration configuration;
- private Map<String, ProjectConfiguration> projectsConfiguration;
+ private Map<String, ProjectConfiguration> projectsConfiguration;
- /**
- * <code>projectWithErrorsDescriptors</code> - A set of paths to project
- * descriptors that couldn't be added becouse they contain errors.
- */
- private Set<String> projectWithErrorsDescriptors;
+ /**
+ * <code>projectWithErrorsDescriptors</code> - A set of paths to project
+ * descriptors that couldn't be added becouse they contain errors.
+ */
+ private Set<String> projectWithErrorsDescriptors;
- private XmlInputFactory isf;
- private JAXBContext projectRWJC = null;
+ private XmlInputFactory isf;
- /**
- * Parses project xml descriptors and stores information about the projects.
- *
- * @param isf
- * A factory of xml files.
- */
- public ProjectsDescriptor(XmlInputFactory isf) {
+ private JAXBContext projectRWJC = null;
- this.isf = isf;
+ /**
+ * Parses project xml descriptors and stores information about the projects.
+ *
+ * @param isf
+ * A factory of xml files.
+ */
+ public ProjectsDescriptor(XmlInputFactory isf) {
- projects = new LinkedHashMap<String,Project>();
- projectWithErrorsDescriptors = new HashSet<String>();
+ this.isf = isf;
- try {
- projectRWJC = JAXBContext.newInstance("org.jboss.forge.common.projects.project.rw");
- } catch (JAXBException e) {
- log.warn("I could not create JAXBContext.", e);
- }
+ projects = new LinkedHashMap<String, Project>();
+ projectWithErrorsDescriptors = new HashSet<String>();
- try {
- unmarshallProjects(isf);
- } catch (Exception e) {
- log.error("Projects descriptor constructor.", e);
- }
+ try {
+ projectRWJC = JAXBContext
+ .newInstance("org.jboss.forge.common.projects.project.rw");
+ } catch (JAXBException e) {
+ log.warn("I could not create JAXBContext.", e);
+ }
- try {
- LabsServices.getProjectPagesService().updatePages(getProjects().values());
- } catch (ServiceRetrievalException e) {
- log.error("Error getting labs project pages service.", e);
- }
- }
+ try {
+ unmarshallProjects(isf);
+ } catch (Exception e) {
+ log.error("Projects descriptor constructor.", e);
+ }
- /**
- * Reads information about all projects contained in the given document
- * root, and fills the projects list with that information.
- * @param isf
- */
- private void unmarshallProjects(XmlInputFactory isf) {
- JAXBContext projectsJC=null;
+ try {
+ LabsServices.getProjectPagesService().updatePages(
+ getProjects().values());
+ } catch (ServiceRetrievalException e) {
+ log.error("Error getting labs project pages service.", e);
+ }
+ }
- try {
- projectsJC = JAXBContext.newInstance("org.jboss.forge.common.projects.configuration");
- } catch (JAXBException e) {
- log.warn("I could not create JAXBContext."+e.getCause());
- }
+ /**
+ * Reads information about all projects contained in the given document
+ * root, and fills the projects list with that information.
+ *
+ * @param isf
+ */
+ private void unmarshallProjects(XmlInputFactory isf) {
+ JAXBContext projectsJC = null;
- if (projectsJC!=null) {
- try {
- Unmarshaller un = projectsJC.createUnmarshaller();
- this.configuration = (Configuration)un.unmarshal(
- isf.getInputSource(ProjectsHelper.PROJECTS_DESC));
+ try {
+ projectsJC = JAXBContext
+ .newInstance("org.jboss.forge.common.projects.configuration");
+ } catch (JAXBException e) {
+ log.warn("I could not create JAXBContext." + e.getCause());
+ }
- projectsConfiguration = new HashMap<String, ProjectConfiguration>();
- for (ProjectConfiguration prjConf : configuration.getProjects()) {
- projectsConfiguration.put(prjConf.getContent(), prjConf);
- }
+ if (projectsJC != null) {
+ try {
+ Unmarshaller un = projectsJC.createUnmarshaller();
+ this.configuration = (Configuration) un.unmarshal(isf
+ .getInputSource(ProjectsHelper.PROJECTS_DESC));
- log.info("Projects.xml configuration created.");
+ projectsConfiguration = new HashMap<String, ProjectConfiguration>();
+ for (ProjectConfiguration prjConf : configuration.getProjects()) {
+ projectsConfiguration.put(prjConf.getContent(), prjConf);
+ }
- for (String projectId : projectsConfiguration.keySet()) {
- unmarshallProjectRW(projectId, isf, projectRWJC);
- }
- } catch (Exception e) {
- log.warn("I could not create projects.xml configuration.",e);
- }
- }
- }
+ log.info("Projects.xml configuration created.");
- private void unmarshallProjectRW(String projectId, XmlInputFactory isf,
- JAXBContext projectRWJC) {
- try {
- if (projectRWJC!=null) {
- try {
- Unmarshaller un = projectRWJC.createUnmarshaller();
+ for (String projectId : projectsConfiguration.keySet()) {
+ unmarshallProjectRW(projectId, isf, projectRWJC);
+ }
+ } catch (Exception e) {
+ log.warn("I could not create projects.xml configuration.", e);
+ }
+ }
+ }
- ProjectRW newProject = (ProjectRW)un.unmarshal(
- isf.getInputSource(projectId+"/" + ProjectsHelper.PROJECT_DESC));
+ private void unmarshallProjectRW(String projectId, XmlInputFactory isf,
+ JAXBContext projectRWJC) {
+ try {
+ if (projectRWJC != null) {
+ try {
+ Unmarshaller un = projectRWJC.createUnmarshaller();
- projects.put(projectId,
- (Project) ReadOnlyProxy.newInstance(newProject));
+ ProjectRW newProject = (ProjectRW) un.unmarshal(isf
+ .getInputSource(projectId + "/"
+ + ProjectsHelper.PROJECT_DESC));
- log.info("Project "+projectId+" created.");
+ setHelpReferences(newProject);
- } catch (Exception e) {
+ projects.put(projectId, (Project) ReadOnlyProxy
+ .newInstance(newProject));
- log.warn("I could not create Project "+projectId+".",e);
- }
- }
+ log.info("Project " + projectId + " created.");
- } catch (Exception e) {
- // In case of any exception, we just don't put the
- // project into the map. We only add its descriptor
- // to the set of projects with errors to monitor
- // any changes in it.
- projectWithErrorsDescriptors.add(projectId + "/"
- + ProjectsHelper.PROJECT_DESC);
+ } catch (Exception e) {
- log.warn("Project " + projectId + " (RW mode) parse error.", e);
- }
+ log
+ .warn("I could not create Project " + projectId
+ + ".", e);
+ }
+ }
+
+ } catch (Exception e) {
+ // In case of any exception, we just don't put the
+ // project into the map. We only add its descriptor
+ // to the set of projects with errors to monitor
+ // any changes in it.
+ projectWithErrorsDescriptors.add(projectId + "/"
+ + ProjectsHelper.PROJECT_DESC);
+
+ log.warn("Project " + projectId + " (RW mode) parse error.", e);
+ }
}
- /**
- * Gets the name of the project with the given id.
- *
- * @param projectId
- * Id of the project.
- * @return Name of the given project or an empty string if no such project
- * exists.
- */
- public String getProjectName(String projectId) {
- Project prj = projects.get(projectId);
- if (prj == null) {
- return "";
- }
+ /**
+ * Gets the name of the project with the given id.
+ *
+ * @param projectId
+ * Id of the project.
+ * @return Name of the given project or an empty string if no such project
+ * exists.
+ */
+ public String getProjectName(String projectId) {
+ Project prj = projects.get(projectId);
+ if (prj == null) {
+ return "";
+ }
- return prj.getName();
- }
+ return prj.getName();
+ }
- /**
- * @return A set of names of resources which are descriptors of projects
- * represented by this ProjectsDescriptor instance.
- */
- public Set<String> getAllDescriptorsNames() {
- Set<String> toFill = new HashSet<String>();
+ /**
+ * @return A set of names of resources which are descriptors of projects
+ * represented by this ProjectsDescriptor instance.
+ */
+ public Set<String> getAllDescriptorsNames() {
+ Set<String> toFill = new HashSet<String>();
- toFill.add(ProjectsHelper.PROJECTS_DESC);
+ toFill.add(ProjectsHelper.PROJECTS_DESC);
- for (Project prj : projects.values()) {
- toFill.add(prj.getId() + "/" + ProjectsHelper.PROJECT_DESC);
- }
+ for (Project prj : projects.values()) {
+ toFill.add(prj.getId() + "/" + ProjectsHelper.PROJECT_DESC);
+ }
- toFill.addAll(projectWithErrorsDescriptors);
+ toFill.addAll(projectWithErrorsDescriptors);
- return toFill;
- }
+ return toFill;
+ }
- /**
- * Gets ids of all projects on the given level, accessible with the given
- * permissions checker.
- * @param pc Permissions checker to use.
- * @return A set of project ids on the given level accessible with the
- * given permissions checker.
- */
- public Set<String> getProjectIds(PermissionsChecker pc) {
- Set<String> ret = new LinkedHashSet<String>();
+ /**
+ * Gets ids of all projects on the given level, accessible with the given
+ * permissions checker.
+ *
+ * @param pc
+ * Permissions checker to use.
+ * @return A set of project ids on the given level accessible with the given
+ * permissions checker.
+ */
+ public Set<String> getProjectIds(PermissionsChecker pc) {
+ Set<String> ret = new LinkedHashSet<String>();
- for (String projectId : projects.keySet()) {
- if (permissionAllowed(pc, projectId)) {
- ret.add(projectId);
- }
- }
+ for (String projectId : projects.keySet()) {
+ if (permissionAllowed(pc, projectId)) {
+ ret.add(projectId);
+ }
+ }
- return ret;
- }
+ return ret;
+ }
- /**
- * Checks if the given project can be accessed.
- */
- public boolean permissionAllowed(PermissionsChecker pc, String projectId) {
- ProjectConfiguration prjConf = projectsConfiguration.get(projectId);
+ /**
+ * Checks if the given project can be accessed.
+ */
+ public boolean permissionAllowed(PermissionsChecker pc, String projectId) {
+ ProjectConfiguration prjConf = projectsConfiguration.get(projectId);
- if (prjConf == null) {
- return false;
- }
+ if (prjConf == null) {
+ return false;
+ }
- String permission = prjConf.getPermission();
- return permission == null || pc.hasPermission(permission);
- }
+ String permission = prjConf.getPermission();
+ return permission == null || pc.hasPermission(permission);
+ }
- /**
- * Checks if the given project can be edited.
- */
- public boolean editPermissionAllowed(PermissionsChecker pc, String projectId) {
- ProjectConfiguration prjConf = projectsConfiguration.get(projectId);
+ /**
+ * Checks if the given project can be edited.
+ */
+ public boolean editPermissionAllowed(PermissionsChecker pc, String projectId) {
+ ProjectConfiguration prjConf = projectsConfiguration.get(projectId);
- if (prjConf == null) {
- return false;
- }
+ if (prjConf == null) {
+ return false;
+ }
- String permission = prjConf.getEditPermission();
- return permission == null || pc.hasPermission(permission);
- }
+ String permission = prjConf.getEditPermission();
+ return permission == null || pc.hasPermission(permission);
+ }
- public Map<String, String> getProjectsNameId() {
+ public Map<String, String> getProjectsNameId() {
Map<String, String> projectsNameId = new HashMap<String, String>();
- for (String projectId : projects.keySet()) {
- projectsNameId.put(projects.get(projectId).getName(), projectId);
- }
+ for (String projectId : projects.keySet()) {
+ projectsNameId.put(projects.get(projectId).getName(), projectId);
+ }
- return projectsNameId;
+ return projectsNameId;
}
public Set<String> getProjectIds() {
@@ -271,63 +287,72 @@
}
/**
- * Be aware that Project beans returned are in read-only mode.
- * Mutable operations will throw IllegalOperationException.
+ * Be aware that Project beans returned are in read-only mode. Mutable
+ * operations will throw IllegalOperationException.
*/
- public Map<String, ? extends Project> getProjects() {
- return projects;
- }
+ public Map<String, ? extends Project> getProjects() {
+ return projects;
+ }
/**
- * @return new Project bean in Read-Write mode.
- * Do NOT use in immutable operations as it will affect performance.
+ * @return new Project bean in Read-Write mode. Do NOT use in immutable
+ * operations as it will affect performance.
*/
- public Project getNewProjectRW(String projectId) {
+ public Project getNewProjectRW(String projectId) {
- ProjectRW newProjectRW;
+ ProjectRW newProjectRW;
try {
Unmarshaller un = projectRWJC.createUnmarshaller();
- newProjectRW = (ProjectRW) un.unmarshal(
- isf.getInputSource(projectId+"/" + ProjectsHelper.PROJECT_DESC));
-
- setHelpReferences(newProjectRW);
+ newProjectRW = (ProjectRW) un.unmarshal(isf
+ .getInputSource(projectId + "/"
+ + ProjectsHelper.PROJECT_DESC));
} catch (Exception e) {
- log.warn("I could not create Project "+projectId+" (RW mode).", e);
- return null;
+ log.warn("I could not create Project " + projectId + " (RW mode).",
+ e);
+ return null;
}
- return (Project) SyncProxy.newInstance(newProjectRW);
- }
+ return (Project) SyncProxy.newInstance(newProjectRW);
+ }
- private void setHelpReferences(ProjectRW project) {
- Downloads d = project.getDownloads();
-
- for (Category cat : d.getCategories().getCategory()) {
- setReference(cat);
+ private void setHelpReferences(ProjectRW project) {
+ DownloadsRW d = project.getDownloads();
+
+ if (d != null) {
+ if (d.getCategories() != null
+ && d.getCategories().getCategory() != null)
+ for (CategoryRW cat : d.getCategories().getCategory()) {
+ setReference(cat);
+ }
+
+ d.updateMaps();
}
-
- d.updateMaps();
}
-
- private void setReference(Category category) {
- for (Category cat : category.getCategories().getCategory()) {
- cat.setParent(category);
- setReference(cat);
- }
-
- for (File file : category.getFiles().getFile()) {
- file.setParent(category);
- }
- }
- public Configuration getConfiguration () {
- return this.configuration;
- }
+ private void setReference(CategoryRW category) {
- public Map<String, ProjectConfiguration> getProjectsConfiguration() {
- return projectsConfiguration;
- }
+ if (category.getCategories() != null
+ && category.getCategories().getCategory() != null)
+ for (CategoryRW cat : category.getCategories().getCategory()) {
+ cat.setParent(category);
+ setReference(cat);
+ }
+
+ if (category.getFiles() != null
+ && category.getFiles().getFile() != null)
+ for (FileRW file : category.getFiles().getFile()) {
+ file.setParent(category);
+ }
+ }
+
+ public Configuration getConfiguration() {
+ return this.configuration;
+ }
+
+ public Map<String, ProjectConfiguration> getProjectsConfiguration() {
+ return projectsConfiguration;
+ }
}
Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/project/Categories.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/project/Categories.java 2007-03-28 14:06:46 UTC (rev 10577)
+++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/project/Categories.java 2007-03-28 15:12:18 UTC (rev 10578)
@@ -29,4 +29,6 @@
*/
public abstract List<? extends Category> getCategory();
+// added by tomek
+ public Category getCategory(String categoryId);
}
\ No newline at end of file
Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/project/Category.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/project/Category.java 2007-03-28 14:06:46 UTC (rev 10577)
+++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/project/Category.java 2007-03-28 15:12:18 UTC (rev 10578)
@@ -105,10 +105,7 @@
public abstract void setCategories(Categories value);
// added by tomek
- public Category getCategory(String categoryId);
- public File getFile(String fileId);
-
public Category getParent();
public void setParent(Category parent);
Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/project/Downloads.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/project/Downloads.java 2007-03-28 14:06:46 UTC (rev 10577)
+++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/project/Downloads.java 2007-03-28 15:12:18 UTC (rev 10578)
@@ -106,9 +106,6 @@
// tomek
- public Category getCategory(String categoryId);
- public File getFile(String fileId);
-
public void updateMaps();
}
\ No newline at end of file
Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/project/Files.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/project/Files.java 2007-03-28 14:06:46 UTC (rev 10577)
+++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/project/Files.java 2007-03-28 15:12:18 UTC (rev 10578)
@@ -68,5 +68,8 @@
*
*/
public abstract void setSorting(Sorting value);
+
+ public File getFile(String fileId);
+
}
\ No newline at end of file
Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/project/rw/CategoriesRW.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/project/rw/CategoriesRW.java 2007-03-28 14:06:46 UTC (rev 10577)
+++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/project/rw/CategoriesRW.java 2007-03-28 15:12:18 UTC (rev 10578)
@@ -23,10 +23,13 @@
package org.jboss.forge.common.projects.project.rw;
import java.io.Serializable;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import org.jboss.forge.common.projects.project.Categories;
@@ -81,5 +84,22 @@
}
return this.category;
}
+
+ @XmlTransient
+ private Map<String, CategoryRW> childCategories = new HashMap<String, CategoryRW>();
+
+ public CategoryRW getCategory(String categoryId) {
+ return childCategories.get(categoryId);
+ }
+
+ protected void updateMaps() {
+ childCategories.clear();
+
+ if (category != null)
+ for (CategoryRW c : category) {
+ childCategories.put(c.getId(), c);
+ c.updateMaps();
+ }
+ }
}
Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/project/rw/CategoryRW.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/project/rw/CategoryRW.java 2007-03-28 14:06:46 UTC (rev 10577)
+++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/project/rw/CategoryRW.java 2007-03-28 15:12:18 UTC (rev 10578)
@@ -37,185 +37,159 @@
import org.jboss.forge.common.projects.project.File;
import org.jboss.forge.common.projects.project.Files;
-
/**
*
- * Class for keeping information about download category.
- * PLEASE, DO NOT MODIFY THIS CLASS UNLESS YOU KNOW JAXB.
- * @author Ryszard Kozmik
- *
+ * Class for keeping information about download category. PLEASE, DO NOT MODIFY
+ * THIS CLASS UNLESS YOU KNOW JAXB.
*
+ * @author Ryszard Kozmik
*
*
+ *
+ *
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "category", propOrder = {
})
-public class CategoryRW
- implements Category, Serializable
-{
+public class CategoryRW implements Category, Serializable {
- private final static long serialVersionUID = 1L;
- @XmlElement(required = true)
- protected String id;
- protected String name;
- protected String description;
- protected FilesRW files;
- protected CategoriesRW categories;
+ private final static long serialVersionUID = 1L;
- /**
- * Gets the value of the id property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public synchronized String getId() {
- return id;
- }
+ @XmlElement(required = true)
+ protected String id;
- /**
- * Sets the value of the id property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public synchronized void setId(String value) {
- this.id = value;
- }
+ protected String name;
- /**
- * Gets the value of the name property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public synchronized String getName() {
- return name;
- }
+ protected String description;
- /**
- * Sets the value of the name property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public synchronized void setName(String value) {
- this.name = value;
- }
+ protected FilesRW files;
- /**
- * Gets the value of the description property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public synchronized String getDescription() {
- return description;
- }
+ protected CategoriesRW categories;
- /**
- * Sets the value of the description property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public synchronized void setDescription(String value) {
- this.description = value;
- }
+ /**
+ * Gets the value of the id property.
+ *
+ * @return possible object is {@link String }
+ *
+ */
+ public synchronized String getId() {
+ return id;
+ }
- /**
- * Gets the value of the files property.
- *
- * @return
- * possible object is
- * {@link FilesRW }
- *
- */
- public synchronized FilesRW getFiles() {
- return files;
- }
+ /**
+ * Sets the value of the id property.
+ *
+ * @param value
+ * allowed object is {@link String }
+ *
+ */
+ public synchronized void setId(String value) {
+ this.id = value;
+ }
- /**
- * Sets the value of the files property.
- *
- * @param value
- * allowed object is
- * {@link FilesRW }
- *
- */
- public synchronized void setFiles(Files value) {
- this.files = (FilesRW) value;
- }
+ /**
+ * Gets the value of the name property.
+ *
+ * @return possible object is {@link String }
+ *
+ */
+ public synchronized String getName() {
+ return name;
+ }
- /**
- * Gets the value of the categories property.
- *
- * @return
- * possible object is
- * {@link CategoriesRW }
- *
- */
- public synchronized CategoriesRW getCategories() {
- return categories;
- }
+ /**
+ * Sets the value of the name property.
+ *
+ * @param value
+ * allowed object is {@link String }
+ *
+ */
+ public synchronized void setName(String value) {
+ this.name = value;
+ }
- /**
- * Sets the value of the categories property.
- *
- * @param value
- * allowed object is
- * {@link CategoriesRW }
- *
- */
- public synchronized void setCategories(Categories value) {
- this.categories = (CategoriesRW) value;
- }
+ /**
+ * Gets the value of the description property.
+ *
+ * @return possible object is {@link String }
+ *
+ */
+ public synchronized String getDescription() {
+ return description;
+ }
+ /**
+ * Sets the value of the description property.
+ *
+ * @param value
+ * allowed object is {@link String }
+ *
+ */
+ public synchronized void setDescription(String value) {
+ this.description = value;
+ }
- //tomek
- @XmlTransient
- private Category parent;
- @XmlTransient
- private Map<String, CategoryRW> childCategories = new HashMap<String, CategoryRW>();
- @XmlTransient
- private Map<String, FileRW> childFiles = new HashMap<String, FileRW>();
-
- protected void updateMaps() {
- for (CategoryRW c : categories.getCategory()) {
- childCategories.put(c.getId(), c);
- c.updateMaps();
- }
-
- for (FileRW f : files.getFile()) {
- childFiles.put(f.getId(), f);
- }
- }
-
- public void setParent(Category parent) {
- this.parent = parent;
- }
-
- public Category getCategory(String categoryId) {
- return childCategories.get(categoryId);
+ /**
+ * Gets the value of the files property.
+ *
+ * @return possible object is {@link FilesRW }
+ *
+ */
+ public synchronized FilesRW getFiles() {
+ return files;
}
- public File getFile(String fileId) {
- return childFiles.get(fileId);
+ /**
+ * Sets the value of the files property.
+ *
+ * @param value
+ * allowed object is {@link FilesRW }
+ *
+ */
+ public synchronized void setFiles(Files value) {
+ this.files = (FilesRW) value;
}
+ /**
+ * Gets the value of the categories property.
+ *
+ * @return possible object is {@link CategoriesRW }
+ *
+ */
+ public synchronized CategoriesRW getCategories() {
+ return categories;
+ }
+
+ /**
+ * Sets the value of the categories property.
+ *
+ * @param value
+ * allowed object is {@link CategoriesRW }
+ *
+ */
+ public synchronized void setCategories(Categories value) {
+ this.categories = (CategoriesRW) value;
+ }
+
+ // tomek
+ @XmlTransient
+ private Category parent;
+
+ protected void updateMaps() {
+ if (categories != null)
+ categories.updateMaps();
+
+ if (files != null)
+ files.updateMaps();
+
+ }
+
+ public void setParent(Category parent) {
+ System.out.println("setting parent: " + parent.getId() + " for: " + id);
+ this.parent = parent;
+ }
+
public Category getParent() {
return parent;
}
@@ -224,8 +198,8 @@
if (parent == null) {
return id;
}
-
- return parent.getFullName() + "/" + id;
+
+ return parent.getFullName() + "/" + id;
}
}
Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/project/rw/DownloadsRW.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/project/rw/DownloadsRW.java 2007-03-28 14:06:46 UTC (rev 10577)
+++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/project/rw/DownloadsRW.java 2007-03-28 15:12:18 UTC (rev 10578)
@@ -38,263 +38,226 @@
import org.jboss.forge.common.projects.project.Files;
import org.jboss.forge.common.projects.project.Sorting;
-
/**
*
- * Class for keeping information about project's downloads.
- * PLEASE, DO NOT MODIFY THIS CLASS UNLESS YOU KNOW JAXB.
- * @author Ryszard Kozmik
- *
+ * Class for keeping information about project's downloads. PLEASE, DO NOT
+ * MODIFY THIS CLASS UNLESS YOU KNOW JAXB.
*
+ * @author Ryszard Kozmik
*
*
+ *
+ *
*/
@XmlAccessorType(XmlAccessType.FIELD)
- at XmlType(name = "downloads", propOrder = {
- "categories",
- "name",
- "description",
- "counters",
- "files"
-})
-public class DownloadsRW
- implements Downloads, Serializable
-{
+ at XmlType(name = "downloads", propOrder = { "categories", "name", "description",
+ "counters", "files" })
+public class DownloadsRW implements Downloads, Serializable {
- private final static long serialVersionUID = 1L;
- protected CategoriesRW categories;
- protected String name;
- protected String description;
- protected DownloadsRW.Counters counters;
- protected FilesRW files;
+ private final static long serialVersionUID = 1L;
- /**
- * Gets the value of the categories property.
- *
- * @return
- * possible object is
- * {@link CategoriesRW }
- *
- */
- public synchronized CategoriesRW getCategories() {
- return categories;
- }
+ protected CategoriesRW categories;
- /**
- * Sets the value of the categories property.
- *
- * @param value
- * allowed object is
- * {@link CategoriesRW }
- *
- */
- public synchronized void setCategories(Categories value) {
- this.categories = (CategoriesRW) value;
- }
+ protected String name;
- /**
- * Gets the value of the name property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public synchronized String getName() {
- return name;
- }
+ protected String description;
- /**
- * Sets the value of the name property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public synchronized void setName(String value) {
- this.name = value;
- }
+ protected DownloadsRW.Counters counters;
- /**
- * Gets the value of the description property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public synchronized String getDescription() {
- return description;
- }
+ protected FilesRW files;
- /**
- * Sets the value of the description property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public synchronized void setDescription(String value) {
- this.description = value;
- }
+ /**
+ * Gets the value of the categories property.
+ *
+ * @return possible object is {@link CategoriesRW }
+ *
+ */
+ public synchronized CategoriesRW getCategories() {
+ return categories;
+ }
- /**
- * Gets the value of the counters property.
- *
- * @return
- * possible object is
- * {@link DownloadsRW.Counters }
- *
- */
- public synchronized DownloadsRW.Counters getCounters() {
- return counters;
- }
+ /**
+ * Sets the value of the categories property.
+ *
+ * @param value
+ * allowed object is {@link CategoriesRW }
+ *
+ */
+ public synchronized void setCategories(Categories value) {
+ this.categories = (CategoriesRW) value;
+ }
- /**
- * Sets the value of the counters property.
- *
- * @param value
- * allowed object is
- * {@link DownloadsRW.Counters }
- *
- */
- public synchronized void setCounters(org.jboss.forge.common.projects.project.Counters value) {
- this.counters = (Counters) value;
- }
+ /**
+ * Gets the value of the name property.
+ *
+ * @return possible object is {@link String }
+ *
+ */
+ public synchronized String getName() {
+ return name;
+ }
- /**
- * Gets the value of the files property.
- *
- * @return
- * possible object is
- * {@link FilesRW }
- *
- */
- public synchronized FilesRW getFiles() {
- return files;
- }
+ /**
+ * Sets the value of the name property.
+ *
+ * @param value
+ * allowed object is {@link String }
+ *
+ */
+ public synchronized void setName(String value) {
+ this.name = value;
+ }
- /**
- * Sets the value of the files property.
- *
- * @param value
- * allowed object is
- * {@link FilesRW }
- *
- */
- public synchronized void setFiles(Files value) {
- this.files = (FilesRW) value;
- }
+ /**
+ * Gets the value of the description property.
+ *
+ * @return possible object is {@link String }
+ *
+ */
+ public synchronized String getDescription() {
+ return description;
+ }
+ /**
+ * Sets the value of the description property.
+ *
+ * @param value
+ * allowed object is {@link String }
+ *
+ */
+ public synchronized void setDescription(String value) {
+ this.description = value;
+ }
- /**
- * <p>Java class for anonymous complex type.
- *
- * <p>The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="sorting" type="{http://jboss.org}sorting" minOccurs="0"/>
- * <element name="visible" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
- * </sequence>
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
- @XmlAccessorType(XmlAccessType.FIELD)
- @XmlType(name = "", propOrder = {
- "sorting",
- "visible"
- })
- public static class Counters
- implements org.jboss.forge.common.projects.project.Counters, Serializable
- {
+ /**
+ * Gets the value of the counters property.
+ *
+ * @return possible object is {@link DownloadsRW.Counters }
+ *
+ */
+ public synchronized DownloadsRW.Counters getCounters() {
+ return counters;
+ }
- private final static long serialVersionUID = 1L;
- protected SortingRW sorting;
- protected Boolean visible;
+ /**
+ * Sets the value of the counters property.
+ *
+ * @param value
+ * allowed object is {@link DownloadsRW.Counters }
+ *
+ */
+ public synchronized void setCounters(
+ org.jboss.forge.common.projects.project.Counters value) {
+ this.counters = (Counters) value;
+ }
- /**
- * Gets the value of the sorting property.
- *
- * @return
- * possible object is
- * {@link SortingRW }
- *
- */
- public synchronized SortingRW getSorting() {
- return sorting;
- }
+ /**
+ * Gets the value of the files property.
+ *
+ * @return possible object is {@link FilesRW }
+ *
+ */
+ public synchronized FilesRW getFiles() {
+ return files;
+ }
- /**
- * Sets the value of the sorting property.
- *
- * @param value
- * allowed object is
- * {@link SortingRW }
- *
- */
- public synchronized void setSorting(Sorting value) {
- this.sorting = (SortingRW) value;
- }
+ /**
+ * Sets the value of the files property.
+ *
+ * @param value
+ * allowed object is {@link FilesRW }
+ *
+ */
+ public synchronized void setFiles(Files value) {
+ this.files = (FilesRW) value;
+ }
- /**
- * Gets the value of the visible property.
- *
- * @return
- * possible object is
- * {@link Boolean }
- *
- */
- public synchronized Boolean isVisible() {
- return visible;
- }
+ /**
+ * <p>
+ * Java class for anonymous complex type.
+ *
+ * <p>
+ * The following schema fragment specifies the expected content contained
+ * within this class.
+ *
+ * <pre>
+ * <complexType>
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="sorting" type="{http://jboss.org}sorting" minOccurs="0"/>
+ * <element name="visible" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+ @XmlAccessorType(XmlAccessType.FIELD)
+ @XmlType(name = "", propOrder = { "sorting", "visible" })
+ public static class Counters implements
+ org.jboss.forge.common.projects.project.Counters, Serializable {
- /**
- * Sets the value of the visible property.
- *
- * @param value
- * allowed object is
- * {@link Boolean }
- *
- */
- public synchronized void setVisible(Boolean value) {
- this.visible = value;
- }
+ private final static long serialVersionUID = 1L;
- }
+ protected SortingRW sorting;
- // tomek
- @XmlTransient
- private Map<String, CategoryRW> childCategories = new HashMap<String, CategoryRW>();
- @XmlTransient
- private Map<String, FileRW> childFiles = new HashMap<String, FileRW>();
+ protected Boolean visible;
- public Category getCategory(String categoryId) {
- return childCategories.get(categoryId);
- }
+ /**
+ * Gets the value of the sorting property.
+ *
+ * @return possible object is {@link SortingRW }
+ *
+ */
+ public synchronized SortingRW getSorting() {
+ return sorting;
+ }
- public File getFile(String fileId) {
- return childFiles.get(fileId);
- }
+ /**
+ * Sets the value of the sorting property.
+ *
+ * @param value
+ * allowed object is {@link SortingRW }
+ *
+ */
+ public synchronized void setSorting(Sorting value) {
+ this.sorting = (SortingRW) value;
+ }
- public void updateMaps() {
- for (CategoryRW c : categories.getCategory()) {
- childCategories.put(c.getId(), c);
- c.updateMaps();
+ /**
+ * Gets the value of the visible property.
+ *
+ * @return possible object is {@link Boolean }
+ *
+ */
+ public synchronized Boolean isVisible() {
+ return visible;
}
-
- for (FileRW f : files.getFile()) {
- childFiles.put(f.getId(), f);
+
+ /**
+ * Sets the value of the visible property.
+ *
+ * @param value
+ * allowed object is {@link Boolean }
+ *
+ */
+ public synchronized void setVisible(Boolean value) {
+ this.visible = value;
}
+
}
+ // tomek
+
+ public void updateMaps() {
+ if (categories != null)
+ categories.updateMaps();
+
+ if (files != null)
+ files.updateMaps();
+ }
+
}
Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/project/rw/FilesRW.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/project/rw/FilesRW.java 2007-03-28 14:06:46 UTC (rev 10577)
+++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/project/rw/FilesRW.java 2007-03-28 15:12:18 UTC (rev 10578)
@@ -23,13 +23,17 @@
package org.jboss.forge.common.projects.project.rw;
import java.io.Serializable;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
+import org.jboss.forge.common.projects.project.File;
import org.jboss.forge.common.projects.project.Files;
import org.jboss.forge.common.projects.project.Sorting;
@@ -143,5 +147,23 @@
public synchronized void setSorting(Sorting value) {
this.sorting = (SortingRW) value;
}
+
+ // tomek
+
+ @XmlTransient
+ private Map<String, FileRW> childFiles = new HashMap<String, FileRW>();
+
+ protected void updateMaps() {
+ childFiles.clear();
+
+ if (file != null)
+ for (FileRW f : file) {
+ childFiles.put(f.getId(), f);
+ }
+ }
+
+ public File getFile(String fileId) {
+ return childFiles.get(fileId);
+ }
}
Modified: labs/jbosslabs/trunk/portal-extensions/forge-portal-attr/src/java/org/jboss/forge/portal/DownloadsFilter.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-portal-attr/src/java/org/jboss/forge/portal/DownloadsFilter.java 2007-03-28 14:06:46 UTC (rev 10577)
+++ labs/jbosslabs/trunk/portal-extensions/forge-portal-attr/src/java/org/jboss/forge/portal/DownloadsFilter.java 2007-03-28 15:12:18 UTC (rev 10578)
@@ -96,11 +96,9 @@
if (tokens.length > 3) {
for (int i = 2; i < tokens.length - 1; i++) {
if (cat == null) {
- cat = getCategory(tokens[i], downl
- .getCategories());
+ cat = downl.getCategories().getCategory(tokens[i]);
} else {
- cat = getCategory(tokens[i], cat
- .getCategories());
+ cat = cat.getCategories().getCategory(tokens[i]);
}
if (cat == null) {
@@ -164,16 +162,6 @@
return null;
}
- private Category getCategory(String catId, Categories categories) {
- for (Category cat : categories.getCategory()) {
- if (cat.getId().equals(catId)) {
- return cat;
- }
- }
-
- return null;
- }
-
public void init(FilterConfig arg0) throws ServletException {
}
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-28 14:06:46 UTC (rev 10577)
+++ labs/jbosslabs/trunk/portal-extensions/forge-portlets/src/java/org/jboss/forge/projects/downloads/Downloads.java 2007-03-28 15:12:18 UTC (rev 10578)
@@ -79,14 +79,14 @@
else {
String[] cats = categoryId.split("/");
- Category cat = getCategory(cats[0], d.getCategories());
+ Category cat = d.getCategories().getCategory(cats[0]);
if (cat == null) {
throw new Exception("No such category: "+categoryId);
}
for (int i = 1; i < cats.length; i++) {
- cat = getCategory(cats[i], cat.getCategories());
+ cat = cat.getCategories().getCategory(cats[i]);
if (cat == null) {
throw new Exception("No such category: "+categoryId);
@@ -124,14 +124,4 @@
response.getWriter().write("ERROR: " + e.getMessage());
}
}
-
- private Category getCategory(String catId, Categories categories) {
- for (Category cat : categories.getCategory()) {
- if (cat.getId().equals(catId)) {
- return cat;
- }
- }
-
- return null;
- }
}
Modified: labs/jbosslabs/trunk/portal-extensions/forge-portlets/src/java/org/jboss/forge/projects/downloads/DownloadsConstants.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-portlets/src/java/org/jboss/forge/projects/downloads/DownloadsConstants.java 2007-03-28 14:06:46 UTC (rev 10577)
+++ labs/jbosslabs/trunk/portal-extensions/forge-portlets/src/java/org/jboss/forge/projects/downloads/DownloadsConstants.java 2007-03-28 15:12:18 UTC (rev 10578)
@@ -31,4 +31,5 @@
public class DownloadsConstants {
public static final String CATEGORIES = "CATEGORIES";
public static final String FILES = "FILES";
+ public static final String DESCRIPTION = "DESCRIPTION";
}
More information about the jboss-svn-commits
mailing list