[jboss-svn-commits] JBL Code SVN: r22875 - in labs/jbosslabs/labs-3.0-build/integration: cs-widgets and 14 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Sep 18 09:05:12 EDT 2008


Author: unibrew
Date: 2008-09-18 09:05:12 -0400 (Thu, 18 Sep 2008)
New Revision: 22875

Added:
   labs/jbosslabs/labs-3.0-build/integration/cs-widgets/
   labs/jbosslabs/labs-3.0-build/integration/cs-widgets/.classpath
   labs/jbosslabs/labs-3.0-build/integration/cs-widgets/.project
   labs/jbosslabs/labs-3.0-build/integration/cs-widgets/.settings/
   labs/jbosslabs/labs-3.0-build/integration/cs-widgets/.settings/org.eclipse.jdt.core.prefs
   labs/jbosslabs/labs-3.0-build/integration/cs-widgets/build.xml
   labs/jbosslabs/labs-3.0-build/integration/cs-widgets/pom.xml
   labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/
   labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/
   labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/java/
   labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/java/org/
   labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/java/org/jboss/
   labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/java/org/jboss/labs/
   labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/java/org/jboss/labs/clearspace/
   labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/java/org/jboss/labs/clearspace/utils/
   labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/java/org/jboss/labs/clearspace/utils/Dev.java
   labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/java/org/jboss/labs/clearspace/utils/DevSpotlightHelper.java
   labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/java/org/jboss/labs/clearspace/widget/
   labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/java/org/jboss/labs/clearspace/widget/DevSpotlightWidget.java
   labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/resources/
   labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/resources/META-INF/
   labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/resources/META-INF/MANIFEST.MF
   labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/resources/plugin.xml
   labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/resources/resources/
   labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/resources/resources/devspotlight.ftl
   labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/test/
   labs/jbosslabs/labs-3.0-build/integration/cs-widgets/target/
Modified:
   labs/jbosslabs/labs-3.0-build/integration/pom.xml
Log:
Yet another Developer Spotlight implementation, this time it's inside Clearspace Widget.

