You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(233) |
Sep
(199) |
Oct
(206) |
Nov
(185) |
Dec
(270) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(232) |
Feb
(426) |
Mar
(623) |
Apr
(592) |
May
(506) |
Jun
(389) |
Jul
(160) |
Aug
(3) |
Sep
(1) |
Oct
(1) |
Nov
(2) |
Dec
(5) |
2007 |
Jan
(1) |
Feb
(1) |
Mar
(2) |
Apr
(2) |
May
(4) |
Jun
(2) |
Jul
|
Aug
(3) |
Sep
(5) |
Oct
(9) |
Nov
(6) |
Dec
(6) |
2008 |
Jan
(3) |
Feb
|
Mar
(1) |
Apr
(3) |
May
(3) |
Jun
(5) |
Jul
(10) |
Aug
(2) |
Sep
(12) |
Oct
(10) |
Nov
(54) |
Dec
(49) |
2009 |
Jan
(19) |
Feb
(13) |
Mar
(20) |
Apr
(24) |
May
(44) |
Jun
(29) |
Jul
(32) |
Aug
(10) |
Sep
(7) |
Oct
(10) |
Nov
(4) |
Dec
(17) |
2010 |
Jan
(14) |
Feb
(5) |
Mar
(23) |
Apr
(50) |
May
(31) |
Jun
(9) |
Jul
(5) |
Aug
(4) |
Sep
(7) |
Oct
(5) |
Nov
(2) |
Dec
(3) |
2011 |
Jan
(12) |
Feb
(5) |
Mar
(5) |
Apr
(3) |
May
(4) |
Jun
(3) |
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
2012 |
Jan
(1) |
Feb
(2) |
Mar
|
Apr
(1) |
May
(1) |
Jun
(2) |
Jul
(4) |
Aug
(1) |
Sep
|
Oct
(1) |
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
(1) |
2015 |
Jan
|
Feb
|
Mar
(2) |
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <jbo...@li...> - 2006-02-04 11:00:31
|
Author: adamw Date: 2006-02-04 06:00:21 -0500 (Sat, 04 Feb 2006) New Revision: 2261 Modified: trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/ContentManager.java Log: Small bug Modified: trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/ContentManager.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/ContentManager.java 2006-02-04 10:07:14 UTC (rev 2260) +++ trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/ContentManager.java 2006-02-04 11:00:21 UTC (rev 2261) @@ -538,19 +538,14 @@ /** * Gets a property of this content manager, as it is written in the - * configuration file (helper method for implementations). Only internal - * properties! + * configuration file (helper method). * * @param name * Name of the property to get. * @return Value of the given property or null, if no such property exists. */ - public static String getProperty(String name) { - if (name.startsWith(Constants.PROPERTIES_INTERNAL)) { - return props.getString(name); - } else { - return null; - } + private static String getProperty(String name) { + return props.getString(name); } /** |
From: <jbo...@li...> - 2006-02-04 10:07:20
|
Author: szimano Date: 2006-02-04 05:07:14 -0500 (Sat, 04 Feb 2006) New Revision: 2260 Modified: trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ContentSettingTest.java Log: content setting test bug Modified: trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ContentSettingTest.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ContentSettingTest.java 2006-02-03 23:32:43 UTC (rev 2259) +++ trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ContentSettingTest.java 2006-02-04 10:07:14 UTC (rev 2260) @@ -43,7 +43,6 @@ @Override protected void setUp() throws Exception { - log.info("setup"); Node n = cm.getRootDirectory().newNode(TEST_FILE); n.save(TEST_FILE); } @@ -94,7 +93,6 @@ @Override protected void tearDown() throws Exception { - log.info("del"); cm.getNode(TEST_FILE).delete(); } } |
From: <jbo...@li...> - 2006-02-03 23:32:54
|
Author: szimano Date: 2006-02-03 18:32:43 -0500 (Fri, 03 Feb 2006) New Revision: 2259 Added: trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/files/ trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/files/test/ trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/files/test/AddGetTest.java Modified: trunk/forge/portal-extensions/shotoku/shotoku-files/src/java/org/jboss/shotoku/files/FileContentManager.java trunk/forge/portal-extensions/shotoku/shotoku-files/src/java/org/jboss/shotoku/files/FileDirectory.java trunk/forge/portal-extensions/shotoku/shotoku-files/src/java/org/jboss/shotoku/files/FileNode.java trunk/forge/portal-extensions/shotoku/shotoku-files/src/java/org/jboss/shotoku/files/FileTools.java trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ContentSettingTest.java Log: testing and modifications to shotoku-files JBSHOTOKU-53 Modified: trunk/forge/portal-extensions/shotoku/shotoku-files/src/java/org/jboss/shotoku/files/FileContentManager.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-files/src/java/org/jboss/shotoku/files/FileContentManager.java 2006-02-03 23:03:01 UTC (rev 2258) +++ trunk/forge/portal-extensions/shotoku/shotoku-files/src/java/org/jboss/shotoku/files/FileContentManager.java 2006-02-03 23:32:43 UTC (rev 2259) @@ -72,8 +72,8 @@ // create paths - pathToRepoCurrent = pathToRepo + File.pathSeparator + CURRENT; - pathToRepoHistory = pathToRepo + File.pathSeparator + HISTORY; + pathToRepoCurrent = pathToRepo + "/" + CURRENT; + pathToRepoHistory = pathToRepo + "/" + HISTORY; // check for current and history existance File fileCur = new File(pathToRepoCurrent); @@ -94,7 +94,7 @@ @Override public Directory getRootDirectory() throws RepositoryException { - return new FileDirectory(getPathToRepoCurrent(), this); + return new FileDirectory(getPathToRepoCurrent(), "", this); } @Override @@ -130,11 +130,11 @@ } public String getPathToRepoCurrent() { - return pathToRepoCurrent + File.pathSeparator + prefix; + return pathToRepoCurrent + "/" + prefix; } public String getPathToRepoHistory() { - return pathToRepoHistory + File.pathSeparator + prefix; + return pathToRepoHistory + "/" + prefix; } public String getPrefix() { Modified: trunk/forge/portal-extensions/shotoku/shotoku-files/src/java/org/jboss/shotoku/files/FileDirectory.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-files/src/java/org/jboss/shotoku/files/FileDirectory.java 2006-02-03 23:03:01 UTC (rev 2258) +++ trunk/forge/portal-extensions/shotoku/shotoku-files/src/java/org/jboss/shotoku/files/FileDirectory.java 2006-02-03 23:32:43 UTC (rev 2259) @@ -30,6 +30,7 @@ import java.util.List; import java.util.Map; import java.util.Properties; +import java.util.Stack; import org.apache.log4j.Logger; import org.jboss.shotoku.Directory; @@ -53,37 +54,51 @@ private String dirPath; - private Properties props; + private Properties props = new Properties(); private boolean dirChanged = false; private Logger log = Logger.getLogger(this.getClass()); + /** * */ private static final long serialVersionUID = 1L; - public FileDirectory(String directory, FileContentManager manager) - throws RepositoryException { + public FileDirectory(FileDirectory parent, String directory, + FileContentManager manager) throws RepositoryException { + + init(parent.getDirFullPath() + "/" + directory, directory, manager); + } + + public FileDirectory(String fullPath, String dirName, + FileContentManager manager) throws RepositoryException { + + init(fullPath, dirName, manager); + } + + private void init(String fullPath, String directory, + FileContentManager manager) { directory = FileTools.normalizeName(directory); - dirFullPath = manager.getPathToRepoCurrent() + File.pathSeparator - + directory; + dirFullPath = fullPath; dirPath = directory; - File dir = new File(dirFullPath); + this.directory = new File(dirFullPath); this.manager = manager; - if (!dir.exists()) + if (!this.directory.exists()) dirChanged = true; - if (dir.exists() && !dir.isDirectory()) { + if (this.directory.exists() && !this.directory.isDirectory()) { throw new RepositoryException(directory + " is not a directory"); } + } - this.directory = dir; + public String getDirFullPath() { + return dirFullPath; } public NodeList getNodes() throws RepositoryException { @@ -119,8 +134,7 @@ // get all children for (File directory : children) { if (directory.isDirectory()) { - list.add(new FileDirectory(dirFullPath + File.pathSeparator - + directory.getName(), manager)); + list.add(new FileDirectory(this, directory.getName(), manager)); } } @@ -131,11 +145,10 @@ ResourceDoesNotExist { name = FileTools.normalizeName(name); - File file = new File(this.directory.getAbsolutePath() - + File.pathSeparator + name); + File file = new File(this.directory.getAbsolutePath() + "/" + name); log.info(file.getAbsoluteFile()); - + if (!file.exists()) { throw new ResourceDoesNotExist("File " + file.getAbsolutePath() + " doesn't exists"); @@ -153,38 +166,26 @@ name = FileTools.normalizeName(name); - File dir = new File(this.directory.getAbsolutePath() - + File.pathSeparator + name); + File dir = new File(this.directory.getAbsolutePath() + "/" + name); if (!dir.exists()) { throw new RepositoryException("Directory " + dir.getAbsolutePath() + " doesn't exists"); } - return new FileDirectory(dirFullPath + File.pathSeparator + name, - manager); + return new FileDirectory(this, name, manager); } public Node newNode(String name) throws ResourceAlreadyExists, RepositoryException { - + name = FileTools.normalizeName(name); - - File file = new File(this.directory.getAbsolutePath() - + File.pathSeparator + name); + File file = new File(this.directory.getAbsolutePath() + "/" + name); + if (file.exists()) { throw new ResourceAlreadyExists("File " + file.getAbsolutePath() + " already exists"); - } else { - try { - if (!file.createNewFile()) { - throw new RepositoryException("Couldn't create new file: " - + file.getAbsolutePath()); - } - } catch (IOException e) { - throw new RepositoryException(e); - } } try { @@ -197,7 +198,7 @@ public Directory newDirectory(String name) throws ResourceAlreadyExists, RepositoryException { - File dir = new File(this.directory.getAbsolutePath() + name); + File dir = new File(this.directory.getAbsolutePath() + "/" + name); if (dir.exists()) { throw new ResourceAlreadyExists("Directory " @@ -209,8 +210,7 @@ } } - return new FileDirectory(dirFullPath + File.pathSeparator + name, - manager); + return new FileDirectory(this, name, manager); } public boolean hasIndex(String arg0) throws RepositoryException { @@ -379,13 +379,38 @@ } public Directory getParent() throws RepositoryException { - return new FileDirectory(directory.getParent(), manager); + return new FileDirectory(directory.getParent(), directory + .getParentFile().getName(), manager); } public void delete() throws DeleteException, RepositoryException { - if (!directory.delete()) { - throw new DeleteException("Couldn't delete directory: " - + dirFullPath); + + File curDir = directory; + + while (directory.exists()) { + File[] files = curDir.listFiles(); + + for (int i = 0; i < files.length; i++) { + if (files[i].isFile()) { + if (!files[i].delete()) { + throw new DeleteException("Couldn't delete directory: " + + dirFullPath); + } + } + } + // after deleting all files check if directory can be deleted + if (curDir.listFiles().length == 0) { + File tmp = curDir; + curDir = directory.getParentFile(); + if (!tmp.delete()) { + throw new DeleteException("Couldn't delete directory: " + + dirFullPath); + } + } else { + // if not - delete next directory + curDir = curDir.listFiles()[0]; + } + } } Modified: trunk/forge/portal-extensions/shotoku/shotoku-files/src/java/org/jboss/shotoku/files/FileNode.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-files/src/java/org/jboss/shotoku/files/FileNode.java 2006-02-03 23:03:01 UTC (rev 2258) +++ trunk/forge/portal-extensions/shotoku/shotoku-files/src/java/org/jboss/shotoku/files/FileNode.java 2006-02-03 23:32:43 UTC (rev 2259) @@ -33,6 +33,7 @@ import java.util.Map; import java.util.Properties; +import org.apache.log4j.Logger; import org.jboss.shotoku.Directory; import org.jboss.shotoku.History; import org.jboss.shotoku.Node; @@ -54,7 +55,7 @@ private Directory directory; - private Properties props; + private Properties props = new Properties(); private boolean propsChanged = false; @@ -64,6 +65,8 @@ private boolean lastVersion = true; + private Logger log = Logger.getLogger(this.getClass()); + /** * */ @@ -72,37 +75,43 @@ public FileNode(Directory directory, String node, boolean newFile, FileContentManager manager) throws RepositoryException, ResourceAlreadyExists, ResourceDoesNotExist { - + node = FileTools.normalizeName(node); + + file = new File(directory + "/" + node); - File fil = new File(directory + File.pathSeparator + node); - this.manager = manager; this.directory = directory; - if (!fil.isFile()) { - throw new RepositoryException(directory + File.pathSeparator + node + if (!newFile && !file.isFile()) { + throw new RepositoryException(directory + "/" + node + " is not a file"); } if (!newFile) { + lastVersion = false; refreshProps(); } - if (newFile && fil.exists()) { - throw new ResourceAlreadyExists(fil.getAbsolutePath() + " already exists"); - } else if (!newFile && !fil.exists()) { - throw new ResourceDoesNotExist(fil.getAbsolutePath() + " doesn't exists"); + if (newFile && file.exists()) { + log.info(file.getAbsolutePath() + " " + file.exists()); + + throw new ResourceAlreadyExists(file.getAbsolutePath() + + " already exists"); + } else if (!newFile && !file.exists()) { + throw new ResourceDoesNotExist(file.getAbsolutePath() + + " doesn't exists"); } - this.file = fil; - - String suffix = node.substring(node.lastIndexOf("."), node.length()); + String suffix; - if (suffix.length() == 0) { + if (node.lastIndexOf(".") != -1) { + suffix = node + .substring(node.lastIndexOf("."), node.length()); + } else { suffix = ".bin"; } - + try { tmpFile = File.createTempFile("shotoku-file", suffix); } catch (IOException e) { @@ -125,10 +134,10 @@ InputStream is = new FileInputStream( (contentChanged || lastVersion) ? tmpFile : file); - char chr; + int chr; - while ((chr = (char) is.read()) != -1) { - buffer.append(chr); + while ((chr = is.read()) != -1) { + buffer.append((char)chr); } is.close(); @@ -327,7 +336,7 @@ */ public void moveTo(Directory dir, String logMessage) throws MoveException { - File toFile = new File(dir + File.pathSeparator + file.getName()); + File toFile = new File(dir + "/" + file.getName()); try { // get new node @@ -432,7 +441,7 @@ * directory is already the root directory. */ public Directory getParent() throws RepositoryException { - return new FileDirectory(file.getParent(), manager); + return new FileDirectory(file.getParent(), file.getParentFile().getName(), manager); } /** @@ -473,19 +482,22 @@ // save props version try { OutputStream hisProps = new FileOutputStream(nextPropFile); - + // get current props - FileTools.getPropertiesForNode(this, manager).store(hisProps, FileTools.STORE_TEXT); - + FileTools.getPropertiesForNode(this, manager).store(hisProps, + FileTools.STORE_TEXT); + hisProps.close(); } catch (IOException e) { throw new RepositoryException(e); } - + // save prevoius version copyToFile(file.getAbsolutePath()); // save new version + log.info(file.getAbsolutePath()); + FileOutputStream newFileOS = null; try { newFileOS = new FileOutputStream(file); @@ -539,7 +551,7 @@ } throw new RepositoryException(e); } - + // set bools to false lastVersion = contentChanged = propsChanged = false; } @@ -575,13 +587,17 @@ * @throws RepositoryException */ public void delete() throws DeleteException, RepositoryException { - try { - if (!file.delete()) { - throw new DeleteException("Couldn't delete file " - + file.getAbsolutePath()); + if (file.exists()) { + try { + if (!file.delete()) { + throw new DeleteException("Couldn't delete file " + + file.getAbsolutePath()); + } else { + log.info("File deleted"); + } + } catch (SecurityException e) { + throw new RepositoryException(e); } - } catch (SecurityException e) { - throw new RepositoryException(e); } } @@ -603,8 +619,7 @@ */ public String getFullName() { return file.getAbsolutePath().replace( - manager.getPathToRepoCurrent() + File.pathSeparator - + manager.getPrefix(), ""); + manager.getPathToRepoCurrent() + "/" + manager.getPrefix(), ""); } public Directory getDirectory() { Modified: trunk/forge/portal-extensions/shotoku/shotoku-files/src/java/org/jboss/shotoku/files/FileTools.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-files/src/java/org/jboss/shotoku/files/FileTools.java 2006-02-03 23:03:01 UTC (rev 2258) +++ trunk/forge/portal-extensions/shotoku/shotoku-files/src/java/org/jboss/shotoku/files/FileTools.java 2006-02-03 23:32:43 UTC (rev 2259) @@ -48,7 +48,7 @@ static { mimeTypes = new MimetypesFileTypeMap(FileTools.class - .getResourceAsStream("/mime.types.txt")); + .getResourceAsStream("/mime-types.txt")); } public static String getMimeType(File file) { @@ -62,8 +62,8 @@ manager.getPathToRepoCurrent(), ""); String pathToHistory = manager.getPathToRepoHistory() - + File.pathSeparator + directory + File.pathSeparator - + node.getNodeName() + "-his" + File.pathSeparator + revison + + "/" + directory + "/" + + node.getNodeName() + "-his" + "/" + revison + REVISION_SUFFIX; File hisFile = new File(pathToHistory); @@ -77,7 +77,7 @@ manager.getPathToRepoCurrent(), ""); String pathToHistory = manager.getPathToRepoHistory() - + File.pathSeparator + directory + File.pathSeparator + + "/" + directory + "/" + node.getNodeName() + "-his"; File hisFile = new File(pathToHistory); @@ -91,12 +91,12 @@ manager.getPathToRepoCurrent(), ""); String pathToHistory = manager.getPathToRepoHistory() - + File.pathSeparator + directory + File.pathSeparator + + "/" + directory + "/" + node.getNodeName() + "-his"; createHistoryStructure(pathToHistory); - File hisFile = new File(pathToHistory + File.pathSeparator + HIST_PROPS); + File hisFile = new File(pathToHistory + "/" + HIST_PROPS); return hisFile; } @@ -107,12 +107,12 @@ manager.getPathToRepoCurrent(), ""); String pathToProps = manager.getPathToRepoHistory() - + File.pathSeparator + directory + File.pathSeparator + + "/" + directory + "/" + node.getNodeName() + "-his"; createHistoryStructure(pathToProps); - File propsFile = new File(pathToProps + File.pathSeparator + PROPS); + File propsFile = new File(pathToProps + "/" + PROPS); return propsFile; } @@ -160,9 +160,9 @@ // create structure hisDir.mkdirs(); try { - (new File(hisDirStr + File.pathSeparator + HIST_PROPS)) + (new File(hisDirStr + "/" + HIST_PROPS)) .createNewFile(); - (new File(hisDirStr + File.pathSeparator + PROPS)) + (new File(hisDirStr + "/" + PROPS)) .createNewFile(); } catch (IOException e) { throw new RepositoryException(e); @@ -177,12 +177,12 @@ manager.getPathToRepoCurrent(), ""); String pathToHistory = manager.getPathToRepoHistory() - + File.pathSeparator + directory + File.pathSeparator + + "/" + directory + "/" + node.getNodeName() + "-his"; createHistoryStructure(pathToHistory); - File hisFile = new File(pathToHistory + File.pathSeparator + version + File hisFile = new File(pathToHistory + "/" + version + REVISION_SUFFIX); return hisFile; @@ -195,12 +195,12 @@ manager.getPathToRepoCurrent(), ""); String pathToHistory = manager.getPathToRepoHistory() - + File.pathSeparator + directory + File.pathSeparator + + "/" + directory + "/" + node.getNodeName() + "-his"; createHistoryStructure(pathToHistory); - File hisFile = new File(pathToHistory + File.pathSeparator + version + File hisFile = new File(pathToHistory + "/" + version + PROPERTIES_SUFFIX); return hisFile; @@ -213,10 +213,10 @@ manager.getPathToRepoCurrent(), ""); String pathToHistory = manager.getPathToRepoHistory() - + File.pathSeparator + directory + File.pathSeparator + + "/" + directory + "/" + node.getNodeName() + "-his"; - File hisFile = new File(pathToHistory + File.pathSeparator + version + File hisFile = new File(pathToHistory + "/" + version + PROPERTIES_SUFFIX); Properties props = new Properties(); @@ -237,7 +237,7 @@ public static File getHistoryDir(FileDirectory directory, FileContentManager manager) { File historyDir = new File(manager.getPathToRepoHistory() - + File.pathSeparator + directory.getFullName() + "-his"); + + "/" + directory.getFullName() + "-his"); if (!historyDir.exists()) { historyDir.mkdirs(); @@ -249,7 +249,7 @@ public static File getPropertiesFileForDirectory(FileDirectory directory, FileContentManager manager) throws IOException { File propsFile = new File(manager.getPathToRepoHistory() - + File.pathSeparator + directory.getFullName() + "-his" + File.pathSeparator + PROPS); + + "/" + directory.getFullName() + "-his" + "/" + PROPS); if (!propsFile.exists()) { getHistoryDir(directory, manager); Added: trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/files/test/AddGetTest.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/files/test/AddGetTest.java 2006-02-03 23:03:01 UTC (rev 2258) +++ trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/files/test/AddGetTest.java 2006-02-03 23:32:43 UTC (rev 2259) @@ -0,0 +1,62 @@ +/* + * 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.shotoku.files.test; + +import org.jboss.shotoku.ContentManager; +import org.jboss.shotoku.Node; +import org.jboss.shotoku.exceptions.RepositoryException; +import org.jboss.shotoku.exceptions.ResourceAlreadyExists; + +public class AddGetTest { + + /** + * @param args + * @throws ResourceAlreadyExists + * @throws RepositoryException + */ + public static void main(String[] args) { + try { + if (ContentManager.isEmbedded()) { + ContentManager.setup(); + } + + ContentManager cm = ContentManager.getContentManager("default", + "shotoku-test"); + + Node n = cm.getRootDirectory().newNode("moj_nowy_node"); + n.setContent("dupa"); + n.save("ble"); + + System.out.println("Node saved"); + + Node n2 = cm.getNode("moj_nowy_node"); + System.out.println("Node content:\n"+n2.getContent()); + + n2.delete(); + + System.out.println("Node deleted"); + } catch (Exception e) { + e.printStackTrace(); + } + } + +} Modified: trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ContentSettingTest.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ContentSettingTest.java 2006-02-03 23:03:01 UTC (rev 2258) +++ trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ContentSettingTest.java 2006-02-03 23:32:43 UTC (rev 2259) @@ -25,6 +25,7 @@ import java.util.Arrays; import org.jboss.shotoku.Node; +import org.jboss.shotoku.exceptions.DeleteException; import org.jboss.shotoku.exceptions.RepositoryException; import org.jboss.shotoku.exceptions.ResourceAlreadyExists; import org.jboss.shotoku.exceptions.ResourceDoesNotExist; @@ -42,6 +43,7 @@ @Override protected void setUp() throws Exception { + log.info("setup"); Node n = cm.getRootDirectory().newNode(TEST_FILE); n.save(TEST_FILE); } @@ -51,7 +53,7 @@ assertTrue(Arrays.equals(content.getBytes(), n.getContentByteArray())); } - public void testString() throws ResourceAlreadyExists, ResourceDoesNotExist, RepositoryException, SaveException { + public void testString() throws ResourceAlreadyExists, ResourceDoesNotExist, RepositoryException, SaveException, DeleteException { // Getting the test node. Node n = cm.getNode(TEST_FILE); @@ -92,6 +94,7 @@ @Override protected void tearDown() throws Exception { + log.info("del"); cm.getNode(TEST_FILE).delete(); } } |
From: <jbo...@li...> - 2006-02-03 22:20:15
|
Author: wrzep Date: 2006-02-03 17:20:06 -0500 (Fri, 03 Feb 2006) New Revision: 2256 Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugins.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusTags.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesEvaluator.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/cc/CcStatusPlugin.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/jira/JiraStatusPlugin.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/svn/SvnStatusPlugin.java Log: Cleanup. Empty dir entries list NPE fix. http://jira.jboss.com/jira/browse/JBLAB-606 Pawel Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugins.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugins.java 2006-02-03 21:37:53 UTC (rev 2255) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugins.java 2006-02-03 22:20:06 UTC (rev 2256) @@ -44,12 +44,6 @@ public class Plugins {; - private final static String PLUGIN_ELEMENT = "plugin"; - - private final static String PLUGIN_ID_ELEMENT = "id"; - private final static String PLUGIN_CLASS_ELEMENT = "class"; - private final static String PLUGIN_PROPERTIES_ELEMENT = "properties"; - /** * All plugins stored in this class. */ @@ -96,8 +90,10 @@ // Get plugin info from pluginNode - String pluginClassString = XmlTools.getChildNodeValue(pluginNode, PLUGIN_CLASS_ELEMENT); - String pluginId = XmlTools.getChildNodeValue(pluginNode, PLUGIN_ID_ELEMENT); + String pluginClassString = + XmlTools.getChildNodeValue(pluginNode, StatusTags.PLUGIN_CLASS_ELEMENT); + String pluginId = + XmlTools.getChildNodeValue(pluginNode, StatusTags.PLUGIN_ID_ELEMENT); if ((pluginClassString == null) || (pluginId == null)) return null; @@ -112,7 +108,9 @@ } // Get plugin properties - Node pluginPropertiesNode = XmlTools.getFirstNodeWithName(pluginNode, PLUGIN_PROPERTIES_ELEMENT); + Node pluginPropertiesNode = + XmlTools.getFirstNodeWithName(pluginNode, + StatusTags.PLUGIN_PROPERTIES_ELEMENT); Properties pluginProperties = getPluginProperties(pluginPropertiesNode); // Get plugin instance; @@ -196,7 +194,7 @@ for (int i = 0; i < pluginNodes.getLength(); i++) { Node pluginNode = pluginNodes.item(i); - if (pluginNode.getNodeName() != PLUGIN_ELEMENT) { + if (pluginNode.getNodeName() != StatusTags.PLUGIN_ELEMENT) { continue; } Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java 2006-02-03 21:37:53 UTC (rev 2255) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java 2006-02-03 22:20:06 UTC (rev 2256) @@ -43,9 +43,6 @@ */ public class Status extends AbstractDescriptor { - private static final String MAIN_PAGE_COLLUMNS_TAG = "main-page"; - private static final String PROJECT_PAGE_COLLUMNS_TAG = "project-page"; - /** Columns to display on the main page */ private Columns mainPageColumns; @@ -77,11 +74,15 @@ plugins.addAll(scorePluginsRoot, portalName, true); // Get columns to display on the main page - Node mainPageRoot = XmlTools.getFirstNodeWithName(statusRoot, MAIN_PAGE_COLLUMNS_TAG); + Node mainPageRoot = + XmlTools.getFirstNodeWithName(statusRoot, + StatusTags.MAIN_PAGE_COLUMNS_TAG); mainPageColumns = new Columns(mainPageRoot, plugins, projects); // Get columns to display on the project page - Node projectPageRoot = XmlTools.getFirstNodeWithName(statusRoot, PROJECT_PAGE_COLLUMNS_TAG); + Node projectPageRoot = + XmlTools.getFirstNodeWithName(statusRoot, + StatusTags.PROJECT_PAGE_COLUMNS_TAG); projectPageColumns = new Columns(projectPageRoot, plugins, projects); allColumns = new Columns(projects); Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusTags.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusTags.java 2006-02-03 21:37:53 UTC (rev 2255) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusTags.java 2006-02-03 22:20:06 UTC (rev 2256) @@ -28,9 +28,27 @@ */ public class StatusTags { - public static final String COLUMNS_ELEMENT = "columns"; - public static final String ORDER_PLUGIN_ELEMENT = "order-plugin"; - + /* status.xml file tags */ + public static final String MAIN_PAGE_COLUMNS_TAG = "main-page"; + public static final String PROJECT_PAGE_COLUMNS_TAG = "project-page"; + public final static String COLUMNS_ELEMENT = "columns"; + public final static String ORDER_PLUGIN_ELEMENT = "order-plugin"; + + /* status-plugins.xml and score-plugins.xml tags */ + public final static String PLUGIN_ELEMENT = "plugin"; + + public final static String PLUGIN_ID_ELEMENT = "id"; + public final static String PLUGIN_CLASS_ELEMENT = "class"; + public final static String PLUGIN_PROPERTIES_ELEMENT = "properties"; + + /* project.xml files tags */ + public static final String JIRA_SERVICE_PROPERTY = "jira-service"; + public static final String JIRA_ADRESS_TAG = "jira-adress"; + public static final String SVN_SERVICE_PROPERTY = "svn-service"; + public static final String SVN_REPO_ADRESS_TAG = "svn-repo"; + public static final String CC_SERVICE_PROPERTY = "cc-service"; + public static final String CC_ADRESS_TAG = "cc-adress"; + /** * This class cannot be instatiated. */ Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesEvaluator.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesEvaluator.java 2006-02-03 21:37:53 UTC (rev 2255) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesEvaluator.java 2006-02-03 22:20:06 UTC (rev 2256) @@ -24,9 +24,10 @@ import java.io.ByteArrayOutputStream; import java.util.Collection; +import java.util.Map; import java.util.HashMap; -import java.util.Map; + import org.jboss.logging.Logger; import org.tmatesoft.svn.core.SVNDirEntry; import org.tmatesoft.svn.core.SVNException; @@ -95,9 +96,14 @@ */ private static long getCodeLinesNumber(SVNRepository repository, String path) { - long cl = 0; Collection<SVNDirEntry> dirEntries = getDirEntries(repository, path); + if (dirEntries == null) { + return 0; + } + + long cl = 0; + for (SVNDirEntry entry : dirEntries) { String entryPath = (path.equals("")) ? @@ -198,7 +204,6 @@ return repository; } - /** * Initializes the library to work with a repository either via svn:// * (and svn+ssh://) or via http:// (and https://) Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/cc/CcStatusPlugin.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/cc/CcStatusPlugin.java 2006-02-03 21:37:53 UTC (rev 2255) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/cc/CcStatusPlugin.java 2006-02-03 22:20:06 UTC (rev 2256) @@ -27,6 +27,7 @@ import java.net.MalformedURLException; +import org.jboss.forge.status.StatusTags; import org.jboss.forge.status.plugins.KosmosStatusPlugin; import org.jboss.logging.Logger; @@ -41,13 +42,12 @@ public abstract class CcStatusPlugin extends KosmosStatusPlugin { - private static final String CC_SERVICE_PROPERTY = "cc-service"; - private static final String CC_ADRESS_TAG = "cc-adress"; - private static final String CC_LINK_NAME = "CruiseControl location"; @Override - protected String getKosmosServiceTag() { return CC_SERVICE_PROPERTY;}; + protected String getKosmosServiceTag() { + return StatusTags.CC_SERVICE_PROPERTY; + }; protected Logger log; @@ -98,7 +98,7 @@ private String getCcURL(String projectId) { - String ccURL = projects.getProjectProperty(projectId, CC_ADRESS_TAG); + String ccURL = projects.getProjectProperty(projectId, StatusTags.CC_ADRESS_TAG); return (ccURL == "" ? null : ccURL); } Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/jira/JiraStatusPlugin.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/jira/JiraStatusPlugin.java 2006-02-03 21:37:53 UTC (rev 2255) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/jira/JiraStatusPlugin.java 2006-02-03 22:20:06 UTC (rev 2256) @@ -27,6 +27,7 @@ import java.net.MalformedURLException; +import org.jboss.forge.status.StatusTags; import org.jboss.forge.status.plugins.KosmosStatusPlugin; import org.jboss.logging.Logger; @@ -41,12 +42,11 @@ public abstract class JiraStatusPlugin extends KosmosStatusPlugin { - private static final String JIRA_SERVICE_PROPERTY = "jira-service"; - private static final String JIRA_ADRESS_TAG = "jira-adress"; - private static final String JIRA_LINK_NAME = "JIRA location"; - protected String getKosmosServiceTag() { return JIRA_SERVICE_PROPERTY;}; + protected String getKosmosServiceTag() { + return StatusTags.JIRA_SERVICE_PROPERTY; + }; protected Logger log; @@ -96,7 +96,7 @@ private String getJiraURL(String projectId) { - String jiraURL = projects.getProjectProperty(projectId, JIRA_ADRESS_TAG); + String jiraURL = projects.getProjectProperty(projectId, StatusTags.JIRA_ADRESS_TAG); return (jiraURL == "" ? null : jiraURL); } Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/svn/SvnStatusPlugin.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/svn/SvnStatusPlugin.java 2006-02-03 21:37:53 UTC (rev 2255) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/svn/SvnStatusPlugin.java 2006-02-03 22:20:06 UTC (rev 2256) @@ -27,6 +27,7 @@ import java.net.MalformedURLException; +import org.jboss.forge.status.StatusTags; import org.jboss.forge.status.plugins.KosmosStatusPlugin; import org.jboss.logging.Logger; @@ -41,12 +42,11 @@ public abstract class SvnStatusPlugin extends KosmosStatusPlugin { - private static final String SVN_SERVICE_PROPERTY = "svn-service"; - private static final String SVN_REPO_ADRESS_TAG = "svn-repo"; - private static final String SVN_LINK_NAME = "Svn repository location"; - protected String getKosmosServiceTag() { return SVN_SERVICE_PROPERTY;}; + protected String getKosmosServiceTag() { + return StatusTags.SVN_SERVICE_PROPERTY; + }; protected Logger log; @@ -96,7 +96,7 @@ } private String getRepoURL(String projectId) { - String repoURL = projects.getProjectProperty(projectId, SVN_REPO_ADRESS_TAG); + String repoURL = projects.getProjectProperty(projectId, StatusTags.SVN_REPO_ADRESS_TAG); return (repoURL == "" ? null : repoURL); } |
From: <jbo...@li...> - 2006-02-03 21:37:59
|
Author: wrzep Date: 2006-02-03 16:37:53 -0500 (Fri, 03 Feb 2006) New Revision: 2255 Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesEvaluator.java Log: http://jira.jboss.com/jira/browse/JBLAB-606 PAwel Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesEvaluator.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesEvaluator.java 2006-02-03 21:36:10 UTC (rev 2254) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesEvaluator.java 2006-02-03 21:37:53 UTC (rev 2255) @@ -67,8 +67,8 @@ return 0; /* Authentication handling */ - /*ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(userName, password); - repository.setAuthenticationManager(authManager);*/ + ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(userName, password); + repository.setAuthenticationManager(authManager); /* Analyze */ log.debug("Analyzing repository " + repository.getLocation() + "."); |
From: <jbo...@li...> - 2006-02-03 21:36:18
|
Author: wrzep Date: 2006-02-03 16:36:10 -0500 (Fri, 03 Feb 2006) New Revision: 2254 Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesEvaluator.java Log: NPE fix. http://jira.jboss.com/jira/browse/JBLAB-606 Pawel Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesEvaluator.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesEvaluator.java 2006-02-03 21:11:54 UTC (rev 2253) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesEvaluator.java 2006-02-03 21:36:10 UTC (rev 2254) @@ -47,11 +47,7 @@ public class CodeLinesEvaluator { - private static Logger log; - - public CodeLinesEvaluator() { - log = Logger.getLogger(this.getClass()); - } + private static Logger log = Logger.getLogger(CodeLinesEvaluator.class); /** * Evaluates number of code lines in files located in secure SVN repository. @@ -71,8 +67,8 @@ return 0; /* Authentication handling */ - ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(userName, password); - repository.setAuthenticationManager(authManager); + /*ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(userName, password); + repository.setAuthenticationManager(authManager);*/ /* Analyze */ log.debug("Analyzing repository " + repository.getLocation() + "."); |
From: <jbo...@li...> - 2006-02-03 21:12:00
|
Author: wrzep Date: 2006-02-03 16:11:54 -0500 (Fri, 03 Feb 2006) New Revision: 2253 Added: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesEvaluator.java Removed: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesDescriptor.java Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java Log: Cleanup. http://jira.jboss.com/jira/browse/JBLAB-606 Pawel Deleted: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesDescriptor.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesDescriptor.java 2006-02-03 20:42:06 UTC (rev 2252) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesDescriptor.java 2006-02-03 21:11:54 UTC (rev 2253) @@ -1,179 +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.status.plugins; - -import java.io.ByteArrayOutputStream; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -import org.jboss.logging.Logger; -import org.tmatesoft.svn.core.SVNDirEntry; -import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.SVNNodeKind; -import org.tmatesoft.svn.core.SVNProperty; -import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager; -import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory; -import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl; -import org.tmatesoft.svn.core.io.SVNRepository; -import org.tmatesoft.svn.core.io.SVNRepositoryFactory; -import org.tmatesoft.svn.core.wc.SVNWCUtil; - -/** -* @author Pawel Wrzeszcz -* Plugin returns total number of lines of code in project svn repository. -*/ - -public class CodeLinesDescriptor { - - private Logger log; - - public CodeLinesDescriptor() { - log = Logger.getLogger(this.getClass()); - } - - public long getValue(String url, String userName, String password) { - - setupLibrary();; - - /* Connect to svn repository */ - SVNRepository repository = connect(url); - if (repository == null) - return 0; - - /* Authentication handling */ - ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(userName, password); - repository.setAuthenticationManager(authManager); - - /* Analyze */ - log.debug("Analyzing repository " + repository.getLocation() + "."); - return analyzeRepo(repository, ""); - } - - public long getValue(String url) { - return getValue(url, "anonymous", "anonymus"); - } - - private long analyzeRepo(SVNRepository repository, String path) { - - long cl = 0; - Collection<SVNDirEntry> dirEntries = getDirEntries(repository, path); - - for (SVNDirEntry entry : dirEntries) { - - String entryPath = (path.equals("")) ? - entry.getName() : path + "/" + entry.getName(); - - if (entry.getKind() == SVNNodeKind.FILE) { - cl += analyzeFile(repository, entryPath); - } else { - if (entry.getKind() == SVNNodeKind.DIR) { - cl += analyzeRepo(repository, entryPath); - } - } - - } - - return cl; - } - - private long analyzeFile(SVNRepository repository, String filePath) { - - long cl = 0; - - /* Get file */ - Map<String,String> fileProperties = new HashMap<String,String>(); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - try { - repository.getFile(filePath, -1, fileProperties, baos); - } catch (SVNException svne) { - log.warn("Error while fetching the file properties: " + - repository.getLocation().toString() + "/" + filePath + - "\nCause:" + svne.getMessage()); - return 0; - } - - /* Get file type */ - String mimeType = (String) fileProperties.get(SVNProperty.MIME_TYPE); - boolean isTextType = SVNProperty.isTextMimeType(mimeType); - - /* Count number of lines */ - if (isTextType) { - cl = baos.toString().split("\n").length; - } - - return cl; - } - - @SuppressWarnings("unchecked") - private Collection<SVNDirEntry> getDirEntries(SVNRepository repository, String path) { - - log.debug("Analyzing " + path + "."); - - Map fileProperties = new HashMap(); - Collection<SVNDirEntry> dirEntries = null; - - try { - dirEntries = repository.getDir(path, -1, fileProperties, (Collection) null); - } catch (SVNException e) { - log.warn("Error fetching directory entries:" + - repository.getLocation().toString() + "/" + path + - "\nCause: " + e.getMessage()); - } - - return dirEntries; - } - -private SVNRepository connect(String url) { - - SVNRepository repository = null; - try { - repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(url)); - } catch (SVNException svne) { - log.warn("Can not connect to the svn repository: " + url + - "\nCause: " + svne.getMessage()); - return null; - } - - return repository; - } - - - /* - * Initializes the library to work with a repository either via svn:// - * (and svn+ssh://) or via http:// (and https://) - */ - private static void setupLibrary() { - /* - * for DAV (over http and https) - */ - DAVRepositoryFactory.setup(); - /* - * for SVN (over svn and svn+ssh) - */ - SVNRepositoryFactoryImpl.setup(); - } - -} Added: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesEvaluator.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesEvaluator.java 2006-02-03 20:42:06 UTC (rev 2252) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesEvaluator.java 2006-02-03 21:11:54 UTC (rev 2253) @@ -0,0 +1,215 @@ +/* + * 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.status.plugins; + +import java.io.ByteArrayOutputStream; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import org.jboss.logging.Logger; +import org.tmatesoft.svn.core.SVNDirEntry; +import org.tmatesoft.svn.core.SVNException; +import org.tmatesoft.svn.core.SVNNodeKind; +import org.tmatesoft.svn.core.SVNProperty; +import org.tmatesoft.svn.core.SVNURL; +import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager; +import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory; +import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl; +import org.tmatesoft.svn.core.io.SVNRepository; +import org.tmatesoft.svn.core.io.SVNRepositoryFactory; +import org.tmatesoft.svn.core.wc.SVNWCUtil; + +/** +* @author Pawel Wrzeszcz +* Evaluating total number of code lines in SVN repository files. +*/ + +public class CodeLinesEvaluator { + + private static Logger log; + + public CodeLinesEvaluator() { + log = Logger.getLogger(this.getClass()); + } + + /** + * Evaluates number of code lines in files located in secure SVN repository. + * + * @param url SVN repository adress + * @param userName user's name used in authorisation + * @param password user's password used in authorisation + * @return number of code lines + */ + public static long getCodeLinesNumber(String url, String userName, String password) { + + setupLibrary();; + + /* Connect to svn repository */ + SVNRepository repository = connect(url); + if (repository == null) + return 0; + + /* Authentication handling */ + ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(userName, password); + repository.setAuthenticationManager(authManager); + + /* Analyze */ + log.debug("Analyzing repository " + repository.getLocation() + "."); + return getCodeLinesNumber(repository, ""); + } + + /** + * Evaluates number of code lines in files located in anonymus SVN repository. + * + * @param url SVN repository adress + * @return number of code lines + */ + public static long getCodeLinesNumber(String url) { + return getCodeLinesNumber(url, "anonymous", "anonymus"); + } + + /** + * For the given repository evaluates number of code lines + * in files located in <code>path</code>. + * + * @param repository SVN repository adress + * @param path path to SVN directory + * @return number of code lines + */ + private static long getCodeLinesNumber(SVNRepository repository, String path) { + + long cl = 0; + Collection<SVNDirEntry> dirEntries = getDirEntries(repository, path); + + for (SVNDirEntry entry : dirEntries) { + + String entryPath = (path.equals("")) ? + entry.getName() : path + "/" + entry.getName(); + + if (entry.getKind() == SVNNodeKind.FILE) { + cl += analyzeFile(repository, entryPath); + } else { + if (entry.getKind() == SVNNodeKind.DIR) { + cl += getCodeLinesNumber(repository, entryPath); + } + } + + } + + return cl; + } + + /** + * Evaluates number of code lines in single file. + * + * @param repository SVN repository adress + * @param filePath path to the file to analyze + * @return number of code lines + */ + private static long analyzeFile(SVNRepository repository, String filePath) { + + long cl = 0; + + /* Get file */ + Map<String,String> fileProperties = new HashMap<String,String>(); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + try { + repository.getFile(filePath, -1, fileProperties, baos); + } catch (SVNException svne) { + log.warn("Error while fetching the file properties: " + + repository.getLocation().toString() + "/" + filePath + + "\nCause:" + svne.getMessage()); + return 0; + } + + /* Get file type */ + String mimeType = (String) fileProperties.get(SVNProperty.MIME_TYPE); + boolean isTextType = SVNProperty.isTextMimeType(mimeType); + + /* Count number of lines */ + if (isTextType) { + cl = baos.toString().split("\n").length; + } + + return cl; + } + + /** + * Returns SVN directory entries. + * + * @param repository SVN repository adress + * @param path SVN directory path + * @return Collection of directory entries + */ + @SuppressWarnings("unchecked") + private static Collection<SVNDirEntry> getDirEntries(SVNRepository repository, String path) { + + log.debug("Analyzing " + path + "."); + + Map fileProperties = new HashMap(); + Collection<SVNDirEntry> dirEntries = null; + + try { + dirEntries = repository.getDir(path, -1, fileProperties, (Collection) null); + } catch (SVNException e) { + log.warn("Error fetching directory entries:" + + repository.getLocation().toString() + "/" + path + + "\nCause: " + e.getMessage()); + } + + return dirEntries; + } + + /** + * Establishes connection with SVN repository. + * + * @param url SVN repository adress + * @return SVN repository + */ + private static SVNRepository connect(String url) { + + SVNRepository repository = null; + try { + repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(url)); + } catch (SVNException svne) { + log.warn("Can not connect to the svn repository: " + url + + "\nCause: " + svne.getMessage()); + return null; + } + + return repository; + } + + + /** + * Initializes the library to work with a repository either via svn:// + * (and svn+ssh://) or via http:// (and https://) + */ + private static void setupLibrary() { + DAVRepositoryFactory.setup(); /* for DAV (over http and https) */ + SVNRepositoryFactoryImpl.setup(); /* for SVN (over svn and svn+ssh) */ + } + +} Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java 2006-02-03 20:42:06 UTC (rev 2252) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java 2006-02-03 21:11:54 UTC (rev 2253) @@ -22,8 +22,8 @@ package org.jboss.forge.status.plugins; -import java.util.HashMap; import java.util.Map; +import java.util.HashMap; /** * @author Pawel Wrzeszcz @@ -35,16 +35,13 @@ private static final String SVN_REPO_ADRESS_TAG = "svn-repo"; private static final String SVN_USERNAME_TAG = "svn-username"; private static final String SVN_PASSWD_TAG = "svn-passwd"; - // TODO move *all* tags to StatusTags + //TODO move *all* tags to StatusTags - private CodeLinesDescriptor cld; - + /* Binds project ids with their number of code lines */ private Map<String,Long> cashedValues; public CodeLinesPlugin() { super(); - - cld = new CodeLinesDescriptor(); cashedValues = new HashMap<String,Long>(); } @@ -62,9 +59,9 @@ String password = getProperty(projectId, SVN_PASSWD_TAG); if ((userName != null) && (password != null)) { - cl = cld.getValue(url, userName, password); + cl = CodeLinesEvaluator.getCodeLinesNumber(url, userName, password); } else { - cl = cld.getValue(url); + cl = CodeLinesEvaluator.getCodeLinesNumber(url); } } |
From: <jbo...@li...> - 2006-02-03 20:42:12
|
Author: wrzep Date: 2006-02-03 15:42:06 -0500 (Fri, 03 Feb 2006) New Revision: 2252 Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesDescriptor.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java Log: Secure repositories handling. Fixed minor bug with null repo adress. http://jira.jboss.com/jira/browse/JBLAB-606 Pawel Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesDescriptor.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesDescriptor.java 2006-02-03 20:15:03 UTC (rev 2251) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesDescriptor.java 2006-02-03 20:42:06 UTC (rev 2252) @@ -33,10 +33,12 @@ import org.tmatesoft.svn.core.SVNNodeKind; import org.tmatesoft.svn.core.SVNProperty; import org.tmatesoft.svn.core.SVNURL; +import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager; import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory; import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl; import org.tmatesoft.svn.core.io.SVNRepository; import org.tmatesoft.svn.core.io.SVNRepositoryFactory; +import org.tmatesoft.svn.core.wc.SVNWCUtil; /** * @author Pawel Wrzeszcz @@ -51,7 +53,7 @@ log = Logger.getLogger(this.getClass()); } - public long getValue(String url) { + public long getValue(String url, String userName, String password) { setupLibrary();; @@ -59,12 +61,20 @@ SVNRepository repository = connect(url); if (repository == null) return 0; - + + /* Authentication handling */ + ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(userName, password); + repository.setAuthenticationManager(authManager); + /* Analyze */ log.debug("Analyzing repository " + repository.getLocation() + "."); return analyzeRepo(repository, ""); } + public long getValue(String url) { + return getValue(url, "anonymous", "anonymus"); + } + private long analyzeRepo(SVNRepository repository, String path) { long cl = 0; Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java 2006-02-03 20:15:03 UTC (rev 2251) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java 2006-02-03 20:42:06 UTC (rev 2252) @@ -33,7 +33,9 @@ public class CodeLinesPlugin extends StatusPlugin { private static final String SVN_REPO_ADRESS_TAG = "svn-repo"; - // TODO move *all* tags to StatusTags + private static final String SVN_USERNAME_TAG = "svn-username"; + private static final String SVN_PASSWD_TAG = "svn-passwd"; + // TODO move *all* tags to StatusTags private CodeLinesDescriptor cld; @@ -50,15 +52,30 @@ public long getValue(String projectId) { if (!cashedValues.containsKey(projectId)) { - String url = getRepoURL(projectId); - cashedValues.put(projectId, new Long(cld.getValue(url))); + + long cl = 0; + + String url = getProperty(projectId, SVN_REPO_ADRESS_TAG); + if (url != null) { + + String userName = getProperty(projectId, SVN_USERNAME_TAG); + String password = getProperty(projectId, SVN_PASSWD_TAG); + + if ((userName != null) && (password != null)) { + cl = cld.getValue(url, userName, password); + } else { + cl = cld.getValue(url); + } + } + + cashedValues.put(projectId, new Long(cl)); } return cashedValues.get(projectId).longValue(); } - private String getRepoURL(String projectId) { - String repoURL = projects.getProjectProperty(projectId, SVN_REPO_ADRESS_TAG); - return (repoURL == "" ? null : repoURL); + private String getProperty(String projectId, String propertyName) { + String prop = projects.getProjectProperty(projectId, propertyName); + return (prop == "" ? null : prop); } } |
From: <jbo...@li...> - 2006-02-03 20:15:10
|
Author: wrzep Date: 2006-02-03 15:15:03 -0500 (Fri, 03 Feb 2006) New Revision: 2251 Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java Log: Removed debug code. http://jira.jboss.com/jira/browse/JBLAB-606 Pawel Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java 2006-02-03 18:44:17 UTC (rev 2250) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java 2006-02-03 20:15:03 UTC (rev 2251) @@ -48,10 +48,7 @@ @Override public long getValue(String projectId) { - - if (!projectId.equals("kosmos")) - return 0; - + if (!cashedValues.containsKey(projectId)) { String url = getRepoURL(projectId); cashedValues.put(projectId, new Long(cld.getValue(url))); |
From: <jbo...@li...> - 2006-02-03 18:44:25
|
Author: wrzep Date: 2006-02-03 13:44:17 -0500 (Fri, 03 Feb 2006) New Revision: 2250 Added: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesDescriptor.java Log: Caching JBLAB-606 PAwel Added: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesDescriptor.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesDescriptor.java 2006-02-03 18:39:15 UTC (rev 2249) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesDescriptor.java 2006-02-03 18:44:17 UTC (rev 2250) @@ -0,0 +1,169 @@ +/* + * 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.status.plugins; + +import java.io.ByteArrayOutputStream; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import org.jboss.logging.Logger; +import org.tmatesoft.svn.core.SVNDirEntry; +import org.tmatesoft.svn.core.SVNException; +import org.tmatesoft.svn.core.SVNNodeKind; +import org.tmatesoft.svn.core.SVNProperty; +import org.tmatesoft.svn.core.SVNURL; +import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory; +import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl; +import org.tmatesoft.svn.core.io.SVNRepository; +import org.tmatesoft.svn.core.io.SVNRepositoryFactory; + +/** +* @author Pawel Wrzeszcz +* Plugin returns total number of lines of code in project svn repository. +*/ + +public class CodeLinesDescriptor { + + private Logger log; + + public CodeLinesDescriptor() { + log = Logger.getLogger(this.getClass()); + } + + public long getValue(String url) { + + setupLibrary();; + + /* Connect to svn repository */ + SVNRepository repository = connect(url); + if (repository == null) + return 0; + + /* Analyze */ + log.debug("Analyzing repository " + repository.getLocation() + "."); + return analyzeRepo(repository, ""); + } + + private long analyzeRepo(SVNRepository repository, String path) { + + long cl = 0; + Collection<SVNDirEntry> dirEntries = getDirEntries(repository, path); + + for (SVNDirEntry entry : dirEntries) { + + String entryPath = (path.equals("")) ? + entry.getName() : path + "/" + entry.getName(); + + if (entry.getKind() == SVNNodeKind.FILE) { + cl += analyzeFile(repository, entryPath); + } else { + if (entry.getKind() == SVNNodeKind.DIR) { + cl += analyzeRepo(repository, entryPath); + } + } + + } + + return cl; + } + + private long analyzeFile(SVNRepository repository, String filePath) { + + long cl = 0; + + /* Get file */ + Map<String,String> fileProperties = new HashMap<String,String>(); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + try { + repository.getFile(filePath, -1, fileProperties, baos); + } catch (SVNException svne) { + log.warn("Error while fetching the file properties: " + + repository.getLocation().toString() + "/" + filePath + + "\nCause:" + svne.getMessage()); + return 0; + } + + /* Get file type */ + String mimeType = (String) fileProperties.get(SVNProperty.MIME_TYPE); + boolean isTextType = SVNProperty.isTextMimeType(mimeType); + + /* Count number of lines */ + if (isTextType) { + cl = baos.toString().split("\n").length; + } + + return cl; + } + + @SuppressWarnings("unchecked") + private Collection<SVNDirEntry> getDirEntries(SVNRepository repository, String path) { + + log.debug("Analyzing " + path + "."); + + Map fileProperties = new HashMap(); + Collection<SVNDirEntry> dirEntries = null; + + try { + dirEntries = repository.getDir(path, -1, fileProperties, (Collection) null); + } catch (SVNException e) { + log.warn("Error fetching directory entries:" + + repository.getLocation().toString() + "/" + path + + "\nCause: " + e.getMessage()); + } + + return dirEntries; + } + +private SVNRepository connect(String url) { + + SVNRepository repository = null; + try { + repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(url)); + } catch (SVNException svne) { + log.warn("Can not connect to the svn repository: " + url + + "\nCause: " + svne.getMessage()); + return null; + } + + return repository; + } + + + /* + * Initializes the library to work with a repository either via svn:// + * (and svn+ssh://) or via http:// (and https://) + */ + private static void setupLibrary() { + /* + * for DAV (over http and https) + */ + DAVRepositoryFactory.setup(); + /* + * for SVN (over svn and svn+ssh) + */ + SVNRepositoryFactoryImpl.setup(); + } + +} |
From: <jbo...@li...> - 2006-02-03 18:39:20
|
Author: wrzep Date: 2006-02-03 13:39:15 -0500 (Fri, 03 Feb 2006) New Revision: 2249 Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java Log: Caching http://jira.jboss.com/jira/browse/JBLAB-606 Pawel Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java 2006-02-03 17:07:39 UTC (rev 2248) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java 2006-02-03 18:39:15 UTC (rev 2249) @@ -22,22 +22,9 @@ package org.jboss.forge.status.plugins; -import java.io.ByteArrayOutputStream; -import java.util.Collection; import java.util.HashMap; import java.util.Map; -import org.jboss.logging.Logger; -import org.tmatesoft.svn.core.SVNDirEntry; -import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.SVNNodeKind; -import org.tmatesoft.svn.core.SVNProperty; -import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory; -import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl; -import org.tmatesoft.svn.core.io.SVNRepository; -import org.tmatesoft.svn.core.io.SVNRepositoryFactory; - /** * @author Pawel Wrzeszcz * Plugin returns total number of lines of code in project svn repository. @@ -48,141 +35,33 @@ private static final String SVN_REPO_ADRESS_TAG = "svn-repo"; // TODO move *all* tags to StatusTags - private Logger log; //TODO logging + private CodeLinesDescriptor cld; + private Map<String,Long> cashedValues; + public CodeLinesPlugin() { super(); - log = Logger.getLogger(this.getClass()); + cld = new CodeLinesDescriptor(); + cashedValues = new HashMap<String,Long>(); } @Override public long getValue(String projectId) { - if ((!projectId.equals("jbosslabs")) - && (!projectId.equals("kosmos"))) //DEBUG - return -1; + if (!projectId.equals("kosmos")) + return 0; - //TODO use CACHE man... it will be horribly slow - - setupLibrary(); - - /* Get svn repository location */ - String url = getRepoURL(projectId); - - /* Connect to svn repository */ - SVNRepository repository = connect(url); - if (repository == null) - return 0; - - /* Analyze */ - return analyzeRepo(repository, ""); - } - - private long analyzeRepo(SVNRepository repository, String path) { - - long cl = 0; - - Collection<SVNDirEntry> dirEntries = getDirEntries(repository, path); - - for (SVNDirEntry entry : dirEntries) { - - String entryPath = (path.equals("")) ? - entry.getName() : path + "/" + entry.getName(); - - if (entry.getKind() == SVNNodeKind.FILE) { - cl += analyzeFile(repository, entryPath); - } else { - if (entry.getKind() == SVNNodeKind.DIR) { - cl += analyzeRepo(repository, entryPath); - } - } - + if (!cashedValues.containsKey(projectId)) { + String url = getRepoURL(projectId); + cashedValues.put(projectId, new Long(cld.getValue(url))); } - - return cl; - } - - private long analyzeFile(SVNRepository repository, String filePath) { - - long cl = 0; - /* Get file */ - Map<String,String> fileProperties = new HashMap<String,String>(); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - try { - repository.getFile(filePath, -1, fileProperties, baos); - } catch (SVNException svne) { - log.warn("Error while fetching the file properties: " + - repository.getLocation().toString() + "/" + filePath + - "\nCause:" + svne.getMessage()); - return 0; - } - - /* Get file type */ - String mimeType = (String) fileProperties.get(SVNProperty.MIME_TYPE); - boolean isTextType = SVNProperty.isTextMimeType(mimeType); - - /* Count number of lines */ - if (isTextType) { - cl = baos.toString().split("\n").length; - } - - return cl; + return cashedValues.get(projectId).longValue(); } - @SuppressWarnings("unchecked") - private Collection<SVNDirEntry> getDirEntries(SVNRepository repository, String path) { - - log.info("analyzing... " + path); - - Map fileProperties = new HashMap(); - Collection<SVNDirEntry> dirEntries = null; - - try { - dirEntries = repository.getDir(path, -1, fileProperties, (Collection) null); - } catch (SVNException e) { - log.warn("Error fetching directory entries:" + - repository.getLocation().toString() + "/" + path + - "\nCause: " + e.getMessage()); - } - - return dirEntries; - } - -private SVNRepository connect(String url) { - - SVNRepository repository = null; - try { - repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(url)); - } catch (SVNException svne) { - log.warn("Can not connect to the svn repository: " + url + - "\nCause: " + svne.getMessage()); - return null; - } - - return repository; - } - private String getRepoURL(String projectId) { String repoURL = projects.getProjectProperty(projectId, SVN_REPO_ADRESS_TAG); return (repoURL == "" ? null : repoURL); } - - /* - * Initializes the library to work with a repository either via svn:// - * (and svn+ssh://) or via http:// (and https://) - */ - private static void setupLibrary() { - /* - * for DAV (over http and https) - */ - DAVRepositoryFactory.setup(); - /* - * for SVN (over svn and svn+ssh) - */ - SVNRepositoryFactoryImpl.setup(); - } - } |
From: <jbo...@li...> - 2006-02-03 17:07:47
|
Author: adamw Date: 2006-02-03 12:07:39 -0500 (Fri, 03 Feb 2006) New Revision: 2248 Added: branches/forge/adam/portal-extensions-2.2/ Log: Branching portal ext for portal 2.2 migration Copied: branches/forge/adam/portal-extensions-2.2 (from rev 2247, trunk/forge/portal-extensions) |
From: <jbo...@li...> - 2006-02-03 17:01:30
|
Author: adamw Date: 2006-02-03 12:00:40 -0500 (Fri, 03 Feb 2006) New Revision: 2246 Modified: trunk/forge/portal-extensions/forge-blog/src/java/org/jboss/portlet/blog/BlogPortlet.java trunk/forge/portal-extensions/forge-service/src/java/org/jboss/forge/service/ForgeService.java Log: http://jira.jboss.com/jira/browse/JBLAB-607 Modified: trunk/forge/portal-extensions/forge-blog/src/java/org/jboss/portlet/blog/BlogPortlet.java =================================================================== --- trunk/forge/portal-extensions/forge-blog/src/java/org/jboss/portlet/blog/BlogPortlet.java 2006-02-03 16:51:37 UTC (rev 2245) +++ trunk/forge/portal-extensions/forge-blog/src/java/org/jboss/portlet/blog/BlogPortlet.java 2006-02-03 17:00:40 UTC (rev 2246) @@ -97,7 +97,7 @@ String projectId = ProjectsHelper.getSelectedProjectId(request, false); if (projectId == null) - projectId = config.getProperty("default.feed"); + projectId = config.getProperty("default.feed"); // Getting the number of headers and entries to display int headersNormal = Integer.valueOf( @@ -110,6 +110,14 @@ String feedAddress = config.getProperty("feed.address"); String remoteFeedAddress = config.getProperty("remote.feed.address"); + String projectFeedAddress = + ProjectsHelper.getProjects(portalName).getProjectProperty(projectId, "feed-address"); + + if ((projectFeedAddress != null) && (!"".equals(projectFeedAddress))) { + feedAddress = projectFeedAddress; + remoteFeedAddress = projectFeedAddress; + } + feedAddress = replaceProperty(feedAddress, "${host.address}", request .getServerName()); feedAddress = replaceProperty(feedAddress, "${scheme.name}", request Modified: trunk/forge/portal-extensions/forge-service/src/java/org/jboss/forge/service/ForgeService.java =================================================================== --- trunk/forge/portal-extensions/forge-service/src/java/org/jboss/forge/service/ForgeService.java 2006-02-03 16:51:37 UTC (rev 2245) +++ trunk/forge/portal-extensions/forge-service/src/java/org/jboss/forge/service/ForgeService.java 2006-02-03 17:00:40 UTC (rev 2246) @@ -164,7 +164,7 @@ new HashMap<CacheKey, Object>()); nodeWatchers = Collections.synchronizedMap( new HashMap<CacheKey, NodeWatcher>()); - + // Adding blog updater node watcher. addNodeWatcher(null, BlogUpdaterNodeWatcher.class.getName(), new BlogUpdaterNodeWatcher()); |
From: <jbo...@li...> - 2006-02-03 17:01:21
|
Author: wrzep Date: 2006-02-03 12:01:17 -0500 (Fri, 03 Feb 2006) New Revision: 2247 Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java Log: http://jira.jboss.com/jira/browse/JBLAB-606 PAwel Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java 2006-02-03 17:00:40 UTC (rev 2246) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java 2006-02-03 17:01:17 UTC (rev 2247) @@ -127,9 +127,6 @@ /* Count number of lines */ if (isTextType) { cl = baos.toString().split("\n").length; - System.out.println("Lines: " + cl); - } else { - System.out.print("Is not text file"); } return cl; @@ -145,7 +142,6 @@ try { dirEntries = repository.getDir(path, -1, fileProperties, (Collection) null); - System.out.println("*** " + repository.getDir(path, -1, fileProperties, (Collection) null)); } catch (SVNException e) { log.warn("Error fetching directory entries:" + repository.getLocation().toString() + "/" + path + |
From: <jbo...@li...> - 2006-02-03 16:51:43
|
Author: wrzep Date: 2006-02-03 11:51:37 -0500 (Fri, 03 Feb 2006) New Revision: 2245 Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java Log: Repository traversing - further implementation. http://jira.jboss.com/jira/browse/JBLAB-606 Pawel Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java 2006-02-03 16:21:48 UTC (rev 2244) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java 2006-02-03 16:51:37 UTC (rev 2245) @@ -59,15 +59,16 @@ @Override public long getValue(String projectId) { - if (!projectId.equals("jbosslabs")) + if ((!projectId.equals("jbosslabs")) + && (!projectId.equals("kosmos"))) //DEBUG return -1; + //TODO use CACHE man... it will be horribly slow + setupLibrary(); - - // TODO use CACHE man... it will be horribly slow /* Get svn repository location */ - String url = "http://anonsvn.labs.jboss.com/trunk/forge/"; + String url = getRepoURL(projectId); /* Connect to svn repository */ SVNRepository repository = connect(url); @@ -75,26 +76,25 @@ return 0; /* Analyze */ - return analyzeRepo(repository, "portal-extensions/forge-status"); + return analyzeRepo(repository, ""); } private long analyzeRepo(SVNRepository repository, String path) { - + long cl = 0; Collection<SVNDirEntry> dirEntries = getDirEntries(repository, path); - - System.out.println("Dir entries " + dirEntries.size()); for (SVNDirEntry entry : dirEntries) { - - System.out.println("Analyzing... " + entry.getName()); + String entryPath = (path.equals("")) ? + entry.getName() : path + "/" + entry.getName(); + if (entry.getKind() == SVNNodeKind.FILE) { - cl += analyzeFile(repository, path + "/" + entry.getName()); + cl += analyzeFile(repository, entryPath); } else { if (entry.getKind() == SVNNodeKind.DIR) { - cl += analyzeRepo(repository, path + "/" + entry.getName()); + cl += analyzeRepo(repository, entryPath); } } @@ -114,7 +114,9 @@ try { repository.getFile(filePath, -1, fileProperties, baos); } catch (SVNException svne) { - System.out.print("error while fetching the file contents and properties: " + svne.getMessage()); + log.warn("Error while fetching the file properties: " + + repository.getLocation().toString() + "/" + filePath + + "\nCause:" + svne.getMessage()); return 0; } @@ -133,9 +135,10 @@ return cl; } + @SuppressWarnings("unchecked") private Collection<SVNDirEntry> getDirEntries(SVNRepository repository, String path) { - System.out.println("path " + path); + log.info("analyzing... " + path); Map fileProperties = new HashMap(); Collection<SVNDirEntry> dirEntries = null; @@ -144,7 +147,9 @@ dirEntries = repository.getDir(path, -1, fileProperties, (Collection) null); System.out.println("*** " + repository.getDir(path, -1, fileProperties, (Collection) null)); } catch (SVNException e) { - e.printStackTrace(); + log.warn("Error fetching directory entries:" + + repository.getLocation().toString() + "/" + path + + "\nCause: " + e.getMessage()); } return dirEntries; @@ -156,7 +161,8 @@ try { repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(url)); } catch (SVNException svne) { - System.out.print("Can not connect to the svn service: " + url + " " + svne.getMessage()); + log.warn("Can not connect to the svn repository: " + url + + "\nCause: " + svne.getMessage()); return null; } |
From: <jbo...@li...> - 2006-02-03 16:21:56
|
Author: wrzep Date: 2006-02-03 11:21:48 -0500 (Fri, 03 Feb 2006) New Revision: 2244 Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java Log: Repository traversing. http://jira.jboss.com/jira/browse/JBLAB-606 Pawel Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java 2006-02-03 15:07:51 UTC (rev 2243) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java 2006-02-03 16:21:48 UTC (rev 2244) @@ -23,10 +23,12 @@ package org.jboss.forge.status.plugins; import java.io.ByteArrayOutputStream; +import java.util.Collection; import java.util.HashMap; import java.util.Map; import org.jboss.logging.Logger; +import org.tmatesoft.svn.core.SVNDirEntry; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNNodeKind; import org.tmatesoft.svn.core.SVNProperty; @@ -55,86 +57,112 @@ } @Override -public long getValue(String projectId) { + public long getValue(String projectId) { + if (!projectId.equals("jbosslabs")) + return -1; + setupLibrary(); + // TODO use CACHE man... it will be horribly slow + /* Get svn repository location */ - String url = "http://anonsvn.labs.jboss.com/trunk/forge/portal-extensions/"; - String filePath = "forge-status/src/java/org/jboss/forge/status/Column.java"; + String url = "http://anonsvn.labs.jboss.com/trunk/forge/"; /* Connect to svn repository */ SVNRepository repository = connect(url); if (repository == null) return 0; - /* Get file to analyze */ - Map fileProperties = new HashMap(); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); + /* Analyze */ + return analyzeRepo(repository, "portal-extensions/forge-status"); + } + + private long analyzeRepo(SVNRepository repository, String path) { + + long cl = 0; + + Collection<SVNDirEntry> dirEntries = getDirEntries(repository, path); - getFile(repository, filePath, fileProperties, baos); + System.out.println("Dir entries " + dirEntries.size()); + + for (SVNDirEntry entry : dirEntries) { + + System.out.println("Analyzing... " + entry.getName()); + + if (entry.getKind() == SVNNodeKind.FILE) { + cl += analyzeFile(repository, path + "/" + entry.getName()); + } else { + if (entry.getKind() == SVNNodeKind.DIR) { + cl += analyzeRepo(repository, path + "/" + entry.getName()); + } + } + + } - /* Analyze file */ - - if (baos.size() != 0) - analyzeFile(baos, fileProperties); - - return -1; + return cl; } - - private void getFile(SVNRepository repository, String filePath, Map fileProperties, ByteArrayOutputStream baos) { + private long analyzeFile(SVNRepository repository, String filePath) { + + long cl = 0; + + /* Get file */ + Map<String,String> fileProperties = new HashMap<String,String>(); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try { - SVNNodeKind nodeKind = repository.checkPath(filePath, -1); - - if (nodeKind == SVNNodeKind.NONE) { - System.out.print("File not found."); - return; - } else if (nodeKind == SVNNodeKind.DIR) { - System.out.print("Dir"); - return; - } - repository.getFile(filePath, -1, fileProperties, baos); - } catch (SVNException svne) { System.out.print("error while fetching the file contents and properties: " + svne.getMessage()); - return; + return 0; } - } - - private SVNRepository connect(String url) { - - SVNRepository repository = null; - try { - repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(url)); - } catch (SVNException svne) { - System.out.print("Can not connect to the svn service: " + url + " " + svne.getMessage()); - return null; - } - - return repository; - } - - private void analyzeFile(ByteArrayOutputStream baos, Map fileProperties) { - + /* Get file type */ - String mimeType = (String) fileProperties.get(SVNProperty.MIME_TYPE); - boolean isTextType = SVNProperty.isTextMimeType(mimeType); /* Count number of lines */ if (isTextType) { - long cl = baos.toString().split("\n").length; + cl = baos.toString().split("\n").length; System.out.println("Lines: " + cl); } else { System.out.print("Is not text file"); } + + return cl; + } + + private Collection<SVNDirEntry> getDirEntries(SVNRepository repository, String path) { + System.out.println("path " + path); + + Map fileProperties = new HashMap(); + Collection<SVNDirEntry> dirEntries = null; + + try { + dirEntries = repository.getDir(path, -1, fileProperties, (Collection) null); + System.out.println("*** " + repository.getDir(path, -1, fileProperties, (Collection) null)); + } catch (SVNException e) { + e.printStackTrace(); + } + + return dirEntries; } - +private SVNRepository connect(String url) { + + SVNRepository repository = null; + try { + repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(url)); + } catch (SVNException svne) { + System.out.print("Can not connect to the svn service: " + url + " " + svne.getMessage()); + return null; + } + + return repository; + } + private String getRepoURL(String projectId) { String repoURL = projects.getProjectProperty(projectId, SVN_REPO_ADRESS_TAG); return (repoURL == "" ? null : repoURL); |
Author: adamw Date: 2006-02-03 10:07:51 -0500 (Fri, 03 Feb 2006) New Revision: 2243 Modified: trunk/forge/portal-extensions/shotoku/shotoku-base/src/etc/shotoku.properties.sample trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/ContentManager.java trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuServiceImpl.java trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/tools/Constants.java trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/tools/Tools.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnContentManager.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnService.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnTools.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/service/SvnServiceImpl.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/test/DummyService.java trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ResourceInjectTest.java trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ShotokuTest.java Log: http://jira.jboss.com/jira/browse/JBSHOTOKU-61 Modified: trunk/forge/portal-extensions/shotoku/shotoku-base/src/etc/shotoku.properties.sample =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-base/src/etc/shotoku.properties.sample 2006-02-03 14:56:14 UTC (rev 2242) +++ trunk/forge/portal-extensions/shotoku/shotoku-base/src/etc/shotoku.properties.sample 2006-02-03 15:07:51 UTC (rev 2243) @@ -8,4 +8,11 @@ shotoku.default.password = shotoku.default.localpath = -shotoku.embedded = false \ No newline at end of file +shotoku.transfer.buffer.size = 1024 +shotoku.service.interval = 10000 + +shotoku.embedded = false + +shotoku.internal.svn.service.interval = 5000 +shotoku.internal.tests.id = default +shotoku.internal.tests.dir= shotoku-test \ No newline at end of file Modified: trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/ContentManager.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/ContentManager.java 2006-02-03 14:56:14 UTC (rev 2242) +++ trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/ContentManager.java 2006-02-03 15:07:51 UTC (rev 2243) @@ -348,10 +348,20 @@ private static final Logger log; /** - * <code>defaultId</code> - id of the default content manager. May be + * Id of the default content manager. May be * overriden by a setting in the xml configuration file. */ private static String defaultId; + + /** + * Size of the transfer buffer. + */ + private static int transferBufferSize; + + /** + * Default interval of the Shotoku service. + */ + private static int defaultServiceInterval; /** * <code>contentManagers</code> - map (content manager id -> content @@ -392,18 +402,6 @@ log = Logger.getLogger(ContentManager.class); } - - /** - * Gets a property of this content manager, as it is written in the - * configuration file (helper method for implementations). - * - * @param name - * Name of the property to get. - * @return Value of the given property or null, if no such property exists. - */ - private static String getProperty(String name) { - return props.getString(name); - } /** * Checks if Shotoku is configured to run in embedded mode or not. @@ -434,9 +432,13 @@ contentManagers = new HashMap<String, Pair<Constructor, Configuration>>(); try { - // Reading the default id - possibly, overriding. + // Reading the default properties. defaultId = props.getString(Constants.PROPERTIES_ID_DEFAULT, Constants.DEFAULT_ID); + transferBufferSize = props.getInt(Constants.PROPERTIES_TRANSFER_BUF_SIZE, + Constants.DEFAULT_TRANSFER_BUF_SIZE); + defaultServiceInterval = props.getInt(Constants.PROPERTIES_SERVICE_INTERVAL, + Constants.DEFAULT_SERVICE_INTERVAL); // Getting ids of defined content managers. String[] ids = props.getStringArray(Constants.PROPERTIES_IDS); @@ -529,4 +531,101 @@ return null; } } + + /* + * Properties accessors. + */ + + /** + * Gets a property of this content manager, as it is written in the + * configuration file (helper method for implementations). Only internal + * properties! + * + * @param name + * Name of the property to get. + * @return Value of the given property or null, if no such property exists. + */ + public static String getProperty(String name) { + if (name.startsWith(Constants.PROPERTIES_INTERNAL)) { + return props.getString(name); + } else { + return null; + } + } + + /** + * Gets a property of this content manager, as it is written in the + * configuration file (helper method for implementations). Only internal + * properties! (long parameter value). + * + * @param name + * Name of the property to get. + * @param defaultValue + * Value to return in case the given property is not set. + * @return Value of the given property or null, if no such property exists. + */ + public static long getProperty(String name, long defaultValue) { + if (name.startsWith(Constants.PROPERTIES_INTERNAL)) { + return props.getLong(name, defaultValue); + } else { + return defaultValue; + } + } + + /** + * Gets a property of this content manager, as it is written in the + * configuration file (helper method for implementations). Only internal + * properties! (long parameter value). + * + * @param name + * Name of the property to get. + * @param defaultValue + * Value to return in case the given property is not set. + * @return Value of the given property or null, if no such property exists. + */ + public static int getProperty(String name, int defaultValue) { + if (name.startsWith(Constants.PROPERTIES_INTERNAL)) { + return props.getInt(name, defaultValue); + } else { + return defaultValue; + } + } + + /** + * Gets a property of this content manager, as it is written in the + * configuration file (helper method for implementations). Only internal + * properties! + * + * @param name + * Name of the property to get. + * @param defaultValue + * Value to return in case the given property is not set. + * @return Value of the given property or null, if no such property exists. + */ + public static String getProperty(String name, String defaultValue) { + if (name.startsWith(Constants.PROPERTIES_INTERNAL)) { + String ret = props.getString(name); + return ((ret == null) ? defaultValue : ret); + } else { + return defaultValue; + } + } + + /** + * Gets the transfer buffer size. + * + * @return Transfer buffer size. + */ + public static int getTransferBufferSize() { + return transferBufferSize; + } + + /** + * Gets the default Shotoku service interval. + * + * @return Default Shotoku service interval. + */ + public static int getDefaultServiceInterval() { + return defaultServiceInterval; + } } Modified: trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuServiceImpl.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuServiceImpl.java 2006-02-03 14:56:14 UTC (rev 2242) +++ trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuServiceImpl.java 2006-02-03 15:07:51 UTC (rev 2243) @@ -53,7 +53,7 @@ ContentManager.setup(); // Setting the default timer interval. - timerInterval = DEFAULT_TIMER_INTERVAL; + timerInterval = ContentManager.getDefaultServiceInterval(); new Thread() { { @@ -93,12 +93,7 @@ /* * Timer interval management functions. */ - - /** - * <code>DEFAULT_TIMER_INTERVAL</code> - default interval length of the - * timer. - */ - private final static long DEFAULT_TIMER_INTERVAL = 1000*10; // 10 seconds + private volatile long timerInterval; public void setTimerInterval(long timerInterval) { Modified: trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/tools/Constants.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/tools/Constants.java 2006-02-03 14:56:14 UTC (rev 2242) +++ trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/tools/Constants.java 2006-02-03 15:07:51 UTC (rev 2243) @@ -26,15 +26,16 @@ * @author Adam Warski (ad...@as...) */ public class Constants { - public static final String DEFAULT_ID = "default"; - public static final String PROPERTIES_FILE = "/shotoku.properties"; public static final String PROPERTIES_ID_DEFAULT = "shotoku.id.default"; public static final String PROPERTIES_IDS = "shotoku.ids"; public static final String PROPERTIES_PREFIX = "shotoku"; + public static final String PROPERTIES_INTERNAL = PROPERTIES_PREFIX + ".internal"; public static final String PROPERTIES_IMPL_SUFFIX = "implementation"; - public static final String PROPERTIES_EMBEDDED = "shotoku.embedded"; + public static final String PROPERTIES_EMBEDDED = PROPERTIES_PREFIX + ".embedded"; + public static final String PROPERTIES_TRANSFER_BUF_SIZE = PROPERTIES_PREFIX + ".transfer.buffer.size"; + public static final String PROPERTIES_SERVICE_INTERVAL = PROPERTIES_PREFIX + ".service.interval"; private static final String VELOCITY_RL = "shotoku.resource.loader"; public static final String VELOCITY_RL_PREFIX = VELOCITY_RL + ".prefix"; @@ -43,7 +44,12 @@ public static final String SETUP_FUNCTION = "setup"; - public static final int TRANSFER_BUF_SIZE = 1024; + /* + * Default values + */ + public static final String DEFAULT_ID = "default"; + public static final int DEFAULT_TRANSFER_BUF_SIZE = 1024; + public static final int DEFAULT_SERVICE_INTERVAL = 10000; /** * <code>SVN_SERVICE_NAME</code> - name under which the svn service is Modified: trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/tools/Tools.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/tools/Tools.java 2006-02-03 14:56:14 UTC (rev 2242) +++ trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/tools/Tools.java 2006-02-03 15:07:51 UTC (rev 2243) @@ -25,6 +25,8 @@ import java.io.InputStream; import java.io.OutputStream; +import org.jboss.shotoku.ContentManager; + /** * Utility, helper functions used internally. * @@ -138,7 +140,7 @@ * @throws IOException */ public static void transfer(InputStream is, OutputStream os) throws IOException { - byte[] buffer = new byte[Constants.TRANSFER_BUF_SIZE]; + byte[] buffer = new byte[ContentManager.getTransferBufferSize()]; int read; while ((read = is.read(buffer)) != -1) os.write(buffer, 0, read); Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnContentManager.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnContentManager.java 2006-02-03 14:56:14 UTC (rev 2242) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnContentManager.java 2006-02-03 15:07:51 UTC (rev 2243) @@ -71,6 +71,8 @@ static { service = SvnTools.getService(); + service.setTimerInterval(ContentManager.getProperty( + SvnTools.PROPERTY_INTERVAL, SvnTools.DEFAULT_TIMER_INTERVAL)); // Configuring the repositories. // for DAV (over http and https) Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnService.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnService.java 2006-02-03 14:56:14 UTC (rev 2242) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnService.java 2006-02-03 15:07:51 UTC (rev 2243) @@ -150,6 +150,20 @@ */ public boolean isDeleted(String id, String fullPath); + /** + * Gets the interval of the service timer. + * + * @return Interval of the service timer. + */ + public long getTimerInterval(); + + /** + * Sets the interval of the service timer. + * + * @param timerInterval New interval of the service timer. + */ + public void setTimerInterval(long timerInterval); + /* * SERVICE MANAGEMENT METHODS */ Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnTools.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnTools.java 2006-02-03 14:56:14 UTC (rev 2242) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnTools.java 2006-02-03 15:07:51 UTC (rev 2243) @@ -67,6 +67,13 @@ public static final String TEMP_FILE_PREFIX = "shotoku-svn"; + /** + * Default interval length of the + * timer. + */ + public final static long DEFAULT_TIMER_INTERVAL = 1000*5; // 5 seconds + public static final String PROPERTY_INTERVAL = Constants.PROPERTIES_INTERNAL + ".svn.service.interval"; + private static SvnService instance; public static final Random random; Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/service/SvnServiceImpl.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/service/SvnServiceImpl.java 2006-02-03 14:56:14 UTC (rev 2242) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/service/SvnServiceImpl.java 2006-02-03 15:07:51 UTC (rev 2243) @@ -48,11 +48,6 @@ public class SvnServiceImpl implements SvnService { private static final Logger log = Logger.getLogger(SvnServiceImpl.class); - /** - * <code>DEFAULT_TIMER_INTERVAL</code> - default interval length of the - * timer. - */ - private final static long DEFAULT_TIMER_INTERVAL = 1000*5; // 5 seconds private volatile long timerInterval; private Map<String, SvnRepository> repositories; @@ -75,7 +70,7 @@ public void start() throws Exception { // Setting the default timer interval. - timerInterval = DEFAULT_TIMER_INTERVAL; + timerInterval = SvnTools.DEFAULT_TIMER_INTERVAL; new Thread() { { Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/test/DummyService.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/test/DummyService.java 2006-02-03 14:56:14 UTC (rev 2242) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/test/DummyService.java 2006-02-03 15:07:51 UTC (rev 2243) @@ -113,4 +113,12 @@ return false; } + public long getTimerInterval() { + return 0; + } + + public void setTimerInterval(long timerInterval) { + + } + } Modified: trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ResourceInjectTest.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ResourceInjectTest.java 2006-02-03 14:56:14 UTC (rev 2242) +++ trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ResourceInjectTest.java 2006-02-03 15:07:51 UTC (rev 2243) @@ -51,13 +51,13 @@ testDir.save(TEST_LOG); } - @NodeInject(SHOTOKU_TEST_DIR + "/" + TEST_NODE) + @NodeInject(DEFAULT_TEST_DIR + "/" + TEST_NODE) private Node injectedNode; - @DirectoryInject(SHOTOKU_TEST_DIR + "/" + TEST_DIR) + @DirectoryInject(DEFAULT_TEST_DIR + "/" + TEST_DIR) private Directory injectedDir; - @NodeInject(SHOTOKU_TEST_DIR + "/" + TEST_NODE) + @NodeInject(DEFAULT_TEST_DIR + "/" + TEST_NODE) private String injectedString; public void testInjects() throws ResourceAlreadyExists, ResourceDoesNotExist { Modified: trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ShotokuTest.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ShotokuTest.java 2006-02-03 14:56:14 UTC (rev 2242) +++ trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ShotokuTest.java 2006-02-03 15:07:51 UTC (rev 2243) @@ -24,6 +24,7 @@ import org.jboss.shotoku.ContentManager; import org.jboss.shotoku.aop.Inject; import org.jboss.shotoku.exceptions.ResourceDoesNotExist; +import org.jboss.shotoku.tools.Constants; import junit.framework.TestCase; @@ -32,16 +33,22 @@ * @author Damon Sicore (da...@si...) */ public abstract class ShotokuTest extends TestCase { - protected final static String CM_ID = "default"; - protected final static String SHOTOKU_TEST_DIR = "shotoku-test"; + protected final static String PROPERTIES_CM_ID = Constants.PROPERTIES_INTERNAL + ".tests.id"; + protected final static String PROPERTIES_TEST_DIR = Constants.PROPERTIES_INTERNAL + ".tests.dir"; - @Inject(id=CM_ID, prefix=SHOTOKU_TEST_DIR) + protected final static String DEFAULT_CM_ID = "default"; + protected final static String DEFAULT_TEST_DIR = "shotoku-test"; + + protected static String CM_ID = DEFAULT_CM_ID; + protected static String TEST_DIR = DEFAULT_TEST_DIR; + + @Inject(id=DEFAULT_CM_ID, prefix=DEFAULT_TEST_DIR) protected ContentManager cm; public ShotokuTest() { // Annotations don't work in embedded mode. if (ContentManager.isEmbedded()) { - cm = ContentManager.getContentManager(CM_ID, SHOTOKU_TEST_DIR); + cm = ContentManager.getContentManager(CM_ID, TEST_DIR); } } @@ -49,15 +56,17 @@ // In embedded mode, setup must be called manually. if (ContentManager.isEmbedded()) { ContentManager.setup(); + CM_ID = ContentManager.getProperty(PROPERTIES_CM_ID, DEFAULT_CM_ID); + TEST_DIR = ContentManager.getProperty(PROPERTIES_TEST_DIR, DEFAULT_TEST_DIR); } // Checking if the test directory exists, and if not, creating it. ContentManager cmTemp = ContentManager.getContentManager(CM_ID, ""); try { - cmTemp.getDirectory(SHOTOKU_TEST_DIR); + cmTemp.getDirectory(TEST_DIR); } catch (ResourceDoesNotExist e) { try { - cmTemp.getRootDirectory().newDirectory(SHOTOKU_TEST_DIR).save(""); + cmTemp.getRootDirectory().newDirectory(TEST_DIR).save(""); } catch (Exception e2) { throw new RuntimeException("Exception while intializing the test directory", e2); } |
From: <jbo...@li...> - 2006-02-03 14:56:17
|
Author: wrzep Date: 2006-02-03 09:56:14 -0500 (Fri, 03 Feb 2006) New Revision: 2242 Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java Log: Cleanup before implementing repo travesing. http://jira.jboss.com/jira/browse/JBLAB-606 Pawel Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java 2006-02-03 12:42:03 UTC (rev 2241) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java 2006-02-03 14:56:14 UTC (rev 2242) @@ -31,12 +31,10 @@ import org.tmatesoft.svn.core.SVNNodeKind; import org.tmatesoft.svn.core.SVNProperty; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager; import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory; import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl; import org.tmatesoft.svn.core.io.SVNRepository; import org.tmatesoft.svn.core.io.SVNRepositoryFactory; -import org.tmatesoft.svn.core.wc.SVNWCUtil; /** * @author Pawel Wrzeszcz @@ -46,8 +44,9 @@ public class CodeLinesPlugin extends StatusPlugin { private static final String SVN_REPO_ADRESS_TAG = "svn-repo"; + // TODO move *all* tags to StatusTags - private Logger log; + private Logger log; //TODO logging public CodeLinesPlugin() { super(); @@ -56,77 +55,85 @@ } @Override - public long getValue(String projectId) { +public long getValue(String projectId) { - if (!projectId.equals("jbosslabs")) - return -1; + setupLibrary(); /* Get svn repository location */ String url = "http://anonsvn.labs.jboss.com/trunk/forge/portal-extensions/"; - String name = "anonymous"; - String password = "anonymous"; String filePath = "forge-status/src/java/org/jboss/forge/status/Column.java"; - - setupLibrary(); - - log.info("connecting..."); + /* Connect to svn repository */ - SVNRepository repository = null; - try { - repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(url)); - } catch (SVNException svne) { - log.error("Can not connect to the svn service: " + url + " / " + svne.getMessage()); - return 0; - } - - ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(name, password); - - repository.setAuthenticationManager(authManager); - - Map fileProperties = new HashMap(); + SVNRepository repository = connect(url); + if (repository == null) + return 0; + + /* Get file to analyze */ + Map fileProperties = new HashMap(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - log.info("chcecking..."); - /* Check if the given path corresponds to a file */ + + getFile(repository, filePath, fileProperties, baos); + + /* Analyze file */ + + if (baos.size() != 0) + analyzeFile(baos, fileProperties); + + return -1; + } + + private void getFile(SVNRepository repository, String filePath, Map fileProperties, ByteArrayOutputStream baos) { + try { SVNNodeKind nodeKind = repository.checkPath(filePath, -1); if (nodeKind == SVNNodeKind.NONE) { - log.error("File not found."); - return 0; + System.out.print("File not found."); + return; } else if (nodeKind == SVNNodeKind.DIR) { - log.error("Dir"); - return 0; + System.out.print("Dir"); + return; } repository.getFile(filePath, -1, fileProperties, baos); } catch (SVNException svne) { - log.error("error while fetching the file contents and properties: " + svne.getMessage()); - return 0; + System.out.print("error while fetching the file contents and properties: " + svne.getMessage()); + return; } + } + + private SVNRepository connect(String url) { + + SVNRepository repository = null; + try { + repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(url)); + } catch (SVNException svne) { + System.out.print("Can not connect to the svn service: " + url + " " + svne.getMessage()); + return null; + } + + return repository; + } + + private void analyzeFile(ByteArrayOutputStream baos, Map fileProperties) { + + /* Get file type */ - log.info("getting properties..."); - /* Get file properties and content */ - String mimeType = (String) fileProperties.get(SVNProperty.MIME_TYPE); boolean isTextType = SVNProperty.isTextMimeType(mimeType); - log.info("counting lines..."); - /* - * Counting number of lines - */ - long cl = -1; - + /* Count number of lines */ if (isTextType) { - cl = baos.toString().split("\n").length; + long cl = baos.toString().split("\n").length; + System.out.println("Lines: " + cl); } else { - log.error("Is not text file"); + System.out.print("Is not text file"); } - - return cl; + } + private String getRepoURL(String projectId) { String repoURL = projects.getProjectProperty(projectId, SVN_REPO_ADRESS_TAG); |
From: <jbo...@li...> - 2006-02-03 12:42:13
|
Author: szimano Date: 2006-02-03 07:42:03 -0500 (Fri, 03 Feb 2006) New Revision: 2241 Modified: trunk/forge/portal-extensions/shotoku/maven.xml Log: added prj-install goal (empty) Modified: trunk/forge/portal-extensions/shotoku/maven.xml =================================================================== --- trunk/forge/portal-extensions/shotoku/maven.xml 2006-02-03 12:38:11 UTC (rev 2240) +++ trunk/forge/portal-extensions/shotoku/maven.xml 2006-02-03 12:42:03 UTC (rev 2241) @@ -9,6 +9,9 @@ <ant:delete dir="${maven.build.dest}"/> </goal> + <goal name="prj-install"> + </goal> + <goal name="all"> <attainGoal name="clean" /> <attainGoal name="shotoku:build" /> |
From: <jbo...@li...> - 2006-02-03 12:38:25
|
Author: adamw Date: 2006-02-03 07:38:11 -0500 (Fri, 03 Feb 2006) New Revision: 2240 Modified: trunk/forge/portal-extensions/shotoku/maven.xml trunk/forge/portal-extensions/shotoku/shotoku-base/src/app/META-INF/application.xml trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/ContentManager.java trunk/forge/portal-extensions/shotoku/shotoku-files/maven.xml trunk/forge/portal-extensions/shotoku/shotoku-files/src/java/org/jboss/shotoku/files/FileContentManager.java trunk/forge/portal-extensions/shotoku/shotoku-files/src/java/org/jboss/shotoku/files/FileDirectory.java trunk/forge/portal-extensions/shotoku/shotoku-files/src/java/org/jboss/shotoku/files/FileNode.java trunk/forge/portal-extensions/shotoku/shotoku-svn/maven.xml trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnContentManager.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnTools.java trunk/forge/portal-extensions/shotoku/shotoku-test/project.xml trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ShotokuTest.java Log: http://jira.jboss.com/jira/browse/JBSHOTOKU-60 Modified: trunk/forge/portal-extensions/shotoku/maven.xml =================================================================== --- trunk/forge/portal-extensions/shotoku/maven.xml 2006-02-03 10:29:54 UTC (rev 2239) +++ trunk/forge/portal-extensions/shotoku/maven.xml 2006-02-03 12:38:11 UTC (rev 2240) @@ -37,6 +37,12 @@ <maven:reactor includes="${prefix}shotoku-base/project.xml" excludes="" basedir="." banner="Shotoku base" goals="prepare-repo" ignoreFailures="false" /> + <maven:reactor includes="${prefix}shotoku-svn/project.xml" excludes="" basedir="." + banner="Shotoku svn" + goals="prepare-repo" ignoreFailures="false" /> + <maven:reactor includes="${prefix}shotoku-files/project.xml" excludes="" basedir="." + banner="Shotoku files" + goals="prepare-repo" ignoreFailures="false" /> </goal> <goal name="build"> @@ -118,7 +124,7 @@ </ant:copy> <ant:copy todir="target/binary" file="shotoku-aop/target/shotoku-aop.aop" /> - <j:set var="jar.to.dir" value="target/binary/${shotoku.ear.dir}/shotoku-base.jar" /> + <j:set var="jar.to.dir" value="target/binary/${shotoku.ear.dir}/shotoku-base.ejb3" /> <attainGoal name="jar-to-dir" /> <j:set var="jar.to.dir" value="target/binary/${shotoku.ear.dir}/shotoku-svn.ejb3" /> <attainGoal name="jar-to-dir" /> Modified: trunk/forge/portal-extensions/shotoku/shotoku-base/src/app/META-INF/application.xml =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-base/src/app/META-INF/application.xml 2006-02-03 10:29:54 UTC (rev 2239) +++ trunk/forge/portal-extensions/shotoku/shotoku-base/src/app/META-INF/application.xml 2006-02-03 12:38:11 UTC (rev 2240) @@ -4,9 +4,9 @@ <ejb>shotoku-svn.ejb3</ejb> </module> <module> - <ejb>shotoku-base.ejb3</ejb> + <ejb>shotoku-files.ejb3</ejb> </module> <module> - <ejb>shotoku-files.ejb3</ejb> + <ejb>shotoku-base.ejb3</ejb> </module> </application> Modified: trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/ContentManager.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/ContentManager.java 2006-02-03 10:29:54 UTC (rev 2239) +++ trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/ContentManager.java 2006-02-03 12:38:11 UTC (rev 2240) @@ -33,6 +33,7 @@ import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.PropertiesConfiguration; +import org.apache.log4j.BasicConfigurator; import org.apache.log4j.Logger; import org.apache.velocity.app.VelocityEngine; import org.jboss.shotoku.exceptions.DeleteException; @@ -344,7 +345,7 @@ * Content manager loading. */ - private static final Logger log = Logger.getLogger(ContentManager.class); + private static final Logger log; /** * <code>defaultId</code> - id of the default content manager. May be @@ -370,7 +371,7 @@ */ private static boolean setupDone; - static { + static { // Setup was not yet executed for sure. setupDone = false; @@ -381,8 +382,15 @@ props.load(ContentManager.class .getResourceAsStream(Constants.PROPERTIES_FILE)); } catch (Exception e) { - log.warn("Error while loading content manager configuration: " + e); + throw new RuntimeException("Error while loading content manager configuration: ", e); } + + // Setuping the logger. + if (isEmbedded()) { + BasicConfigurator.configure(); + } + + log = Logger.getLogger(ContentManager.class); } /** @@ -393,9 +401,18 @@ * Name of the property to get. * @return Value of the given property or null, if no such property exists. */ - public static String getProperty(String name) { + private static String getProperty(String name) { return props.getString(name); } + + /** + * Checks if Shotoku is configured to run in embedded mode or not. + * + * @return True iff Shotoku is configured to run in embedded mode. + */ + public static boolean isEmbedded() { + return Tools.isTrue(getProperty(Constants.PROPERTIES_EMBEDDED)); + } /** * Setups the content managers before first used. In embedded mode, should @@ -410,7 +427,7 @@ // Preventing setup to be executed twice. setupDone = true; } - + engines = Collections .synchronizedMap(new HashMap<String, VelocityEngine>()); Modified: trunk/forge/portal-extensions/shotoku/shotoku-files/maven.xml =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-files/maven.xml 2006-02-03 10:29:54 UTC (rev 2239) +++ trunk/forge/portal-extensions/shotoku/shotoku-files/maven.xml 2006-02-03 12:38:11 UTC (rev 2240) @@ -8,11 +8,19 @@ <attainGoal name="prj-clean" /> </goal> + <goal name="prepare-repo"> + <attainGoal name="jar" /> + + <ant:copy overwrite="true" + tofile="${maven.repo.local}/shotoku/jars/shotoku-files.jar" + file="target/shotoku-files-1.0.jar" /> + </goal> + + <goal name="build"> - <attainGoal name="jar" /> + <attainGoal name="ejb" /> </goal> - <goal name="deploy"> + <goal name="deploy"> </goal> - </project> Modified: trunk/forge/portal-extensions/shotoku/shotoku-files/src/java/org/jboss/shotoku/files/FileContentManager.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-files/src/java/org/jboss/shotoku/files/FileContentManager.java 2006-02-03 10:29:54 UTC (rev 2239) +++ trunk/forge/portal-extensions/shotoku/shotoku-files/src/java/org/jboss/shotoku/files/FileContentManager.java 2006-02-03 12:38:11 UTC (rev 2240) @@ -25,7 +25,7 @@ import java.util.Collection; import org.apache.commons.configuration.Configuration; -import org.jboss.logging.Logger; +import org.apache.log4j.Logger; import org.jboss.shotoku.ContentManager; import org.jboss.shotoku.Directory; import org.jboss.shotoku.Node; @@ -61,10 +61,10 @@ prefix = prefix.substring(0, prefix.length() - 1); } - pathToRepo = getProperty("shotoku.default.localpath"); + pathToRepo = conf.getString("localpath"); if (pathToRepo == null) { - throw new RepositoryException("shotoku.default.localpath is not set in properties"); + throw new RepositoryException("localpath is not set in properties"); } else if (!(new File(pathToRepo)).exists() || !(new File(pathToRepo)).isDirectory()){ throw new RepositoryException(pathToRepo+" doesn't exist or isn't a directory"); Modified: trunk/forge/portal-extensions/shotoku/shotoku-files/src/java/org/jboss/shotoku/files/FileDirectory.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-files/src/java/org/jboss/shotoku/files/FileDirectory.java 2006-02-03 10:29:54 UTC (rev 2239) +++ trunk/forge/portal-extensions/shotoku/shotoku-files/src/java/org/jboss/shotoku/files/FileDirectory.java 2006-02-03 12:38:11 UTC (rev 2240) @@ -31,8 +31,7 @@ import java.util.Map; import java.util.Properties; -import org.jboss.logging.Logger; -import org.jboss.shotoku.ContentManager; +import org.apache.log4j.Logger; import org.jboss.shotoku.Directory; import org.jboss.shotoku.Node; import org.jboss.shotoku.NodeList; Modified: trunk/forge/portal-extensions/shotoku/shotoku-files/src/java/org/jboss/shotoku/files/FileNode.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-files/src/java/org/jboss/shotoku/files/FileNode.java 2006-02-03 10:29:54 UTC (rev 2239) +++ trunk/forge/portal-extensions/shotoku/shotoku-files/src/java/org/jboss/shotoku/files/FileNode.java 2006-02-03 12:38:11 UTC (rev 2240) @@ -44,8 +44,6 @@ import org.jboss.shotoku.exceptions.ResourceDoesNotExist; import org.jboss.shotoku.exceptions.SaveException; -import sun.misc.Perf.GetPerfAction; - public class FileNode implements Node { private File file; Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/maven.xml =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/maven.xml 2006-02-03 10:29:54 UTC (rev 2239) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/maven.xml 2006-02-03 12:38:11 UTC (rev 2240) @@ -8,6 +8,14 @@ <attainGoal name="prj-clean" /> </goal> + <goal name="prepare-repo"> + <attainGoal name="jar" /> + + <ant:copy overwrite="true" + tofile="${maven.repo.local}/shotoku/jars/shotoku-svn.jar" + file="target/shotoku-svn-1.0.jar" /> + </goal> + <goal name="build"> <attainGoal name="ejb" /> </goal> Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnContentManager.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnContentManager.java 2006-02-03 10:29:54 UTC (rev 2239) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnContentManager.java 2006-02-03 12:38:11 UTC (rev 2240) @@ -116,8 +116,8 @@ repository.setAuthenticationManager(authManager); ISVNOptions options = SVNWCUtil.createDefaultOptions(true); - clientManager = - SVNClientManager.newInstance(options, username, password); + + clientManager = SVNClientManager.newInstance(options, username, password); } /** Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnTools.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnTools.java 2006-02-03 10:29:54 UTC (rev 2239) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnTools.java 2006-02-03 12:38:11 UTC (rev 2240) @@ -40,7 +40,6 @@ import org.jboss.shotoku.exceptions.RepositoryException; import org.jboss.shotoku.svn.service.SvnServiceImpl; import org.jboss.shotoku.tools.Constants; -import org.jboss.shotoku.tools.Tools; import org.tmatesoft.svn.core.ISVNLogEntryHandler; import org.tmatesoft.svn.core.SVNDirEntry; import org.tmatesoft.svn.core.SVNException; @@ -84,8 +83,7 @@ public static SvnService getService() { try { if (instance == null) { - if (Tools.isTrue(ContentManager.getProperty( - Constants.PROPERTIES_EMBEDDED))) { + if (ContentManager.isEmbedded()) { // Embedded mode - simply creating a new service instance. instance = new SvnServiceImpl(); instance.create(); Modified: trunk/forge/portal-extensions/shotoku/shotoku-test/project.xml =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-test/project.xml 2006-02-03 10:29:54 UTC (rev 2239) +++ trunk/forge/portal-extensions/shotoku/shotoku-test/project.xml 2006-02-03 12:38:11 UTC (rev 2240) @@ -6,6 +6,7 @@ --> <project> <pomVersion>3</pomVersion> + <extend>../project.xml</extend> <id>shotoku-test</id> <name>Shotoku test</name> <currentVersion>1.0</currentVersion> @@ -21,6 +22,18 @@ <artifactId>shotoku-base</artifactId> <jar>shotoku-base.jar</jar> </dependency> + + <dependency> + <groupId>shotoku</groupId> + <artifactId>shotoku-svn</artifactId> + <jar>shotoku-svn.jar</jar> + </dependency> + + <dependency> + <groupId>shotoku</groupId> + <artifactId>shotoku-files</artifactId> + <jar>shotoku-files.jar</jar> + </dependency> <dependency> <groupId>shotoku</groupId> @@ -35,12 +48,6 @@ <jar>javax.servlet.jar</jar> </dependency> - <dependency> - <groupId>velocity</groupId> - <artifactId>velocity</artifactId> - <version>1.4</version> - </dependency> - <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> @@ -49,6 +56,13 @@ <war.bundle>true</war.bundle> </properties> </dependency> + + <dependency> + <groupId>tmate</groupId> + <artifactId>javasvn</artifactId> + <version>1.0</version> + <jar>javasvn.jar</jar> + </dependency> </dependencies> <build> Modified: trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ShotokuTest.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ShotokuTest.java 2006-02-03 10:29:54 UTC (rev 2239) +++ trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ShotokuTest.java 2006-02-03 12:38:11 UTC (rev 2240) @@ -23,6 +23,7 @@ import org.jboss.shotoku.ContentManager; import org.jboss.shotoku.aop.Inject; +import org.jboss.shotoku.exceptions.ResourceDoesNotExist; import junit.framework.TestCase; @@ -31,7 +32,35 @@ * @author Damon Sicore (da...@si...) */ public abstract class ShotokuTest extends TestCase { + protected final static String CM_ID = "default"; protected final static String SHOTOKU_TEST_DIR = "shotoku-test"; - @Inject(prefix=SHOTOKU_TEST_DIR) + + @Inject(id=CM_ID, prefix=SHOTOKU_TEST_DIR) protected ContentManager cm; + + public ShotokuTest() { + // Annotations don't work in embedded mode. + if (ContentManager.isEmbedded()) { + cm = ContentManager.getContentManager(CM_ID, SHOTOKU_TEST_DIR); + } + } + + static { + // In embedded mode, setup must be called manually. + if (ContentManager.isEmbedded()) { + ContentManager.setup(); + } + + // Checking if the test directory exists, and if not, creating it. + ContentManager cmTemp = ContentManager.getContentManager(CM_ID, ""); + try { + cmTemp.getDirectory(SHOTOKU_TEST_DIR); + } catch (ResourceDoesNotExist e) { + try { + cmTemp.getRootDirectory().newDirectory(SHOTOKU_TEST_DIR).save(""); + } catch (Exception e2) { + throw new RuntimeException("Exception while intializing the test directory", e2); + } + } + } } |
Author: mic...@jb... Date: 2006-02-03 05:29:54 -0500 (Fri, 03 Feb 2006) New Revision: 2239 Added: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/util/proxy/ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/util/proxy/FactInterceptor.java trunk/labs/jbossrules/drools-core/src/main/java/org/drools/util/proxy/FieldIndexAccessor.java trunk/labs/jbossrules/drools-core/src/main/java/org/drools/util/proxy/FieldOrderInspector.java trunk/labs/jbossrules/drools-core/src/main/java/org/drools/util/proxy/ProxyGenerator.java trunk/labs/jbossrules/drools-core/src/main/java/org/drools/util/proxy/ShadowedFactInterceptor.java trunk/labs/jbossrules/drools-core/src/main/java/org/drools/util/proxy/TargetAccessor.java trunk/labs/jbossrules/drools-core/src/test/java/org/drools/util/proxy/ trunk/labs/jbossrules/drools-core/src/test/java/org/drools/util/proxy/FieldExtractorTest.java trunk/labs/jbossrules/drools-core/src/test/java/org/drools/util/proxy/Person.java trunk/labs/jbossrules/drools-core/src/test/java/org/drools/util/proxy/ProxyGeneratorTest.java Log: Shadow & proxy implementation Added: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/util/proxy/FactInterceptor.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/util/proxy/FactInterceptor.java 2006-02-02 22:32:45 UTC (rev 2238) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/util/proxy/FactInterceptor.java 2006-02-03 10:29:54 UTC (rev 2239) @@ -0,0 +1,63 @@ +package org.drools.util.proxy; + +import java.lang.reflect.Method; + +import net.sf.cglib.proxy.MethodInterceptor; +import net.sf.cglib.proxy.MethodProxy; + +/** + * This implements the stuff used by the dynamic proxies that are wrapped around facts. + * This version is a simple non-shadow one. + * + * This is where all the field handling is done. + * + * @author Michael Neale + */ +public class FactInterceptor + implements + MethodInterceptor { + + protected final Object target; + protected static final Method indexAccessor = getIndexAccessor(); + protected static final Method targetAccessor = getTargetAccessor(); + protected final Method[] targetFields; + + public FactInterceptor(Object target, Method[] fieldMethods) { + this.target = target; + this.targetFields = fieldMethods; + } + + public Object intercept(Object obj, + Method method, + Object[] args, + MethodProxy proxy) throws Throwable { + if (method.getDeclaringClass() == indexAccessor.getDeclaringClass() ) { + Integer arg = (Integer) args[0]; + return targetFields[arg.intValue() - 1].invoke(target, null); + } else if (method.getDeclaringClass() == targetAccessor.getDeclaringClass() ) { + return target; + } + return method.invoke(target, args); + + } + + private static Method getIndexAccessor() { + try { + return FieldIndexAccessor.class.getMethod("getField", new Class[]{int.class}); + } + catch ( Exception e ) { + throw new IllegalStateException( e ); + } + } + + private static Method getTargetAccessor() { + try { + return TargetAccessor.class.getMethod("getTarget", null); + } + catch ( Exception e ) { + throw new IllegalStateException( e ); + } + } + + +} Property changes on: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/util/proxy/FactInterceptor.java ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/util/proxy/FieldIndexAccessor.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/util/proxy/FieldIndexAccessor.java 2006-02-02 22:32:45 UTC (rev 2238) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/util/proxy/FieldIndexAccessor.java 2006-02-03 10:29:54 UTC (rev 2239) @@ -0,0 +1,22 @@ +package org.drools.util.proxy; + +/** + * This provides access to "fields" by number. + * Fields are properties, essentually. + * + * Actually, they are methods are public "getXXX", or "isXXX" and take no parameters, and return something. + * + * The order in which they are numbered are the order in which they appear in the class file. + * (NOT the order of the attributes which they expose, which according to *my* reading of the bytecode spec, + * is not defined. + * + * Of course, if code obfuscators were used this may mean that it is also out of order (but at least consistent). + * A future enhancement would be to allow annotations to specify the order, or similar. + * + * @author Michael Neale + */ +public interface FieldIndexAccessor { + + Object getField(int index); + +} Property changes on: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/util/proxy/FieldIndexAccessor.java ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/util/proxy/FieldOrderInspector.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/util/proxy/FieldOrderInspector.java 2006-02-02 22:32:45 UTC (rev 2238) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/util/proxy/FieldOrderInspector.java 2006-02-03 10:29:54 UTC (rev 2239) @@ -0,0 +1,119 @@ +package org.drools.util.proxy; + +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; + +import org.objectweb.asm.Attribute; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.CodeVisitor; + + +/** + * Visit a POJO user class, and extract the property getter methods that are public, in the + * order in which they are declared actually in the class itself (not using introspection). + * + * @author Michael Neale + */ +public class FieldOrderInspector { + + private List methods; + + /** + * @param clazz The class that the fields to be shadowed are extracted for. + * @throws IOException + */ + public FieldOrderInspector(Class clazz) throws IOException { + String name = getResourcePath( clazz ); + InputStream stream = this.getClass().getResourceAsStream(name); + ClassReader reader = new ClassReader(stream); + ClassFieldVisitor visitor = new ClassFieldVisitor(clazz); + reader.accept(visitor, false); + this.methods = visitor.getPropertyGetters(); + } + + /** + * Convert it to a form so we can load the bytes from the classpath. + */ + private String getResourcePath(Class clazz) { + return "/" + clazz.getName().replaceAll("\\.", "/") + ".class"; + } + + /** + * Return a list in order of which the getters (and "is") methods were found. + * This should only be done once when compiling a rulebase ideally. + */ + public List getPropertyGetters() { + return methods; + } + + + /** + * Using the ASM classfield extractor to pluck it out in the order they appear in the class file. + * @author Michael Neale + */ + static class ClassFieldVisitor implements ClassVisitor { + + private static final int PUBLIC_ACCESS = 1; + private List methodList = new ArrayList(); + private Class clazz; + + + ClassFieldVisitor(Class cls) { + this.clazz = cls; + } + + + public List getPropertyGetters() { + return methodList; + } + + public CodeVisitor visitMethod(int access, + String name, + String desc, + String[] signature, + Attribute attr) { + //only want public methods that are get or is + if (access == PUBLIC_ACCESS) { + if (name.startsWith("get") || name.startsWith("is")) { + try { + Method method = clazz.getMethod(name, null); + methodList.add(method); + } catch (NoSuchMethodException e) { + //TODO: must be a better way. We only want fields with no args. + } + } + } + return null; + } + + + public void visit(int arg0, + int arg1, + String arg2, + String arg3, + String[] arg4, + String arg5) {} + + public void visitInnerClass(String arg0, + String arg1, + String arg2, + int arg3) {} + + public void visitField(int access, + String arg1, + String arg2, + Object arg3, + Attribute arg4) {} + + + public void visitAttribute(Attribute arg0) {} + + public void visitEnd() {} + + + } +} Property changes on: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/util/proxy/FieldOrderInspector.java ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/util/proxy/ProxyGenerator.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/util/proxy/ProxyGenerator.java 2006-02-02 22:32:45 UTC (rev 2238) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/util/proxy/ProxyGenerator.java 2006-02-03 10:29:54 UTC (rev 2239) @@ -0,0 +1,92 @@ +package org.drools.util.proxy; + +import java.io.IOException; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; + +import net.sf.cglib.proxy.Enhancer; +import net.sf.cglib.proxy.Factory; + +public class ProxyGenerator { + + //cache the generated classes, and lists of indexable "fields" on each pojo class + private static Map cache = new HashMap(); + + /** + * Generate a proxy that adds in a field index accessor, and an accessor to get to the target. + * Shadow and non shadow options are available. + * + * @throws IOException If unable to load the class data to proxy. + */ + public static Object generateProxy(Object pojo, boolean shadow) throws IOException { + Class cls = pojo.getClass(); + + GeneratedEntry holder = getEntryFor(cls); + + Factory factory = holder.instanceFactory; + Method[] fieldMethods = holder.fieldMethods; + FactInterceptor interceptor; + if (shadow) { + interceptor = new ShadowedFactInterceptor(pojo, fieldMethods); + } else { + interceptor = new FactInterceptor(pojo, fieldMethods); + } + + return factory.newInstance(interceptor); + } + + + /** + * Keep a cache of generated classes (actually keeps a prototype instance) + * and lists of methods for accessing fields. + */ + private static GeneratedEntry getEntryFor(Class pojoClass) throws IOException { + GeneratedEntry entry = (GeneratedEntry) cache.get(pojoClass); + if (entry == null) { + entry = new GeneratedEntry(); + entry.instanceFactory = createInstanceFactory(pojoClass); + entry.fieldMethods = calcFieldMethodsInOrder(pojoClass); + cache.put(pojoClass, entry); + } + return entry; + } + + /** + * Create a instance of the CGLib factory, which will then be used to quickly create new instances + * in the future. + */ + private static Factory createInstanceFactory(Class pojoClass) { + Enhancer enhancer = new Enhancer(); + enhancer.setSuperclass(pojoClass); + enhancer.setInterfaces(new Class[] {FieldIndexAccessor.class, TargetAccessor.class}); + //just need some callback of the correct type to keep it happy, gets replaced when instantiating anyway. + enhancer.setCallback(new FactInterceptor(null, null)); + return (Factory) enhancer.create(); + } + + + /** + * Get an array of methods that are indexable as fields. + * This is also what may be shadowed. + * + * This is generally useful even outside of the proxy. + * To access field 1, you do + * <code>method[1].invoke(yourObject, null);</code> - Simple ! + * + * This uses ASM to work out the innards of the class. + */ + public static Method[] calcFieldMethodsInOrder(Class pojoClass) throws IOException { + FieldOrderInspector ext = new FieldOrderInspector(pojoClass); + return (Method[]) ext.getPropertyGetters().toArray(new Method[] {}); + + } + + + /** used for the cache */ + static class GeneratedEntry { + Factory instanceFactory; + Method[] fieldMethods; + } + +} Property changes on: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/util/proxy/ProxyGenerator.java ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/util/proxy/ShadowedFactInterceptor.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/util/proxy/ShadowedFactInterceptor.java 2006-02-02 22:32:45 UTC (rev 2238) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/util/proxy/ShadowedFactInterceptor.java 2006-02-03 10:29:54 UTC (rev 2239) @@ -0,0 +1,78 @@ +package org.drools.util.proxy; + +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; + +import net.sf.cglib.proxy.MethodProxy; + +/** + * This keeps shadow copies of facts that are accessible as indexed fields. + * + * Scalar values are copies, Objects are pointer copies (thus if they are + * immutable types, then they are effectively copies). + * + * Only values which are accessible as getField are shadowed. All other methods + * are passed through to the target. + * + * If a getter is called on a field which is shadowed, the shadow is returned. + * If the getField method of the FieldIndexAccessor interface is used, the shadow is returned. + * Otherwise its just normal, turtles all the way down. + * + * @author Michael Neale + */ +public class ShadowedFactInterceptor extends FactInterceptor { + + private final Object[] values; + private final Map fieldToValue; + + public ShadowedFactInterceptor(Object target, + Method[] fieldMethods) { + + super( target, + fieldMethods ); + + fieldToValue = new HashMap(); + int numOfFields = fieldMethods.length; + values = new Object[numOfFields]; + try { + for ( int i = 0; i < numOfFields; i++ ) { + + //read all the objects into a value array + Method method = fieldMethods[i]; + Object val = method.invoke( target, null); + values[i] = fieldMethods[i].invoke( target, + null ); + fieldToValue.put(method, val); + } + } + catch ( Exception e ) { + throw new IllegalStateException( e ); + } + + } + + public Object intercept(Object obj, + Method method, + Object[] args, + MethodProxy proxy) throws Throwable { + + //this one is a little different... + if (method.getDeclaringClass() == indexAccessor.getDeclaringClass() ) { + Integer arg = (Integer) args[0]; + return values[arg.intValue() - 1]; + } else if (method.getDeclaringClass() == targetAccessor.getDeclaringClass() ) { + return target; + } else { + //check if method is in targetFields + Object val = fieldToValue.get(method); + if (val != null) { + return val; + } else { + //bugger it, lets pass through. + return method.invoke(target, args); + } + } + } + +} Property changes on: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/util/proxy/ShadowedFactInterceptor.java ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/util/proxy/TargetAccessor.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/util/proxy/TargetAccessor.java 2006-02-02 22:32:45 UTC (rev 2238) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/util/proxy/TargetAccessor.java 2006-02-03 10:29:54 UTC (rev 2239) @@ -0,0 +1,14 @@ +package org.drools.util.proxy; + +/** + * All proxies implement this to allow access to the underlying object. + * @author Michael Neale + */ +public interface TargetAccessor { + + /** + * This will return the target pojo that has been proxied. + */ + Object getTarget(); + +} Property changes on: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/util/proxy/TargetAccessor.java ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/labs/jbossrules/drools-core/src/test/java/org/drools/util/proxy/FieldExtractorTest.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/test/java/org/drools/util/proxy/FieldExtractorTest.java 2006-02-02 22:32:45 UTC (rev 2238) +++ trunk/labs/jbossrules/drools-core/src/test/java/org/drools/util/proxy/FieldExtractorTest.java 2006-02-03 10:29:54 UTC (rev 2239) @@ -0,0 +1,12 @@ +package org.drools.util.proxy; + +import junit.framework.TestCase; + +public class FieldExtractorTest extends TestCase { + + public void testIt() throws Exception { + FieldOrderInspector ext = new FieldOrderInspector( Person.class ); + assertTrue(ext.getPropertyGetters().size() > 0); + } + +} Property changes on: trunk/labs/jbossrules/drools-core/src/test/java/org/drools/util/proxy/FieldExtractorTest.java ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/labs/jbossrules/drools-core/src/test/java/org/drools/util/proxy/Person.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/test/java/org/drools/util/proxy/Person.java 2006-02-02 22:32:45 UTC (rev 2238) +++ trunk/labs/jbossrules/drools-core/src/test/java/org/drools/util/proxy/Person.java 2006-02-03 10:29:54 UTC (rev 2239) @@ -0,0 +1,71 @@ +package org.drools.util.proxy; + +import java.io.PrintWriter; +import java.util.List; + + + +public class Person { + public final Blah SOME_CONST = new Blah(); + + private String name; + + private int age; + + //private so not a "field" + private Integer getZoom() { + return null; + } + + //first field + public String getName() { + return name; + } + + //second field + public int getAge() { + return age; + } + + //not a field, as it takes a parameter.. move along... + public boolean getNothing(int something) { + return true; + } + + //third field + public boolean isHappy() { + return true; + } + + public void setAge(int age) { + this.age = age; + } + + + + public void setName(String name) { + this.name = name; + } + + public void printNameAndAge(PrintWriter out) { + out.println(name + age); + } + + public void doSomethingComplex(List list, + int num, String s, char c, long l, boolean b) { + + + } + + public void changeName(String newName) { + this.name = newName; + } + + public int moreComplex(Blah b) { + return 42; + } + + static class Blah { + + } +} Property changes on: trunk/labs/jbossrules/drools-core/src/test/java/org/drools/util/proxy/Person.java ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/labs/jbossrules/drools-core/src/test/java/org/drools/util/proxy/ProxyGeneratorTest.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/test/java/org/drools/util/proxy/ProxyGeneratorTest.java 2006-02-02 22:32:45 UTC (rev 2238) +++ trunk/labs/jbossrules/drools-core/src/test/java/org/drools/util/proxy/ProxyGeneratorTest.java 2006-02-03 10:29:54 UTC (rev 2239) @@ -0,0 +1,65 @@ +package org.drools.util.proxy; + +import java.io.IOException; + +import junit.framework.TestCase; + +public class ProxyGeneratorTest extends TestCase { + + public void testNonShadow() throws IOException { + Person original = new Person(); + original.setAge(31); + original.setName("michael"); + + Person p = (Person) ProxyGenerator.generateProxy(original, false); + standardTests( original, + p ); + + + //check that stuff is passed through (bypasses the proxy). + p.changeName("jo"); + assertEquals("jo", p.getName()); + assertEquals("jo", original.getName()); + } + + public void testShadow() throws IOException { + Person original = new Person(); + original.setAge(31); + original.setName("michael"); + + Person p = (Person) ProxyGenerator.generateProxy(original, true); + standardTests( original, + p ); + + //check that stuff is passed through, but shadow keeps old copy + p.changeName("jo"); + assertEquals("michael", p.getName()); //ooh clever... + assertEquals("jo", original.getName()); + + } + + private void standardTests(Person original, + Person p) { + assertTrue(p instanceof FieldIndexAccessor); + assertNotSame(p, original); + + //check we can use the proxy + assertEquals(original.getName(), p.getName()); + assertEquals(original.getAge(), p.getAge()); + assertEquals(original.isHappy(), p.isHappy()); + + FieldIndexAccessor s = (FieldIndexAccessor) p; + + //check that order of declarations count, and we can access then via the indexaccessor interface + assertNotNull(p.getName(), s.getField(1)); + assertEquals(p.getAge(), ((Integer)s.getField(2)).intValue()); + assertEquals(p.isHappy(), ((Boolean) s.getField(3)).booleanValue()); + + + //now check that you can get back to the target + assertTrue(p instanceof TargetAccessor); + TargetAccessor t = (TargetAccessor) p; + assertEquals(original, t.getTarget()); + } + +} Property changes on: trunk/labs/jbossrules/drools-core/src/test/java/org/drools/util/proxy/ProxyGeneratorTest.java ___________________________________________________________________ Name: svn:eol-style + native |
Author: adamw Date: 2006-02-02 17:32:45 -0500 (Thu, 02 Feb 2006) New Revision: 2238 Added: trunk/forge/portal-extensions/shotoku/shotoku-base/src/app/ trunk/forge/portal-extensions/shotoku/shotoku-base/src/app/META-INF/ trunk/forge/portal-extensions/shotoku/shotoku-base/src/app/META-INF/application.xml trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/service/ trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuService.java trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuServiceImpl.java trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuServiceLocal.java Removed: trunk/forge/portal-extensions/shotoku/shotoku-files/src/app/ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/app/ Modified: trunk/forge/portal-extensions/shotoku/maven.xml trunk/forge/portal-extensions/shotoku/project.xml trunk/forge/portal-extensions/shotoku/shotoku-base/maven.xml trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/tools/Constants.java trunk/forge/portal-extensions/shotoku/shotoku-files/ trunk/forge/portal-extensions/shotoku/shotoku-files/maven.xml trunk/forge/portal-extensions/shotoku/shotoku-svn/maven.xml trunk/forge/portal-extensions/shotoku/shotoku-svn/project.xml trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnResourceProxy.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnService.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnTools.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/service/SvnServiceImpl.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/service/SvnServiceTimer.java Log: http://jira.jboss.com/jira/browse/JBSHOTOKU-59 Modified: trunk/forge/portal-extensions/shotoku/maven.xml =================================================================== --- trunk/forge/portal-extensions/shotoku/maven.xml 2006-02-02 22:06:05 UTC (rev 2237) +++ trunk/forge/portal-extensions/shotoku/maven.xml 2006-02-02 22:32:45 UTC (rev 2238) @@ -13,11 +13,6 @@ <attainGoal name="clean" /> <attainGoal name="shotoku:build" /> <attainGoal name="shotoku:deploy" /> - <!--<j:set var="prefix" value="" /> - <j:set var="goal" value="build" /> - <attainGoal name="shotoku-all-projects" /> - <j:set var="goal" value="deploy" /> - <attainGoal name="shotoku-all-projects" />--> </goal> <goal name="shotoku-all-projects"> @@ -38,12 +33,21 @@ goals="${goal}" ignoreFailures="false" /> </goal> + <goal name="prepare-repo"> + <maven:reactor includes="${prefix}shotoku-base/project.xml" excludes="" basedir="." + banner="Shotoku base" + goals="prepare-repo" ignoreFailures="false" /> + </goal> + <goal name="build"> <ant:copy todir="${maven.repo.local}" overwrite="true"> <ant:fileset dir="lib" /> </ant:copy> <j:set var="prefix" value="shotoku/" /> + + <attainGoal name="prepare-repo" /> + <j:set var="goal" value="build" /> <attainGoal name="shotoku-all-projects" /> </goal> @@ -55,7 +59,7 @@ <!-- Copying the ear to the deploy directory. --> <ant:copy todir="${local.deploy.dir}"> - <ant:fileset dir="shotoku-svn/target" flatten="true" overwrite="true"> + <ant:fileset dir="shotoku-base/target" flatten="true" overwrite="true"> <ant:filename name="${shotoku.ear.dir}/**" /> </ant:fileset> </ant:copy> @@ -65,8 +69,11 @@ <ant:copy todir="${maven.repo.local}" overwrite="true"> <ant:fileset dir="lib" /> </ant:copy> - + <j:set var="prefix" value="" /> + + <attainGoal name="prepare-repo" /> + <j:set var="goal" value="build" /> <attainGoal name="shotoku-all-projects" /> </goal> @@ -78,7 +85,7 @@ <!-- Copying the ear to the deploy directory. --> <ant:copy todir="${local.deploy.dir}"> - <ant:fileset dir="shotoku-svn/target" flatten="true" overwrite="true"> + <ant:fileset dir="shotoku-base/target" flatten="true" overwrite="true"> <ant:filename name="${shotoku.ear.dir}/**" /> </ant:fileset> </ant:copy> Modified: trunk/forge/portal-extensions/shotoku/project.xml =================================================================== --- trunk/forge/portal-extensions/shotoku/project.xml 2006-02-02 22:06:05 UTC (rev 2237) +++ trunk/forge/portal-extensions/shotoku/project.xml 2006-02-02 22:32:45 UTC (rev 2238) @@ -21,13 +21,11 @@ <artifactId>xercesImpl</artifactId> <version>2.6.2</version> </dependency> - <dependency> <groupId>xerces</groupId> <artifactId>xmlParserAPIs</artifactId> <version>2.6.2</version> </dependency> - <dependency> <groupId>xalan</groupId> <artifactId>xalan</artifactId> @@ -39,15 +37,24 @@ <artifactId>log4j</artifactId> <version>1.2.9</version> </dependency> - <dependency> + + <!-- Velocity dependencies --> + + <dependency> <groupId>velocity</groupId> <artifactId>velocity</artifactId> <version>1.4</version> + <properties> + <ejb.manifest.classpath>true</ejb.manifest.classpath> + </properties> </dependency> <dependency> <groupId>velocity</groupId> <artifactId>velocity-dep</artifactId> <version>1.4</version> + <properties> + <ejb.manifest.classpath>true</ejb.manifest.classpath> + </properties> </dependency> <dependency> <groupId>velocity</groupId> @@ -55,6 +62,8 @@ <version>1.4-dev</version> </dependency> + <!-- Commons dependencies --> + <dependency> <groupId>commons-configuration</groupId> <artifactId>commons-configuration</artifactId> @@ -79,5 +88,44 @@ <ejb.manifest.classpath>true</ejb.manifest.classpath> </properties> </dependency> + + <!-- JBoss EJB3 dependencies --> + + <dependency> + <groupId>jboss</groupId> + <artifactId>jboss-ejb3</artifactId> + <version>1.0</version> + <jar>jboss-ejb3.jar</jar> + </dependency> + <dependency> + <groupId>jboss</groupId> + <artifactId>jboss-ejb3x</artifactId> + <version>1.0</version> + <jar>jboss-ejb3x.jar</jar> + </dependency> + <dependency> + <groupId>jboss</groupId> + <artifactId>jboss-annotations-ejb3</artifactId> + <version>1.0</version> + <jar>jboss-annotations-ejb3.jar</jar> + </dependency> + <dependency> + <groupId>jboss</groupId> + <artifactId>jboss-jmx</artifactId> + <version>1.0</version> + <jar>jboss-jmx.jar</jar> + </dependency> + <dependency> + <groupId>jboss</groupId> + <artifactId>jboss-j2ee</artifactId> + <version>1.0</version> + <jar>jboss-j2ee.jar</jar> + </dependency> + <dependency> + <groupId>jboss</groupId> + <artifactId>activation</artifactId> + <version>1.0</version> + <jar>activation.jar</jar> + </dependency> </dependencies> </project> Modified: trunk/forge/portal-extensions/shotoku/shotoku-base/maven.xml =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-base/maven.xml 2006-02-02 22:06:05 UTC (rev 2237) +++ trunk/forge/portal-extensions/shotoku/shotoku-base/maven.xml 2006-02-02 22:32:45 UTC (rev 2238) @@ -5,19 +5,55 @@ --> <project xmlns:j="jelly:core" xmlns:ant="jelly:ant" xmlns:u="jelly:util"> <goal name="clean"> - <attainGoal name="prj-clean" /> + <attainGoal name="prj-clean" /> </goal> - <goal name="build"> + <goal name="prepare-repo"> <attainGoal name="jar" /> - <ant:copy - file="target/shotoku-base-1.0.jar" - tofile="${maven.repo.local}/shotoku/jars/shotoku-base.jar" - flatten="true" - overwrite="true" /> + <ant:copy overwrite="true" + tofile="${maven.repo.local}/shotoku/jars/shotoku-base.jar" + file="target/shotoku-base-1.0.jar" /> </goal> - + + <goal name="build"> + <attainGoal name="ejb" /> + </goal> + <goal name="deploy"> + <!-- Constructing the ear. --> + <ant:copy overwrite="true" + tofile="target/${shotoku.ear.dir}/shotoku-svn.ejb3" + file="../shotoku-svn/target/shotoku-svn-1.0.jar" /> + <ant:copy + tofile="target/${shotoku.ear.dir}/shotoku-base.ejb3" overwrite="true" + file="target/shotoku-base-1.0.jar" /> + <ant:copy + tofile="target/${shotoku.ear.dir}/shotoku-files.ejb3" overwrite="true" + file="../shotoku-files/target/shotoku-files-1.0.jar" /> + <ant:copy + todir="target/${shotoku.ear.dir}" overwrite="true" + file="${maven.repo.local}/commons-configuration/jars/commons-configuration-1.1.jar" /> + <ant:copy + todir="target/${shotoku.ear.dir}" overwrite="true" + file="${maven.repo.local}/commons-lang/jars/commons-lang-2.1.jar" /> + <ant:copy + todir="target/${shotoku.ear.dir}" overwrite="true" + file="${maven.repo.local}/commons-collections/jars/commons-collections-3.1.jar" /> + <ant:copy + todir="target/${shotoku.ear.dir}" overwrite="true" + file="${maven.repo.local}/tmate/jars/javasvn.jar" /> + <ant:copy + todir="target/${shotoku.ear.dir}" overwrite="true"> + <ant:fileset dir="${maven.repo.local}/velocity/jars"> + <ant:filename name="velocity*-1.4.jar" /> + </ant:fileset> + </ant:copy> + + <ant:copy todir="target/${shotoku.ear.dir}"> + <ant:fileset dir="src/app" flatten="true" overwrite="true"> + <ant:filename name="**" /> + </ant:fileset> + </ant:copy> </goal> </project> Added: trunk/forge/portal-extensions/shotoku/shotoku-base/src/app/META-INF/application.xml =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-base/src/app/META-INF/application.xml 2006-02-02 22:06:05 UTC (rev 2237) +++ trunk/forge/portal-extensions/shotoku/shotoku-base/src/app/META-INF/application.xml 2006-02-02 22:32:45 UTC (rev 2238) @@ -0,0 +1,12 @@ +<application> + <display-name>Shotoku service</display-name> + <module> + <ejb>shotoku-svn.ejb3</ejb> + </module> + <module> + <ejb>shotoku-base.ejb3</ejb> + </module> + <module> + <ejb>shotoku-files.ejb3</ejb> + </module> +</application> Added: trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuService.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuService.java 2006-02-02 22:06:05 UTC (rev 2237) +++ trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuService.java 2006-02-02 22:32:45 UTC (rev 2238) @@ -0,0 +1,37 @@ +/* + * 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.shotoku.service; + +/** + * + * @author Adam Warski (ad...@as...) + */ +public interface ShotokuService { + /* + * SERVICE MANAGEMENT METHODS + */ + + public void create() throws Exception; + public void start() throws Exception; + public void stop(); + public void destroy(); +} Added: trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuServiceImpl.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuServiceImpl.java 2006-02-02 22:06:05 UTC (rev 2237) +++ trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuServiceImpl.java 2006-02-02 22:32:45 UTC (rev 2238) @@ -0,0 +1,111 @@ +/* + * 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.shotoku.service; + +import javax.ejb.Local; + +import org.jboss.annotation.ejb.Depends; +import org.jboss.annotation.ejb.Management; +import org.jboss.annotation.ejb.Service; +import org.jboss.shotoku.ContentManager; +import org.jboss.shotoku.tools.Constants; + +/** + * + * @author Adam Warski (ad...@as...) + */ +@Service(objectName=Constants.SHOTOKU_SERVICE_NAME) +@Local(ShotokuServiceLocal.class) +@Management(ShotokuService.class) +@Depends(Constants.SVN_SERVICE_NAME) +public class ShotokuServiceImpl implements ShotokuService, ShotokuServiceLocal { + /* + * Service-handling functions. + */ + + public void create() throws Exception { + + } + + public void start() throws Exception { + /* + * Setting up content managers. + */ + ContentManager.setup(); + + // Setting the default timer interval. + timerInterval = DEFAULT_TIMER_INTERVAL; + + new Thread() { + { + setDaemon(true); + } + + public void run() { + while (true) { + try { + sleep(getTimerInterval()); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + update(); + } + } + }.start(); + } + + public void stop() { + + } + + public void destroy() { + + } + + /* + * Update functions. + */ + + public void update() { + //System.out.println("SHOTOKU SERVICE UPDATE"); + } + + /* + * Timer interval management functions. + */ + + /** + * <code>DEFAULT_TIMER_INTERVAL</code> - default interval length of the + * timer. + */ + private final static long DEFAULT_TIMER_INTERVAL = 1000*10; // 10 seconds + private volatile long timerInterval; + + public void setTimerInterval(long timerInterval) { + this.timerInterval = timerInterval; + } + + public long getTimerInterval() { + return timerInterval; + } +} Added: trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuServiceLocal.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuServiceLocal.java 2006-02-02 22:06:05 UTC (rev 2237) +++ trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuServiceLocal.java 2006-02-02 22:32:45 UTC (rev 2238) @@ -0,0 +1,30 @@ +/* + * 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.shotoku.service; + +/** + * + * @author Adam Warski (ad...@as...) + */ +public interface ShotokuServiceLocal { + public void update(); +} Modified: trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/tools/Constants.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/tools/Constants.java 2006-02-02 22:06:05 UTC (rev 2237) +++ trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/tools/Constants.java 2006-02-02 22:32:45 UTC (rev 2238) @@ -44,4 +44,16 @@ public static final String SETUP_FUNCTION = "setup"; public static final int TRANSFER_BUF_SIZE = 1024; + + /** + * <code>SVN_SERVICE_NAME</code> - name under which the svn service is + * registered (if svn implementation is used). + */ + public final static String SVN_SERVICE_NAME = "shotoku:service=svn"; + + /** + * <code>SHOTOKU_SERVICE_NAME</code> - name under which the shotoku service is + * registered. + */ + public final static String SHOTOKU_SERVICE_NAME = "shotoku:service=shotoku"; } Property changes on: trunk/forge/portal-extensions/shotoku/shotoku-files ___________________________________________________________________ Name: svn:ignore + .settings .project target Modified: trunk/forge/portal-extensions/shotoku/shotoku-files/maven.xml =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-files/maven.xml 2006-02-02 22:06:05 UTC (rev 2237) +++ trunk/forge/portal-extensions/shotoku/shotoku-files/maven.xml 2006-02-02 22:32:45 UTC (rev 2238) @@ -10,19 +10,9 @@ <goal name="build"> <attainGoal name="jar" /> - - <ant:copy overwrtie="true" - tofile="${maven.repo.local}/shotoku/jars/shotoku-files.jar" - file="target/shotoku-files-1.0.jar" /> </goal> <goal name="deploy"> - <!-- Constructing the ear. --> - - <!-- <ant:copy overwrtie="true" - tofile="../shotoku-svn/target/${shotoku.ear.dir}/shotoku-files.jar" - file="target/shotoku-files-1.0.jar" /> --> - </goal> </project> Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/maven.xml =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/maven.xml 2006-02-02 22:06:05 UTC (rev 2237) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/maven.xml 2006-02-02 22:32:45 UTC (rev 2238) @@ -12,41 +12,6 @@ <attainGoal name="ejb" /> </goal> - <goal name="deploy"> - <!-- Constructing the ear. --> - <ant:copy overwrite="true" - tofile="target/${shotoku.ear.dir}/shotoku-svn.ejb3" - file="target/shotoku-svn-1.0.jar" /> - <ant:copy - todir="target/${shotoku.ear.dir}" overwrite="true" - file="${maven.repo.local}/shotoku/jars/shotoku-base.jar" /> - <ant:copy - todir="target/${shotoku.ear.dir}" overwrite="true" - file="${maven.repo.local}/shotoku/jars/shotoku-files.jar" /> - <ant:copy - todir="target/${shotoku.ear.dir}" overwrite="true" - file="${maven.repo.local}/commons-configuration/jars/commons-configuration-1.1.jar" /> - <ant:copy - todir="target/${shotoku.ear.dir}" overwrite="true" - file="${maven.repo.local}/commons-lang/jars/commons-lang-2.1.jar" /> - <ant:copy - todir="target/${shotoku.ear.dir}" overwrite="true" - file="${maven.repo.local}/commons-collections/jars/commons-collections-3.1.jar" /> - <ant:copy - todir="target/${shotoku.ear.dir}" overwrite="true" - file="${maven.repo.local}/tmate/jars/javasvn.jar" /> - <ant:copy - todir="target/${shotoku.ear.dir}" overwrite="true"> - <ant:fileset dir="${maven.repo.local}/velocity/jars"> - <ant:filename name="velocity*-1.4.jar" /> - </ant:fileset> - </ant:copy> - - <ant:copy todir="target/${shotoku.ear.dir}"> - <ant:fileset dir="src/app" flatten="true" overwrite="true"> - <ant:filename name="**" /> - </ant:fileset> - </ant:copy> - + <goal name="deploy"> </goal> </project> Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/project.xml =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/project.xml 2006-02-02 22:06:05 UTC (rev 2237) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/project.xml 2006-02-02 22:32:45 UTC (rev 2238) @@ -26,83 +26,12 @@ <ejb.manifest.classpath>true</ejb.manifest.classpath> </properties> </dependency> - - <dependency> + + <dependency> <groupId>shotoku</groupId> <artifactId>shotoku-base</artifactId> - <jar>shotoku-base.jar</jar> - <properties> - <ejb.manifest.classpath>true</ejb.manifest.classpath> - </properties> + <jar>shotoku-base.jar</jar> </dependency> - - <dependency> - <groupId>shotoku</groupId> - <artifactId>shotoku-files</artifactId> - <jar>shotoku-files.jar</jar> - <properties> - <ejb.manifest.classpath>true</ejb.manifest.classpath> - </properties> - </dependency> - - <dependency> - <groupId>velocity</groupId> - <artifactId>velocity</artifactId> - <version>1.4</version> - <properties> - <ejb.manifest.classpath>true</ejb.manifest.classpath> - </properties> - </dependency> - <dependency> - <groupId>velocity</groupId> - <artifactId>velocity-dep</artifactId> - <version>1.4</version> - <properties> - <ejb.manifest.classpath>true</ejb.manifest.classpath> - </properties> - </dependency> - - <dependency> - <groupId>jboss</groupId> - <artifactId>jboss-ejb3</artifactId> - <version>1.0</version> - <jar>jboss-ejb3.jar</jar> - </dependency> - - <dependency> - <groupId>jboss</groupId> - <artifactId>jboss-ejb3x</artifactId> - <version>1.0</version> - <jar>jboss-ejb3x.jar</jar> - </dependency> - - <dependency> - <groupId>jboss</groupId> - <artifactId>jboss-annotations-ejb3</artifactId> - <version>1.0</version> - <jar>jboss-annotations-ejb3.jar</jar> - </dependency> - - <dependency> - <groupId>jboss</groupId> - <artifactId>jboss-jmx</artifactId> - <version>1.0</version> - <jar>jboss-jmx.jar</jar> - </dependency> - - <dependency> - <groupId>jboss</groupId> - <artifactId>jboss-j2ee</artifactId> - <version>1.0</version> - <jar>jboss-j2ee.jar</jar> - </dependency> - - <dependency> - <groupId>jboss</groupId> - <artifactId>activation</artifactId> - <version>1.0</version> - <jar>activation.jar</jar> - </dependency> </dependencies> <build> Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnResourceProxy.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnResourceProxy.java 2006-02-02 22:06:05 UTC (rev 2237) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnResourceProxy.java 2006-02-02 22:32:45 UTC (rev 2238) @@ -35,7 +35,7 @@ import org.jboss.shotoku.svn.operations.ResourceOperation; /** - * A base class for new resource helpers - their function is to tunnel all + * A base class for new resource proxies - their function is to tunnel all * functions to a "new resource" class implementation if a new resource * hasn't been yet saved, and to a "normal resource" class implementation if * a new resource has been saved. Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnService.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnService.java 2006-02-02 22:06:05 UTC (rev 2237) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnService.java 2006-02-02 22:32:45 UTC (rev 2238) @@ -150,12 +150,6 @@ */ public boolean isDeleted(String id, String fullPath); - /** - * <code>SVN_SERVICE_NAME</code> - name under which the svn service is - * registered. - */ - public final static String SVN_SERVICE_NAME = "shotoku:service=svn"; - /* * SERVICE MANAGEMENT METHODS */ Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnTools.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnTools.java 2006-02-02 22:06:05 UTC (rev 2237) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnTools.java 2006-02-02 22:32:45 UTC (rev 2238) @@ -94,7 +94,7 @@ // Application server mode - creating a proxy to a mbean. instance = (SvnService) MBeanProxyExt.create( SvnService.class, - SvnService.SVN_SERVICE_NAME, + Constants.SVN_SERVICE_NAME, MBeanServerLocator.locate()); } } Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/service/SvnServiceImpl.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/service/SvnServiceImpl.java 2006-02-02 22:06:05 UTC (rev 2237) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/service/SvnServiceImpl.java 2006-02-02 22:32:45 UTC (rev 2238) @@ -32,9 +32,9 @@ import org.apache.log4j.Logger; import org.jboss.annotation.ejb.Management; import org.jboss.annotation.ejb.Service; -import org.jboss.shotoku.ContentManager; import org.jboss.shotoku.svn.SvnService; import org.jboss.shotoku.svn.SvnTools; +import org.jboss.shotoku.tools.Constants; import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory; import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl; @@ -42,7 +42,7 @@ * @author Adam Warski (ad...@as...) * @author Damon Sicore (da...@si...) */ -@Service(objectName=SvnService.SVN_SERVICE_NAME) +@Service(objectName=Constants.SVN_SERVICE_NAME) @Local(SvnServiceLocal.class) @Management(SvnService.class) public class SvnServiceImpl implements SvnService { @@ -71,12 +71,6 @@ repositories = Collections.synchronizedMap( new HashMap<String, SvnRepository>()); - - /* - * Setting up content managers - svn repositories should be added - * during this operation. - */ - ContentManager.setup(); } public void start() throws Exception { Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/service/SvnServiceTimer.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/service/SvnServiceTimer.java 2006-02-02 22:06:05 UTC (rev 2237) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/service/SvnServiceTimer.java 2006-02-02 22:32:45 UTC (rev 2238) @@ -31,7 +31,7 @@ import org.jboss.mx.util.MBeanProxyExt; import org.jboss.mx.util.MBeanServerLocator; -import org.jboss.shotoku.svn.SvnService; +import org.jboss.shotoku.tools.Constants; /** * @author Adam Warski (ad...@as...) @@ -56,7 +56,7 @@ try { ssi = ((SvnServiceLocal) MBeanProxyExt.create( SvnServiceLocal.class, - SvnService.SVN_SERVICE_NAME, + Constants.SVN_SERVICE_NAME, MBeanServerLocator.locate())); } catch (MalformedObjectNameException e) { e.printStackTrace(); |
From: <jbo...@li...> - 2006-02-02 22:06:13
|
Author: dam...@jb... Date: 2006-02-02 17:06:05 -0500 (Thu, 02 Feb 2006) New Revision: 2237 Added: branches/forge/adam/ Log: Added a branch for Adam. |
From: <jbo...@li...> - 2006-02-02 21:02:24
|
Author: wrzep Date: 2006-02-02 16:02:14 -0500 (Thu, 02 Feb 2006) New Revision: 2236 Modified: trunk/forge/portal-extensions/forge-status/project.xml trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java Log: couning #code lines for single file http://jira.jboss.com/jira/browse/JBLAB-606 Pawel Modified: trunk/forge/portal-extensions/forge-status/project.xml =================================================================== --- trunk/forge/portal-extensions/forge-status/project.xml 2006-02-02 19:28:00 UTC (rev 2235) +++ trunk/forge/portal-extensions/forge-status/project.xml 2006-02-02 21:02:14 UTC (rev 2236) @@ -17,6 +17,7 @@ <description></description> <dependencies> + <dependency> <groupId>jboss-forge</groupId> <artifactId>forge-common</artifactId> @@ -38,6 +39,13 @@ </properties> </dependency> + <dependency> + <groupId>tmate</groupId> + <artifactId>javasvn</artifactId> + <version>1.0</version> + <jar>javasvn.jar</jar> + </dependency> + <dependency> <groupId>kosmos</groupId> <artifactId>kosmos</artifactId> Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java 2006-02-02 19:28:00 UTC (rev 2235) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java 2006-02-02 21:02:14 UTC (rev 2236) @@ -22,12 +22,130 @@ package org.jboss.forge.status.plugins; +import java.io.ByteArrayOutputStream; +import java.util.HashMap; +import java.util.Map; + +import org.jboss.logging.Logger; +import org.tmatesoft.svn.core.SVNException; +import org.tmatesoft.svn.core.SVNNodeKind; +import org.tmatesoft.svn.core.SVNProperty; +import org.tmatesoft.svn.core.SVNURL; +import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager; +import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory; +import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl; +import org.tmatesoft.svn.core.io.SVNRepository; +import org.tmatesoft.svn.core.io.SVNRepositoryFactory; +import org.tmatesoft.svn.core.wc.SVNWCUtil; + /** * @author Pawel Wrzeszcz * Plugin returns total number of lines of code in project svn repository. */ -public abstract class CodeLinesPlugin extends StatusPlugin { +public class CodeLinesPlugin extends StatusPlugin { + private static final String SVN_REPO_ADRESS_TAG = "svn-repo"; + private Logger log; + + public CodeLinesPlugin() { + super(); + + log = Logger.getLogger(this.getClass()); + } + + @Override + public long getValue(String projectId) { + + if (!projectId.equals("jbosslabs")) + return -1; + + /* Get svn repository location */ + String url = "http://anonsvn.labs.jboss.com/trunk/forge/portal-extensions/"; + String name = "anonymous"; + String password = "anonymous"; + String filePath = "forge-status/src/java/org/jboss/forge/status/Column.java"; + + setupLibrary(); + + log.info("connecting..."); + /* Connect to svn repository */ + SVNRepository repository = null; + try { + repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(url)); + } catch (SVNException svne) { + log.error("Can not connect to the svn service: " + url + " / " + svne.getMessage()); + return 0; + } + + ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(name, password); + + repository.setAuthenticationManager(authManager); + + Map fileProperties = new HashMap(); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + log.info("chcecking..."); + /* Check if the given path corresponds to a file */ + try { + SVNNodeKind nodeKind = repository.checkPath(filePath, -1); + + if (nodeKind == SVNNodeKind.NONE) { + log.error("File not found."); + return 0; + } else if (nodeKind == SVNNodeKind.DIR) { + log.error("Dir"); + return 0; + } + + repository.getFile(filePath, -1, fileProperties, baos); + + } catch (SVNException svne) { + log.error("error while fetching the file contents and properties: " + svne.getMessage()); + return 0; + } + + log.info("getting properties..."); + /* Get file properties and content */ + + String mimeType = (String) fileProperties.get(SVNProperty.MIME_TYPE); + + boolean isTextType = SVNProperty.isTextMimeType(mimeType); + + log.info("counting lines..."); + /* + * Counting number of lines + */ + long cl = -1; + + if (isTextType) { + cl = baos.toString().split("\n").length; + } else { + log.error("Is not text file"); + } + + return cl; + } + + private String getRepoURL(String projectId) { + String repoURL = projects.getProjectProperty(projectId, SVN_REPO_ADRESS_TAG); + return (repoURL == "" ? null : repoURL); + } + + /* + * Initializes the library to work with a repository either via svn:// + * (and svn+ssh://) or via http:// (and https://) + */ + private static void setupLibrary() { + /* + * for DAV (over http and https) + */ + DAVRepositoryFactory.setup(); + /* + * for SVN (over svn and svn+ssh) + */ + SVNRepositoryFactoryImpl.setup(); + } + } |
From: <jbo...@li...> - 2006-02-02 19:28:10
|
Author: wrzep Date: 2006-02-02 14:28:00 -0500 (Thu, 02 Feb 2006) New Revision: 2235 Added: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java Log: http://jira.jboss.com/jira/browse/JBLAB-606 Pawel Added: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java 2006-02-02 18:23:30 UTC (rev 2234) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/CodeLinesPlugin.java 2006-02-02 19:28:00 UTC (rev 2235) @@ -0,0 +1,33 @@ +/* + * 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.status.plugins; + +/** +* @author Pawel Wrzeszcz +* Plugin returns total number of lines of code in project svn repository. +*/ + +public abstract class CodeLinesPlugin extends StatusPlugin { + + +} |