[jboss-svn-commits] JBoss PortletSwap SVN: r215 - in src/textClient: src and 8 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Jan 23 16:28:46 EST 2008
Author: thomas.heute at jboss.com
Date: 2008-01-23 16:28:46 -0500 (Wed, 23 Jan 2008)
New Revision: 215
Added:
src/textClient/.classpath
src/textClient/.project
src/textClient/pom.xml
src/textClient/src/
src/textClient/src/main/
src/textClient/src/main/java/
src/textClient/src/main/java/org/
src/textClient/src/main/java/org/jboss/
src/textClient/src/main/java/org/jboss/portletswap/
src/textClient/src/main/java/org/jboss/portletswap/textclient/
src/textClient/src/main/java/org/jboss/portletswap/textclient/TextClient.java
src/textClient/src/main/resources/
src/textClient/src/test/
src/textClient/src/test/resources/
src/textClient/src/test/resources/settings.xml
Log:
Initial import.
Added: src/textClient/.classpath
===================================================================
--- src/textClient/.classpath (rev 0)
+++ src/textClient/.classpath 2008-01-23 21:28:46 UTC (rev 215)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: src/textClient/.project
===================================================================
--- src/textClient/.project (rev 0)
+++ src/textClient/.project 2008-01-23 21:28:46 UTC (rev 215)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>textClient</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ </natures>
+</projectDescription>
Added: src/textClient/pom.xml
===================================================================
--- src/textClient/pom.xml (rev 0)
+++ src/textClient/pom.xml 2008-01-23 21:28:46 UTC (rev 215)
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.portletswap</groupId>
+ <artifactId>text-client</artifactId>
+ <version>0.0.1</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ <version>2.0.0.Beta9</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>jackrabbit-core</artifactId>
+ <version>1.3.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.portletswap</groupId>
+ <artifactId>server-lib</artifactId>
+ <version>1.0-CR1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.portal.common</groupId>
+ <artifactId>jboss-portal-modules-common</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>1.4.3</version>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jnpserver</artifactId>
+ <version>3.2.3</version>
+ </dependency>
+
+ </dependencies>
+
+
+
+<build>
+ <plugins>
+ <!-- this is a java 1.5 project -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>org.jboss.portletswap.textclient.TextClient</mainClass>
+ <packageName>org.jboss.portletswap.textclient</packageName>
+ <addClasspath>true</addClasspath>
+ </manifest>
+ <manifestEntries>
+ <mode>development</mode>
+ <url>${pom.url}</url>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+</project>
+
Added: src/textClient/src/main/java/org/jboss/portletswap/textclient/TextClient.java
===================================================================
--- src/textClient/src/main/java/org/jboss/portletswap/textclient/TextClient.java (rev 0)
+++ src/textClient/src/main/java/org/jboss/portletswap/textclient/TextClient.java 2008-01-23 21:28:46 UTC (rev 215)
@@ -0,0 +1,404 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.portletswap.textclient;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
+import org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.common.util.Version;
+import org.jboss.portal.common.util.Version.Qualifier;
+import org.jboss.portletswap.DirectoryService;
+import org.jboss.portletswap.PortletswapException;
+import org.jboss.portletswap.RepositoryService;
+import org.jboss.portletswap.jcr.JCRServiceImpl;
+import org.jboss.portletswap.model.Artifact;
+import org.jboss.portletswap.model.Category;
+import org.jboss.portletswap.model.FileArtifact;
+import org.jboss.portletswap.model.Module;
+import org.jboss.portletswap.model.Type;
+import org.jboss.portletswap.repository.NotFoundException;
+import org.jboss.portletswap.repository.RepositoryException;
+import org.jboss.portletswap.repository.impl.jcr.RepositoryServiceImpl;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class TextClient
+{
+
+ public RepositoryService repositoryService;
+
+ private DirectoryService directoryService;
+
+ public TextClient()
+ {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ URL url = cl.getResource("jboss-beans.xml");
+
+ // Start JBoss Microcontainer
+ BasicBootstrap bootstrap = new BasicBootstrap();
+ bootstrap.run();
+
+ Kernel kernel = bootstrap.getKernel();
+
+ BasicXMLDeployer basicXMLDeployer = new BasicXMLDeployer(kernel);
+ try
+ {
+ basicXMLDeployer.deploy(url);
+ }
+ catch (Throwable e)
+ {
+ // FIXME
+ e.printStackTrace();
+ }
+
+ KernelController controller = kernel.getController();
+
+ ControllerContext context = controller.getInstalledContext("RepositoryService");
+ if (context != null) {
+ repositoryService = (RepositoryService) context.getTarget();
+ ((JCRServiceImpl)((RepositoryServiceImpl)repositoryService).getJcrService()).init();
+ }
+
+ context = controller.getInstalledContext("DirectoryService");
+ if (context != null) {
+ directoryService = (DirectoryService) context.getTarget();
+ }
+
+ }
+
+ /** FIXME Comment this
+ *
+ * @param args
+ */
+ public static void main(String[] args)
+ {
+ TextClient textClient = null;
+ try
+ {
+ textClient = new TextClient();
+ textClient.populate();
+ }
+ catch (Exception e)
+ {
+ // FIXME
+ e.printStackTrace();
+ }
+ catch (Throwable e)
+ {
+ // FIXME
+ e.printStackTrace();
+ }
+
+ String action = null;
+ if (args.length == 0)
+ {
+ action = "help";
+ }
+ else
+ {
+ action = args[0].substring(1);
+ }
+
+ if ("listCategories".equals(action))
+ {
+ textClient.listCategories();
+ }
+ else if ("listModules".equals(action))
+ {
+ textClient.listModules();
+ }
+ else if ("addCategory".equals(action))
+ {
+ textClient.addCategory();
+ }
+ else if ("addModule".equals(action))
+ {
+ textClient.addModule();
+ }
+ else if ("addFileArtifact".equals(action))
+ {
+ textClient.addFileArtifact();
+ }
+ else
+ {
+ System.out.println("Unknown command: ");
+ System.out.println(" -listCategories : List all categories");
+ System.out.println(" -listModules : List all modules");
+ System.out.println(" -addCategory : Add a new category");
+ System.out.println(" -addModule : Add a new module");
+ System.out.println(" -addFileArtifact : Add a file artifact");
+ }
+
+ }
+
+ private void listModules()
+ {
+ List<Module> modules = directoryService.getModules(false);
+ for (Module module: modules)
+ {
+ System.out.println(" Module " + module.getName() + " : " + module.getId());
+ }
+ }
+
+ // cc178f72-4bca-48f3-95fa-e592e29e3fc7
+ private void addFileArtifact()
+ {
+ System.out.println("Enter an artifact file path:");
+ System.out.print("> ");
+
+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
+
+ String filename = null;
+ try {
+ filename = br.readLine();
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+
+ System.out.println("Enter a module id:");
+ System.out.print("> ");
+
+ br = new BufferedReader(new InputStreamReader(System.in));
+
+ String moduleId = null;
+ try {
+ moduleId = br.readLine();
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+
+ try
+ {
+ Module module = repositoryService.getModule(moduleId);
+ Artifact artifact = new FileArtifact(Type.JSR168PORTLET, new File(filename), new FileInputStream(filename));
+ artifact = repositoryService.storeArtifact(module, artifact);
+ System.out.println("Successfully inserted artifact: " + artifact.getId());
+ }
+ catch (PortletswapException e)
+ {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ catch (FileNotFoundException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ private void addModule()
+ {
+ System.out.println("Enter a module name:");
+ System.out.print("> ");
+
+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
+
+ String moduleName = null;
+ try {
+ moduleName = br.readLine();
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+
+ Version version = new Version("", 1, 0, 0, new Version.Qualifier(Version.Qualifier.Prefix.GA), "");
+
+ System.out.println("Enter a category id:");
+ System.out.print("> ");
+
+ br = new BufferedReader(new InputStreamReader(System.in));
+
+ String categoryId = null;
+ try {
+ categoryId = br.readLine();
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+
+ try
+ {
+ Category category = repositoryService.getCategory(categoryId);
+ Module module = new Module(moduleName, version);
+ List<Category> categories = new ArrayList<Category>();
+ categories.add(category);
+ module.setCategories(categories);
+ module = repositoryService.storeModule(module);
+ System.out.println("Successfully inserted module: " + module.getId());
+ }
+ catch (PortletswapException e)
+ {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+
+ private void addCategory()
+ {
+ System.out.println("Enter a category name:");
+ System.out.print("> ");
+
+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
+
+ String categoryName = null;
+ try {
+ categoryName = br.readLine();
+ } catch (IOException ioe) {
+ System.out.println("IO error trying to read your name!");
+ System.exit(1);
+ }
+
+ System.out.println("Enter a parent category id:");
+ System.out.print("> ");
+
+ br = new BufferedReader(new InputStreamReader(System.in));
+
+ String categoryId = null;
+ try {
+ categoryId = br.readLine();
+ } catch (IOException ioe) {
+ System.out.println("IO error trying to read your name!");
+ System.exit(1);
+ }
+
+ try
+ {
+ Category parent = repositoryService.getCategory(categoryId);
+ Category newCategory = new Category(categoryName, parent);
+ repositoryService.storeCategory(newCategory);
+ }
+ catch (PortletswapException e)
+ {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+
+ private void listCategories()
+ {
+ Category root = null;
+ try
+ {
+ root = repositoryService.getRootCategory();
+ }
+ catch (RepositoryException e)
+ {
+ e.printStackTrace();
+ }
+ catch (NotFoundException e)
+ {
+ e.printStackTrace();
+ }
+ System.out.println("CATEGORIES");
+ System.out.println("+ Root");
+ listCategories(root, 1);
+ }
+
+ private void listCategories(Category category, int index)
+ {
+ for (Category tmpCategory: category.getChildren())
+ {
+ for (int i=0; i<index*3; i++)
+ {
+ System.out.print(" ");
+ }
+ System.out.println("+ " + tmpCategory.getName() + " : " + tmpCategory.getId());
+ listCategories(tmpCategory, index+1);
+ }
+ }
+
+ public void populate() throws RepositoryException
+ {
+ Version version1 = new Version("", 1, 0, 0, new Qualifier(Qualifier.Prefix.ALPHA), "");
+ Module module1 = new Module("Module1", version1);
+ FileArtifact fileArtifact1_1 = new FileArtifact(Type.JSR168PORTLET, null, null);
+ fileArtifact1_1.setDisplayName(new LocalizedString("Artifact 1:1", Locale.ENGLISH));
+ module1.addArtifact(fileArtifact1_1);
+ module1 = repositoryService.storeModule(module1);
+
+ Version version2 = new Version("", 1, 0, 0, new Qualifier(Qualifier.Prefix.CR), "");
+ Module module2 = new Module("Module2", version2);
+ module2 = repositoryService.storeModule(module2);
+
+ Version version3 = new Version("", 1, 0, 0, new Qualifier(Qualifier.Prefix.BETA), "");
+ Module module3 = new Module("Module3", version3);
+ module3 = repositoryService.storeModule(module3);
+
+ Module module4 = new Module("Module4", version1);
+ FileArtifact fileArtifact4_1 = new FileArtifact(Type.JSR168PORTLET, null, null);
+ fileArtifact4_1.setDisplayName(new LocalizedString("Artifact 4:1", Locale.ENGLISH));
+ module4.addArtifact(fileArtifact4_1);
+ FileArtifact fileArtifact4_2 = new FileArtifact(Type.JSR168PORTLET, null, null);
+ fileArtifact4_2.setDisplayName(new LocalizedString("Artifact 4:2", Locale.ENGLISH));
+ module4.addArtifact(fileArtifact4_2);
+ module4 = repositoryService.storeModule(module4);
+
+ Module module5 = new Module("Module5", version2);
+ module5 = repositoryService.storeModule(module5);
+
+ Category rootCategory;
+ try
+ {
+ rootCategory = repositoryService.getRootCategory();
+ Category category_1 = new Category("Category_1", rootCategory);
+ category_1 = repositoryService.storeCategory(category_1);
+ @SuppressWarnings("unused")
+ Category category_1_1 = new Category("Category_1_1", category_1);
+ category_1_1 = repositoryService.storeCategory(category_1_1);
+ @SuppressWarnings("unused")
+ Category category_1_2 = new Category("Category_1_2", category_1);
+ category_1_2 = repositoryService.storeCategory(category_1_2);
+ @SuppressWarnings("unused")
+ Category category_1_2_1 = new Category("Category_1_2_1", category_1_2);
+ category_1_2_1 = repositoryService.storeCategory(category_1_2_1);
+ @SuppressWarnings("unused")
+ Category category_2 = new Category("Category_2", rootCategory);
+ category_2 = repositoryService.storeCategory(category_2);
+ }
+ catch (NotFoundException e)
+ {
+ // FIXME
+ e.printStackTrace();
+ }
+
+
+ }
+}
+
Added: src/textClient/src/test/resources/settings.xml
===================================================================
--- src/textClient/src/test/resources/settings.xml (rev 0)
+++ src/textClient/src/test/resources/settings.xml 2008-01-23 21:28:46 UTC (rev 215)
@@ -0,0 +1,40 @@
+<Repository>
+ <FileSystem
+ class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+ <param name="path" value="${rep.home}/repository" />
+ </FileSystem>
+ <Security appName="Jackrabbit">
+ <AccessManager
+ class="org.apache.jackrabbit.core.security.SimpleAccessManager" />
+ <LoginModule
+ class="org.apache.jackrabbit.core.security.SimpleLoginModule">
+ <param name="anonymousId" value="anonymous" />
+ </LoginModule>
+ </Security>
+ <Workspaces rootPath="${rep.home}/workspaces"
+ defaultWorkspace="default" />
+ <Workspace name="${wsp.name}">
+ <FileSystem
+ class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+ <param name="path" value="${wsp.home}" />
+ </FileSystem>
+ <PersistenceManager
+ class="org.apache.jackrabbit.core.state.xml.XMLPersistenceManager" />
+ <SearchIndex
+ class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+ <param name="path" value="${wsp.home}/index" />
+ </SearchIndex>
+ </Workspace>
+ <Versioning rootPath="${rep.home}/version">
+ <FileSystem
+ class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+ <param name="path" value="${rep.home}/version" />
+ </FileSystem>
+ <PersistenceManager
+ class="org.apache.jackrabbit.core.state.xml.XMLPersistenceManager" />
+ </Versioning>
+ <SearchIndex
+ class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+ <param name="path" value="${rep.home}/repository/index" />
+ </SearchIndex>
+</Repository>
\ No newline at end of file
More information about the jboss-svn-commits
mailing list