[jboss-svn-commits] JBL Code SVN: r8877 - in labs/jbosslabs/trunk/portal-extensions-2.6: binaries/maven-repo-addons/jboss/jars and 11 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Jan 16 18:09:23 EST 2007


Author: adamw
Date: 2007-01-16 18:08:22 -0500 (Tue, 16 Jan 2007)
New Revision: 8877

Added:
   labs/jbosslabs/trunk/portal-extensions-2.6/forge-contributor/src/java/org/jboss/forge/contributor/ConCacheItem.java
   labs/jbosslabs/trunk/portal-extensions-2.6/polls/src/java/org/jboss/forge/polls/PollsCacheItem.java
   labs/jbosslabs/trunk/portal-extensions-2.6/primates/src/java/org/jbosslabs/portlets/primates/PrimatesCacheItem.java
Removed:
   labs/jbosslabs/trunk/portal-extensions-2.6/forge-service/
   labs/jbosslabs/trunk/portal-extensions-2.6/polls/src/java/org/jboss/forge/polls/PollsWatcher.java
   labs/jbosslabs/trunk/portal-extensions-2.6/primates/src/java/org/jbosslabs/portlets/primates/PrimatesNodeWatcher.java
Modified:
   labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/activation.jar
   labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/ejb3-persistence.jar
   labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/jboss-common.jar
   labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/jboss-jmx.jar
   labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/jboss-portlet-api-lib.jar
   labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/jboss-system.jar
   labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/portal-api-lib.jar
   labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/portal-bridge-lib.jar
   labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/portal-common-lib.jar
   labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/portal-core-lib.jar
   labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/portal-faces-lib.jar
   labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/portal-format-lib.jar
   labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/portal-identity-lib.jar
   labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/portal-portlet-lib.jar
   labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/portal-security-lib.jar
   labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/portal-server-lib.jar
   labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/portal-theme-lib.jar
   labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/portlet-api-lib.jar
   labs/jbosslabs/trunk/portal-extensions-2.6/forge-common/src/java/org/jboss/forge/common/PermissionTools.java
   labs/jbosslabs/trunk/portal-extensions-2.6/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterTools.java
   labs/jbosslabs/trunk/portal-extensions-2.6/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersWatcher.java
   labs/jbosslabs/trunk/portal-extensions-2.6/forge-common/src/java/org/jboss/forge/common/soa/projects/ProjectsServiceImpl.java
   labs/jbosslabs/trunk/portal-extensions-2.6/forge-contributor/src/java/org/jboss/forge/contributor/ConMainBean.java
   labs/jbosslabs/trunk/portal-extensions-2.6/forge-contributor/src/java/org/jboss/forge/contributor/ConServer.java
   labs/jbosslabs/trunk/portal-extensions-2.6/forge-feeds/forge-feeds.iml
   labs/jbosslabs/trunk/portal-extensions-2.6/forge-file-access/src/java/org/jboss/forge/fileaccess/DownloadsFileAccessMonitor.java
   labs/jbosslabs/trunk/portal-extensions-2.6/forge-file-access/src/java/org/jboss/forge/fileaccess/portlet/DownloadCounterPortlet.java
   labs/jbosslabs/trunk/portal-extensions-2.6/forge-login/maven.xml
   labs/jbosslabs/trunk/portal-extensions-2.6/forge-login/project.properties
   labs/jbosslabs/trunk/portal-extensions-2.6/jbosswiki/maven.xml
   labs/jbosslabs/trunk/portal-extensions-2.6/polls/src/java/org/jboss/forge/polls/PollTools.java
   labs/jbosslabs/trunk/portal-extensions-2.6/polls/src/java/org/jboss/forge/polls/PollsPortlet.java
   labs/jbosslabs/trunk/portal-extensions-2.6/primates/src/java/org/jbosslabs/portlets/primates/PrimatesTools.java
Log:
http://jira.jboss.com/jira/browse/JBLAB-817

Modified: labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/activation.jar
===================================================================
(Binary files differ)

Modified: labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/ejb3-persistence.jar
===================================================================
(Binary files differ)

Modified: labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/jboss-common.jar
===================================================================
(Binary files differ)

Modified: labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/jboss-jmx.jar
===================================================================
(Binary files differ)

Modified: labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/jboss-portlet-api-lib.jar
===================================================================
(Binary files differ)

Modified: labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/jboss-system.jar
===================================================================
(Binary files differ)

Modified: labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/portal-api-lib.jar
===================================================================
(Binary files differ)

Modified: labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/portal-bridge-lib.jar
===================================================================
(Binary files differ)

Modified: labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/portal-common-lib.jar
===================================================================
(Binary files differ)

Modified: labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/portal-core-lib.jar
===================================================================
(Binary files differ)

Modified: labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/portal-faces-lib.jar
===================================================================
(Binary files differ)

Modified: labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/portal-format-lib.jar
===================================================================
(Binary files differ)

Modified: labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/portal-identity-lib.jar
===================================================================
(Binary files differ)

Modified: labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/portal-portlet-lib.jar
===================================================================
(Binary files differ)

Modified: labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/portal-security-lib.jar
===================================================================
(Binary files differ)

Modified: labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/portal-server-lib.jar
===================================================================
(Binary files differ)

Modified: labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/portal-theme-lib.jar
===================================================================
(Binary files differ)

Modified: labs/jbosslabs/trunk/portal-extensions-2.6/binaries/maven-repo-addons/jboss/jars/portlet-api-lib.jar
===================================================================
(Binary files differ)