Added: labs/jbosslabs/labs-3.0-build/integration/cs-widgets/.classpath
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-widgets/.classpath	                        (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-widgets/.classpath	2008-09-18 13:05:12 UTC (rev 22875)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/main/java"/>
+	<classpathentry excluding="**/*.java" kind="src" path="src/main/resources"/>
+	<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="var" path="M2_REPO/com/geronimo/geronimo-ws-metadata/1.0/geronimo-ws-metadata-1.0.jar"/>
+	<classpathentry kind="var" path="M2_REPO/com/google/code/guice/guice/1.0/guice-1.0.jar"/>
+	<classpathentry kind="var" path="M2_REPO/com/jivesoftware/clearspace/2.5.0.rc/clearspace-2.5.0.rc.jar"/>
+	<classpathentry kind="var" path="M2_REPO/com/sun/jaxb-api/1.0/jaxb-api-1.0.jar"/>
+	<classpathentry kind="var" path="M2_REPO/com/sun/sun-jaxws-api/1.0/sun-jaxws-api-1.0.jar"/>
+	<classpathentry kind="var" path="M2_REPO/com/tangosol/tangosol/1.0/tangosol-1.0.jar"/>
+	<classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
+	<classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/acegisecurity/acegi-security/1.0.6/acegi-security-1.0.6.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/springframework/spring-core/1.2.9/spring-core-1.2.9.jar"/>
+	<classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging/1.0.4/commons-logging-1.0.4.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/springframework/spring-remoting/1.2.9/spring-remoting-1.2.9.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/springframework/spring-aop/1.2.9/spring-aop-1.2.9.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/springframework/spring-beans/1.2.9/spring-beans-1.2.9.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/springframework/spring-context/1.2.9/spring-context-1.2.9.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/springframework/spring-jdbc/1.2.9/spring-jdbc-1.2.9.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/springframework/spring-dao/1.2.9/spring-dao-1.2.9.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/springframework/spring-support/1.2.9/spring-support-1.2.9.jar"/>
+	<classpathentry kind="var" path="M2_REPO/commons-lang/commons-lang/2.1/commons-lang-2.1.jar"/>
+	<classpathentry kind="var" path="M2_REPO/commons-codec/commons-codec/1.3/commons-codec-1.3.jar"/>
+	<classpathentry kind="var" path="M2_REPO/oro/oro/2.0.8/oro-2.0.8.jar"/>
+	<classpathentry kind="var" path="M2_REPO/commons-collections/commons-collections/3.1/commons-collections-3.1.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/codehaus/jra/1.0/jra-1.0.jar"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

Added: labs/jbosslabs/labs-3.0-build/integration/cs-widgets/.project
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-widgets/.project	                        (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-widgets/.project	2008-09-18 13:05:12 UTC (rev 22875)
@@ -0,0 +1,14 @@
+<projectDescription>
+  <name>cs-widgets</name>
+  <comment>Parent POM for all JBoss Projects. Provides default project build
+    configuration.</comment>
+  <projects/>
+  <buildSpec>
+    <buildCommand>
+      <name>org.eclipse.jdt.core.javabuilder</name>
+    </buildCommand>
+  </buildSpec>
+  <natures>
+    <nature>org.eclipse.jdt.core.javanature</nature>
+  </natures>
+</projectDescription>
\ No newline at end of file

Added: labs/jbosslabs/labs-3.0-build/integration/cs-widgets/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-widgets/.settings/org.eclipse.jdt.core.prefs	                        (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-widgets/.settings/org.eclipse.jdt.core.prefs	2008-09-18 13:05:12 UTC (rev 22875)
@@ -0,0 +1,5 @@
+#Mon Sep 08 13:03:09 CEST 2008
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5

Added: labs/jbosslabs/labs-3.0-build/integration/cs-widgets/build.xml
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-widgets/build.xml	                        (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-widgets/build.xml	2008-09-18 13:05:12 UTC (rev 22875)
@@ -0,0 +1,67 @@
+<?xml version="1.0"?>
+
+<!-- 
+	Targets to create plugin projects, build and build plugins.
+-->
+<project name="SimpleExamples" default="build.plugins" basedir=".">
+
+    <!-- ======================================================================================= -->
+    <!-- Properties ============================================================================ -->
+    <!-- ======================================================================================= -->
+
+	<!-- Change this value to your plugin's name. -->
+	<property name="plugin.name" value="simpleexamples"/>
+	<property name="plugin.jar.name" value="${plugin.name}.jar"/>	
+	
+	<!-- Assumes that this file is in the plugins/plugins/<my_plugin> directory. 
+		Change as needed. -->
+	<property name="jiveHome" value="/Users/tomek/forge/jive"/>
+	<property name="plugins.dir" value="${jiveHome}/plugins" />
+
+	<!-- Assumes that this file is in the plugins/plugins/<my_plugin> directory. 
+		Change as needed. -->
+	<property name="server.home.dir" value="/Users/tomek/jboss/cs"/>
+	<property name="clearspace.lib.dir" value="${server.home.dir}/webapps/ROOT.war/WEB-INF/lib"/>
+
+	<!-- ======================================================================================= -->
+    <!-- Targets =============================================================================== -->
+    <!-- ======================================================================================= -->
+
+	<target name="create.plugin.dirs" description="Creates the subdirectories of a plugin project.">
+		<mkdir dir="${basedir}/resources" />
+		<mkdir dir="${basedir}/src" />
+	</target>
+
+    <target name="build.plugins" depends="clean.plugins" description="Builds all plugins in source directory">
+    	<mkdir dir="classes"/>
+    	<javac srcdir="${basedir}/src"
+    	         destdir="${basedir}/classes"
+    	         debug="on"
+    	         source="1.5"
+		>
+    		<!-- Classpath to build the example plugin. Change as needed. -->
+			<classpath>
+				<fileset dir="${clearspace.lib.dir}">
+			        <include name="**/*.jar"/>
+				</fileset>
+				<fileset dir="${server.home.dir}/lib">
+					<include name="servlet-api.jar"></include>
+				</fileset>
+			</classpath>
+  		</javac>
+    	<jar destfile="${plugin.jar.name}"
+    		basedir="${basedir}"
+			includes="classes/** resources/** plugin.xml schema.xml xwork-plugin.xml *.png"
+		/>
+    </target>
+	
+	<target name="deploy.plugins" description="Copies the plugin JAR to the jiveHome/plugins directory.">
+		<copy file="${basedir}/${plugin.jar.name}" tofile="${plugins.dir}/${plugin.jar.name}"/>
+	</target>
+
+	<target name="clean.plugins" description="Deletes generated plugin output, including classes directory in plugin source">
+		<delete dir="classes" />
+        <delete file="${plugin.jar.name}" />
+    </target>
+
+</project>

Added: labs/jbosslabs/labs-3.0-build/integration/cs-widgets/pom.xml
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-widgets/pom.xml	                        (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-widgets/pom.xml	2008-09-18 13:05:12 UTC (rev 22875)
@@ -0,0 +1,90 @@
+<?xml version="1.0"?>
+<project>
+	<parent>
+		<artifactId>integration</artifactId>
+		<groupId>org.jboss.labs</groupId>
+		<version>1.0-SNAPSHOT</version>
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>org.jboss.labs</groupId>
+	<artifactId>cs-widgets</artifactId>
+	<name>cs-widgets</name>
+	<version>1.0-SNAPSHOT</version>
+	<url>http://maven.apache.org</url>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>3.8.1</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>com.jivesoftware</groupId>
+			<artifactId>clearspace</artifactId>
+			<version>2.5.0.rc</version>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.acegisecurity</groupId>
+			<artifactId>acegi-security</artifactId>
+			<version>1.0.6</version>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>com.tangosol</groupId>
+			<artifactId>tangosol</artifactId>
+			<version>1.0</version>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>com.sun</groupId>
+			<artifactId>sun-jaxws-api</artifactId>
+			<version>1.0</version>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>com.sun</groupId>
+			<artifactId>jaxb-api</artifactId>
+			<version>1.0</version>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>com.geronimo</groupId>
+			<artifactId>geronimo-ws-metadata</artifactId>
+			<version>1.0</version>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.codehaus</groupId>
+			<artifactId>jra</artifactId>
+			<version>1.0</version>
+			<scope>provided</scope>
+		</dependency>
+	</dependencies>
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.jboss.labs</groupId>
+				<artifactId>maven-labs-plugin</artifactId>
+				<executions>
+					<execution>
+						<id>install</id>
+						<phase>install</phase>
+						<goals>
+							<goal>cs-setup</goal>
+						</goals>
+						<configuration>
+							<!-- LabsClearspaceSetupMojo configuration -->
+							<csSetupable>true</csSetupable>
+							<csDeploy>false</csDeploy>
+							<destinationFolder>JIVE_HOME/plugins</destinationFolder>
+							<resourcesFolder>target</resourcesFolder>
+							<labsDeploy>false</labsDeploy>
+							<includes>.+SNAPSHOT.jar</includes>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+		</plugins>
+	</build>
+</project>

Added: labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/java/org/jboss/labs/clearspace/utils/Dev.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/java/org/jboss/labs/clearspace/utils/Dev.java	                        (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/java/org/jboss/labs/clearspace/utils/Dev.java	2008-09-18 13:05:12 UTC (rev 22875)
@@ -0,0 +1,158 @@
+/*
+* JBoss Labs. http://labs.jboss.com/jbosslabs
+*
+* Copyright © 2008  Red Hat Middleware, LLC. All rights reserved.
+*
+* This copyrighted material is made available to anyone wishing to use,
+* modify, copy, or redistribute it subject to the terms and conditions
+* of the GNU Lesser General Public License, v. 2.1.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT A 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, v.2.1 along with this distribution; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+* 02110-1301, USA.
+*
+* Red Hat Author(s): Bob McWhirter, Przemyslaw Dej, Ryszard Kozmik,
+*     Tomasz Szymanski, Adam Warski, Pawel Wrzeszcz
+*/
+
+package org.jboss.labs.clearspace.utils;
+
+
+public class Dev implements Comparable<Dev> {
+
+        /*public final static String USER_LOGIN_ELEMENT   = "login";
+        public final static String USER_LOGINS_ELEMENT  = "logins";
+	public final static String NAME_ELEMENT		= "name";
+	public final static String TITLE_ELEMENT	= "title";
+	public final static String PROJECT_ELEMENT	= "project";
+	public final static String PROJECTS_ELEMENT	= "projects";
+	public final static String MUGSHOT_ELEMENT	= "mugshot";
+	public final static String STATUS_ELEMENT	= "status";
+	public final static String BIO_ELEMENT		= "bio";
+	public final static String COUNTRY_ELEMENT	= "country";*/
+	
+    private String username;
+    
+	private String name;
+
+	private String title;
+
+	private String mugshot;
+
+	private String status;
+
+	private String country;
+
+	private String bio;
+	
+	private String url;
+	
+	public Dev() {
+
+	}
+	
+	public String getNameForUrl() {
+	    String tmp = null;
+	    
+	    if (name != null) {
+	        tmp = name.replaceAll("\\W","");
+	        tmp = "#" + tmp;
+	    }
+	    
+	    return tmp;
+	}
+	
+	public String getNameForUrlWithoutHash() {
+	    String tmp = null;
+	        
+	    if (name != null) {
+	        tmp = name.replaceAll("\\W","");
+	    }
+	        
+	    return tmp;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getMugshot() {
+        return mugshot;
+    }
+
+    public void setMugshot(String mugshot) {
+        this.mugshot = mugshot;
+    }
+
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+
+    public String getCountry() {
+        return country;
+    }
+
+    public void setCountry(String country) {
+        this.country = country;
+    }
+
+    public String getBio() {
+        return bio;
+    }
+
+    public void setBio(String bio) {
+        this.bio = bio;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public int compareTo(Dev dev) {
+        
+        if (this == dev) return 0;
+        
+        if (name == null) {
+            return 1;
+        }
+        
+        return name.compareTo(dev.getName());
+    }
+    
+    
+    
+}


Property changes on: labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/java/org/jboss/labs/clearspace/utils/Dev.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/java/org/jboss/labs/clearspace/utils/DevSpotlightHelper.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/java/org/jboss/labs/clearspace/utils/DevSpotlightHelper.java	                        (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/java/org/jboss/labs/clearspace/utils/DevSpotlightHelper.java	2008-09-18 13:05:12 UTC (rev 22875)
@@ -0,0 +1,92 @@
+/*
+ * JBoss Labs. http://labs.jboss.com/jbosslabs
+ *
+ * Copyright © 2008  Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT A 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, v.2.1 along with this distribution; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ * Red Hat Author(s): Bob McWhirter, Przemyslaw Dej, Ryszard Kozmik,
+ *     Tomasz Szymanski, Adam Warski, Pawel Wrzeszcz
+ */
+
+package org.jboss.labs.clearspace.utils;
+
+import java.util.Map;
+
+import com.jivesoftware.base.User;
+import com.jivesoftware.community.user.profile.ProfileFieldManager;
+import com.jivesoftware.community.user.profile.ProfileFieldValue;
+import com.jivesoftware.community.user.profile.ProfileManager;
+
+/**
+ * 
+ * @author <a href="ryszard.kozmik at jboss.com">Ryszard Kozmik</a>
+ * 
+ */
+public final class DevSpotlightHelper
+{
+
+    public static final long TITLE_FIELD_ID = 1L;
+
+    public static final long ADDRESS_FIELD_ID = 3L;
+
+    public static final long BIOGRAPHY_FIELD_ID = 11L;
+
+    public static final long URL_FIELD_ID = 9L;
+
+    public static long STATUS_FIELD_ID = -1L;
+
+    private DevSpotlightHelper () {}
+    
+    public static Dev userToDev(User user, ProfileManager pm, ProfileFieldManager pfm)
+            throws Exception
+    {
+
+        if (STATUS_FIELD_ID < 0L)
+        {
+            STATUS_FIELD_ID = pfm.getProfileField("Status").getID();
+        }
+
+        Dev dev = new Dev();
+        dev.setUsername(user.getUsername());
+        dev.setName(user.getName());
+
+        Map<Long, ProfileFieldValue> userProfiles = pm.getProfile(user);
+
+        if (userProfiles != null)
+        {
+            ProfileFieldValue temp = userProfiles.get(TITLE_FIELD_ID);
+            dev.setTitle(temp==null?"":temp.getValue());
+            
+            temp = userProfiles.get(ADDRESS_FIELD_ID);
+            String address = temp==null?"":temp.getValue();
+            for (String s : address.split(","))
+            {
+                if (s.startsWith("country:"))
+                {
+                    dev.setCountry(s.replaceFirst("country:", ""));
+                }
+            }
+            
+            temp = userProfiles.get(BIOGRAPHY_FIELD_ID);
+            dev.setBio(temp==null?"":temp.getValue());
+            
+            temp = userProfiles.get(URL_FIELD_ID);
+            dev.setUrl(temp==null?"":temp.getValue());
+        }
+
+        return dev;
+    }
+}

Added: labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/java/org/jboss/labs/clearspace/widget/DevSpotlightWidget.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/java/org/jboss/labs/clearspace/widget/DevSpotlightWidget.java	                        (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/java/org/jboss/labs/clearspace/widget/DevSpotlightWidget.java	2008-09-18 13:05:12 UTC (rev 22875)
@@ -0,0 +1,172 @@
+/*
+ * JBoss Labs. http://labs.jboss.com/jbosslabs
+ *
+ * Copyright © 2008  Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT A 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, v.2.1 along with this distribution; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ * Red Hat Author(s): Bob McWhirter, Przemyslaw Dej, Ryszard Kozmik,
+ *     Tomasz Szymanski, Adam Warski, Pawel Wrzeszcz
+ */
+
+package org.jboss.labs.clearspace.widget;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+
+import org.jboss.labs.clearspace.utils.Dev;
+import org.jboss.labs.clearspace.utils.DevSpotlightHelper;
+
+import com.jivesoftware.base.GroupManager;
+import com.jivesoftware.base.GroupNotFoundException;
+import com.jivesoftware.base.User;
+import com.jivesoftware.community.socialgroup.SocialGroupManager;
+import com.jivesoftware.community.user.profile.ProfileFieldManager;
+import com.jivesoftware.community.user.profile.ProfileManager;
+import com.jivesoftware.community.widget.BaseWidget;
+import com.jivesoftware.community.widget.WidgetContext;
+import com.jivesoftware.community.widget.WidgetType;
+import com.jivesoftware.community.widget.WidgetTypeMarker;
+
+/**
+ * 
+ * @author <a href="ryszard.kozmik at jboss.com">Ryszard Kozmik</a>
+ * 
+ */
+ at WidgetTypeMarker(
+{ WidgetType.HOMEPAGE, WidgetType.COMMUNITY })
+// @PropertyNames({"random","number"})
+public class DevSpotlightWidget extends BaseWidget
+{
+
+    private GroupManager groupManager;
+
+    private ProfileManager profileManager;
+
+    private ProfileFieldManager profileFieldManager;
+    
+    private SocialGroupManager socialGroupManager;
+
+    private static final String FTL_FILE_PATH = "/plugins/devspotlight/resources/devspotlight.ftl";
+
+    private boolean displayAll = false;
+
+    private String groupIds;
+
+    public void setGroupManager(GroupManager groupManager)
+    {
+        this.groupManager = groupManager;
+    }
+
+    public void setProfileManager(ProfileManager profileManager)
+    {
+        this.profileManager = profileManager;
+    }
+
+    public void setProfileFieldManager(ProfileFieldManager profileFieldManager)
+    {
+        this.profileFieldManager = profileFieldManager;
+    }
+    
+    public void setSocialGroupManager (SocialGroupManager socialGroupManager) {
+        this.socialGroupManager = socialGroupManager;
+    }
+
+    public boolean getDisplayAll()
+    {
+        return displayAll;
+    }
+
+    public void setDisplayAll(boolean displayAll)
+    {
+        this.displayAll = displayAll;
+    }
+
+    public String getDescription(WidgetContext widgetContext)
+    {
+        return "This widget displays a spotlight of one or more developers.";
+    }
+
+    public String getTitle(WidgetContext widgetContext)
+    {
+        return "Developer Spotlight Widget";
+    }
+
+    public String getGroupIds()
+    {
+        return groupIds;
+    }
+
+    public void setGroupIds(String groupIds)
+    {
+        this.groupIds = groupIds;
+    }
+
+    public String render(WidgetContext widgetContext,
+            ContainerSize containerSize)
+    {
+        return applyFreemarkerTemplate(widgetContext, containerSize,
+                FTL_FILE_PATH);
+    }
+
+    protected Map<String, Object> loadProperties(WidgetContext widgetContext,
+            ContainerSize containerSize)
+    {
+
+        Map<String, Object> properties = super.loadProperties(widgetContext,
+                containerSize);
+        List<User> users = null;
+        
+        for (String groupId : groupIds.split(","))
+        {
+            try
+            {
+                users = groupManager.getGroup(new Long(groupId).longValue()).getMembers();
+                if (!displayAll)
+                {
+                    Random random = new Random();
+                    List<User> randomUserList = new LinkedList<User>();
+                    randomUserList.add(users.get(random.nextInt(users.size())));
+                    users = randomUserList;
+                }
+
+            } catch (GroupNotFoundException e)
+            {
+                e.printStackTrace();
+                return null;
+            }
+        }
+
+        List<Dev> developers = new LinkedList<Dev>();
+
+        try
+        {
+            for (User user : users)
+            {
+                Dev developer = DevSpotlightHelper.userToDev(user,
+                        profileManager, profileFieldManager);
+                developers.add(developer);
+            }
+            properties.put("developers", developers);
+        } catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+
+        return properties;
+    }
+}
\ No newline at end of file

Added: labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/resources/META-INF/MANIFEST.MF
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/resources/META-INF/MANIFEST.MF	                        (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/resources/META-INF/MANIFEST.MF	2008-09-18 13:05:12 UTC (rev 22875)
@@ -0,0 +1,4 @@
+Manifest-Version: 1.0
+Ant-Version: Apache Ant 1.7.0
+Created-By: 1.5.0_13-119 (Apple Inc.)
+

Added: labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/resources/plugin.xml
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/resources/plugin.xml	                        (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/resources/plugin.xml	2008-09-18 13:05:12 UTC (rev 22875)
@@ -0,0 +1,12 @@
+<plugin xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:noNamespaceSchemaLocation="http://www.jivesoftware.com/schemas/clearspace/2_0/plugin.xsd">
+    <name>devspotlight</name>
+    <description>A widget that renders developer spotlight.</description>
+    <author>Rysiek</author>
+    <version>1.0.0</version>
+    <minServerVersion>2.0.0</minServerVersion>
+
+    <!-- Defines a custom widget for this plugin -->
+    <widget class="org.jboss.labs.clearspace.widget.DevSpotlightWidget" />
+ 
+</plugin>
\ No newline at end of file

Added: labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/resources/resources/devspotlight.ftl
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/resources/resources/devspotlight.ftl	                        (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-widgets/src/main/resources/resources/devspotlight.ftl	2008-09-18 13:05:12 UTC (rev 22875)
@@ -0,0 +1,25 @@
+<div class="homespot" id="developerspotlight">
+   <#list developers as developer >
+   <div>
+      <a href="/people/${developer.username}">
+         <img style="padding-top:15px;" border=0 
+         src="<@s.url value='/profile-image-display.jspa?username=${developer.username}' />" alt="" />
+      </a>
+      <h4>${developer.name}</h4>
+      <p>
+         <strong>Country:</strong>${developer.COUNTRY}
+         <br />
+         <strong>Title:</strong>${developer.TITLE}
+         <br />
+         <strong>Status:</status>${developer.STATUS}
+         <br />
+      </p>
+      <p>
+         <strong>Bio:</strong>${developer.BIO} 
+         ... 
+         <a href="/people/${developer.username}">More Information</a>
+      </p>
+   </div>
+   <hr />
+   </#list>
+</div>
\ No newline at end of file


Property changes on: labs/jbosslabs/labs-3.0-build/integration/cs-widgets/target
___________________________________________________________________
Name: svn:ignore
   + target
.classpath
.project
.settings
.iml



Modified: labs/jbosslabs/labs-3.0-build/integration/pom.xml
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/pom.xml	2008-09-18 11:45:08 UTC (rev 22874)
+++ labs/jbosslabs/labs-3.0-build/integration/pom.xml	2008-09-18 13:05:12 UTC (rev 22875)
@@ -16,8 +16,9 @@
     <module>seam-guice</module>
     <module>cs-nukes-login</module>
     <module>cs-macros</module>
+    <module>cs-widgets</module>
   </modules>
 <properties>
                 <labsrepo-rel>../..</labsrepo-rel>
         </properties>
-</project>
\ No newline at end of file
+</project>




More information about the jboss-svn-commits mailing list