[jboss-svn-commits] JBL Code SVN: r10075 - in labs/jbosslabs/trunk/portal-extensions: forge-common/src/java/org/jboss/forge/common/ejb3 and 12 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Mar 8 10:45:59 EST 2007
Author: adamw
Date: 2007-03-08 10:45:59 -0500 (Thu, 08 Mar 2007)
New Revision: 10075
Added:
labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/configuration/ProjectConfiguration.java
Removed:
labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/portlet/ContentPortlet.java
labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/AbstractDescriptor.java
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/configuration/Project.java
labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/elements/
labs/jbosslabs/trunk/portal-extensions/forge-portlets/src/java/org/jboss/forge/projects/info/Info.java
labs/jbosslabs/trunk/portal-extensions/forge-portlets/src/java/org/jbosslabs/portlet/ads/
Modified:
labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/XmlTools.java
labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/ejb3/ConfigurationService.java
labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterDescriptor.java
labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDescriptor.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/ProjectsConfigurationWatcher.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-common/src/java/org/jboss/forge/common/projects/configuration/Configuration.java
labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/configuration/ObjectFactory.java
labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/configuration/package-info.java
labs/jbosslabs/trunk/portal-extensions/forge-common/src/web/WEB-INF/projects.xsd
labs/jbosslabs/trunk/portal-extensions/forge-ejb3/src/java/org/jboss/forge/ejb3/configuration/ConfigurationServiceImpl.java
labs/jbosslabs/trunk/portal-extensions/forge-feeds/src/java/org/jboss/forge/feeds/ProjectVariableResolver.java
labs/jbosslabs/trunk/portal-extensions/forge-portlets/src/java/org/jboss/forge/podcast/Podcast.java
labs/jbosslabs/trunk/portal-extensions/forge-portlets/src/java/org/jboss/forge/projects/info/ProjectInfoBean.java
labs/jbosslabs/trunk/portal-extensions/forge-portlets/src/web/WEB-INF/portlet.xml
labs/jbosslabs/trunk/portal-extensions/polls/src/java/org/jboss/forge/polls/PollDescriptor.java
labs/jbosslabs/trunk/portal-extensions/polls/src/java/org/jboss/forge/polls/PollsDescriptor.java
labs/jbosslabs/trunk/portal-extensions/primates/src/java/org/jbosslabs/portlets/primates/Primate.java
Log:
Cleanup
Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/XmlTools.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/XmlTools.java 2007-03-08 15:14:35 UTC (rev 10074)
+++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/XmlTools.java 2007-03-08 15:45:59 UTC (rev 10075)
@@ -28,7 +28,6 @@
import javax.xml.transform.TransformerException;
import org.jboss.forge.common.projects.DomToXmlTransformer;
-import org.jboss.forge.common.projects.elements.PropertiesMap;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -46,29 +45,6 @@
private XmlTools() {
}
-
- /**
- * Reads all attributes of the given node and returns them as a properties map.
- * @param root Node from which to read the attributes.
- * @return A properties map holding all attributes of the given node.
- */
- public static PropertiesMap getPropertiesFromNodeAttributes(Node root) {
- PropertiesMap properties = new PropertiesMap();
- NamedNodeMap nnm = root.getAttributes();
-
- if (nnm != null) {
- Node n;
-
- for (int i=0; i<nnm.getLength(); i++) {
- n = nnm.item(i);
- if (n.getNodeType() == Node.ATTRIBUTE_NODE) {
- properties.add(n.getNodeName(), XmlTools.unmarshallText(n));
- }
- }
- }
-
- return properties;
- }
/**
* Reads all attributes of the given node and returns them as a map. Only
@@ -150,7 +126,7 @@
return unmarshallText(n);
}
-
+
/**
* Reads and returns a HTML block contained in the children of the specified
* node.
@@ -177,7 +153,7 @@
return buf.toString();
}
-
+
/**
* Reads and returns a HTML block contained in the children of the specified
* node with a default xml -> html transformer.
@@ -203,7 +179,7 @@
return "";
}
}
-
+
/**
* Gets a node that is a child node of the given one and has the given
* name.
Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/ejb3/ConfigurationService.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/ejb3/ConfigurationService.java 2007-03-08 15:14:35 UTC (rev 10074)
+++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/ejb3/ConfigurationService.java 2007-03-08 15:45:59 UTC (rev 10075)
@@ -1,7 +1,7 @@
package org.jboss.forge.common.ejb3;
import org.jboss.forge.common.projects.configuration.Configuration;
-import org.jboss.forge.common.projects.configuration.Project;
+import org.jboss.forge.common.projects.configuration.ProjectConfiguration;
import java.util.List;
@@ -12,12 +12,10 @@
public Configuration getConfiguration();
- public List<Project> getConfiguredProjects ();
+ public List<ProjectConfiguration> getConfiguredProjects ();
public String getProjectPermission (String projectId) ;
- public String getProjectLevel (String projectId) ;
-
public String getProjectEditPermission (String projectId) ;
// Life cycle methods
Deleted: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/portlet/ContentPortlet.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/portlet/ContentPortlet.java 2007-03-08 15:14:35 UTC (rev 10074)
+++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/portlet/ContentPortlet.java 2007-03-08 15:45:59 UTC (rev 10075)
@@ -1,329 +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.portlet;
-
-import org.jboss.forge.common.ForgeHelper;
-import org.jboss.portlet.JBossPortlet;
-import org.jboss.portlet.JBossRenderRequest;
-import org.jboss.portlet.JBossRenderResponse;
-import org.jboss.shotoku.ContentManager;
-import org.jboss.shotoku.aop.CacheItem;
-import org.jboss.shotoku.tools.Pair;
-import org.jboss.shotoku.cache.ShotokuResourceWatcher;
-import org.jboss.shotoku.cache.ChangeType;
-import org.jboss.shotoku.exceptions.ResourceDoesNotExist;
-
-import javax.portlet.*;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.util.Map;
-
-/**
- * A portlet super-class that reads content from a svn repository and displays
- * it.
- *
- * @author adamw
- */
-public abstract class ContentPortlet extends JBossPortlet {
- private static String CACHE_KEY_BASE = "contentPortlet/";
-
- protected String title;
-
- protected String id;
-
- protected ContentManager cm;
-
- // TODO
- private synchronized ContentManager getCm() {
- if (cm == null) {
- cm = ForgeHelper.getContentManager(getContentManagerSuffix());
- }
-
- return cm;
- }
-
- /**
- * Gets the suffix to use in the content reader.
- *
- * @return Suffix for use in the content reader.
- */
- protected String getContentManagerSuffix() {
- return "";
- }
-
- /**
- * @param title
- * Display title of the portlet.
- * @param id
- * SVN directory of this portlet.
- */
- public ContentPortlet(String title, String id) {
- this.title = title;
- this.id = id;
- }
-
- public void init() {
-
- }
-
- /**
- * Override this method if you need to set any attributes in the request.
- *
- * @param rReq
- * Request to prepare
- */
- public void prepareRequest(JBossRenderRequest rReq) {
-
- }
-
- /**
- * Gets an array of files basing on which content is generated.
- *
- * @return An array of watched files.
- */
- abstract protected String[] getWatchedFiles(JBossRenderRequest rReq);
-
- /**
- * Generate the page content basing on the svn repository. Should be called
- * only from doView().
- *
- * @param portalName
- * Name of the portal in which the portlet is shown.
- * @return An object representing the page's content.
- * @throws IOException
- */
- abstract protected Object generateContent(JBossRenderRequest rReq,
- String portalName) throws IOException;
-
- /**
- * Displays the portlet's content on its output.
- *
- * @param ws
- * Current portlet's window state.
- * @param content
- * Content to display.
- * @throws IOException
- */
- abstract protected void displayContent(JBossRenderRequest rReq,
- JBossRenderResponse rRes, WindowState ws, Object content)
- throws PortletException, IOException;
-
- /**
- * Generates a unique cache key for the given render request and portal
- * name.
- *
- * @param portalName
- * Name of the portal in which the portlet is shown.
- * @return A unique cache key.
- */
- abstract protected String getCacheKey(JBossRenderRequest rReq,
- String portalName);
-
- /**
- * In str, replaces each occurence of pattern with replace.
- */
- private String replace(String str, String pattern, String replace) {
- int s = 0;
- int e;
- StringBuffer result = new StringBuffer();
-
- while ((e = str.indexOf(pattern, s)) >= 0) {
- result.append(str.substring(s, e));
- result.append(replace);
- s = e + pattern.length();
- }
- result.append(str.substring(s));
- return result.toString();
- }
-
- /**
- * In the given content, replaces a property with the given name (typically
- * ${name}) with the provided value.
- */
- public String replaceProperty(String content, String name, String value) {
- return replace(content, name, value);
- }
-
- /**
- * Replaces the ${server.address} property to the actuall address of the
- * host.
- */
- public String replaceServerAddressProperty(JBossRenderRequest rReq,
- String content) {
- return replaceProperty(content, "${server.address}", rReq
- .getServerName()
- + ":" + rReq.getServerPort());
- }
-
- /**
- * Reads a file from the repository. Should be called only from
- * generateContent().
- *
- * @param filename
- * Name of the file to read.
- * @return Content of the demanded file.
- * @throws IOException
- * @throws ResourceDoesNotExist
- */
- public String readFile(String filename) throws IOException, ResourceDoesNotExist {
- return getCm().getNode(filename).getContent();
- }
-
- /**
- * Writes the given object's string representation to the portlet's output.
- *
- * @param rRes
- * @param content
- * Content to display.
- * @throws IOException
- */
- public void writeString(JBossRenderResponse rRes, Object content)
- throws IOException {
- rRes.setContentType("text/html");
- Writer writer = rRes.getWriter();
- writer.write(content.toString());
- }
-
- /**
- * Includes the given jsp in the portlet's output (content type must be
- * already set!).
- *
- * @param rReq
- * @param rRes
- * @param fileName
- * Name of the jsp do display.
- * @throws IOException
- * @throws PortletException
- */
- public void writeJsp(JBossRenderRequest rReq, JBossRenderResponse rRes,
- String fileName) throws PortletException, IOException {
- PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(
- fileName);
- rd.include(rReq, rRes);
- }
-
- /**
- * Displays an error on the portlet's output.
- *
- * @param rRes
- * @param message
- * Error message to display.
- * @throws IOException
- */
- protected void showError(JBossRenderResponse rRes, String message)
- throws IOException {
- rRes.setContentType("text/html");
- Writer writer = rRes.getWriter();
- writer.write(message);
- }
-
- public static class ContentPortletWatcherKey extends Pair<String, String> {
- private ContentPortlet portlet;
- private JBossRenderRequest rReq;
-
- public ContentPortletWatcherKey(String obj1, String obj2,
- ContentPortlet portlet,
- JBossRenderRequest rReq) {
- super(obj1, obj2);
- this.portlet = portlet;
- this.rReq = rReq;
- }
-
- public ContentPortlet getPortlet() {
- return portlet;
- }
-
- public JBossRenderRequest getRReq() {
- return rReq;
- }
- }
-
- public static class ContentPortletWatcher
- extends ShotokuResourceWatcher<ContentPortletWatcherKey, Object> {
- boolean resWatched;
-
- private Object getContent(ContentPortletWatcherKey key) {
- String[] watched = key.getPortlet().getWatchedFiles(key.getRReq());
-
- if ((watched == null) || (watched.length == 0)) {
- resWatched = false;
- } else {
- resetWatchedPaths(key);
- for (String aWatched : watched) {
- addWatchedPath(key, aWatched);
- }
- }
-
- try {
- return key.getPortlet().generateContent(key.getRReq(),
- key.getFirst());
- } catch (Exception e) {
- return null;
- }
- }
-
- protected void update(ContentPortletWatcherKey key, Object currentObject,
- Map<String, ChangeType> changes) {
- if (resWatched) {
- put(key, getContent(key));
- }
- }
-
- public Object init(ContentPortletWatcherKey key) {
- return getContent(key);
- }
- }
-
- @CacheItem
- private ContentPortletWatcher cpw;
-
- protected void doView(final JBossRenderRequest rReq,
- JBossRenderResponse rRes) throws PortletException, IOException,
- UnavailableException {
- final String portalName = ForgeHelper.getPortalName(rReq);
-
- /* Key under which we store this portlet's data. */
- String cacheKey = CACHE_KEY_BASE + id + portalName
- + getCacheKey(rReq, portalName);
- /* Content to display in the portlet. */
- Object content;
-
- /* If the window state is minimzed, we don't print anything. */
- WindowState ws = rReq.getWindowState();
- if ((!javax.portlet.WindowState.NORMAL.equals(ws))
- && (!javax.portlet.WindowState.MAXIMIZED.equals(ws)))
- return;
-
- content = cpw.get(new ContentPortletWatcherKey(portalName, cacheKey,
- this, rReq));
-
- prepareRequest(rReq);
- displayContent(rReq, rRes, ws, content);
- }
-
- public void render(JBossRenderRequest rReq, JBossRenderResponse rRes)
- throws PortletException, IOException {
- rRes.setTitle(title);
- doDispatch(rReq, rRes);
- }
-}
\ No newline at end of file
Deleted: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/AbstractDescriptor.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/AbstractDescriptor.java 2007-03-08 15:14:35 UTC (rev 10074)
+++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/AbstractDescriptor.java 2007-03-08 15:45:59 UTC (rev 10075)
@@ -1,46 +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;
-
-/**
- * A base class for XML descriptors.
- *
- * @author adamw
- */
-public abstract class AbstractDescriptor {
- /**
- * @deprecated
- */
- protected String unmarshallHtml(Node root, DomToXmlTransformer xht) {
- return XmlTools.unmarshallHtml(root, xht);
- }
-
- /**
- * @deprecated
- */
- protected String unmarshallText(Node textNode) {
- return XmlTools.unmarshallText(textNode);
- }
-}
Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterDescriptor.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterDescriptor.java 2007-03-08 15:14:35 UTC (rev 10074)
+++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterDescriptor.java 2007-03-08 15:45:59 UTC (rev 10075)
@@ -44,7 +44,7 @@
* @author Ryszard Kozmik
*/
-public class DownloadCounterDescriptor extends AbstractDescriptor {
+public class DownloadCounterDescriptor {
/**
* This variable contains all links, which need to be tracked, collected from xml descriptor.
Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDescriptor.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDescriptor.java 2007-03-08 15:14:35 UTC (rev 10074)
+++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDescriptor.java 2007-03-08 15:45:59 UTC (rev 10075)
@@ -55,7 +55,7 @@
* @author Ryszard Kozmik
*/
-public class DownloadCountersDescriptor extends AbstractDescriptor {
+public class DownloadCountersDescriptor {
/**
* Name of tag in counters.xml containing counter value.
Deleted: 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-08 15:14:35 UTC (rev 10074)
+++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/ProjectDescriptor.java 2007-03-08 15:45:59 UTC (rev 10075)
@@ -1,312 +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.IOException;
-import java.util.Set;
-
-import org.apache.xerces.parsers.DOMParser;
-import org.jboss.forge.common.projects.XmlInputFactory.XmlNotFoundException;
-import org.jboss.forge.common.projects.elements.BindingsHandlerIterSingleKey;
-import org.jboss.forge.common.projects.elements.ExtendedPropertiesMap;
-import org.jboss.forge.common.projects.elements.OutsidePropertiesMap;
-import org.jboss.forge.common.projects.elements.PropertiesHandlerDefault;
-import org.jboss.forge.common.projects.elements.ElementDescriptor;
-import org.jboss.forge.common.projects.elements.PropertiesHandler;
-import org.jboss.forge.common.projects.elements.PropertiesHandlerStack;
-import org.jboss.forge.common.projects.elements.PropertiesMap;
-import org.jboss.forge.common.projects.permissions.PermissionsChecker;
-import org.jboss.logging.Logger;
-import org.jboss.portal.core.servlet.jsp.taglib.context.DelegateContext;
-import org.jboss.shotoku.ContentManager;
-import org.jboss.shotoku.aop.Inject;
-import org.jboss.shotoku.tools.Tools;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.xml.sax.SAXException;
-
-/**
- * Contains information about one project.
- *
- * @author adamw
- */
-public class ProjectDescriptor extends AbstractDescriptor {
-
- private static final Logger log = Logger.getLogger(ProjectDescriptor.class);
-
- private String portalName;
-
- private ElementDescriptor thisProject;
-
- @Inject
- private ContentManager cm;
-
- /**
- * Reads information about a project from an xml file.
- *
- * @param isf
- * A factory of xml files.
- * @param xht
- * A XML -> HTML transformer.
- * @param opm
- * An outside properties map, to be used while parsing the
- * project.
- * @param portalName
- * Name of the portal to which this project belongs to.
- * @param adminProperties
- * Properties that are set by the administrator, to be included
- * while filling the context.
- * @throws SAXException
- * @throws IOException
- * @throws XmlNotFoundException
- */
- public ProjectDescriptor(String projectId, XmlInputFactory isf,
- DomToXmlTransformer xht, OutsidePropertiesMap opm,
- String portalName, PropertiesMap adminProperties)
- throws SAXException, IOException,
- XmlNotFoundException {
- this.portalName = portalName;
-
- // Parsing the XML.
- DOMParser parser = new DOMParser();
- parser.parse(isf.getInputSource(projectId+"/" +
- ProjectsHelper.PROJECT_DESC));
- Document doc = parser.getDocument();
-
- Element node = doc.getDocumentElement();
-
- // Creating an element which will hold all project information.
- thisProject = new ElementDescriptor(node, xht,
- getProjectPropertiesHandler(),
- getProjectExtendedPropertiesMap(), opm);
-
- // Checking if the ids match.
- if (!projectId.equals(thisProject.getId()))
- throw new IOException("Ids do not match");
-
- // Adding properties set by the administrator.
- if (adminProperties != null) {
- thisProject.addProperties(adminProperties, true);
- }
-
- /*if (projectId.compareTo("jbosswiki")==0) {
- System.out.println("TWORZ?? PROJEKT");
- try {
- //JAXBContext jc = JAXBContext.newInstance("org.jboss.forge.common.projects.test");
- JAXBContext jc = JAXBContext.newInstance("org.jboss.forge.common.projects.test");
- System.out.println("NODE: "+cm.getNode("default/members/jbosswiki/project.xml").getContent());
- Unmarshaller un = jc.createUnmarshaller();
- Project project = (Project)un.unmarshal(cm.getNode("default/members/jbosswiki/project.xml").getContentInputStream());
- System.out.println("Project: "+project);
- System.out.println("Project.id: "+project.getId());
- System.out.println("Project.name: "+project.getName());
- System.out.println("Project.companyName: "+project.getCompanyName());
- System.out.println("Project.logo: "+project.getLogo());
- System.out.println("Project.description: "+project.getDescription());
- System.out.println("Project.developers: "+project.getDevelopers());
- System.out.println("Project.jems: "+project.getJems());
- System.out.println("Project.repository: "+project.getRepository());
- System.out.println("Project.repomonitor: "+project.getRepoMonitor());
- System.out.println("Project.issueTracker: "+project.getIssueTracker());
- System.out.println("Project.buildResults: "+project.getBuildResults());
- System.out.println("Project.supportServices: "+project.getSupportServices());
- System.out.println("Project.forums: "+project.getForums());
- System.out.println("Project.documentation: "+project.getDocumentation());
- System.out.println("Project.polls: "+project.getPolls());
- System.out.println("Project.downloads: "+project.getDownloads());
- System.out.println("Project.menu: "+project.getMenu());
- } catch (Exception e) {
- e.printStackTrace();
- }
- //new ObjectFactory().createProject();
- }*/
- }
-
- /**
- * EXTENDED_PROPERTIES - an array holding information about extended
- * properties that a project can have. Each element is:
- * - a name of the property in the XML file
- * - a name under which information about the property should be stored in
- * a context
- * - a handler for these properties
- * elements.
- */
- private final Object[][] EXTENDED_PROPERTIES = {
- /*{ "outside-link", "outsidelinks", new PropertiesHandlerDefault() },
- { "freezone-link", "freezonelinks", getFreezonePropertiesHandler() },*/
- { "ad", "ads", getAdsPropertiesHandler() }
- };
-
- private ExtendedPropertiesMap getProjectExtendedPropertiesMap() {
- ExtendedPropertiesMap epm = new ExtendedPropertiesMap();
- for (Object[] aEXTENDED_PROPERTIES : EXTENDED_PROPERTIES) {
- epm.addPropertySupport((String) aEXTENDED_PROPERTIES[0],
- (PropertiesHandler) aEXTENDED_PROPERTIES[2],
- new BindingsHandlerIterSingleKey(
- (String) aEXTENDED_PROPERTIES[0],
- (String) aEXTENDED_PROPERTIES[1],
- false));
- }
-
- return epm;
- }
-
- private PropertiesHandler getProjectPropertiesHandler() {
- PropertiesHandlerStack stack = new PropertiesHandlerStack();
- // Adding a default properties handler.
- stack.addHandler(new PropertiesHandlerDefault());
-
- // And a custom one, which holds more information.
- stack.addHandler(new PropertiesHandler() {
- public void fillContext(PropertiesMap properties,
- DelegateContext context, PermissionsChecker pc) {
- context.put("companyname", properties.get("company-name")
- .getFirstValue());
- context.put("info", properties.get("info").getFirstValue());
- if (properties.hasValues("logo")) {
- context.next("logopresent");
- context.put("logo", properties.get("logo").getFirstValue());
- } else {
- context.next("logonotpresent");
- }
-
- if (properties.hasValues("company-logo")) {
- context.next("companylogopresent");
- context.put("companylogo", properties.get("company-logo")
- .getFirstValue());
- } else {
- context.next("companylogonotpresent");
- }
- }
-
- public void processNode(ElementDescriptor thisElement, Node node) {
- }
-
- public void collect(PropertiesMap properties, Object data,
- PermissionsChecker pc) {
-
- }
- });
-
- return stack;
- }
-
- private PropertiesHandler getAdsPropertiesHandler() {
- PropertiesHandlerStack ph = new PropertiesHandlerStack();
- ph.addHandler(new PropertiesHandlerDefault());
- ph.addHandler(new PropertiesHandler() {
- public void fillContext(PropertiesMap properties,
- DelegateContext context, PermissionsChecker pc) {
- context.put("link", properties.get("link").getFirstValue());
- context.put("image", properties.get("image").getFirstValue());
- }
-
- public void processNode(ElementDescriptor thisElement, Node node) {
-
- }
-
- public void collect(PropertiesMap properties, Object data,
- PermissionsChecker pc) {
-
- }
- });
-
- return ph;
- }
-
- /**
- * Fills the given context with basic project information - name,
- * description, info.
- *
- * @param context
- * Context to fill.
- * @param pc
- * Permissions checker to use.
- */
- public void fillContextShallow(DelegateContext context, PermissionsChecker pc) {
- thisProject.fillContextShallow(context, pc);
- }
-
- /**
- * Fills the given context with full project information.
- *
- * @param context
- * Context to fill.
- * @param pc
- * Permissions checker to use.
- */
- public void fillContext(DelegateContext context, PermissionsChecker pc) {
- thisProject.fillContext(context, pc);
- }
-
- /**
- * Gets the id of this project.
- *
- * @return Id of this project.
- */
- public String getId() {
- return thisProject.getId();
- }
-
- /**
- * Fills the given set with names of resources from which this project
- * descriptor was generated.
- * @param toFill Set to fill.
- */
- public void getAllDescriptorsNames(Set<String> toFill) {
- toFill.add(getId() + "/" + ProjectsHelper.PROJECT_DESC);
- }
-
- /**
- * Gets the value of a given project property.
- *
- * @param propertyName
- * Name of the property.
- * @return Value of the property with the given name.
- */
- public String getProperty(String propertyName) {
- return thisProject.getProperty(propertyName);
- }
-
- /**
- * Checks if permission to read this project is allowed with permissions
- * set represented by the given permissions checker.
- *
- * @param pc Permissions checker to use.
- * @return True iff permission is allowed.
- */
- public boolean permissionAllowed(PermissionsChecker pc) {
- return thisProject.permissionAllowed(pc);
- }
-
- /**
- * Checks if permission to edit this project is allowed with permissions
- * set represented by the given permissions checker.
- *
- * @param pc Permissions checker to use.
- * @return True iff edit permission is allowed.
- */
- public boolean editPermissionAllowed(PermissionsChecker pc) {
- return thisProject.editPermissionAllowed(pc);
- }
-}
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-08 15:14:35 UTC (rev 10074)
+++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Projects.java 2007-03-08 15:45:59 UTC (rev 10075)
@@ -26,7 +26,7 @@
import java.util.Set;
import org.jboss.forge.common.projects.permissions.PermissionsChecker;
-import org.jboss.portal.core.servlet.jsp.taglib.context.DelegateContext;
+import org.jboss.forge.common.projects.permissions.TotalPermissionsChecker;
/**
* A class which manages creating project and projects descriptors for a given
@@ -43,9 +43,6 @@
// @CacheItem
private ProjectsConfigurationWatcher pcw;
- /**
- * @param portalName
- */
public Projects(String portalName) {
pcw = new ProjectsConfigurationWatcher();
this.portalName = portalName;
@@ -59,15 +56,6 @@
}
/**
- * Gets context of the given project.
- * @param pc Permissions checker to use.
- * @param id Id of the project to get.
- */
- public DelegateContext getProjectContext(PermissionsChecker pc, String id) {
- return getProjectsDescriptor().getProjectContext(pc, id);
- }
-
- /**
* Gets the name of the project with the given id.
*/
public String getProjectName(String projectId) {
@@ -87,7 +75,8 @@
* @return True iff a project with the given id exists.
*/
public boolean projectExists(String projectId) {
- return getProjectsDescriptor().getProjectDescriptor(projectId) != null;
+ return getProjectsDescriptor().permissionAllowed(new TotalPermissionsChecker(),
+ projectId);
}
/**
@@ -98,23 +87,10 @@
* @return True iff a project with the given id exists.
*/
public boolean projectExists(PermissionsChecker pc, String projectId) {
- return getProjectsDescriptor().getProjectContext(pc, projectId) != null;
+ return getProjectsDescriptor().permissionAllowed(pc, projectId);
}
/**
- * Gets ids of all projects on the given level, accessible with the given
- * permissions checker.
- * @param pc Permissions checker to use.
- * @param projectLevel Level of the projects to return. Null, if all
- * projects are to be returned.
- * @return A set of project ids on the given level accessible with the
- * given permissions checker.
- */
- public Set<String> getProjectIds(PermissionsChecker pc, String projectLevel) {
- return getProjectsDescriptor().getProjectIds(pc, projectLevel);
- }
-
- /**
* Checks if the given project can be edited.
*/
public boolean editPermissionAllowed(PermissionsChecker pc, String projectId) {
@@ -124,8 +100,12 @@
public Map<String, String> getProjectsNameId() {
return getProjectsDescriptor().getProjectsNameId();
}
-
- public Set<String> getProjectIds() {
+
+ public Set<String> getProjectIds(PermissionsChecker pc) {
+ return getProjectsDescriptor().getProjectIds(pc);
+ }
+
+ public Set<String> getProjectIds() {
return getProjectsDescriptor().getProjectIds();
}
}
Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/ProjectsConfigurationWatcher.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/ProjectsConfigurationWatcher.java 2007-03-08 15:14:35 UTC (rev 10074)
+++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/ProjectsConfigurationWatcher.java 2007-03-08 15:45:59 UTC (rev 10075)
@@ -37,7 +37,7 @@
public ProjectsDescriptor getProjectsDescriptor(String key) {
ProjectsDescriptor pd = new ProjectsDescriptor(
XmlInputFactory.getContentReadingInstance(
- getContentManager(key)), key);
+ getContentManager(key)));
resetWatchedPaths(key);
for (String descriptor : pd.getAllDescriptorsNames()) {
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-08 15:14:35 UTC (rev 10074)
+++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/ProjectsDescriptor.java 2007-03-08 15:45:59 UTC (rev 10075)
@@ -21,41 +21,22 @@
*/
package org.jboss.forge.common.projects;
-import java.io.IOException;
import java.util.*;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
-import org.apache.xerces.parsers.DOMParser;
-import org.jboss.forge.common.ForgeHelper;
-import org.jboss.forge.common.SearchTools;
-import org.jboss.forge.common.XmlTools;
import org.jboss.forge.common.exceptions.ServiceRetrievalException;
import org.jboss.forge.common.ejb3.LabsServices;
-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.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.forge.common.projects.project.Project;
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;
import org.jboss.forge.common.projects.configuration.Configuration;
+import org.jboss.forge.common.projects.configuration.ProjectConfiguration;
import org.jboss.logging.Logger;
-import org.jboss.portal.core.servlet.jsp.taglib.context.DelegateContext;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
/**
* Holds information about all projects.
@@ -64,7 +45,7 @@
* @author <a href="ryszard.kozmik at jboss.com">Ryszard Kozmik</a>
* @author Pawel Wrzeszcz (pawel . wrzeszcz [at] jboss . com)
*/
-public class ProjectsDescriptor extends AbstractDescriptor {
+public class ProjectsDescriptor {
/**
* <code>INFO_PAGE_ATTRIBUTE</code> - name of an xml attribute in which
* information on whether a freezone info page should be displayed instead
@@ -78,56 +59,27 @@
static final String LEVEL_ATTRIBUTE = "level";
- private final static String BASIC_PRJ_ADMIN_PERM = "project-manager";
-
private static final Logger log = Logger
.getLogger(ProjectsDescriptor.class);
/**
- * Project id --> Corresponding project descriptor object
- */
- private Map<String, ProjectDescriptor> projects;
-
- /**
* Project id --> Corresponding NEW project descriptor object
*/
private Map<String, Project> newProjects;
-
/**
* Configuration from projects.xml descriptor.
*/
private Configuration configuration;
- /**
- * Permissions descriptor --> Corresponding global context
- */
- private Map<String, DelegateContext> contexts;
+ private Map<String, ProjectConfiguration> projectsConfiguration;
/**
- * Project id + permissions descriptor --> Corresponding project context
- */
- private Map<String, DelegateContext> projectsContexts;
-
- private OutsidePropertiesMap opm;
-
- /**
* <code>projectWithErrorsDescriptors</code> - A set of paths to project
* descriptors that couldn't be added becouse they contain errors.
*/
private Set<String> projectWithErrorsDescriptors;
- /**
- * A collection of all level ids.
- */
- private Set<String> allLevels;
-
- /**
- * Permissions descriptor --> corresponding levels context
- */
- private Map<String, DelegateContext> levelsContexts;
-
- private String portalName;
private XmlInputFactory isf;
private JAXBContext projectRWJC = null;
@@ -136,23 +88,14 @@
*
* @param isf
* A factory of xml files.
- * @param portalName
- * Name of the portal to which projects belongs to.
*/
- public ProjectsDescriptor(XmlInputFactory isf, String portalName) {
-
- this.portalName = portalName;
+ public ProjectsDescriptor(XmlInputFactory isf) {
+
this.isf = isf;
-
- projects = new LinkedHashMap<String, ProjectDescriptor>();
+
newProjects = new LinkedHashMap<String,Project>();
projectWithErrorsDescriptors = new HashSet<String>();
- projectsContexts = Collections
- .synchronizedMap(new LinkedHashMap<String, DelegateContext>());
- contexts = Collections
- .synchronizedMap(new HashMap<String, DelegateContext>());
-
try {
projectRWJC = JAXBContext.newInstance("org.jboss.forge.common.projects.project.rw");
} catch (JAXBException e) {
@@ -160,20 +103,8 @@
}
try {
- DomToXmlTransformer xht = new DomToXmlTransformer();
- opm = getProjectOutsidePropertiesMap(isf, xht, portalName);
-
- DOMParser parser = new DOMParser();
- parser.parse(isf.getInputSource(ProjectsHelper.PROJECTS_DESC));
- Document doc = parser.getDocument();
-
- Node node = doc.getDocumentElement();
-
- unmarshallProjects(node, isf, xht, portalName);
-
- fillContext(new NullPermissionsChecker());
- fillLevels();
+ unmarshallProjects(isf);
} catch (Exception e) {
log.error("Projects descriptor constructor.", e);
}
@@ -185,178 +116,45 @@
}
}
- private final static String PROJECT_EL = "project";
-
- private final static String PROJECTS_PROP_KEY = "projects";
-
- private final static String PROJECTS_CTX_KEY = PROJECTS_PROP_KEY;
-
/**
- * Array of properties of outside properties: each element consists of a
- * XML file name, element name in XML files, context name, properties
- * handler.
- */
- private final static Object[][] OUTSIDE_PROPERTIES = {
- { ProjectsHelper.CATEGORIES_DESC, "category", "categories",
- getOPDefaultPropertiesHandler() },
- { ProjectsHelper.JEMS_DESC, "jems", "jems",
- getOPDefaultPropertiesHandler() }};
-
- private static PropertiesHandler getOPDefaultPropertiesHandler() {
- PropertiesHandlerStack phs = new PropertiesHandlerStack();
- phs.addHandler(new PropertiesHandlerDefault());
-
- return phs;
- }
-
- private static PropertiesHandler getLevelsPropertiesHandler(
- final String portalName) {
- PropertiesHandlerStack phs = new PropertiesHandlerStack();
- phs.addHandler(new PropertiesHandlerDefault());
- phs.addHandler(new PropertiesHandler() {
- public void fillContext(PropertiesMap properties,
- DelegateContext context, PermissionsChecker pc) {
- context.put("link", ForgeHelper.createLink(portalName,
- properties.get(TYPE_ATTRIBUTE).getFirstValue(),
- properties.get(LINK_ELEMENT).getFirstValue()));
- }
-
- public void processNode(ElementDescriptor thisElement, Node node) {
- if (LINK_ELEMENT.equals(node.getNodeName())) {
- // Adding the type attribute to the properties.
- PropertiesMap pm = new PropertiesMap();
-
- String type = XmlTools.getAttributeValue(node,
- TYPE_ATTRIBUTE);
-
- pm.add(TYPE_ATTRIBUTE, type == null ? "" : type);
- thisElement.addProperties(pm, false);
- }
- }
-
- public void collect(PropertiesMap properties, Object data,
- PermissionsChecker pc) {
-
- }
- });
-
- return phs;
- }
-
- private void addOutsideProperty(XmlInputFactory isf,
- DomToXmlTransformer xht, OutsidePropertiesMap opm, Object[] data)
- throws SAXException, IOException, XmlNotFoundException {
- opm
- .addPropertySupport((String) data[1], new ElementsDescriptor(
- isf.getInputSource((String) data[0]), isf, xht,
- (String) data[1], (PropertiesHandler) data[3]),
- new BindingsHandlerIterSingleKey((String) data[1],
- (String) data[2], false),
- PROJECTS_PROP_KEY, new BindingsHandlerIterSingleKey(
- PROJECTS_PROP_KEY, PROJECTS_CTX_KEY, true));
- }
-
- private OutsidePropertiesMap getProjectOutsidePropertiesMap(
- XmlInputFactory isf, DomToXmlTransformer xht, String portalName)
- throws SAXException, IOException, XmlNotFoundException {
- OutsidePropertiesMap opm = new OutsidePropertiesMap();
-
- for (int i = 0; i < OUTSIDE_PROPERTIES.length; i++) {
- addOutsideProperty(isf, xht, opm, OUTSIDE_PROPERTIES[i]);
- }
-
- addOutsideProperty(isf, xht, opm, new Object[] {
- ProjectsHelper.LEVELS_DESC, "level", "levels",
- getLevelsPropertiesHandler(portalName) });
-
- return opm;
- }
-
- private DelegateContext fillContext(PermissionsChecker pc) {
- String permDesc = pc.getPermissionsDescriptor();
-
- DelegateContext context = new DelegateContext();
-
- for (Iterator iter = projects.keySet().iterator(); iter.hasNext();) {
- String projectId = (String) iter.next();
-
- ProjectDescriptor pd = projects.get(projectId);
-
- // / Checking if we can read data from this project.
- if (!pd.permissionAllowed(pc))
- continue;
-
- DelegateContext projectContext = context.next(PROJECTS_CTX_KEY);
-
- pd.fillContext(projectContext, pc);
- projectsContexts.put(ElementsDescriptor.getContextMapKey(projectId,
- permDesc), projectContext);
- }
-
- for (int i = 0; i < OUTSIDE_PROPERTIES.length; i++) {
- opm
- .getElementsDescriptor((String) OUTSIDE_PROPERTIES[i][1])
- .fillContext(context, (String) OUTSIDE_PROPERTIES[i][2], pc);
- }
-
- contexts.put(permDesc, context);
-
- return context;
- }
-
- /**
* Reads information about all projects contained in the given document
* root, and fills the projects list with that information.
+ * @param isf
*/
- private void unmarshallProjects(Node root, XmlInputFactory isf,
- DomToXmlTransformer xht, String portalName) {
- Node n;
- NodeList nodes = root.getChildNodes();
-
+ private void unmarshallProjects(XmlInputFactory isf) {
JAXBContext projectsJC=null;
try {
projectsJC = JAXBContext.newInstance("org.jboss.forge.common.projects.configuration");
} catch (JAXBException e) {
log.warn("I could not create JAXBContext."+e.getCause());
- }
+ }
-
if (projectsJC!=null) {
try {
Unmarshaller un = projectsJC.createUnmarshaller();
this.configuration = (Configuration)un.unmarshal(
isf.getInputSource(ProjectsHelper.PROJECTS_DESC));
+
+ projectsConfiguration = new HashMap<String, ProjectConfiguration>();
+ for (ProjectConfiguration prjConf : configuration.getProjects()) {
+ projectsConfiguration.put(prjConf.getContent(), prjConf);
+ }
+
log.info("Projects.xml configuration created.");
} catch (Exception e) {
log.warn("I could not create projects.xml configuration.",e);
}
}
- for (int i = 0; i < nodes.getLength(); i++) {
- n = nodes.item(i);
-
- if ((n.getNodeType() == Node.ELEMENT_NODE)
- && (n.getNodeName().equals(PROJECT_EL))) {
- PropertiesMap adminProperties
- = XmlTools.getPropertiesFromNodeAttributes(n);
-
- String projectId = XmlTools.unmarshallText(n);
-
- unmarshallProjectRW(projectId, isf, xht, portalName, adminProperties, projectRWJC);
- }
+ for (String projectId : projectsConfiguration.keySet()) {
+ unmarshallProjectRW(projectId, isf, projectRWJC);
}
}
- private void unmarshallProjectRW(String projectId, XmlInputFactory isf, DomToXmlTransformer xht, String portalName2, PropertiesMap adminProperties, JAXBContext projectRWJC) {
-
- ProjectDescriptor pd;
-
+ private void unmarshallProjectRW(String projectId, XmlInputFactory isf,
+ JAXBContext projectRWJC) {
try {
- pd = new ProjectDescriptor(projectId, isf, xht, opm,
- portalName, adminProperties);
- projects.put(projectId, pd);
-
if (projectRWJC!=null) {
try {
Unmarshaller un = projectRWJC.createUnmarshaller();
@@ -387,159 +185,7 @@
}
}
-
- private boolean projectAdmissable(String projectId) {
- return !"default".equals(projectId);
- }
-
/**
- * Fills the <code>allLevels</code> set with ids of all levels.
- */
- private void fillLevels() {
- allLevels = new LinkedHashSet<String>();
-
- for (String projectId : projects.keySet()) {
- if (projectAdmissable(projectId)) {
- allLevels.add(projects.get(projectId).getProperty(LEVEL_ATTRIBUTE));
- }
- }
-
- levelsContexts = new HashMap<String, DelegateContext>();
- }
-
- /**
- * Gets a descriptor of a specified project.
- *
- * @param projectId
- * Id of the project for which to get the descriptor.
- * @return A descriptor of the given project.
- */
- public ProjectDescriptor getProjectDescriptor(String projectId) {
- if (!projectAdmissable(projectId)) {
- return null;
- }
-
- return projects.get(projectId);
- }
-
- /**
- * Transforms the given permissions checker for internal use. If a user,
- * who's permissions are represented by <code>pc</code>, isn't a project
- * manager, then he won't be able to get customized contexts, and a
- * <code>NullPermissionsChecker</code> is returned. Otherwise,
- * <code>pc</code> is returned.
- *
- * @param pc
- * Permissions checker to transform.
- * @return A new null permissions checker or the given permissions checker.
- */
- private PermissionsChecker transformPermissionsChecker(PermissionsChecker pc) {
- if (!pc.hasPermission(BASIC_PRJ_ADMIN_PERM))
- return new NullPermissionsChecker();
-
- return pc;
- }
-
- /**
- * Gets a context holding information about all projects.
- *
- * @param pc
- * Permissions checker to use.
- * @return A context holding information about all projects.
- */
- public DelegateContext getContext(PermissionsChecker pc) {
- PermissionsChecker pcToUse = transformPermissionsChecker(pc);
- DelegateContext context = contexts.get(pcToUse
- .getPermissionsDescriptor());
-
- // If no context for the given permissions set is yet defined, we create
- // a new one
- // and return it.
- if (context == null) {
- return fillContext(pcToUse);
- }
-
- return context;
- }
-
- /**
- * Gets a context holding information about all levels (and projects).
- *
- * @param pc
- * Permissions checker to use.
- * @return A context holding information about all projects.
- */
- public DelegateContext getLevelsContext(PermissionsChecker pc) {
- PermissionsChecker pcToUse = transformPermissionsChecker(pc);
- DelegateContext context = levelsContexts.get(pcToUse.getPermissionsDescriptor());
-
- // If no context for the given permissions set is yet defined, we create
- // a new one and return it.
- if (context == null) {
- return fillLevelsContext(pcToUse);
- }
-
- return context;
- }
-
- /**
- * Creates a context holding information about all levels, fills it
- * with appropriate data and returns them.
- */
- private DelegateContext fillLevelsContext(PermissionsChecker pc) {
- DelegateContext ret = new DelegateContext();
-
- for (String levelId : allLevels) {
- ret.next("levels").append("level", getOutsidePropertyContext(pc,
- LEVEL_ATTRIBUTE, levelId));
- }
-
- levelsContexts.put(pc.getPermissionsDescriptor(), ret);
-
- return ret;
- }
-
- /**
- * Gets a context for a project with the given id.
- *
- * @param pc
- * Permissions checker to use.
- * @param id
- * Id of the project for which to get the context.
- * @return A context holding information about a specified project.
- */
- public DelegateContext getProjectContext(PermissionsChecker pc, String id) {
- if (!projectAdmissable(id)) {
- return null;
- }
-
- PermissionsChecker pcToUse = transformPermissionsChecker(pc);
- String permDesc = pcToUse.getPermissionsDescriptor();
-
- if (contexts.get(permDesc) == null)
- fillContext(pcToUse);
-
- return projectsContexts.get(ElementsDescriptor
- .getContextMapKey(id, permDesc));
- }
-
- /**
- * Gets a context of an outside property of projects.
- *
- * @param pc
- * Permissions checker to use.
- * @param propertyName
- * Name of the outside property
- * @param id
- * Id of the element for which to get the context.
- * @return A context desciribing an outside property with the given id.
- */
- public DelegateContext getOutsidePropertyContext(PermissionsChecker pc,
- String propertyName, String id) {
- return opm.getContextForElement(propertyName, id, pc);
- }
-
- /**
* Gets the name of the project with the given id.
*
* @param projectId
@@ -548,19 +194,16 @@
* exists.
*/
public String getProjectName(String projectId) {
- if (!projectAdmissable(projectId)) {
+ Project prj = newProjects.get(projectId);
+ if (prj == null) {
return "";
}
- ProjectDescriptor pd = projects.get(projectId);
- if (pd == null)
- return "";
-
- return pd.getProperty("name");
+ return prj.getName();
}
/**
- * Gets a set of names of resources which are descriptors of projects
+ * @return A set of names of resources which are descriptors of projects
* represented by this ProjectsDescriptor instance.
*/
public Set<String> getAllDescriptorsNames() {
@@ -568,15 +211,10 @@
toFill.add(ProjectsHelper.PROJECTS_DESC);
- for (Object[] aOUTSIDE_PROPERTIES : OUTSIDE_PROPERTIES) {
- toFill.add((String) aOUTSIDE_PROPERTIES[0]);
+ for (Project prj : newProjects.values()) {
+ toFill.add(prj.getId() + "/" + ProjectsHelper.PROJECT_DESC);
}
- toFill.add(ProjectsHelper.LEVELS_DESC);
-
- for (ProjectDescriptor pd : projects.values())
- pd.getAllDescriptorsNames(toFill);
-
toFill.addAll(projectWithErrorsDescriptors);
return toFill;
@@ -586,24 +224,15 @@
* Gets ids of all projects on the given level, accessible with the given
* permissions checker.
* @param pc Permissions checker to use.
- * @param projectLevel Level of the projects to return. Null, if all
- * projects are to be returned.
* @return A set of project ids on the given level accessible with the
* given permissions checker.
*/
- public Set<String> getProjectIds(PermissionsChecker pc, String projectLevel) {
+ public Set<String> getProjectIds(PermissionsChecker pc) {
Set<String> ret = new LinkedHashSet<String>();
- for (String projectId : projects.keySet()) {
- ProjectDescriptor project = projects.get(projectId);
- if ((project.permissionAllowed(pc)) &&
- ((projectLevel == null) ||
- (projectLevel.equals(project.getProperty(
- LEVEL_ATTRIBUTE))))) {
- // Not adding the default project.
- if (projectAdmissable(projectId)) {
- ret.add(projectId);
- }
+ for (String projectId : newProjects.keySet()) {
+ if (permissionAllowed(pc, projectId)) {
+ ret.add(projectId);
}
}
@@ -614,52 +243,42 @@
* Checks if the given project can be accessed.
*/
public boolean permissionAllowed(PermissionsChecker pc, String projectId) {
- ProjectDescriptor pd = projects.get(projectId);
- if (pd == null) {
- // If a project doesn't exist, we can't access it.
+ ProjectConfiguration prjConf = projectsConfiguration.get(projectId);
+
+ if (prjConf == null) {
return false;
}
- return pd.permissionAllowed(transformPermissionsChecker(pc));
+ 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) {
- ProjectDescriptor pd = projects.get(projectId);
- if (pd == null) {
- // If a project doesn't exist, we can't edit it.
+ ProjectConfiguration prjConf = projectsConfiguration.get(projectId);
+
+ if (prjConf == null) {
return false;
}
- return pd.editPermissionAllowed(transformPermissionsChecker(pc));
+ 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()) {
- ProjectDescriptor project = projects.get(projectId);
- // Not adding the default project.
- if (projectAdmissable(projectId)) {
- projectsNameId.put(project.getProperty("name"), projectId);
- }
- }
- return projectsNameId;
+
+ for (String projectId : newProjects.keySet()) {
+ projectsNameId.put(newProjects.get(projectId).getName(), projectId);
+ }
+
+ return projectsNameId;
}
public Set<String> getProjectIds() {
-
- Set<String> ret = new LinkedHashSet<String>();
- for (String projectId : projects.keySet()) {
- ProjectDescriptor project = projects.get(projectId);
- // Not adding the default project.
- if (projectAdmissable(projectId)) {
- ret.add(projectId);
- }
- }
- return ret;
+ return newProjects.keySet();
}
/**
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-08 15:14:35 UTC (rev 10074)
+++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/ProjectsHelper.java 2007-03-08 15:45:59 UTC (rev 10075)
@@ -166,10 +166,10 @@
} else if ((!withDefault) && (DEFAULT_PROJECT.equals(projectId))) {
projectId = null;
} else if ((!DEFAULT_PROJECT.equals(projectId)) &&
- (getProjects(ForgeHelper.getPortalName(request)).getProjectContext(
+ (!getProjects().getProjectsDescriptor().
+ permissionAllowed(
PermissionsCheckerFactory.getPermissionsChecker(request),
- projectId) == null)) {
- // No project context --> project does not exist.
+ projectId))) {
projectId = null;
}
Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/configuration/Configuration.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/configuration/Configuration.java 2007-03-08 15:14:35 UTC (rev 10074)
+++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/configuration/Configuration.java 2007-03-08 15:45:59 UTC (rev 10075)
@@ -1,25 +1,11 @@
-/*
- * 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.
- */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.1.2-b01-fcs
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2007.03.08 at 03:58:06 PM CET
+//
+
package org.jboss.forge.common.projects.configuration;
import java.io.Serializable;
@@ -53,7 +39,7 @@
private final static long serialVersionUID = 1L;
@XmlElement(name = "project")
- protected List<Project> projects;
+ protected List<ProjectConfiguration> projects;
/**
* Gets the value of the projects property.
@@ -73,13 +59,13 @@
*
* <p>
* Objects of the following type(s) are allowed in the list
- * {@link Project }
+ * {@link ProjectConfiguration }
*
*
*/
- public List<Project> getProjects() {
+ public List<ProjectConfiguration> getProjects() {
if (projects == null) {
- projects = new ArrayList<Project>();
+ projects = new ArrayList<ProjectConfiguration>();
}
return this.projects;
}
Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/configuration/ObjectFactory.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/configuration/ObjectFactory.java 2007-03-08 15:14:35 UTC (rev 10074)
+++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/configuration/ObjectFactory.java 2007-03-08 15:45:59 UTC (rev 10075)
@@ -1,25 +1,11 @@
-/*
- * 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.
- */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.1.2-b01-fcs
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2007.03.08 at 03:58:06 PM CET
+//
+
package org.jboss.forge.common.projects.configuration;
import javax.xml.bind.annotation.XmlRegistry;
@@ -59,11 +45,11 @@
}
/**
- * Create an instance of {@link Project }
+ * Create an instance of {@link ProjectConfiguration }
*
*/
- public Project createProject() {
- return new Project();
+ public ProjectConfiguration createProjectConfiguration() {
+ return new ProjectConfiguration();
}
}
Deleted: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/configuration/Project.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/configuration/Project.java 2007-03-08 15:14:35 UTC (rev 10074)
+++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/configuration/Project.java 2007-03-08 15:45:59 UTC (rev 10075)
@@ -1,158 +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.configuration;
-
-import java.io.Serializable;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlType;
-import javax.xml.bind.annotation.XmlValue;
-
-
-/**
- *
- * This class describes main info about project availability,
- * permissions, level in navigation etc.
- * PLEASE, DO NOT MODIFY THIS CLASS UNLESS YOU KNOW JAXB.
- * @author Ryszard Kozmik
- *
- *
- *
- *
- */
- at XmlAccessorType(XmlAccessType.FIELD)
- at XmlType(name = "project", propOrder = {
- "content"
-})
-public class Project
- implements Serializable
-{
-
- private final static long serialVersionUID = 1L;
- @XmlValue
- protected String content;
- @XmlAttribute(required = true)
- protected String level;
- @XmlAttribute(name = "edit-permission")
- protected String editPermission;
- @XmlAttribute
- protected String permission;
-
- /**
- * Gets the value of the content property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getContent() {
- return content;
- }
-
- /**
- * Sets the value of the content property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setContent(String value) {
- this.content = value;
- }
-
- /**
- * Gets the value of the level property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getLevel() {
- return level;
- }
-
- /**
- * Sets the value of the level property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setLevel(String value) {
- this.level = value;
- }
-
- /**
- * Gets the value of the editPermission property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getEditPermission() {
- return editPermission;
- }
-
- /**
- * Sets the value of the editPermission property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setEditPermission(String value) {
- this.editPermission = value;
- }
-
- /**
- * Gets the value of the permission property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getPermission() {
- return permission;
- }
-
- /**
- * Sets the value of the permission property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setPermission(String value) {
- this.permission = value;
- }
-
-}
Added: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/configuration/ProjectConfiguration.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/configuration/ProjectConfiguration.java (rev 0)
+++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/configuration/ProjectConfiguration.java 2007-03-08 15:45:59 UTC (rev 10075)
@@ -0,0 +1,118 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.1.2-b01-fcs
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2007.03.08 at 03:58:06 PM CET
+//
+
+
+package org.jboss.forge.common.projects.configuration;
+
+import java.io.Serializable;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlValue;
+
+
+/**
+ *
+ * This class describes main info about project availability,
+ * permissions, level in navigation etc.
+ * PLEASE, DO NOT MODIFY THIS CLASS UNLESS YOU KNOW JAXB.
+ * @author Ryszard Kozmik
+ *
+ *
+ *
+ *
+ */
+ at XmlAccessorType(XmlAccessType.FIELD)
+ at XmlType(name = "project", propOrder = {
+ "content"
+})
+public class ProjectConfiguration
+ implements Serializable
+{
+
+ private final static long serialVersionUID = 1L;
+ @XmlValue
+ protected String content;
+ @XmlAttribute(name = "edit-permission")
+ protected String editPermission;
+ @XmlAttribute
+ protected String permission;
+
+ /**
+ * Gets the value of the content property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getContent() {
+ return content;
+ }
+
+ /**
+ * Sets the value of the content property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setContent(String value) {
+ this.content = value;
+ }
+
+ /**
+ * Gets the value of the editPermission property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getEditPermission() {
+ return editPermission;
+ }
+
+ /**
+ * Sets the value of the editPermission property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setEditPermission(String value) {
+ this.editPermission = value;
+ }
+
+ /**
+ * Gets the value of the permission property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getPermission() {
+ return permission;
+ }
+
+ /**
+ * Sets the value of the permission property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setPermission(String value) {
+ this.permission = value;
+ }
+
+}
Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/configuration/package-info.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/configuration/package-info.java 2007-03-08 15:14:35 UTC (rev 10074)
+++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/configuration/package-info.java 2007-03-08 15:45:59 UTC (rev 10075)
@@ -1,24 +1,9 @@
-/*
- * 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.
- */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.1.2-b01-fcs
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2007.03.08 at 03:58:06 PM CET
+//
@javax.xml.bind.annotation.XmlSchema(namespace = "http://jboss.org", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package org.jboss.forge.common.projects.configuration;
Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/web/WEB-INF/projects.xsd
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-common/src/web/WEB-INF/projects.xsd 2007-03-08 15:14:35 UTC (rev 10074)
+++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/web/WEB-INF/projects.xsd 2007-03-08 15:45:59 UTC (rev 10075)
@@ -65,7 +65,7 @@
<xs:complexType name="project" mixed="true" >
<xs:annotation>
<xs:appinfo>
- <jxb:class>
+ <jxb:class name="projectConfiguration">
<jxb:javadoc>
This class describes main info about project availability,
permissions, level in navigation etc.
@@ -75,7 +75,6 @@
</jxb:class>
</xs:appinfo>
</xs:annotation>
- <xs:attribute name="level" type="xs:string" use="required" />
<xs:attribute name="edit-permission" type="xs:string" use="optional" />
<xs:attribute name="permission" type="xs:string" use="optional" />
</xs:complexType>
Modified: labs/jbosslabs/trunk/portal-extensions/forge-ejb3/src/java/org/jboss/forge/ejb3/configuration/ConfigurationServiceImpl.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-ejb3/src/java/org/jboss/forge/ejb3/configuration/ConfigurationServiceImpl.java 2007-03-08 15:14:35 UTC (rev 10074)
+++ labs/jbosslabs/trunk/portal-extensions/forge-ejb3/src/java/org/jboss/forge/ejb3/configuration/ConfigurationServiceImpl.java 2007-03-08 15:45:59 UTC (rev 10075)
@@ -7,7 +7,7 @@
import org.jboss.annotation.ejb.Management;
import org.jboss.forge.common.ejb3.ConfigurationService;
import org.jboss.forge.common.projects.configuration.Configuration;
-import org.jboss.forge.common.projects.configuration.Project;
+import org.jboss.forge.common.projects.configuration.ProjectConfiguration;
import org.jboss.forge.common.projects.ProjectsHelper;
import org.jboss.forge.common.projects.Projects;
import org.jboss.forge.common.Constants;
@@ -24,20 +24,20 @@
return projectsClass.getProjectsDescriptor().getConfiguration();
}
- public List<Project> getConfiguredProjects() {
+ public List<ProjectConfiguration> getConfiguredProjects() {
Configuration configuration = getConfiguration();
if (configuration==null) {
- return new ArrayList<Project>();
+ return new ArrayList<ProjectConfiguration>();
}
return configuration.getProjects();
}
- public Project getConfiguredProject(String projectId) {
+ public ProjectConfiguration getConfiguredProject(String projectId) {
if (projectId==null || projectId.trim().length()==0) {
return null;
}
- List<Project> projects = getConfiguredProjects();
- for (Project project : projects) {
+ List<ProjectConfiguration> projects = getConfiguredProjects();
+ for (ProjectConfiguration project : projects) {
if (project.getContent().compareTo(projectId)==0) {
return project;
}
@@ -49,29 +49,18 @@
if (projectId==null || projectId.trim().length()==0) {
return null;
}
- Project project = getConfiguredProject(projectId);
+ ProjectConfiguration project = getConfiguredProject(projectId);
if (project==null) {
return null;
}
return project.getPermission();
}
- public String getProjectLevel (String projectId) {
- if (projectId==null || projectId.trim().length()==0) {
- return null;
- }
- Project project = getConfiguredProject(projectId);
- if (project==null) {
- return null;
- }
- return project.getLevel();
- }
-
public String getProjectEditPermission (String projectId) {
if (projectId==null || projectId.trim().length()==0) {
return null;
}
- Project project = getConfiguredProject(projectId);
+ ProjectConfiguration project = getConfiguredProject(projectId);
if (project==null) {
return null;
}
Modified: labs/jbosslabs/trunk/portal-extensions/forge-feeds/src/java/org/jboss/forge/feeds/ProjectVariableResolver.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-feeds/src/java/org/jboss/forge/feeds/ProjectVariableResolver.java 2007-03-08 15:14:35 UTC (rev 10074)
+++ labs/jbosslabs/trunk/portal-extensions/forge-feeds/src/java/org/jboss/forge/feeds/ProjectVariableResolver.java 2007-03-08 15:45:59 UTC (rev 10075)
@@ -32,13 +32,9 @@
if ("*".equals(projectLevelAttr)) {
projectIds = ProjectsHelper.getProjects(org.jboss.forge.feeds.ProjectVariableResolver.PROJECTS_ID).getProjectIds(
- new NullPermissionsChecker(), null);
+ new NullPermissionsChecker());
} else {
- String[] projectLevels = projectLevelAttr.split("[,]");
- for (String projectLevel : projectLevels) {
- projectIds.addAll(ProjectsHelper.getProjects(org.jboss.forge.feeds.ProjectVariableResolver.PROJECTS_ID).getProjectIds(
- new NullPermissionsChecker(), projectLevel));
- }
+ System.out.println("LEVELS UNSUPPORTED!");
}
projects = projectIds.toArray(new String[0]);
Modified: labs/jbosslabs/trunk/portal-extensions/forge-portlets/src/java/org/jboss/forge/podcast/Podcast.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-portlets/src/java/org/jboss/forge/podcast/Podcast.java 2007-03-08 15:14:35 UTC (rev 10074)
+++ labs/jbosslabs/trunk/portal-extensions/forge-portlets/src/java/org/jboss/forge/podcast/Podcast.java 2007-03-08 15:45:59 UTC (rev 10075)
@@ -38,7 +38,6 @@
import java.io.IOException;
import org.jboss.forge.common.XmlTools;
-import org.jboss.forge.common.projects.AbstractDescriptor;
import org.jboss.portal.core.servlet.jsp.taglib.context.DelegateContext;
import org.jboss.logging.Logger;
@@ -61,7 +60,7 @@
*
* @author Pawel Wrzeszcz
*/
-public class Podcast extends AbstractDescriptor {
+public class Podcast {
/**
* <code>PODCAST_ELEMENT</code> - root tag in the xml file defining the list of watched feeds
Deleted: labs/jbosslabs/trunk/portal-extensions/forge-portlets/src/java/org/jboss/forge/projects/info/Info.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-portlets/src/java/org/jboss/forge/projects/info/Info.java 2007-03-08 15:14:35 UTC (rev 10074)
+++ labs/jbosslabs/trunk/portal-extensions/forge-portlets/src/java/org/jboss/forge/projects/info/Info.java 2007-03-08 15:45:59 UTC (rev 10075)
@@ -1,117 +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.projects.info;
-
-import java.io.IOException;
-
-import javax.portlet.PortletException;
-import javax.portlet.PortletRequestDispatcher;
-
-import org.jboss.forge.common.ForgeHelper;
-import org.jboss.forge.common.portlet.JBossLabsPortlet;
-import org.jboss.forge.common.projects.Projects;
-import org.jboss.forge.common.projects.ProjectsHelper;
-import org.jboss.forge.common.projects.permissions.PermissionsChecker;
-import org.jboss.forge.common.projects.permissions.RenderRequestPermissionsChecker;
-import org.jboss.logging.Logger;
-import org.jboss.portal.core.servlet.jsp.taglib.context.DelegateContext;
-import org.jboss.portal.core.servlet.jsp.PortalJsp;
-import org.jboss.portlet.JBossRenderRequest;
-import org.jboss.portlet.JBossRenderResponse;
-import org.jboss.shotoku.ContentManager;
-import org.jboss.shotoku.Node;
-import org.jboss.shotoku.aop.Inject;
-import org.jboss.shotoku.exceptions.ResourceDoesNotExist;
-
-/**
- * A portlet for displaying information about a project.
- *
- * @author adamw
- */
-public class Info extends JBossLabsPortlet {
- private final static String INFO_JSP = "prj-info/info.jsp";
-
- private final static String INFO_ERROR_JSP = "prj-info/info_error.jsp";
-
- private static final Logger log = Logger.getLogger(Info.class);
-
- @Inject
- private ContentManager cm;
-
- protected boolean isAllowed(JBossRenderRequest request, JBossRenderResponse response) {
- return true;
- }
-
- public void labsDoView(JBossRenderRequest request, JBossRenderResponse response)
- throws IOException, PortletException {
- response.setContentType("text/html");
-
- String projectId = ProjectsHelper.getSelectedProjectId(request);
- String portalName = ForgeHelper.getPortalName(request);
- Projects projects = ProjectsHelper.getProjects(portalName);
-
- request.setAttribute("PROJ-URL", "/portal/" + projectId);
-
- if (request.getUser() != null) {
- request.setAttribute("PROJ-USER", request.getUser().getUserName());
- }
-
- DelegateContext context = null;
- PortletRequestDispatcher rd;
-
- PermissionsChecker pc = new RenderRequestPermissionsChecker(request);
-
- if (projectId != null)
- context = projects.getProjectContext(pc, projectId);
-
- if (context == null) {
- rd = getPortletContext().getRequestDispatcher(
- ForgeHelper
- .createRepoAccessPath(portalName, INFO_ERROR_JSP));
- } else {
- // Name of the file in freezone containing project's description
- String descriptionFreezoneFilePath = context.get("description");
- if (descriptionFreezoneFilePath != null
- && descriptionFreezoneFilePath.trim().length() > 0) {
- String absolutePathToInfo = "/" + portalName + "/"
- + ProjectsHelper.MEMBERS_DIR + "/" + projectId + "/"
- + ProjectsHelper.FREEZONE_DIR + "/"
- + descriptionFreezoneFilePath.trim();
- try {
- Node node = cm.getNode(absolutePathToInfo);
- String content = node.getContent();
- context.put("infoPageContent", content);
- } catch (ResourceDoesNotExist e) {
- log.warn("Resource given in description tag of "
- + projectId
- + "'s project.xml descriptor is not available.");
- }
- }
- request.setAttribute(PortalJsp.CTX_REQUEST, context);
- rd = getPortletContext().getRequestDispatcher(
- ForgeHelper.createRepoAccessPath(portalName, INFO_JSP));
- }
-
- ProjectsHelper.prepareRequest(request);
- rd.include(request, response);
- }
-}
Modified: labs/jbosslabs/trunk/portal-extensions/forge-portlets/src/java/org/jboss/forge/projects/info/ProjectInfoBean.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-portlets/src/java/org/jboss/forge/projects/info/ProjectInfoBean.java 2007-03-08 15:14:35 UTC (rev 10074)
+++ labs/jbosslabs/trunk/portal-extensions/forge-portlets/src/java/org/jboss/forge/projects/info/ProjectInfoBean.java 2007-03-08 15:45:59 UTC (rev 10075)
@@ -59,10 +59,11 @@
JBossRenderRequest req = (JBossRenderRequest) request;
String projectId = ProjectsHelper.getSelectedProjectId(req);
+
+ project = getProjectById(projectId);
+
+ portalName = ForgeHelper.getPortalName(req);
- project = getProjectById(projectId);
- portalName = ForgeHelper.getPortalName(req);
-
projectURL = "/portal/" + project.getId();
if (req.getUser() != null) {
Modified: labs/jbosslabs/trunk/portal-extensions/forge-portlets/src/web/WEB-INF/portlet.xml
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-portlets/src/web/WEB-INF/portlet.xml 2007-03-08 15:14:35 UTC (rev 10074)
+++ labs/jbosslabs/trunk/portal-extensions/forge-portlets/src/web/WEB-INF/portlet.xml 2007-03-08 15:45:59 UTC (rev 10075)
@@ -71,28 +71,8 @@
</preference>
</portlet-preferences>
</portlet>
-
+
<portlet>
- <portlet-name>AdsPortlet</portlet-name>
- <portlet-class>org.jbosslabs.portlet.ads.AdsPortlet</portlet-class>
-
- <supports>
- <mime-type>text/html</mime-type>
- <portlet-mode>VIEW</portlet-mode>
- </supports>
- <supported-locale>en</supported-locale>
- <portlet-info>
- <title>JBoss Advertisements Portlet</title>
- </portlet-info>
- <portlet-preferences>
- <preference>
- <name>projectId</name>
- <value>default</value>
- </preference>
- </portlet-preferences>
- </portlet>
-
- <portlet>
<description>Podcast Portlet</description>
<portlet-name>PodcastPortlet</portlet-name>
<display-name>Feeds</display-name>
Modified: labs/jbosslabs/trunk/portal-extensions/polls/src/java/org/jboss/forge/polls/PollDescriptor.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/polls/src/java/org/jboss/forge/polls/PollDescriptor.java 2007-03-08 15:14:35 UTC (rev 10074)
+++ labs/jbosslabs/trunk/portal-extensions/polls/src/java/org/jboss/forge/polls/PollDescriptor.java 2007-03-08 15:45:59 UTC (rev 10075)
@@ -33,7 +33,6 @@
import org.apache.xerces.parsers.DOMParser;
import org.jboss.forge.common.XmlTools;
-import org.jboss.forge.common.projects.AbstractDescriptor;
import org.jboss.forge.common.projects.XmlInputFactory.XmlNotFoundException;
import org.jboss.forge.polls.service.PollDTO;
import org.w3c.dom.Document;
@@ -48,7 +47,7 @@
* @author Ryszard Kozmik
*
*/
-public class PollDescriptor extends AbstractDescriptor {
+public class PollDescriptor {
/**
* This variable contains all polls containing questions from the xml descriptor.
Modified: labs/jbosslabs/trunk/portal-extensions/polls/src/java/org/jboss/forge/polls/PollsDescriptor.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/polls/src/java/org/jboss/forge/polls/PollsDescriptor.java 2007-03-08 15:14:35 UTC (rev 10074)
+++ labs/jbosslabs/trunk/portal-extensions/polls/src/java/org/jboss/forge/polls/PollsDescriptor.java 2007-03-08 15:45:59 UTC (rev 10075)
@@ -34,7 +34,6 @@
import java.util.Set;
import org.jboss.forge.common.XmlTools;
-import org.jboss.forge.common.projects.AbstractDescriptor;
import org.jboss.forge.common.projects.ProjectsHelper;
import org.jboss.forge.polls.service.PollAnswerDTO;
import org.jboss.forge.polls.service.PollDTO;
@@ -52,7 +51,7 @@
* @author Ryszard Kozmik
*
*/
-public class PollsDescriptor extends AbstractDescriptor {
+public class PollsDescriptor {
/**
Modified: labs/jbosslabs/trunk/portal-extensions/primates/src/java/org/jbosslabs/portlets/primates/Primate.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/primates/src/java/org/jbosslabs/portlets/primates/Primate.java 2007-03-08 15:14:35 UTC (rev 10074)
+++ labs/jbosslabs/trunk/portal-extensions/primates/src/java/org/jbosslabs/portlets/primates/Primate.java 2007-03-08 15:45:59 UTC (rev 10075)
@@ -27,7 +27,6 @@
import java.util.Set;
import org.jboss.forge.common.XmlTools;
-import org.jboss.forge.common.projects.AbstractDescriptor;
import org.jboss.portal.core.servlet.jsp.taglib.context.DelegateContext;
import org.jboss.shotoku.ContentManager;
import org.jboss.shotoku.exceptions.ResourceDoesNotExist;
@@ -40,7 +39,7 @@
* @author Rysiek
* A class representing a primate.
*/
-public class Primate extends AbstractDescriptor {
+public class Primate {
public final static String USER_LOGIN_ELEMENT = "login";
public final static String USER_LOGINS_ELEMENT = "logins";
More information about the jboss-svn-commits
mailing list