Modified: labs/jbosslabs/trunk/portal-extensions-2.6/forge-common/src/java/org/jboss/forge/common/PermissionTools.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-2.6/forge-common/src/java/org/jboss/forge/common/PermissionTools.java	2007-01-16 20:20:41 UTC (rev 8876)
+++ labs/jbosslabs/trunk/portal-extensions-2.6/forge-common/src/java/org/jboss/forge/common/PermissionTools.java	2007-01-16 23:08:22 UTC (rev 8877)
@@ -17,26 +17,45 @@
 public class PermissionTools {
     private static final Logger log = Logger.getLogger(PermissionTools.class);
 
-    private static RoleModule rm;
+    private static IdentityServiceController isc;
 
-    private static RoleModule getRm() {
-        if (rm == null) {
+    private static IdentityServiceController getIsc() {
+        if (isc == null) {
             try {
                 InitialContext initialContext = new InitialContext();
-                rm = (RoleModule) initialContext
-                        //.lookup("portal:service=Module,type=Role");
-                		.lookup(ModuleConstants.ROLEMODULE_JNDINAME);
+                isc = (IdentityServiceController) initialContext
+                        .lookup("portal:service=Module,type=IdentityServiceController");
             } catch (NamingException e) {
                 log.error("Exception while getting the role module", e);
             }
         }
 
-        return rm;
+        return isc;
     }
 
+    public static MembershipModule getMembershipModule() {
+        try {
+            return (MembershipModule) isc.getIdentityContext().getObject(
+                    IdentityContext.TYPE_MEMBERSHIP_MODULE);
+        } catch (IdentityException e) {
+            log.error(e);
+            return null;
+        }
+    }
+
+    public static UserProfileModule getUserProfileModule() {
+        try {
+            return (UserProfileModule) isc.getIdentityContext().getObject(
+                    IdentityContext.TYPE_USER_PROFILE_MODULE);
+        } catch (IdentityException e) {
+            log.error(e);
+            return null;
+        }
+    }
+
     public static boolean isUserInRole(User user, String roleName) {
         try {
-            for (Object roleObj : getRm().getRoles(user)) {
+            for (Object roleObj : getMembershipModule().getRoles(user)) {
                 Role role = (Role) roleObj;
 
                 if (Tools.objectsEqual(roleName, role.getName())) {
@@ -53,7 +72,7 @@
     public static List<String> getRoleNames(User user) {
         List<String> ret = new ArrayList<String>();
         try {
-            for (Object roleObj : getRm().getRoles(user)) {
+            for (Object roleObj : getMembershipModule().getRoles(user)) {
                 ret.add(((Role) roleObj).getName());
             }
         } catch (IdentityException e) {
@@ -65,7 +84,7 @@
     
     public static void setRoles(User user, Set roles) {
     	try {
-			getRm().setRoles(user, roles);
+			getMembershipModule().assignRoles(user, roles);
 		} catch (IdentityException e) {
 			log.error(e);
 		}

Modified: labs/jbosslabs/trunk/portal-extensions-2.6/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterTools.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-2.6/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterTools.java	2007-01-16 20:20:41 UTC (rev 8876)
+++ labs/jbosslabs/trunk/portal-extensions-2.6/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterTools.java	2007-01-16 23:08:22 UTC (rev 8877)
@@ -29,8 +29,9 @@
 import org.jboss.forge.common.ForgeHelper;
 import org.jboss.portal.core.servlet.jsp.taglib.context.DelegateContext;
 import org.jboss.shotoku.ContentManager;
+import org.jboss.shotoku.aop.CacheItem;
 
-/**
+ /**
  * DownloadCounterTools class is just a tool class with static methods
  * helpiing download counters to work.
  * 
@@ -79,11 +80,10 @@
 	 * @param portalName
 	 * @param projectId
 	 * 		Project id name for which tracked links should be added to the context.
-	 * @param contentManager
 	 * @return DelegateContext object containing content for JSP file.
 	 * @throws Exception
 	 */
-	public static DelegateContext getContext (final String portalName,final String projectId,ContentManager contentManager) throws Exception {
+	public static DelegateContext getContext (final String portalName,final String projectId) throws Exception {
 		
 		//  If the projectId is null method returns empty DelegateContext object.
 		if (projectId==null) {
@@ -94,7 +94,7 @@
 		DelegateContext ctx = new DelegateContext();
 		
 		// Getting the DownloadCountersDescriptor object containing counters.
-		DownloadCountersDescriptor desc = getDesc(portalName,contentManager);
+		DownloadCountersDescriptor desc = getDesc(portalName);
 		
 		// If there isn't a descriptor in cache, return empty context.
 		if (desc==null) {
@@ -120,25 +120,16 @@
 		}
 		return ctx;
 	}
-	
-	/**
+
+    private static @CacheItem DownloadCountersWatcher dcw;
+
+    /**
 	 * Method gets DownloadCountersDescriptor object from the forge cache.
 	 * @param portalName
 	 * @return DownloadCountersDescriptor object.
 	 */
-	public static DownloadCountersDescriptor getDesc(final String portalName,final ContentManager contentManager) {
-		DownloadCountersDescriptor desc = (DownloadCountersDescriptor) ForgeHelper
-				.getForgeManagement().getFromCache(portalName,
-						DownloadCountersDescriptor.class.getName());
-		if (desc == null)
-			desc = (DownloadCountersDescriptor) ForgeHelper
-					.getForgeManagement().addNodeWatcher(
-							portalName,
-							DownloadCountersDescriptor.class
-									.getName(),
-							new DownloadCountersWatcher(
-									contentManager));
-		return desc;
+	public static DownloadCountersDescriptor getDesc(final String portalName) {
+		return dcw.get(portalName);
 	}
 	
 	/**
@@ -179,13 +170,11 @@
 	 * 		Project id name for which sum must be generated.
 	 * @param portalName
 	 * 		Name of the portal.
-	 * @param cm
-	 * 		ContentManager object.
 	 * @return
 	 * 		Returns sum of all downloads.
 	 */
-	public static long getOverallDownloadsForProject (String projectId,String portalName,ContentManager cm) {
-		DownloadCountersDescriptor desc = getDesc(portalName,cm);
+	public static long getOverallDownloadsForProject (String projectId,String portalName) {
+		DownloadCountersDescriptor desc = getDesc(portalName);
 		Map<String,Long> values = desc!=null?desc.getValuesForPortlet(projectId):null;
 		if (values==null || values.size()==0) {
 			return 0;

Modified: labs/jbosslabs/trunk/portal-extensions-2.6/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersWatcher.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-2.6/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersWatcher.java	2007-01-16 20:20:41 UTC (rev 8876)
+++ labs/jbosslabs/trunk/portal-extensions-2.6/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersWatcher.java	2007-01-16 23:08:22 UTC (rev 8877)
@@ -24,92 +24,55 @@
 package org.jboss.forge.common.projects;
 
 import java.util.Set;
+import java.util.Map;
 
 import org.jboss.forge.common.service.NodeWatcher;
 import org.jboss.forge.common.service.ResourceWatcher;
 import org.jboss.shotoku.ContentManager;
+import org.jboss.shotoku.cache.ShotokuResourceWatcher;
+import org.jboss.shotoku.cache.ChangeType;
 
 /**
  * DownloadCounterWatcher class which implements NodeWatcher interface
  * is used for invoking updates of the main download counter xml descriptor
  * and watching for changes in projects download counter descriptors.
- * 
+ *
  * @author Ryszard Kozmik
- * 
+ *
  */
-public class DownloadCountersWatcher implements NodeWatcher{
+public class DownloadCountersWatcher extends ShotokuResourceWatcher<String, DownloadCountersDescriptor> {
 
-	ContentManager contentManager;
-	ResourceWatcher rw;
-	
-	/**
-	 * This Collection contains names of projects which contain counter.xml descriptors.
-	 */
-	Set<String> counterDescriptors;
-	/**
-	 * Simple constructor saving ContentManager given in parameter
-	 * <code>conentManager</code>
-	 * @param contentManager
-	 */
-	public DownloadCountersWatcher (ContentManager contentManager) {
-		this.contentManager = contentManager;
-	}
-	
-	
-	public Object init(String portalName) {
-		return getDescriptor(portalName);
-	}
-	
-	/**
-	 * Method constructs the DownloadCountersDescriptor object registers it
-	 * with the ResourceWatcher as well as all found DownloadCounterDescriptors.
-	 * 
-	 * @param portalName
-	 * @return DownloadCountersDescriptor object.
-	 */
-	private Object getDescriptor (String portalName) {                
-                DownloadCountersDescriptor descriptor = 
-			new DownloadCountersDB(portalName, contentManager);
-		rw = new ResourceWatcher(contentManager);
-		// Registering ResourceWatcher to watch for main download counters xml file change.
-		//rw.watchResource(DownloadCounterTools.getMainXmlPath(portalName));
-		
-		// Getting the project ids names where are project download counter descriptors.
-		counterDescriptors = descriptor.getDownloadDescriptors(portalName).keySet();
-		// Adding found project download counter descriptors to the ResourceWatcher to watch
-		// for their changes.
-		for (String id:counterDescriptors) {
-			rw.watchResource(DownloadCounterTools.getProjectXmlPath(portalName,id));
-		}
-		return descriptor;
-	}
 
-	/**
-	 * Method updates main downlaod counters descriptor if there is such a need.
-	 * If the object is changed the method returns new object if not returns null.
-	 */
-	public Object nodeUpdate(String portalName, Object currentValue) {
-                if (currentValue==null || rw.checkResources()
-				|| !checkForNewResources((DownloadCountersDescriptor)currentValue,portalName)) {
-			return getDescriptor(portalName);
-		} else if (((DownloadCountersDescriptor)currentValue).hasChanged()){
-			DownloadCountersDescriptor descriptor = 
-				(DownloadCountersDescriptor)currentValue;
-			descriptor.synchronizeWithFile(portalName);
-			return null;
-		}
-		return null;
-	}
-	
-        /**
-         * Method checks if there was no new xml project' descriptor added.
-         * @param desc
-         * @param portalName
-         * @return
-        */
-	private boolean checkForNewResources (DownloadCountersDescriptor desc, String portalName) {
-		return counterDescriptors.containsAll(desc.getDownloadDescriptors(portalName).keySet());
-	}
+    /**
+     * Method constructs the DownloadCountersDescriptor object registers it
+     * with the ResourceWatcher as well as all found DownloadCounterDescriptors.
+     *
+     * @return DownloadCountersDescriptor object.
+     */
+    private DownloadCountersDescriptor getDescriptor (String key) {
+        DownloadCountersDescriptor descriptor =
+                new DownloadCountersDB(key, getContentManager(key));
 
+        // Getting the project ids names where are poll descriptors.
+        Set<String> projects = ProjectsHelper.getProjectIds(key);
 
+        // Adding found project poll descriptors to the ResourceWatcher to watch
+        // for their changes.
+        resetWatchedPaths(key);
+        for (String projectId : projects) {
+            addWatchedPath(key, DownloadCounterTools.getProjectXmlPath(key, projectId));
+        }
+
+        descriptor.synchronizeWithFile(key);
+
+        return descriptor;
+    }
+
+    protected void update(String key, DownloadCountersDescriptor currentObject, Map<String, ChangeType> changes) {
+        put(key, getDescriptor(key));
+    }
+
+    public DownloadCountersDescriptor init(String key) {
+        return getDescriptor(key);
+    }
 }

Modified: labs/jbosslabs/trunk/portal-extensions-2.6/forge-common/src/java/org/jboss/forge/common/soa/projects/ProjectsServiceImpl.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-2.6/forge-common/src/java/org/jboss/forge/common/soa/projects/ProjectsServiceImpl.java	2007-01-16 20:20:41 UTC (rev 8876)
+++ labs/jbosslabs/trunk/portal-extensions-2.6/forge-common/src/java/org/jboss/forge/common/soa/projects/ProjectsServiceImpl.java	2007-01-16 23:08:22 UTC (rev 8877)
@@ -153,7 +153,7 @@
 
     public long getOverallDownloadsForProject(String projectId, String portalName) {
 	
-		return DownloadCounterTools.getOverallDownloadsForProject(projectId, portalName, cm);
+		return DownloadCounterTools.getOverallDownloadsForProject(projectId, portalName);
 	}
     
     public boolean getPackagedForDownload(String projectId) {

Added: labs/jbosslabs/trunk/portal-extensions-2.6/forge-contributor/src/java/org/jboss/forge/contributor/ConCacheItem.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-2.6/forge-contributor/src/java/org/jboss/forge/contributor/ConCacheItem.java	2007-01-16 20:20:41 UTC (rev 8876)
+++ labs/jbosslabs/trunk/portal-extensions-2.6/forge-contributor/src/java/org/jboss/forge/contributor/ConCacheItem.java	2007-01-16 23:08:22 UTC (rev 8877)
@@ -0,0 +1,7 @@
+package org.jboss.forge.contributor;
+
+/**
+ * @author <a href="mailto:adamw at aster.pl">Adam Warski</a>
+ */
+public class ConCacheItem {
+}

Modified: labs/jbosslabs/trunk/portal-extensions-2.6/forge-contributor/src/java/org/jboss/forge/contributor/ConMainBean.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-2.6/forge-contributor/src/java/org/jboss/forge/contributor/ConMainBean.java	2007-01-16 20:20:41 UTC (rev 8876)
+++ labs/jbosslabs/trunk/portal-extensions-2.6/forge-contributor/src/java/org/jboss/forge/contributor/ConMainBean.java	2007-01-16 23:08:22 UTC (rev 8877)
@@ -85,7 +85,7 @@
 		} else {
 			addMessage(getServer().getMessages().getString("commitError"));
 		}
-		getServer().resetDesc(ConTools.getPortalName());		
+		getServer().resetDesc(ConTools.getPortalName());
 		return null;
 	}
 	
@@ -259,9 +259,9 @@
 			
 			ConTools.getExternalContext().getSessionMap().put(
 					ALREADY_CONFIRMED_KEY, Constants.TRUE_VALUE);
-			
+
 			getServer().resetDesc(ConTools.getPortalName());
-			
+
 			return true;
 		}
 		

Modified: labs/jbosslabs/trunk/portal-extensions-2.6/forge-contributor/src/java/org/jboss/forge/contributor/ConServer.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-2.6/forge-contributor/src/java/org/jboss/forge/contributor/ConServer.java	2007-01-16 20:20:41 UTC (rev 8876)
+++ labs/jbosslabs/trunk/portal-extensions-2.6/forge-contributor/src/java/org/jboss/forge/contributor/ConServer.java	2007-01-16 23:08:22 UTC (rev 8877)
@@ -33,11 +33,13 @@
 import java.util.Set;
 
 import org.jboss.forge.common.ForgeHelper;
+import org.jboss.forge.common.PermissionTools;
 import org.jboss.forge.common.projects.ProjectsHelper;
 import org.jboss.forge.common.projects.project.Developers;
 import org.jboss.forge.common.soa.LabsServices;
 import org.jboss.forge.common.soa.projects.ProjectsService;
 import org.jboss.portal.api.node.PortalNodeURL;
+import org.jboss.portal.identity.User;
 import org.jboss.shotoku.ContentManager;
 import org.jboss.shotoku.Node;
 import org.jboss.shotoku.aop.CacheItem;
@@ -52,507 +54,511 @@
  * and writing the xml file with agreements.
  */
 public class ConServer {
-	/**
-	 * <code>CONTRIBUTOR_DIR</code> - Directory in which the xml with
-	 * agreements is held relative to portal directory.
-	 */
-	final static String CONTRIBUTOR_DIR = "contributor";
-	/**
-	 * <code>AGREEMENTS_XML</code> - Name of the xml file with
-	 * signed agreements.
-	 */
-	final static String AGREEMENTS_XML  = "agreements.xml";
-	/**
-	 * <code>UNCOFIRMED_XML</code> - Name of the xml file with
-	 * unconfirmed agreements.
-	 */
-	final static String UNCONFIRMED_XML  = "unconfirmed.xml";
-	
-	static String getBaseFilePath() {
-		return ConTools.getPortalName() + "/" + ConServer.CONTRIBUTOR_DIR ;
-	}
-	
-	static String getConfirmedFilePath() {
-		return getBaseFilePath() + "/" + ConServer.AGREEMENTS_XML;
-	}
-	
-	static String getUnconfirmedFilePath() {
-		return getBaseFilePath() + "/" + ConServer.UNCONFIRMED_XML;
-	}
-	
-	@Inject
+    /**
+     * <code>CONTRIBUTOR_DIR</code> - Directory in which the xml with
+     * agreements is held relative to portal directory.
+     */
+    final static String CONTRIBUTOR_DIR = "contributor";
+    /**
+     * <code>AGREEMENTS_XML</code> - Name of the xml file with
+     * signed agreements.
+     */
+    final static String AGREEMENTS_XML  = "agreements.xml";
+    /**
+     * <code>UNCOFIRMED_XML</code> - Name of the xml file with
+     * unconfirmed agreements.
+     */
+    final static String UNCONFIRMED_XML  = "unconfirmed.xml";
+
+    static String getBaseFilePath() {
+        return ConTools.getPortalName() + "/" + ConServer.CONTRIBUTOR_DIR ;
+    }
+
+    static String getConfirmedFilePath() {
+        return getBaseFilePath() + "/" + ConServer.AGREEMENTS_XML;
+    }
+
+    static String getUnconfirmedFilePath() {
+        return getBaseFilePath() + "/" + ConServer.UNCONFIRMED_XML;
+    }
+
+    @Inject
     private ContentManager cm;
 
     @CacheItem
     private ConNodeWatcher conf;
-	
+
     private ResourceBundle messages;
     private Locale currentLocale;
-    
-	public ConServer() {
+
+    public ConServer() {
         currentLocale = new Locale("en", "US");
         messages = ResourceBundle.getBundle("Messages", currentLocale);
-	}
-	
-	ResourceBundle getMessages() {
-		return messages;
-	}
-	
-	/**
-	 * Gets a contributors descriptor for the given portal.
-	 * @param portalName Name of the current portal. 
-	 * @return A contributors descriptor.
-	 */
-	synchronized ConDescriptor getDesc(final String portalName) {
-		return conf.get(portalName);
-	}
-	
-	synchronized void resetDesc(String portalName) {
-		ForgeHelper.getForgeManagement().forceNodeUpdate(portalName, 
-				ConServer.class.getName());
-	}
+    }
 
-	private boolean checkString(String s) {
+    ResourceBundle getMessages() {
+        return messages;
+    }
+
+    /**
+     * Gets a contributors descriptor for the given portal.
+     * @param portalName Name of the current portal.
+     * @return A contributors descriptor.
+     */
+    synchronized ConDescriptor getDesc(final String portalName) {
+        return conf.get(portalName);
+    }
+
+    private boolean checkString(String s) {
         return !((s == null) || (s.trim().equals("")));
     }
-	
-	private String getFormattedMessage(String key, Object[] arguments) {
-		MessageFormat formatter = new MessageFormat("");
-		formatter.setLocale(currentLocale);
-		formatter.applyPattern(messages.getString(key));
-		return formatter.format(arguments);
-	}
-	
-	synchronized boolean acceptByProjectLead(ConDataBean contributor) {
-		
-		String oldXml = contributor.getXml();
-		
-		Set<String> projectIds = ConTools.getLeadProjectIds();
-		Map<String, String> projectsInfo = contributor.getProjectsInfo();
-		for (String projectId : projectsInfo.keySet()) {
-			if (projectIds.contains(projectId)) {
-				if ("0".equals(projectsInfo.get(projectId))) {
-					projectsInfo.put(projectId, "1");
-				}
-			}
-		}
-		
-		contributor.setProjectsInfo(projectsInfo);
-		String newXml = contributor.getXml();
-	
-		try {
-			Node confirmed = cm.getNode(getConfirmedFilePath());
-			String content = confirmed.getContent();
-			
-			String newContent = ForgeHelper.replace(content, 
-				oldXml, newXml);
-			
-			confirmed.setContent(newContent);
-			confirmed.save("New application accepted");
-			
-			getDesc(ConTools.getPortalName()).getNotAcceptedByLeadsData().remove(contributor);
-			
-			if (!projectsInfo.containsValue("0")) {
-				PortalNodeURL url = ConTools.createRenderURL();
-				String adminURL = ConTools.getBaseServerAddress() + 
-					url.toString();
 
-				// sending email to admin
-				ForgeHelper.postMail(
-						ForgeHelper.getProperties().getProperty("contribadmin"),
-						messages.getString("adminMailSubject"),
-						getFormattedMessage("adminMailText", 
-								new Object[] { newXml, adminURL }),
-						"labs-admin at jboss.com");
-			}
-			
-			org.jboss.portal.identity.User projectLead = ConTools.getUser();
-			
-			if (projectLead != null) {
-				String projectLeadEmail = projectLead.getRealEmail();
-				
-				if (projectLeadEmail != null) {
-					
-					// email to project lead
-					ForgeHelper.postMail(
-							projectLeadEmail,
-							messages.getString("acceptedMailSubject"),
-							getFormattedMessage("acceptedMailTextAdmin", 
-									new Object[] { contributor.getName(),
-									contributor.getEmail(), contributor.getType(),
-									contributor.getLogin(), contributor.getProjects() }),
-							"labs-robot at labs.jboss.com");
-				}
-			}
-			
-			return true;
-		} catch (Exception e) {
-			e.printStackTrace();
-			return false;
-		}
-	}
-	
-	/**
-	 * Accepts the given application.
-	 * @param dataBean Application to accept.
-	 * @return True iff accepting was successfull.
-	 */
-	synchronized boolean accept(ConDataBean dataBean) {
-		String oldXml = dataBean.getXml();
-		
-		dataBean.setAccepted("1");
-		String newXml = dataBean.getXml();	
-		
-		try {
-			// Values ok, adding application.
-			Node confirmed = cm.getNode(getConfirmedFilePath());
-			String content = confirmed.getContent();
-			
-			String newContent = ForgeHelper.replace(content, 
-				oldXml, newXml);
-			
-			confirmed.setContent(newContent);
-			confirmed.save("New application accepted");
-			
-			getDesc(ConTools.getPortalName()).getNotAcceptedData().remove(dataBean);
-			
-			// Posting a notification to the contributor
-			ForgeHelper.postMail(dataBean.getEmail(),
-					messages.getString("acceptedMailSubject"),
-					getFormattedMessage("acceptedMailText", 
-							new Object[] { dataBean.getName() }),
-					"labs-robot at labs.jboss.com");
-			
-			// Posting a notification to the con-admin
-			ForgeHelper.postMail(
-					ForgeHelper.getProperties().getProperty("contribadmin"),
-					messages.getString("acceptedMailSubject"),
-					getFormattedMessage("acceptedMailTextAdmin", 
-							new Object[] { dataBean.getName(),
-							dataBean.getEmail(), dataBean.getType(),
-							dataBean.getLogin(), dataBean.getProjects() }),
-					"labs-robot at labs.jboss.com");
-			
-			if ("1".equals(dataBean.getCommitter())) {
-				ForgeHelper.postMail(
-						ForgeHelper.getProperties().getProperty("jira"),
-						messages.getString("committerAccessMailSubject") + " " + dataBean.getName(),
-						getFormattedMessage("committerAccessMailText", 
-								new Object[] { dataBean.getName(),
-								dataBean.getEmail(), dataBean.getType(),
-								dataBean.getLogin(), dataBean.getProjects() }),
-						"labs-robot at labs.jboss.com");				
-			}
-			
-			return true;
-		} catch (Exception e) {
-			return false;
-		}
-	}
-	
-	/**
-	 * Deletes the given application.
-	 * @param dataBean Application to delete.
-	 * @return True iff deleting was successfull.
-	 */
-	synchronized boolean delete(ConDataBean dataBean, String comment) {
-		String oldXml = dataBean.getXml();
-		
-		try {
-			// Values ok, adding application.
-			Node confirmed;
-			try {
-				confirmed = cm.getNode(getConfirmedFilePath());
-			} catch (ResourceDoesNotExist e) {
-				// Nothing to do here ...
-				throw new RuntimeException(e);
-			}
-			String content = confirmed.getContent();
-			
-			String newContent = ForgeHelper.replace(content, 
-				oldXml, "");
-			
-			confirmed.setContent(newContent);
-			try {
-				confirmed.save("New application deleted");
-			} catch (SaveException e) {
-				// TODO 
-				throw new RuntimeException(e);
-			}
-			
-			getDesc(ConTools.getPortalName()).getNotAcceptedData().remove(dataBean);
-			
-			return true;
-		} finally {
-			// Sending the "you-are-reject" email no matter exception or not.
-			try {
-				if (comment != null && comment.length() != 0) {
-					ForgeHelper.postMail(dataBean.getEmail(),
-							messages.getString("deletedMailSubject"),
-							getFormattedMessage("deletedMailTextWithComment", 
-									new Object[] { dataBean.getName(), comment }),
-							"forge-robot at labs.jboss.com");
-				} else {
-					ForgeHelper.postMail(dataBean.getEmail(),
-						messages.getString("deletedMailSubject"),
-						getFormattedMessage("deletedMailText", 
-								new Object[] { dataBean.getName() }),
-						"forge-robot at labs.jboss.com");
-				}
-			} catch (Exception e) {
-				// Nothing to do here. No mail... well.
-			}
-		}
-	}
+    private String getFormattedMessage(String key, Object[] arguments) {
+        MessageFormat formatter = new MessageFormat("");
+        formatter.setLocale(currentLocale);
+        formatter.applyPattern(messages.getString(key));
+        return formatter.format(arguments);
+    }
 
-	/**
-	 * Deletes the given application.
-	 * @param dataBean Application to delete.
-	 * @return True iff deleting was successfull.
-	 */
-	synchronized boolean deleteByLead(ConDataBean dataBean, String comment) {
-		String oldXml = dataBean.getXml();
-		
-		try {
-			// Values ok, adding application.
-			Node confirmed;
-			try {
-				confirmed = cm.getNode(getConfirmedFilePath());
-			} catch (ResourceDoesNotExist e) {
-				// Nothing to do here ...
-				throw new RuntimeException(e);
-			}
-			String content = confirmed.getContent();
-			
-			String newContent = ForgeHelper.replace(content, 
-				oldXml, "");
-			
-			confirmed.setContent(newContent);
-			try {
-				confirmed.save("New application deleted");
-			} catch (SaveException e) {
-				// TODO 
-				throw new RuntimeException(e);
-			}
-			
-			getDesc(ConTools.getPortalName()).getNotAcceptedByLeadsData().remove(dataBean);
-			
-			return true;
-		} finally {
-			// Sending the "you-are-reject" email no matter exception or not.
-			try {
-				if (comment != null && comment.length() != 0) {
-					ForgeHelper.postMail(dataBean.getEmail(),
-							messages.getString("deletedMailSubject"),
-							getFormattedMessage("deletedMailTextWithComment", 
-									new Object[] { dataBean.getName(), comment }),
-							"forge-robot at labs.jboss.com");
-				} else {
-					ForgeHelper.postMail(dataBean.getEmail(),
-						messages.getString("deletedMailSubject"),
-						getFormattedMessage("deletedMailText", 
-								new Object[] { dataBean.getName() }),
-						"forge-robot at labs.jboss.com");
-				}
-			} catch (Exception e) {
-				// Nothing to do here. No mail... well.
-			}
-		}
-	}
-	
-	/**
-	 * Confirms the given agreement.
-	 * @param code Confirmation code.
-	 * @return An error string or null, if no error occured.
-	 */
-	String confirm(String code) {
-		String unconfirmedXmlFilePath = getUnconfirmedFilePath();
-		String confirmedXmlFilePath = getConfirmedFilePath();
-		
-		// Looking for agreement that is to be confirmed.
-		//ElementDescriptor toConfirm;
-		ConDataBean toConfirm;
-		try {
-			ConDescriptor desc = new ConDescriptor(cm, getUnconfirmedFilePath());
-			toConfirm = desc.getUnconfirmedContributor(code);
-			
-			/*toConfirm = new ElementsDescriptor(
-					new InputSource(cm.getNode(
-							unconfirmedXmlFilePath).getContentInputStream()),
-					XmlInputFactory.getContentReadingInstance(cm),
-					ConDescriptor.AGREEMENT_TAG,
-					new PropertiesHandlerDefault()).getElementWithId(code);*/
-			
-		} catch (Exception e) {
-			return messages.getString("unableToConfirm");
-		}
-		
-		if (toConfirm == null)
-			return messages.getString("confirmationCodeInvalid");
-		
-		// Generating xml representations of the agreement - before
-		// and after confirmation.
-		String oldXml = toConfirm.getXml();
+    void resetDesc(String portalName) {
+        conf.update(portalName, null, null);
+    }
 
-		String newXml = new ConDataBean("0",
-				toConfirm.getEmail(),
-				toConfirm.getAccepted(),
-				toConfirm.getProjectsInfo(),
-				toConfirm.getSince(),
-				toConfirm.getType(), 
-				toConfirm.getLogin(),
-				toConfirm.getCommitter()).getXml();
-		
-		// Writing changes to xml files.
-		try {
-			Node confirmed = cm.getNode(confirmedXmlFilePath);
-			Node unconfirmed = cm.getNode(unconfirmedXmlFilePath);
-			
-			String confirmedContent = confirmed.getContent();
-			String unconfirmedContent = unconfirmed.getContent(); 
-			
-			confirmedContent = ForgeHelper.replace(confirmedContent, 
-					"</"+ConDescriptor.AGREEMENTS_TAG+">",
-					newXml
-					+ "</"+ConDescriptor.AGREEMENTS_TAG+">"
-					);
-			unconfirmedContent = ForgeHelper.replace(unconfirmedContent, 
-					oldXml, "");
-			
-			confirmed.setContent(confirmedContent);
-			unconfirmed.setContent(unconfirmedContent);
-			
-			confirmed.save("Confirming new application");
-			unconfirmed.save("Confirming new application");
-			
-			PortalNodeURL url = ConTools.createRenderURL();
-			String adminURL = ConTools.getBaseServerAddress() + 
-				url.toString();
-			
-			try {
-				ProjectsService projectsService = LabsServices.getProjectsService();
+    synchronized boolean acceptByProjectLead(ConDataBean contributor) {
 
-				for (String projectId : toConfirm.getProjectsInfo().keySet()) {
-					Developers developers = projectsService.getProjectDevelopers(projectId);
+        String oldXml = contributor.getXml();
 
-					if (developers != null) {
-						String username = developers.getLeadDeveloper();
+        Set<String> projectIds = ConTools.getLeadProjectIds();
+        Map<String, String> projectsInfo = contributor.getProjectsInfo();
+        for (String projectId : projectsInfo.keySet()) {
+            if (projectIds.contains(projectId)) {
+                if ("0".equals(projectsInfo.get(projectId))) {
+                    projectsInfo.put(projectId, "1");
+                }
+            }
+        }
 
-						if (username != null) {
-							org.jboss.portal.identity.User projectLead = 
-								LabsServices.getPrimatesService().getUser(username);
+        contributor.setProjectsInfo(projectsInfo);
+        String newXml = contributor.getXml();
 
-							// Sending an email to project lead
-							if (projectLead != null && projectLead.getRealEmail() != null) {
-								System.out.println(projectLead.getRealEmail());
-								ForgeHelper.postMail(
-									projectLead.getRealEmail(),
-									messages.getString("adminMailSubject"),
-									getFormattedMessage("adminMailText", 
-											new Object[] { newXml, adminURL }),
-									"labs-admin at jboss.com");
-							}
-						}
-					}
-				}
-			} catch (Exception e) {
-				e.printStackTrace();
-			}
+        try {
+            Node confirmed = cm.getNode(getConfirmedFilePath());
+            String content = confirmed.getContent();
 
-		} catch (Exception e) {
-			e.printStackTrace();
-			return messages.getString("unableToConfirm");
-		} 
+            String newContent = ForgeHelper.replace(content,
+                    oldXml, newXml);
 
-		
-		
-		return null;
-	}
-	
-	/**
-	 * Generates a unique string that can be used as an confirmation code.
-	 * @return A string containing random characters.
-	 */
-	private String generateCode() {
-		Random random =  new Random();
-		return Long.toHexString(random.nextLong()) + 
-			Long.toHexString(random.nextLong());
-	}
-	
-	/**
-	 * Processes the given applications, that is, adds it to the xml file
-	 * as not accepted.
-	 * @param name
-	 * @param email
-	 * @param type
-	 * @param projects
-	 * @param username
-	 * @return An error string or null, if no error occured.
-	 */
-	synchronized String processApplication(String name, String email, String type,
-			List<String> projects, String username, String committer) {
-		
-		if ((!checkString(name)) || (!checkString(email)) ||
-				(!checkString(type)) || (projects.isEmpty()))
-			return messages.getString("notAllFieldsFilledError");
-		
-		String portalName = ConTools.getPortalName();
-		
-		if ((getDesc(portalName).getTakenIds().contains(name)))
-			return messages.getString("nameAlreadyExistsError");
-		
-		// Getting the "since" date, that is, the current date.
-		String since = DateFormat.getDateInstance(DateFormat.SHORT, currentLocale).format(
-				new Date(Calendar.getInstance().getTimeInMillis()));
-			
-		// Getting the confirmation code.
-		String confirmationCode = generateCode();
-		
-		// Creating the new xml entry. Putting the contributor's name in
-		// "accepted", and the code into the "name" field, to easily find
-		// the agreement during confimation.
-		String newAgreement =
-			new ConDataBean(name, email, confirmationCode, 
-					projects, since, type, username, committer).getXml();
-		
-		try {
-			// Values ok, adding application.
-			
-			// Sending the confirmation e-mail.
-			PortalNodeURL url = ConTools.createRenderURL();
-			url.setParameter("confirm", confirmationCode);
-			String confirmationURL = ConTools.getBaseServerAddress() + 
-				url.toString();
-			
-			Node unconfirmed = cm.getNode(getUnconfirmedFilePath());
-			String content = unconfirmed.getContent();
-			
-			String newContent = ForgeHelper.replace(content, 
-				"</"+ConDescriptor.AGREEMENTS_TAG+">",
-				newAgreement
-				+ "</"+ConDescriptor.AGREEMENTS_TAG+">"
-				);
-			
-			unconfirmed.setContent(newContent);
-			unconfirmed.save("Moving application to uncofirmed");
-			
-			ForgeHelper.postMail(email,
-					messages.getString("confirmMailSubject"),
-					getFormattedMessage("confirmMailText", 
-							new Object[] { name, confirmationURL }),
-					"forge-robot at labs.jboss.com");
+            confirmed.setContent(newContent);
+            confirmed.save("New application accepted");
 
-		} catch (Exception e) {
-			e.printStackTrace();
-			return messages.getString("unableToAdd");
-		} 
-		
-		return null;
-	}
-	
-	Map<String, String> getProjectsNameId() {
-		
-		return ProjectsHelper.getProjectsNameId(ConTools.getPortalName());
-	}
+            getDesc(ConTools.getPortalName()).getNotAcceptedByLeadsData().remove(contributor);
 
+            if (!projectsInfo.containsValue("0")) {
+                PortalNodeURL url = ConTools.createRenderURL();
+                String adminURL = ConTools.getBaseServerAddress() +
+                        url.toString();
+
+                // sending email to admin
+                ForgeHelper.postMail(
+                        ForgeHelper.getProperties().getProperty("contribadmin"),
+                        messages.getString("adminMailSubject"),
+                        getFormattedMessage("adminMailText",
+                                new Object[] { newXml, adminURL }),
+                        "labs-admin at jboss.com");
+            }
+
+            org.jboss.portal.identity.User projectLead = ConTools.getUser();
+
+            if (projectLead != null) {
+                String projectLeadEmail = PermissionTools.getUserProfileModule().
+                        getProperty(projectLead, User.INFO_USER_EMAIL_REAL).toString();
+
+                if (projectLeadEmail != null) {
+
+                    // email to project lead
+                    ForgeHelper.postMail(
+                            projectLeadEmail,
+                            messages.getString("acceptedMailSubject"),
+                            getFormattedMessage("acceptedMailTextAdmin",
+                                    new Object[] { contributor.getName(),
+                                            contributor.getEmail(), contributor.getType(),
+                                            contributor.getLogin(), contributor.getProjects() }),
+                            "labs-robot at labs.jboss.com");
+                }
+            }
+
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    /**
+     * Accepts the given application.
+     * @param dataBean Application to accept.
+     * @return True iff accepting was successfull.
+     */
+    synchronized boolean accept(ConDataBean dataBean) {
+        String oldXml = dataBean.getXml();
+
+        dataBean.setAccepted("1");
+        String newXml = dataBean.getXml();
+
+        try {
+            // Values ok, adding application.
+            Node confirmed = cm.getNode(getConfirmedFilePath());
+            String content = confirmed.getContent();
+
+            String newContent = ForgeHelper.replace(content,
+                    oldXml, newXml);
+
+            confirmed.setContent(newContent);
+            confirmed.save("New application accepted");
+
+            getDesc(ConTools.getPortalName()).getNotAcceptedData().remove(dataBean);
+
+            // Posting a notification to the contributor
+            ForgeHelper.postMail(dataBean.getEmail(),
+                    messages.getString("acceptedMailSubject"),
+                    getFormattedMessage("acceptedMailText",
+                            new Object[] { dataBean.getName() }),
+                    "labs-robot at labs.jboss.com");
+
+            // Posting a notification to the con-admin
+            ForgeHelper.postMail(
+                    ForgeHelper.getProperties().getProperty("contribadmin"),
+                    messages.getString("acceptedMailSubject"),
+                    getFormattedMessage("acceptedMailTextAdmin",
+                            new Object[] { dataBean.getName(),
+                                    dataBean.getEmail(), dataBean.getType(),
+                                    dataBean.getLogin(), dataBean.getProjects() }),
+                    "labs-robot at labs.jboss.com");
+
+            if ("1".equals(dataBean.getCommitter())) {
+                ForgeHelper.postMail(
+                        ForgeHelper.getProperties().getProperty("jira"),
+                        messages.getString("committerAccessMailSubject") + " " + dataBean.getName(),
+                        getFormattedMessage("committerAccessMailText",
+                                new Object[] { dataBean.getName(),
+                                        dataBean.getEmail(), dataBean.getType(),
+                                        dataBean.getLogin(), dataBean.getProjects() }),
+                        "labs-robot at labs.jboss.com");
+            }
+
+            return true;
+        } catch (Exception e) {
+            return false;
+        }
+    }
+
+    /**
+     * Deletes the given application.
+     * @param dataBean Application to delete.
+     * @return True iff deleting was successfull.
+     */
+    synchronized boolean delete(ConDataBean dataBean, String comment) {
+        String oldXml = dataBean.getXml();
+
+        try {
+            // Values ok, adding application.
+            Node confirmed;
+            try {
+                confirmed = cm.getNode(getConfirmedFilePath());
+            } catch (ResourceDoesNotExist e) {
+                // Nothing to do here ...
+                throw new RuntimeException(e);
+            }
+            String content = confirmed.getContent();
+
+            String newContent = ForgeHelper.replace(content,
+                    oldXml, "");
+
+            confirmed.setContent(newContent);
+            try {
+                confirmed.save("New application deleted");
+            } catch (SaveException e) {
+                // TODO
+                throw new RuntimeException(e);
+            }
+
+            getDesc(ConTools.getPortalName()).getNotAcceptedData().remove(dataBean);
+
+            return true;
+        } finally {
+            // Sending the "you-are-reject" email no matter exception or not.
+            try {
+                if (comment != null && comment.length() != 0) {
+                    ForgeHelper.postMail(dataBean.getEmail(),
+                            messages.getString("deletedMailSubject"),
+                            getFormattedMessage("deletedMailTextWithComment",
+                                    new Object[] { dataBean.getName(), comment }),
+                            "forge-robot at labs.jboss.com");
+                } else {
+                    ForgeHelper.postMail(dataBean.getEmail(),
+                            messages.getString("deletedMailSubject"),
+                            getFormattedMessage("deletedMailText",
+                                    new Object[] { dataBean.getName() }),
+                            "forge-robot at labs.jboss.com");
+                }
+            } catch (Exception e) {
+                // Nothing to do here. No mail... well.
+            }
+        }
+    }
+
+    /**
+     * Deletes the given application.
+     * @param dataBean Application to delete.
+     * @return True iff deleting was successfull.
+     */
+    synchronized boolean deleteByLead(ConDataBean dataBean, String comment) {
+        String oldXml = dataBean.getXml();
+
+        try {
+            // Values ok, adding application.
+            Node confirmed;
+            try {
+                confirmed = cm.getNode(getConfirmedFilePath());
+            } catch (ResourceDoesNotExist e) {
+                // Nothing to do here ...
+                throw new RuntimeException(e);
+            }
+            String content = confirmed.getContent();
+
+            String newContent = ForgeHelper.replace(content,
+                    oldXml, "");
+
+            confirmed.setContent(newContent);
+            try {
+                confirmed.save("New application deleted");
+            } catch (SaveException e) {
+                // TODO
+                throw new RuntimeException(e);
+            }
+
+            getDesc(ConTools.getPortalName()).getNotAcceptedByLeadsData().remove(dataBean);
+
+            return true;
+        } finally {
+            // Sending the "you-are-reject" email no matter exception or not.
+            try {
+                if (comment != null && comment.length() != 0) {
+                    ForgeHelper.postMail(dataBean.getEmail(),
+                            messages.getString("deletedMailSubject"),
+                            getFormattedMessage("deletedMailTextWithComment",
+                                    new Object[] { dataBean.getName(), comment }),
+                            "forge-robot at labs.jboss.com");
+                } else {
+                    ForgeHelper.postMail(dataBean.getEmail(),
+                            messages.getString("deletedMailSubject"),
+                            getFormattedMessage("deletedMailText",
+                                    new Object[] { dataBean.getName() }),
+                            "forge-robot at labs.jboss.com");
+                }
+            } catch (Exception e) {
+                // Nothing to do here. No mail... well.
+            }
+        }
+    }
+
+    /**
+     * Confirms the given agreement.
+     * @param code Confirmation code.
+     * @return An error string or null, if no error occured.
+     */
+    String confirm(String code) {
+        String unconfirmedXmlFilePath = getUnconfirmedFilePath();
+        String confirmedXmlFilePath = getConfirmedFilePath();
+
+        // Looking for agreement that is to be confirmed.
+        //ElementDescriptor toConfirm;
+        ConDataBean toConfirm;
+        try {
+            ConDescriptor desc = new ConDescriptor(cm, getUnconfirmedFilePath());
+            toConfirm = desc.getUnconfirmedContributor(code);
+
+            /*toConfirm = new ElementsDescriptor(
+                       new InputSource(cm.getNode(
+                               unconfirmedXmlFilePath).getContentInputStream()),
+                       XmlInputFactory.getContentReadingInstance(cm),
+                       ConDescriptor.AGREEMENT_TAG,
+                       new PropertiesHandlerDefault()).getElementWithId(code);*/
+
+        } catch (Exception e) {
+            return messages.getString("unableToConfirm");
+        }
+
+        if (toConfirm == null)
+            return messages.getString("confirmationCodeInvalid");
+
+        // Generating xml representations of the agreement - before
+        // and after confirmation.
+        String oldXml = toConfirm.getXml();
+
+        String newXml = new ConDataBean("0",
+                toConfirm.getEmail(),
+                toConfirm.getAccepted(),
+                toConfirm.getProjectsInfo(),
+                toConfirm.getSince(),
+                toConfirm.getType(),
+                toConfirm.getLogin(),
+                toConfirm.getCommitter()).getXml();
+
+        // Writing changes to xml files.
+        try {
+            Node confirmed = cm.getNode(confirmedXmlFilePath);
+            Node unconfirmed = cm.getNode(unconfirmedXmlFilePath);
+
+            String confirmedContent = confirmed.getContent();
+            String unconfirmedContent = unconfirmed.getContent();
+
+            confirmedContent = ForgeHelper.replace(confirmedContent,
+                    "</"+ConDescriptor.AGREEMENTS_TAG+">",
+                    newXml
+                            + "</"+ConDescriptor.AGREEMENTS_TAG+">"
+            );
+            unconfirmedContent = ForgeHelper.replace(unconfirmedContent,
+                    oldXml, "");
+
+            confirmed.setContent(confirmedContent);
+            unconfirmed.setContent(unconfirmedContent);
+
+            confirmed.save("Confirming new application");
+            unconfirmed.save("Confirming new application");
+
+            PortalNodeURL url = ConTools.createRenderURL();
+            String adminURL = ConTools.getBaseServerAddress() +
+                    url.toString();
+
+            try {
+                ProjectsService projectsService = LabsServices.getProjectsService();
+
+                for (String projectId : toConfirm.getProjectsInfo().keySet()) {
+                    Developers developers = projectsService.getProjectDevelopers(projectId);
+
+                    if (developers != null) {
+                        String username = developers.getLeadDeveloper();
+
+                        if (username != null) {
+                            org.jboss.portal.identity.User projectLead =
+                                    LabsServices.getPrimatesService().getUser(username);
+
+                            // Sending an email to project lead
+                            if (projectLead != null) {
+                                String realEmail = PermissionTools.getUserProfileModule().
+                                        getProperty(projectLead, User.INFO_USER_EMAIL_REAL).
+                                        toString();
+                                if (realEmail != null) {
+                                    ForgeHelper.postMail(
+                                        realEmail,
+                                        messages.getString("adminMailSubject"),
+                                        getFormattedMessage("adminMailText",
+                                                new Object[] { newXml, adminURL }),
+                                        "labs-admin at jboss.com");
+                                }
+                            }
+                        }
+                    }
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            return messages.getString("unableToConfirm");
+        }
+
+
+
+        return null;
+    }
+
+    /**
+     * Generates a unique string that can be used as an confirmation code.
+     * @return A string containing random characters.
+     */
+    private String generateCode() {
+        Random random =  new Random();
+        return Long.toHexString(random.nextLong()) +
+                Long.toHexString(random.nextLong());
+    }
+
+    /**
+     * Processes the given applications, that is, adds it to the xml file
+     * as not accepted.
+     * @param name
+     * @param email
+     * @param type
+     * @param projects
+     * @param username
+     * @return An error string or null, if no error occured.
+     */
+    synchronized String processApplication(String name, String email, String type,
+                                           List<String> projects, String username, String committer) {
+
+        if ((!checkString(name)) || (!checkString(email)) ||
+                (!checkString(type)) || (projects.isEmpty()))
+            return messages.getString("notAllFieldsFilledError");
+
+        String portalName = ConTools.getPortalName();
+
+        if ((getDesc(portalName).getTakenIds().contains(name)))
+            return messages.getString("nameAlreadyExistsError");
+
+        // Getting the "since" date, that is, the current date.
+        String since = DateFormat.getDateInstance(DateFormat.SHORT, currentLocale).format(
+                new Date(Calendar.getInstance().getTimeInMillis()));
+
+        // Getting the confirmation code.
+        String confirmationCode = generateCode();
+
+        // Creating the new xml entry. Putting the contributor's name in
+        // "accepted", and the code into the "name" field, to easily find
+        // the agreement during confimation.
+        String newAgreement =
+                new ConDataBean(name, email, confirmationCode,
+                        projects, since, type, username, committer).getXml();
+
+        try {
+            // Values ok, adding application.
+
+            // Sending the confirmation e-mail.
+            PortalNodeURL url = ConTools.createRenderURL();
+            url.setParameter("confirm", confirmationCode);
+            String confirmationURL = ConTools.getBaseServerAddress() +
+                    url.toString();
+
+            Node unconfirmed = cm.getNode(getUnconfirmedFilePath());
+            String content = unconfirmed.getContent();
+
+            String newContent = ForgeHelper.replace(content,
+                    "</"+ConDescriptor.AGREEMENTS_TAG+">",
+                    newAgreement
+                            + "</"+ConDescriptor.AGREEMENTS_TAG+">"
+            );
+
+            unconfirmed.setContent(newContent);
+            unconfirmed.save("Moving application to uncofirmed");
+
+            ForgeHelper.postMail(email,
+                    messages.getString("confirmMailSubject"),
+                    getFormattedMessage("confirmMailText",
+                            new Object[] { name, confirmationURL }),
+                    "forge-robot at labs.jboss.com");
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            return messages.getString("unableToAdd");
+        }
+
+        return null;
+    }
+
+    Map<String, String> getProjectsNameId() {
+
+        return ProjectsHelper.getProjectsNameId(ConTools.getPortalName());
+    }
+
 }
\ No newline at end of file

Modified: labs/jbosslabs/trunk/portal-extensions-2.6/forge-feeds/forge-feeds.iml
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-2.6/forge-feeds/forge-feeds.iml	2007-01-16 20:20:41 UTC (rev 8876)
+++ labs/jbosslabs/trunk/portal-extensions-2.6/forge-feeds/forge-feeds.iml	2007-01-16 23:08:22 UTC (rev 8877)
@@ -16,7 +16,6 @@
     <orderEntry type="module" module-name="shotoku-base" />
     <orderEntry type="module" module-name="shotoku-feeds" />
     <orderEntry type="library" name="velocity" level="application" />
-    <orderEntry type="module" module-name="forge-links" />
     <orderEntryProperties />
   </component>
 </module>

Modified: labs/jbosslabs/trunk/portal-extensions-2.6/forge-file-access/src/java/org/jboss/forge/fileaccess/DownloadsFileAccessMonitor.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-2.6/forge-file-access/src/java/org/jboss/forge/fileaccess/DownloadsFileAccessMonitor.java	2007-01-16 20:20:41 UTC (rev 8876)
+++ labs/jbosslabs/trunk/portal-extensions-2.6/forge-file-access/src/java/org/jboss/forge/fileaccess/DownloadsFileAccessMonitor.java	2007-01-16 23:08:22 UTC (rev 8877)
@@ -5,6 +5,7 @@
 import org.jboss.shotoku.ContentManager;
 import org.jboss.forge.common.projects.DownloadCountersDescriptor;
 import org.jboss.forge.common.projects.DownloadCountersWatcher;
+import org.jboss.forge.common.projects.DownloadCounterTools;
 import org.jboss.forge.common.ForgeHelper;
 
 import javax.servlet.http.HttpServletResponse;
@@ -25,21 +26,9 @@
 
             // Trying to get DownloadCountersDescriptor object from the
             // cache
-            DownloadCountersDescriptor downloadCounters = (DownloadCountersDescriptor) ForgeHelper
-                    .getForgeManagement().getFromCache(portalName,
-                    DownloadCountersDescriptor.class.getName());
-
-            // Checking if there was DownloadCountersDescriptor object
-            // in cache.
-            // If not creating new one.
-            if (downloadCounters == null)
-                downloadCounters = (DownloadCountersDescriptor) ForgeHelper
-                        .getForgeManagement().addNodeWatcher(
-                        portalName,
-                        DownloadCountersDescriptor.class
-                                .getName(),
-                        new DownloadCountersWatcher(cm));
-
+            DownloadCountersDescriptor downloadCounters =
+                    DownloadCounterTools.getDesc(portalName);
+            
             // Sending the request link to the DownloadCounter to
             // increment
             // counter for this link if it's one of the tracked links.

Modified: labs/jbosslabs/trunk/portal-extensions-2.6/forge-file-access/src/java/org/jboss/forge/fileaccess/portlet/DownloadCounterPortlet.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-2.6/forge-file-access/src/java/org/jboss/forge/fileaccess/portlet/DownloadCounterPortlet.java	2007-01-16 20:20:41 UTC (rev 8876)
+++ labs/jbosslabs/trunk/portal-extensions-2.6/forge-file-access/src/java/org/jboss/forge/fileaccess/portlet/DownloadCounterPortlet.java	2007-01-16 23:08:22 UTC (rev 8877)
@@ -68,7 +68,7 @@
 		DelegateContext context = null;
 		try {
 			// Getting context for view of download counters tracked for project.
-			context = DownloadCounterTools.getContext(portalName,projectId,contentManager);
+			context = DownloadCounterTools.getContext(portalName,projectId);
 			//	Adding content context to request for JSP file.
 			request.setAttribute(PortalJsp.CTX_REQUEST, context);
 		} catch (Exception e) {

Modified: labs/jbosslabs/trunk/portal-extensions-2.6/forge-login/maven.xml
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-2.6/forge-login/maven.xml	2007-01-16 20:20:41 UTC (rev 8876)
+++ labs/jbosslabs/trunk/portal-extensions-2.6/forge-login/maven.xml	2007-01-16 23:08:22 UTC (rev 8877)
@@ -14,15 +14,15 @@
     </goal>
 	
     <goal name="build">
-    	<attainGoal name="jar" />
+    	<!--<attainGoal name="jar" />-->
     </goal>
     
     <goal name="deploy">
-	<ant:copy todir="${local.deploy.dir}" flatten="true">
+	<!--<ant:copy todir="${local.deploy.dir}" flatten="true">
 	    	<ant:fileset dir=".">
 				<ant:filename name="target/*.jar" />
 	    	</ant:fileset>
-	</ant:copy>
+	</ant:copy>-->
     </goal> 
     
 </project>

Modified: labs/jbosslabs/trunk/portal-extensions-2.6/forge-login/project.properties
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-2.6/forge-login/project.properties	2007-01-16 20:20:41 UTC (rev 8876)
+++ labs/jbosslabs/trunk/portal-extensions-2.6/forge-login/project.properties	2007-01-16 23:08:22 UTC (rev 8877)
@@ -3,3 +3,5 @@
 maven.war.src=${basedir}/src/web
 maven.ejb.includes=**/ejb3/*.class,**/autologin/LoginMemoryService.class
 maven.jar.excludes=**/ejb3/*.class
+
+maven.final.name=${pom.artifactId}

Modified: labs/jbosslabs/trunk/portal-extensions-2.6/jbosswiki/maven.xml
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-2.6/jbosswiki/maven.xml	2007-01-16 20:20:41 UTC (rev 8876)
+++ labs/jbosslabs/trunk/portal-extensions-2.6/jbosswiki/maven.xml	2007-01-16 23:08:22 UTC (rev 8877)
@@ -9,7 +9,7 @@
 	-->
 	
 	<goal name="build">
-		<attainGoal name="wiki:build" />
+		<!--<attainGoal name="wiki:build" />-->
 	</goal>
 
  	<goal name="prj-install">

Modified: labs/jbosslabs/trunk/portal-extensions-2.6/polls/src/java/org/jboss/forge/polls/PollTools.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-2.6/polls/src/java/org/jboss/forge/polls/PollTools.java	2007-01-16 20:20:41 UTC (rev 8876)
+++ labs/jbosslabs/trunk/portal-extensions-2.6/polls/src/java/org/jboss/forge/polls/PollTools.java	2007-01-16 23:08:22 UTC (rev 8877)
@@ -41,6 +41,8 @@
 import org.jboss.portal.core.servlet.jsp.taglib.context.DelegateContext;
 import org.jboss.portlet.JBossRenderResponse;
 import org.jboss.shotoku.ContentManager;
+import org.jboss.shotoku.tools.Pair;
+import org.jboss.shotoku.aop.CacheItem;
 
 /**
  * This class is used for creating context for PollsPortlet and is
@@ -157,32 +159,19 @@
 		return portalName+File.separator+ProjectsHelper.MEMBERS_DIR+File.separator+projectId+
 				File.separator+ProjectsHelper.POLL_DESC;
 	}
-	
-	/**
+
+    private static @CacheItem PollsCacheItem pci;
+
+    /**
 	 * This method returns PollsDescriptor received from Cache. If there is no object
 	 * in the cache it creates new one, puts it into Cache and returns the object.
 	 * @param portalName
 	 * 			Name of the portal.
-	 * @param contentManager
-	 * 			ContentManager object used for access to cms.
 	 * @return
 	 * 			PollsDescriptor object.
 	 */
-	public static PollsDescriptor getDesc(final String portalName,ContentManager contentManager) {
-		
-		// Trying to get descriptor from the Cache.
-		PollsDescriptor desc = (PollsDescriptor) ForgeHelper
-				.getForgeManagement().getFromCache(portalName,
-						PollsDescriptor.class.getName());
-		
-		// If descriptor doesn't exist - create new one.
-		if (desc==null) {
-			desc = (PollsDescriptor) ForgeHelper.getForgeManagement()
-			.addNodeWatcher(portalName,	
-					PollsDescriptor.class.getName(),
-					new PollsWatcher(contentManager));
-		}
-		return desc;
+	public static PollsDescriptor getDesc(final String portalName) {
+		return pci.get(new Pair<String, String>(portalName, PollsDescriptor.class.getName()));
 	}
 	
 	/**

Added: labs/jbosslabs/trunk/portal-extensions-2.6/polls/src/java/org/jboss/forge/polls/PollsCacheItem.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-2.6/polls/src/java/org/jboss/forge/polls/PollsCacheItem.java	2007-01-16 20:20:41 UTC (rev 8876)
+++ labs/jbosslabs/trunk/portal-extensions-2.6/polls/src/java/org/jboss/forge/polls/PollsCacheItem.java	2007-01-16 23:08:22 UTC (rev 8877)
@@ -0,0 +1,46 @@
+package org.jboss.forge.polls;
+
+import org.jboss.shotoku.tools.Pair;
+import org.jboss.shotoku.cache.ShotokuResourceWatcher;
+import org.jboss.shotoku.cache.ChangeType;
+import org.jboss.forge.common.service.ResourceWatcher;
+import org.jboss.forge.common.projects.ProjectsHelper;
+
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:adamw at aster.pl">Adam Warski</a>
+ */
+public class PollsCacheItem extends ShotokuResourceWatcher<Pair<String, String>, PollsDescriptor> {
+    protected void update(Pair<String, String> key, PollsDescriptor currentObject, Map<String, ChangeType> changes) {
+        put(key, getDescriptor(key));
+    }
+
+    public PollsDescriptor init(Pair<String, String> key) {
+        return getDescriptor(key);
+    }
+
+    /**
+     * Method constructs the PollsDescriptor object registers it
+     * with the ResourceWatcher as well as all found PollDescriptors.
+     *
+     * @return PollsDescriptor object.
+     */
+    private PollsDescriptor getDescriptor (Pair<String, String> key) {
+        PollsDescriptor descriptor =
+                new PollsDescriptor(key.getFirst(), getContentManager(key));
+
+        // Getting the project ids names where are poll descriptors.
+        Set<String> projects = ProjectsHelper.getProjectIds(key.getFirst());
+
+        // Adding found project poll descriptors to the ResourceWatcher to watch
+        // for their changes.
+        resetWatchedPaths(key);
+        for (String projectId : projects) {
+            addWatchedPath(key, PollTools.getProjectXmlPath(key.getFirst(), projectId));
+        }
+        return descriptor;
+    }
+
+}

Modified: labs/jbosslabs/trunk/portal-extensions-2.6/polls/src/java/org/jboss/forge/polls/PollsPortlet.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-2.6/polls/src/java/org/jboss/forge/polls/PollsPortlet.java	2007-01-16 20:20:41 UTC (rev 8876)
+++ labs/jbosslabs/trunk/portal-extensions-2.6/polls/src/java/org/jboss/forge/polls/PollsPortlet.java	2007-01-16 23:08:22 UTC (rev 8877)
@@ -97,7 +97,7 @@
 		// It is used if an instance have defined preference in instance descriptor.
 		Object modeFromPref = request.getPreferences().getValue("random",null);
 
-		PollTools.getDesc(portalName, contentManager);
+		PollTools.getDesc(portalName);
 		
 		try {
 			if (modeFromPref!=null && !modeFromPref.equals("") &&  

Deleted: labs/jbosslabs/trunk/portal-extensions-2.6/polls/src/java/org/jboss/forge/polls/PollsWatcher.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-2.6/polls/src/java/org/jboss/forge/polls/PollsWatcher.java	2007-01-16 20:20:41 UTC (rev 8876)
+++ labs/jbosslabs/trunk/portal-extensions-2.6/polls/src/java/org/jboss/forge/polls/PollsWatcher.java	2007-01-16 23:08:22 UTC (rev 8877)
@@ -1,125 +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.polls;
-
-import java.util.Set;
-
-import org.jboss.forge.common.service.NodeWatcher;
-import org.jboss.forge.common.service.ResourceWatcher;
-import org.jboss.shotoku.ContentManager;
-
-/**
- * This class which implements NodeWatcher interface is looking after changes
- * in xml descriptors connected to Polls and executes apropriate methods according
- * to the noticed change.
- * @author Ryszard Kozmik
- *
- */
-public class PollsWatcher implements NodeWatcher{
-
-	ContentManager contentManager;
-	ResourceWatcher rw;
-
-	/**
-	 * This Collection contains id names of projects which contain poll.xml descriptors.
-	 */
-	Set<String> pollDescriptors;
-	
-	/**
-	 * Simple constructor saving ContentManager given in parameter
-	 * <code>conentManager</code>
-	 * @param contentManager
-	 */
-	public PollsWatcher (ContentManager contentManager) {
-		this.contentManager = contentManager;
-	}
-	
-	
-	public Object init(String portalName) {
-		return getDescriptor(portalName);
-	}
-	
-	/**
-	 * Method constructs the PollsDescriptor object registers it
-	 * with the ResourceWatcher as well as all found PollDescriptors.
-	 * 
-	 * @param portalName
-	 * @return PollsDescriptor object.
-	 */
-	private Object getDescriptor (String portalName) {
-		PollsDescriptor descriptor = 
-			new PollsDescriptor(portalName, contentManager);
-		rw = new ResourceWatcher(contentManager);
-		
-		// Getting the project ids names where are poll descriptors.
-		pollDescriptors = descriptor.getPollDescriptors(portalName).keySet();
-		
-		// Adding found project poll descriptors to the ResourceWatcher to watch
-		// for their changes.
-		for (String id:pollDescriptors) {
-			rw.watchResource(PollTools.getProjectXmlPath(portalName,id));
-		}
-		return descriptor;
-	}
-
-	/**
-	 * Method updates main polls descriptor if there is such a need.
-	 * If the object is changed the method returns new object if not returns null.
-	 */
-	public Object nodeUpdate(String portalName, Object currentValue) {
-		
-		boolean resources = rw.checkResources();
-		boolean descriptors = false;
-		if (currentValue!=null) descriptors = checkForNewResources((PollsDescriptor)currentValue,portalName);
-
-		if (currentValue==null || resources || !descriptors){
-			
-			return getDescriptor(portalName);
-			
-		} else if (((PollsDescriptor)currentValue).hasChanged()){
-
-			// There was some change on object connected to main polls xml descriptor
-			// so we must synchronize the object with the file.
-			PollsDescriptor descriptor = (PollsDescriptor)currentValue;
-			//descriptor.synchronizeWithFile(portalName);
-			return null;
-		}
-
-		return null;
-	}
-	
-	/**
-	 * This method checks whether someone hasn't added new poll.xml descriptor to his/her project dir.
-	 * @param desc
-	 * 		Main PollsDescriptor object.
-	 * @param portalName
-	 * 		Name of the portal.
-	 * @return
-	 * 		False if someone added poll.xml descriptor, true if not.
-	 */
-	private boolean checkForNewResources (PollsDescriptor desc, String portalName) {
-		return pollDescriptors.containsAll(desc.getPollDescriptors(portalName).keySet());
-	}
-
-}

Added: labs/jbosslabs/trunk/portal-extensions-2.6/primates/src/java/org/jbosslabs/portlets/primates/PrimatesCacheItem.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-2.6/primates/src/java/org/jbosslabs/portlets/primates/PrimatesCacheItem.java	2007-01-16 20:20:41 UTC (rev 8876)
+++ labs/jbosslabs/trunk/portal-extensions-2.6/primates/src/java/org/jbosslabs/portlets/primates/PrimatesCacheItem.java	2007-01-16 23:08:22 UTC (rev 8877)
@@ -0,0 +1,22 @@
+package org.jbosslabs.portlets.primates;
+
+import org.jboss.shotoku.cache.ShotokuResourceWatcher;
+import org.jboss.shotoku.cache.ChangeType;
+import org.jboss.shotoku.tools.Pair;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:adamw at aster.pl">Adam Warski</a>
+ */
+public class PrimatesCacheItem extends ShotokuResourceWatcher<Pair<String, String>, PrimatesDescriptor> {
+    protected void update(Pair<String, String> key, PrimatesDescriptor currentObject, Map<String, ChangeType> changes) {
+        put(key, new PrimatesDescriptor(key.getFirst(), getContentManager(key)));
+    }
+
+    public PrimatesDescriptor init(Pair<String, String> key) {
+        PrimatesDescriptor desc = new PrimatesDescriptor(key.getFirst(), getContentManager(key));
+		addWatchedPath(key, PrimatesTools.getXmlCmPath(key.getFirst()));
+		return desc;
+    }
+}

Deleted: labs/jbosslabs/trunk/portal-extensions-2.6/primates/src/java/org/jbosslabs/portlets/primates/PrimatesNodeWatcher.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-2.6/primates/src/java/org/jbosslabs/portlets/primates/PrimatesNodeWatcher.java	2007-01-16 20:20:41 UTC (rev 8876)
+++ labs/jbosslabs/trunk/portal-extensions-2.6/primates/src/java/org/jbosslabs/portlets/primates/PrimatesNodeWatcher.java	2007-01-16 23:08:22 UTC (rev 8877)
@@ -1,60 +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.jbosslabs.portlets.primates;
-
-/**
- * @author <a href="mailto:ryszard.kozmik at jboss.com">Ryszard Kozmik</a>
- */
-
-import org.jboss.shotoku.ContentManager;
-import org.jboss.forge.common.service.NodeWatcher;
-import org.jboss.forge.common.service.ResourceWatcher;
-
-public class PrimatesNodeWatcher implements NodeWatcher {
-	private ResourceWatcher rw;
-	private ContentManager cm;
-	
-	public PrimatesNodeWatcher(ContentManager cm) {
-		this.cm = cm;
-	}
-	
-	private PrimatesDescriptor getDesc(String portalName) {
-		PrimatesDescriptor desc = new PrimatesDescriptor(portalName, cm);
-		
-		rw = new ResourceWatcher(cm);
-		rw.watchResource(PrimatesTools.getXmlCmPath(portalName));
-		
-		return desc;
-	}
-	
-	public Object init(String portalName) {
-		return getDesc(portalName);
-	}
-
-	public Object nodeUpdate(String portalName, Object currentValue) {
-		if ((currentValue == null) || (rw.checkResources()))
-			return getDesc(portalName);
-		else
-			return null;
-	}
-}

Modified: labs/jbosslabs/trunk/portal-extensions-2.6/primates/src/java/org/jbosslabs/portlets/primates/PrimatesTools.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-2.6/primates/src/java/org/jbosslabs/portlets/primates/PrimatesTools.java	2007-01-16 20:20:41 UTC (rev 8876)
+++ labs/jbosslabs/trunk/portal-extensions-2.6/primates/src/java/org/jbosslabs/portlets/primates/PrimatesTools.java	2007-01-16 23:08:22 UTC (rev 8877)
@@ -25,11 +25,12 @@
 import org.jboss.forge.common.ForgeHelper;
 import java.io.File;
 
-import org.jboss.portal.core.servlet.jsp.taglib.context.DelegateContext;
 import org.jboss.shotoku.ContentManager;
+import org.jboss.shotoku.aop.CacheItem;
 import org.jboss.shotoku.tools.Tools;
+import org.jboss.shotoku.tools.Pair;
 
-/**
+ /**
  * @author adamw Common constants and functions.
  * @author <a href="mailto:ryszard.kozmik at jboss.com">Ryszard Kozmik</a>
  */
@@ -54,12 +55,6 @@
 
 	public static final String RANDOM_VIEW = "random";
 
-	private static ContentManager cm;
-
-	static {
-		cm = ForgeHelper.getContentManager("");
-	}
-
 	/**
 	 * Method returns path to XML file.
 	 * 
@@ -110,19 +105,12 @@
 				+ BIOS_DIR;
 	}
 
-	public static synchronized PrimatesDescriptor getDesc(
-			final String portalName) {
-		PrimatesDescriptor desc = (PrimatesDescriptor) ForgeHelper
-				.getForgeManagement().getFromCache(portalName,
-						PrimatesDescriptor.class.getName());
+    private static @CacheItem PrimatesCacheItem pci;
 
-		if (desc == null)
-			desc = (PrimatesDescriptor) ForgeHelper.getForgeManagement()
-					.addNodeWatcher(portalName,
-							PrimatesDescriptor.class.getName(),
-							new PrimatesNodeWatcher(cm));
-
-		return desc;
+    public static synchronized PrimatesDescriptor getDesc(
+			final String portalName) {
+        return pci.get(new Pair<String, String>(portalName,
+                PrimatesDescriptor.class.getName()));
 	}
 
 	private static String NO_PROJECT_PARAM = "&noproject=true";




More information about the jboss-svn-commits mailing list