[jboss-svn-commits] JBL Code SVN: r12613 - in labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src: java/org/jboss/forge/kosmos/jira and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Jun 15 07:31:26 EDT 2007
Author: wrzep
Date: 2007-06-15 07:31:26 -0400 (Fri, 15 Jun 2007)
New Revision: 12613
Added:
labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/jira/
labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/jira/LabsKosmosJiraDescriptor.java
labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/jira/LabsKosmosJiraPortlet.java
labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/jira/LabsKosmosJiraWatcher.java
labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/svn/
labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/svn/LabsKosmosSvnDescriptor.java
labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/svn/LabsKosmosSvnPortlet.java
labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/svn/LabsKosmosSvnWatcher.java
Removed:
labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/LabsKosmosJiraDescriptor.java
labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/LabsKosmosJiraPortlet.java
labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/LabsKosmosJiraWatcher.java
labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/LabsKosmosSvnDescriptor.java
labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/LabsKosmosSvnPortlet.java
labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/LabsKosmosSvnWatcher.java
Modified:
labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/web/WEB-INF/portlet.template.xml
Log:
JBLAB-868 refactoring
Deleted: labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/LabsKosmosJiraDescriptor.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/LabsKosmosJiraDescriptor.java 2007-06-15 11:13:46 UTC (rev 12612)
+++ labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/LabsKosmosJiraDescriptor.java 2007-06-15 11:31:26 UTC (rev 12613)
@@ -1,112 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC 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.kosmos;
-
-import java.net.MalformedURLException;
-import java.util.Date;
-import java.util.List;
-
-import hu.midori.kosmos.model.JiraProject;
-import hu.midori.kosmos.protocol.JiraService;
-
-import javax.portlet.PortletContext;
-
-import org.jboss.forge.common.ejb3.LabsServices;
-import org.jboss.forge.common.exceptions.ServiceRetrievalException;
-import org.jboss.forge.common.projects.project.IssueTracker;
-import org.jboss.forge.common.projects.project.rw.IssueTrackerTypeRW;
-import org.jboss.logging.Logger;
-
-import com.caucho.hessian.client.HessianProxyFactory;
-
-/**
- * @author Pawel Wrzeszcz (pwrzeszcz [at] jboss . org)
- * @author <a href="mailto:aron.gombas at midori.hu">Aron Gombas</a>
- */
-public class LabsKosmosJiraDescriptor {
-
- protected final static Logger log = Logger.getLogger(LabsKosmosJiraDescriptor.class);
-
- private JiraProject jiraProject;
- private Date timestamp;
-
- public LabsKosmosJiraDescriptor(String projectId, String serviceUrl) {
-
- JiraService service = getService(serviceUrl);
-
- List<JiraProject> projects = null;
-
- String monitoredUrl = getProjectJira(projectId);
-
- // get project list if the service was successfully set-up
- if ((service != null) && (monitoredUrl != null)) {
-
- projects = service.getProjects(monitoredUrl);
- }
-
- if ((projects != null) && (projects.size() > 0)) {
-
- timestamp = service.getTimestamp();
- jiraProject = projects.get(0);
-
- log.info("JIRA project downloaded: " + monitoredUrl + " timestamp: " + timestamp);
- } else {
- log.info("Failed to download JIRA project: " + monitoredUrl);
- }
-
- }
-
- public void fillContext(PortletContext portletContext) {
-
- portletContext.setAttribute("project", jiraProject);
- portletContext.setAttribute("timestamp", timestamp);
- }
-
- private static JiraService getService(String serviceUrl) {
-
- JiraService service = null;
- HessianProxyFactory factory = new HessianProxyFactory();
- try {
- service = (JiraService)factory.create(JiraService.class, serviceUrl);
- } catch (MalformedURLException ex) {
- log.error("Unable to connect to the service", ex);
- }
- return service;
- }
-
- private static String getProjectJira(String projectId) {
-
- try {
- IssueTracker it =
- LabsServices.getProjectsService().getProjectIssueTracker(projectId);
-
- if ((it != null) && (IssueTrackerTypeRW.JIRA.equals(it.getType()))) {
- return it.getValue();
- }
-
- } catch (ServiceRetrievalException e) {
- log.warn("Unable to get project " + projectId, e);
- }
-
- return null;
- }
-}
Deleted: labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/LabsKosmosJiraPortlet.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/LabsKosmosJiraPortlet.java 2007-06-15 11:13:46 UTC (rev 12612)
+++ labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/LabsKosmosJiraPortlet.java 2007-06-15 11:31:26 UTC (rev 12613)
@@ -1,51 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC 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.kosmos;
-
-import javax.portlet.RenderRequest;
-import javax.portlet.RenderResponse;
-
-import org.jboss.forge.common.projects.ProjectsHelper;
-import org.jboss.shotoku.aop.CacheItem;
-import org.jboss.shotoku.tools.Pair;
-
-/**
- * @author Pawel Wrzeszcz (pwrzeszcz [at] jboss . org)
- * @author <a href="mailto:aron.gombas at midori.hu">Aron Gombas</a>
- */
-public class LabsKosmosJiraPortlet extends LabsKosmosPortlet {
-
- @CacheItem(interval=KOSMOS_PORTLET_UPDATE_INTERVAL)
- private static LabsKosmosJiraWatcher jiraWatcher;
-
- @Override
- public void doView(RenderRequest request, RenderResponse response) {
-
- String projectId = ProjectsHelper.getSelectedProjectId(request);
-
- LabsKosmosJiraDescriptor desc = jiraWatcher.get(new Pair<String, String>(projectId,serviceUrl));
-
- desc.fillContext(getPortletContext());
-
- renderJsp(request, response, page, String.format("%s / %s", "JIRA", projectId));
- }
-}
\ No newline at end of file
Deleted: labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/LabsKosmosJiraWatcher.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/LabsKosmosJiraWatcher.java 2007-06-15 11:13:46 UTC (rev 12612)
+++ labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/LabsKosmosJiraWatcher.java 2007-06-15 11:31:26 UTC (rev 12613)
@@ -1,57 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC 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.kosmos;
-
-import java.util.Map;
-
-import org.jboss.shotoku.cache.ChangeType;
-import org.jboss.shotoku.cache.ShotokuResourceWatcher;
-import org.jboss.shotoku.tools.Pair;
-
-/**
- * @author Pawel Wrzeszcz (pwrzeszcz [at] jboss . org)
- */
-public class LabsKosmosJiraWatcher extends ShotokuResourceWatcher<Pair<String,String>,LabsKosmosJiraDescriptor> {
-
- public LabsKosmosJiraWatcher(long interval) {
- super(interval);
- }
-
- @Override
- public LabsKosmosJiraDescriptor init(Pair<String,String> key) {
- return getDesc(key);
- }
-
- @Override
- protected void update(Pair<String,String> key, LabsKosmosJiraDescriptor currentObject,
- Map<String, ChangeType> changes) {
- put(key, getDesc(key));
- }
-
- private LabsKosmosJiraDescriptor getDesc(Pair<String,String> key) {
-
- String projectId = key.getFirst();
- String serviceUrl = key.getSecond();
-
- return new LabsKosmosJiraDescriptor(projectId, serviceUrl);
- }
-}
Deleted: labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/LabsKosmosSvnDescriptor.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/LabsKosmosSvnDescriptor.java 2007-06-15 11:13:46 UTC (rev 12612)
+++ labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/LabsKosmosSvnDescriptor.java 2007-06-15 11:31:26 UTC (rev 12613)
@@ -1,109 +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.kosmos;
-
-import hu.midori.kosmos.model.SvnRepository;
-import hu.midori.kosmos.protocol.SvnService;
-
-import java.net.MalformedURLException;
-import java.util.Date;
-import java.util.List;
-
-import javax.portlet.PortletContext;
-import org.jboss.forge.common.ejb3.LabsServices;
-import org.jboss.forge.common.exceptions.ServiceRetrievalException;
-import org.jboss.forge.common.projects.project.rw.RepoTypeRW;
-import org.jboss.logging.Logger;
-
-import com.caucho.hessian.client.HessianProxyFactory;
-
-/**
- * @author <a href="mailto:aron.gombas at midori.hu">Aron Gombas</a>
- * @author Pawel Wrzeszcz (pwrzeszcz [at] jboss . org)
- */
-public class LabsKosmosSvnDescriptor {
-
- protected final static Logger log = Logger.getLogger(LabsKosmosJiraDescriptor.class);
-
- private SvnRepository repository;
- private Date timestamp;
-
- public LabsKosmosSvnDescriptor(String projectId, String serviceUrl) {
-
- SvnService service = getService(serviceUrl);
-
- List<SvnRepository> repositories = null;
-
- String monitoredUrl = getProjectSvn(projectId);
-
- // get project list if the service was successfully set-up
- if ((service != null) && (monitoredUrl != null)) {
-
- repositories = service.getRepositories(monitoredUrl);
- }
-
- if ((repositories != null) && (repositories.size() > 0)) {
-
- repository = repositories.get(0);
- timestamp = service.getTimestamp();
-
- log.info("SVN repository downloaded: " + monitoredUrl + " timestamp: " + timestamp);
- } else {
- log.info("Failed to download SVN repository: " + monitoredUrl);
- }
- }
-
- public void fillContext(PortletContext portletContext) {
-
- portletContext.setAttribute("repository", repository);
- portletContext.setAttribute("timestamp", timestamp);
- }
-
- private static SvnService getService(String serviceUrl) {
-
- SvnService service = null;
- HessianProxyFactory factory = new HessianProxyFactory();
- try {
- service = (SvnService)factory.create(SvnService.class, serviceUrl);
- } catch (MalformedURLException ex) {
- log.error("Unable to connect to the service", ex);
- }
- return service;
- }
-
- private static String getProjectSvn(String projectId) {
-
- try {
-
- if (RepoTypeRW.SVN.equals(
- LabsServices.getProjectsService().getProjectRepoType(projectId))) {
-
- return LabsServices.getProjectsService().getProjectAnonRepo(projectId);
- }
-
- } catch (ServiceRetrievalException e) {
- log.warn("Unable to get project " + projectId, e);
- }
-
- return null;
- }
-}
Deleted: labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/LabsKosmosSvnPortlet.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/LabsKosmosSvnPortlet.java 2007-06-15 11:13:46 UTC (rev 12612)
+++ labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/LabsKosmosSvnPortlet.java 2007-06-15 11:31:26 UTC (rev 12613)
@@ -1,51 +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.kosmos;
-
-import javax.portlet.RenderRequest;
-import javax.portlet.RenderResponse;
-
-import org.jboss.forge.common.projects.ProjectsHelper;
-import org.jboss.shotoku.aop.CacheItem;
-import org.jboss.shotoku.tools.Pair;
-
-/**
- * @author <a href="mailto:aron.gombas at midori.hu">Aron Gombas</a>
- * @author Pawel Wrzeszcz (pwrzeszcz [at] jboss . org)
- */
-public class LabsKosmosSvnPortlet extends LabsKosmosPortlet {
-
- @CacheItem(interval=KOSMOS_PORTLET_UPDATE_INTERVAL)
- private static LabsKosmosSvnWatcher svnWatcher;
-
- @Override
- public void doView(RenderRequest request, RenderResponse response) {
-
- String projectId = ProjectsHelper.getSelectedProjectId(request);
-
- LabsKosmosSvnDescriptor desc = svnWatcher.get(new Pair<String, String>(projectId,serviceUrl));
-
- desc.fillContext(getPortletContext());
-
- renderJsp(request, response, page, String.format("%s / %s", "SVN", projectId));
- }
-}
Deleted: labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/LabsKosmosSvnWatcher.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/LabsKosmosSvnWatcher.java 2007-06-15 11:13:46 UTC (rev 12612)
+++ labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/LabsKosmosSvnWatcher.java 2007-06-15 11:31:26 UTC (rev 12613)
@@ -1,57 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC 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.kosmos;
-
-import java.util.Map;
-
-import org.jboss.shotoku.cache.ChangeType;
-import org.jboss.shotoku.cache.ShotokuResourceWatcher;
-import org.jboss.shotoku.tools.Pair;
-
-/**
- * @author Pawel Wrzeszcz (pwrzeszcz [at] jboss . org)
- */
-public class LabsKosmosSvnWatcher extends ShotokuResourceWatcher<Pair<String,String>,LabsKosmosSvnDescriptor> {
-
- public LabsKosmosSvnWatcher(long interval) {
- super(interval);
- }
-
- @Override
- public LabsKosmosSvnDescriptor init(Pair<String,String> key) {
- return getDesc(key);
- }
-
- @Override
- protected void update(Pair<String,String> key, LabsKosmosSvnDescriptor currentObject,
- Map<String, ChangeType> changes) {
- put(key, getDesc(key));
- }
-
- private LabsKosmosSvnDescriptor getDesc(Pair<String,String> key) {
-
- String projectId = key.getFirst();
- String serviceUrl = key.getSecond();
-
- return new LabsKosmosSvnDescriptor(projectId, serviceUrl);
- }
-}
Added: labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/jira/LabsKosmosJiraDescriptor.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/jira/LabsKosmosJiraDescriptor.java (rev 0)
+++ labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/jira/LabsKosmosJiraDescriptor.java 2007-06-15 11:31:26 UTC (rev 12613)
@@ -0,0 +1,112 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC 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.kosmos.jira;
+
+import java.net.MalformedURLException;
+import java.util.Date;
+import java.util.List;
+
+import hu.midori.kosmos.model.JiraProject;
+import hu.midori.kosmos.protocol.JiraService;
+
+import javax.portlet.PortletContext;
+
+import org.jboss.forge.common.ejb3.LabsServices;
+import org.jboss.forge.common.exceptions.ServiceRetrievalException;
+import org.jboss.forge.common.projects.project.IssueTracker;
+import org.jboss.forge.common.projects.project.rw.IssueTrackerTypeRW;
+import org.jboss.logging.Logger;
+
+import com.caucho.hessian.client.HessianProxyFactory;
+
+/**
+ * @author Pawel Wrzeszcz (pwrzeszcz [at] jboss . org)
+ * @author <a href="mailto:aron.gombas at midori.hu">Aron Gombas</a>
+ */
+public class LabsKosmosJiraDescriptor {
+
+ protected final static Logger log = Logger.getLogger(LabsKosmosJiraDescriptor.class);
+
+ private JiraProject jiraProject;
+ private Date timestamp;
+
+ public LabsKosmosJiraDescriptor(String projectId, String serviceUrl) {
+
+ JiraService service = getService(serviceUrl);
+
+ List<JiraProject> projects = null;
+
+ String monitoredUrl = getProjectJira(projectId);
+
+ // get project list if the service was successfully set-up
+ if ((service != null) && (monitoredUrl != null)) {
+
+ projects = service.getProjects(monitoredUrl);
+ }
+
+ if ((projects != null) && (projects.size() > 0)) {
+
+ timestamp = service.getTimestamp();
+ jiraProject = projects.get(0);
+
+ log.info("JIRA project downloaded: " + monitoredUrl + " timestamp: " + timestamp);
+ } else {
+ log.info("Failed to download JIRA project: " + monitoredUrl);
+ }
+
+ }
+
+ public void fillContext(PortletContext portletContext) {
+
+ portletContext.setAttribute("project", jiraProject);
+ portletContext.setAttribute("timestamp", timestamp);
+ }
+
+ private static JiraService getService(String serviceUrl) {
+
+ JiraService service = null;
+ HessianProxyFactory factory = new HessianProxyFactory();
+ try {
+ service = (JiraService)factory.create(JiraService.class, serviceUrl);
+ } catch (MalformedURLException ex) {
+ log.error("Unable to connect to the service", ex);
+ }
+ return service;
+ }
+
+ private static String getProjectJira(String projectId) {
+
+ try {
+ IssueTracker it =
+ LabsServices.getProjectsService().getProjectIssueTracker(projectId);
+
+ if ((it != null) && (IssueTrackerTypeRW.JIRA.equals(it.getType()))) {
+ return it.getValue();
+ }
+
+ } catch (ServiceRetrievalException e) {
+ log.warn("Unable to get project " + projectId, e);
+ }
+
+ return null;
+ }
+}
Added: labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/jira/LabsKosmosJiraPortlet.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/jira/LabsKosmosJiraPortlet.java (rev 0)
+++ labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/jira/LabsKosmosJiraPortlet.java 2007-06-15 11:31:26 UTC (rev 12613)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC 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.kosmos.jira;
+
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+
+import org.jboss.forge.common.projects.ProjectsHelper;
+import org.jboss.forge.kosmos.LabsKosmosPortlet;
+import org.jboss.shotoku.aop.CacheItem;
+import org.jboss.shotoku.tools.Pair;
+
+/**
+ * @author Pawel Wrzeszcz (pwrzeszcz [at] jboss . org)
+ * @author <a href="mailto:aron.gombas at midori.hu">Aron Gombas</a>
+ */
+public class LabsKosmosJiraPortlet extends LabsKosmosPortlet {
+
+ @CacheItem(interval=KOSMOS_PORTLET_UPDATE_INTERVAL)
+ private static LabsKosmosJiraWatcher jiraWatcher;
+
+ @Override
+ public void doView(RenderRequest request, RenderResponse response) {
+
+ String projectId = ProjectsHelper.getSelectedProjectId(request);
+
+ LabsKosmosJiraDescriptor desc = jiraWatcher.get(new Pair<String, String>(projectId,serviceUrl));
+
+ desc.fillContext(getPortletContext());
+
+ renderJsp(request, response, page, String.format("%s / %s", "JIRA", projectId));
+ }
+}
\ No newline at end of file
Added: labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/jira/LabsKosmosJiraWatcher.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/jira/LabsKosmosJiraWatcher.java (rev 0)
+++ labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/jira/LabsKosmosJiraWatcher.java 2007-06-15 11:31:26 UTC (rev 12613)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC 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.kosmos.jira;
+
+import java.util.Map;
+
+import org.jboss.shotoku.cache.ChangeType;
+import org.jboss.shotoku.cache.ShotokuResourceWatcher;
+import org.jboss.shotoku.tools.Pair;
+
+/**
+ * @author Pawel Wrzeszcz (pwrzeszcz [at] jboss . org)
+ */
+public class LabsKosmosJiraWatcher extends ShotokuResourceWatcher<Pair<String,String>,LabsKosmosJiraDescriptor> {
+
+ public LabsKosmosJiraWatcher(long interval) {
+ super(interval);
+ }
+
+ @Override
+ public LabsKosmosJiraDescriptor init(Pair<String,String> key) {
+ return getDesc(key);
+ }
+
+ @Override
+ protected void update(Pair<String,String> key, LabsKosmosJiraDescriptor currentObject,
+ Map<String, ChangeType> changes) {
+ put(key, getDesc(key));
+ }
+
+ private LabsKosmosJiraDescriptor getDesc(Pair<String,String> key) {
+
+ String projectId = key.getFirst();
+ String serviceUrl = key.getSecond();
+
+ return new LabsKosmosJiraDescriptor(projectId, serviceUrl);
+ }
+}
Added: labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/svn/LabsKosmosSvnDescriptor.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/svn/LabsKosmosSvnDescriptor.java (rev 0)
+++ labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/svn/LabsKosmosSvnDescriptor.java 2007-06-15 11:31:26 UTC (rev 12613)
@@ -0,0 +1,110 @@
+/*
+ * 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.kosmos.svn;
+
+import hu.midori.kosmos.model.SvnRepository;
+import hu.midori.kosmos.protocol.SvnService;
+
+import java.net.MalformedURLException;
+import java.util.Date;
+import java.util.List;
+
+import javax.portlet.PortletContext;
+import org.jboss.forge.common.ejb3.LabsServices;
+import org.jboss.forge.common.exceptions.ServiceRetrievalException;
+import org.jboss.forge.common.projects.project.rw.RepoTypeRW;
+import org.jboss.forge.kosmos.jira.LabsKosmosJiraDescriptor;
+import org.jboss.logging.Logger;
+
+import com.caucho.hessian.client.HessianProxyFactory;
+
+/**
+ * @author <a href="mailto:aron.gombas at midori.hu">Aron Gombas</a>
+ * @author Pawel Wrzeszcz (pwrzeszcz [at] jboss . org)
+ */
+public class LabsKosmosSvnDescriptor {
+
+ protected final static Logger log = Logger.getLogger(LabsKosmosJiraDescriptor.class);
+
+ private SvnRepository repository;
+ private Date timestamp;
+
+ public LabsKosmosSvnDescriptor(String projectId, String serviceUrl) {
+
+ SvnService service = getService(serviceUrl);
+
+ List<SvnRepository> repositories = null;
+
+ String monitoredUrl = getProjectSvn(projectId);
+
+ // get project list if the service was successfully set-up
+ if ((service != null) && (monitoredUrl != null)) {
+
+ repositories = service.getRepositories(monitoredUrl);
+ }
+
+ if ((repositories != null) && (repositories.size() > 0)) {
+
+ repository = repositories.get(0);
+ timestamp = service.getTimestamp();
+
+ log.info("SVN repository downloaded: " + monitoredUrl + " timestamp: " + timestamp);
+ } else {
+ log.info("Failed to download SVN repository: " + monitoredUrl);
+ }
+ }
+
+ public void fillContext(PortletContext portletContext) {
+
+ portletContext.setAttribute("repository", repository);
+ portletContext.setAttribute("timestamp", timestamp);
+ }
+
+ private static SvnService getService(String serviceUrl) {
+
+ SvnService service = null;
+ HessianProxyFactory factory = new HessianProxyFactory();
+ try {
+ service = (SvnService)factory.create(SvnService.class, serviceUrl);
+ } catch (MalformedURLException ex) {
+ log.error("Unable to connect to the service", ex);
+ }
+ return service;
+ }
+
+ private static String getProjectSvn(String projectId) {
+
+ try {
+
+ if (RepoTypeRW.SVN.equals(
+ LabsServices.getProjectsService().getProjectRepoType(projectId))) {
+
+ return LabsServices.getProjectsService().getProjectAnonRepo(projectId);
+ }
+
+ } catch (ServiceRetrievalException e) {
+ log.warn("Unable to get project " + projectId, e);
+ }
+
+ return null;
+ }
+}
Added: labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/svn/LabsKosmosSvnPortlet.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/svn/LabsKosmosSvnPortlet.java (rev 0)
+++ labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/svn/LabsKosmosSvnPortlet.java 2007-06-15 11:31:26 UTC (rev 12613)
@@ -0,0 +1,52 @@
+/*
+ * 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.kosmos.svn;
+
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+
+import org.jboss.forge.common.projects.ProjectsHelper;
+import org.jboss.forge.kosmos.LabsKosmosPortlet;
+import org.jboss.shotoku.aop.CacheItem;
+import org.jboss.shotoku.tools.Pair;
+
+/**
+ * @author <a href="mailto:aron.gombas at midori.hu">Aron Gombas</a>
+ * @author Pawel Wrzeszcz (pwrzeszcz [at] jboss . org)
+ */
+public class LabsKosmosSvnPortlet extends LabsKosmosPortlet {
+
+ @CacheItem(interval=KOSMOS_PORTLET_UPDATE_INTERVAL)
+ private static LabsKosmosSvnWatcher svnWatcher;
+
+ @Override
+ public void doView(RenderRequest request, RenderResponse response) {
+
+ String projectId = ProjectsHelper.getSelectedProjectId(request);
+
+ LabsKosmosSvnDescriptor desc = svnWatcher.get(new Pair<String, String>(projectId,serviceUrl));
+
+ desc.fillContext(getPortletContext());
+
+ renderJsp(request, response, page, String.format("%s / %s", "SVN", projectId));
+ }
+}
Added: labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/svn/LabsKosmosSvnWatcher.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/svn/LabsKosmosSvnWatcher.java (rev 0)
+++ labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/java/org/jboss/forge/kosmos/svn/LabsKosmosSvnWatcher.java 2007-06-15 11:31:26 UTC (rev 12613)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC 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.kosmos.svn;
+
+import java.util.Map;
+
+import org.jboss.shotoku.cache.ChangeType;
+import org.jboss.shotoku.cache.ShotokuResourceWatcher;
+import org.jboss.shotoku.tools.Pair;
+
+/**
+ * @author Pawel Wrzeszcz (pwrzeszcz [at] jboss . org)
+ */
+public class LabsKosmosSvnWatcher extends ShotokuResourceWatcher<Pair<String,String>,LabsKosmosSvnDescriptor> {
+
+ public LabsKosmosSvnWatcher(long interval) {
+ super(interval);
+ }
+
+ @Override
+ public LabsKosmosSvnDescriptor init(Pair<String,String> key) {
+ return getDesc(key);
+ }
+
+ @Override
+ protected void update(Pair<String,String> key, LabsKosmosSvnDescriptor currentObject,
+ Map<String, ChangeType> changes) {
+ put(key, getDesc(key));
+ }
+
+ private LabsKosmosSvnDescriptor getDesc(Pair<String,String> key) {
+
+ String projectId = key.getFirst();
+ String serviceUrl = key.getSecond();
+
+ return new LabsKosmosSvnDescriptor(projectId, serviceUrl);
+ }
+}
Modified: labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/web/WEB-INF/portlet.template.xml
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/web/WEB-INF/portlet.template.xml 2007-06-15 11:13:46 UTC (rev 12612)
+++ labs/jbosslabs/trunk/portal-extensions/forge-kosmos-portlets/src/web/WEB-INF/portlet.template.xml 2007-06-15 11:31:26 UTC (rev 12613)
@@ -9,7 +9,7 @@
<description>Kosmos JIRA Open Issues By Assignee Portlet</description>
<portlet-name>KosmosJIRAIssuesByAssigneePortlet</portlet-name>
<display-name>Kosmos JIRA Open Issues By Assignee Portlet</display-name>
- <portlet-class>org.jboss.forge.kosmos.LabsKosmosJiraPortlet</portlet-class>
+ <portlet-class>org.jboss.forge.kosmos.jira.LabsKosmosJiraPortlet</portlet-class>
<init-param>
<name>service.url</name>
<value>#{kosmos.server.address}/kosmos-server/kosmos-services/jira-service</value>
@@ -31,7 +31,7 @@
<description>Kosmos JIRA Issues By Status Portlet</description>
<portlet-name>KosmosJIRAIssuesByStatusPortlet</portlet-name>
<display-name>Kosmos JIRA Issues By Status Portlet</display-name>
- <portlet-class>org.jboss.forge.kosmos.LabsKosmosJiraPortlet</portlet-class>
+ <portlet-class>org.jboss.forge.kosmos.jira.LabsKosmosJiraPortlet</portlet-class>
<init-param>
<name>service.url</name>
<value>#{kosmos.server.address}/kosmos-server/kosmos-services/jira-service</value>
@@ -53,7 +53,7 @@
<description>Kosmos JIRA Issues By Priority Portlet</description>
<portlet-name>KosmosJIRAIssuesByPriorityPortlet</portlet-name>
<display-name>Kosmos JIRA Issues By Priority Portlet</display-name>
- <portlet-class>org.jboss.forge.kosmos.LabsKosmosJiraPortlet</portlet-class>
+ <portlet-class>org.jboss.forge.kosmos.jira.LabsKosmosJiraPortlet</portlet-class>
<init-param>
<name>service.url</name>
<value>#{kosmos.server.address}/kosmos-server/kosmos-services/jira-service</value>
@@ -77,7 +77,7 @@
<description>Kosmos Svn Activity</description>
<portlet-name>KosmosSvnActivityPortlet</portlet-name>
<display-name>Kosmos Svn Activity Portlet</display-name>
- <portlet-class>org.jboss.forge.kosmos.LabsKosmosSvnPortlet</portlet-class>
+ <portlet-class>org.jboss.forge.kosmos.svn.LabsKosmosSvnPortlet</portlet-class>
<init-param>
<name>service.url</name>
<value>#{kosmos.server.address}/kosmos-server/kosmos-services/svn-service</value>
@@ -99,7 +99,7 @@
<description>Kosmos Svn Commiters</description>
<portlet-name>KosmosSvnCommitersPortlet</portlet-name>
<display-name>Kosmos Svn Commiters Portlet</display-name>
- <portlet-class>org.jboss.forge.kosmos.LabsKosmosSvnPortlet</portlet-class>
+ <portlet-class>org.jboss.forge.kosmos.svn.LabsKosmosSvnPortlet</portlet-class>
<init-param>
<name>service.url</name>
<value>#{kosmos.server.address}/kosmos-server/kosmos-services/svn-service</value>
@@ -121,7 +121,7 @@
<description>Kosmos Svn Repository Details</description>
<portlet-name>KosmosSvnRepositoryPortlet</portlet-name>
<display-name>Kosmos Svn Repository Details Portlet</display-name>
- <portlet-class>org.jboss.forge.kosmos.LabsKosmosSvnPortlet</portlet-class>
+ <portlet-class>org.jboss.forge.kosmos.svn.LabsKosmosSvnPortlet</portlet-class>
<init-param>
<name>service.url</name>
<value>#{kosmos.server.address}/kosmos-server/kosmos-services/svn-service</value>
@@ -143,7 +143,7 @@
<description>Kosmos Svn Revision Details</description>
<portlet-name>KosmosSvnRevisionPortlet</portlet-name>
<display-name>Kosmos Svn Revision Details Portlet</display-name>
- <portlet-class>org.jboss.forge.kosmos.LabsKosmosSvnPortlet</portlet-class>
+ <portlet-class>org.jboss.forge.kosmos.svn.LabsKosmosSvnPortlet</portlet-class>
<init-param>
<name>service.url</name>
<value>#{kosmos.server.address}/kosmos-server/kosmos-services/svn-service</value>
More information about the jboss-svn-commits
mailing list