[jboss-svn-commits] JBoss Portal SVN: r5457 - in trunk/cms/src/main/org/jboss/portal/cms: . management

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Oct 16 04:29:11 EDT 2006


Author: thomas.heute at jboss.com
Date: 2006-10-16 04:29:09 -0400 (Mon, 16 Oct 2006)
New Revision: 5457

Added:
   trunk/cms/src/main/org/jboss/portal/cms/management/
   trunk/cms/src/main/org/jboss/portal/cms/management/CMS.java
   trunk/cms/src/main/org/jboss/portal/cms/management/CMSImpl.java
Log:
Add CMS management 

Added: trunk/cms/src/main/org/jboss/portal/cms/management/CMS.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/management/CMS.java	2006-10-14 16:09:10 UTC (rev 5456)
+++ trunk/cms/src/main/org/jboss/portal/cms/management/CMS.java	2006-10-16 08:29:09 UTC (rev 5457)
@@ -0,0 +1,31 @@
+/*
+* 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.portal.cms.management;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface CMS {
+
+	public int getNbFiles();
+}

Added: trunk/cms/src/main/org/jboss/portal/cms/management/CMSImpl.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/management/CMSImpl.java	2006-10-14 16:09:10 UTC (rev 5456)
+++ trunk/cms/src/main/org/jboss/portal/cms/management/CMSImpl.java	2006-10-16 08:29:09 UTC (rev 5457)
@@ -0,0 +1,73 @@
+/*
+* 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.portal.cms.management;
+
+import java.util.List;
+
+import org.jboss.portal.cms.CMSException;
+import org.jboss.portal.cms.Command;
+import org.jboss.portal.cms.model.Folder;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class CMSImpl extends AbstractJBossService implements CMS {
+
+	private org.jboss.portal.cms.CMS cms;
+	
+	public void setCMS(org.jboss.portal.cms.CMS cms)
+	{
+		this.cms = cms;
+	}
+	
+	/** Very costly 
+	 *  TODO: Make it cheap 
+	 */
+	public int getNbFiles()
+	{
+		String sPath ="/";
+		try {
+			return nbFiles(sPath);
+		} catch (CMSException e) {
+			e.printStackTrace();
+		}
+		return -1;
+	}
+	
+	private int nbFiles(String path) throws CMSException
+	{
+		Command listCMD = cms.getCommandFactory().createFolderGetListCommand(path);
+		Folder mainFolder = (Folder)cms.execute(listCMD);
+		List files = mainFolder.getFiles();
+		int nbFiles = files.size();
+		List folders = mainFolder.getFolders();
+		for (int i=0; i<folders.size(); i++)
+		{
+			Folder folder = (Folder)folders.get(i);
+			nbFiles += nbFiles(folder.getBasePath());
+		}
+		return nbFiles;
+	}
+	
+}




More information about the jboss-svn-commits mailing list