Author: glandais Date: 2008-02-04 14:47:21 +0000 (Mon, 04 Feb 2008) New Revision: 628 Removed: trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/test/ Modified: trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/MetaDataGenerator.java trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/SimExplorerStorageException.java trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/VersionGenerator.java trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/attachment/AttachmentHandler.java trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/attachment/FileSystemAttachmentHandler.java trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/Database.java trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/DatabaseConstants.java trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabase.java trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/lucene/SearcherPool.java trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngine.java trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngineImpl.java trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/util/Config.java trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/util/KeyValue.java trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/util/ZipStreamEncoder.java trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/VersionGeneratorTest.java trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseLoadMassTestCase.java trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseTestCase.java trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseThread.java trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseThreadsMassTestCase.java trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneSimpleTest.java Log: Javadoc Modified: trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/MetaDataGenerator.java =================================================================== --- trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/MetaDataGenerator.java 2008-02-04 14:46:14 UTC (rev 627) +++ trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/MetaDataGenerator.java 2008-02-04 14:47:21 UTC (rev 628) @@ -27,8 +27,12 @@ import java.util.Map; import java.util.UUID; +/** + * The Class MetaDataGenerator. + */ public class MetaDataGenerator { + /** The r. */ java.util.Random r = new java.util.Random(); /* @@ -40,8 +44,22 @@ * descriptorFields[i] = "descriptor" + i; } } */ + /** + * Generate meta data entity. + * + * @param uuid + * the uuid + * @param version + * the version + * @param parentVersion + * the parent version + * @param parentData + * the parent data + * + * @return the meta data + */ public MetaData generateMetaDataEntity(String uuid, Version version, - MetaData parentVersion, MetaData parentData) { + MetaData parentVersion, MetaData parentData) { MetaData me = generateMetaDataEntity(uuid, version, parentVersion); if (parentData != null) { me.setParentDataUuid(parentData.getUuid()); @@ -50,8 +68,20 @@ return me; } + /** + * Generate meta data entity. + * + * @param uuid + * the uuid + * @param version + * the version + * @param parentVersion + * the parent version + * + * @return the meta data + */ public MetaData generateMetaDataEntity(String uuid, Version version, - MetaData parentVersion) { + MetaData parentVersion) { MetaData me = generateMetaDataEntity(uuid, version); if (parentVersion != null) { @@ -64,6 +94,16 @@ return me; } + /** + * Generate meta data entity. + * + * @param uuid + * the uuid + * @param version + * the version + * + * @return the meta data + */ public MetaData generateMetaDataEntity(String uuid, Version version) { MetaData me = new MetaData(); @@ -92,11 +132,21 @@ return me; } + /** + * Generate meta data entity. + * + * @return the meta data + */ public MetaData generateMetaDataEntity() { - return generateMetaDataEntity(UUID.randomUUID().toString(), - Version.valueOf("1.0")); + return generateMetaDataEntity(UUID.randomUUID().toString(), Version + .valueOf("1.0")); } + /** + * Generate versionned meta data entity. + * + * @return the meta data[] + */ public MetaData[] generateVersionnedMetaDataEntity() { Version[] versions = VersionGenerator.getInstance().generateVersions(); @@ -112,9 +162,18 @@ return mes; } + /** + * Generate versionned meta data entity. + * + * @param nbMax + * the nb max + * + * @return the meta data[] + */ public MetaData[] generateVersionnedMetaDataEntity(int nbMax) { - Version[] versions = VersionGenerator.getInstance().generateVersions(nbMax); + Version[] versions = VersionGenerator.getInstance().generateVersions( + nbMax); String uuid = UUID.randomUUID().toString(); int nb = versions.length; @@ -127,9 +186,18 @@ return mes; } + /** + * Generate versionned meta data. + * + * @param mandatory + * the mandatory + * + * @return the meta data[] + */ public MetaData[] generateVersionnedMetaData(Version mandatory) { - Version[] versions = VersionGenerator.getInstance().generateVersions(mandatory); + Version[] versions = VersionGenerator.getInstance().generateVersions( + mandatory); String uuid = UUID.randomUUID().toString(); int nb = versions.length; Modified: trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/SimExplorerStorageException.java =================================================================== --- trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/SimExplorerStorageException.java 2008-02-04 14:46:14 UTC (rev 627) +++ trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/SimExplorerStorageException.java 2008-02-04 14:47:21 UTC (rev 628) @@ -17,22 +17,49 @@ * ##% */ package fr.cemagref.simexplorer.is.storage; +/** + * The Class SimExplorerStorageException. + */ public class SimExplorerStorageException extends Exception { + /** The Constant serialVersionUID. */ private static final long serialVersionUID = 4405447107690074844L; + /** + * Instantiates a new sim explorer storage exception. + */ public SimExplorerStorageException() { super(); } + /** + * Instantiates a new sim explorer storage exception. + * + * @param message + * the message + */ public SimExplorerStorageException(String message) { super(message); } + /** + * Instantiates a new sim explorer storage exception. + * + * @param cause + * the cause + */ public SimExplorerStorageException(Throwable cause) { super(cause); } + /** + * Instantiates a new sim explorer storage exception. + * + * @param message + * the message + * @param cause + * the cause + */ public SimExplorerStorageException(String message, Throwable cause) { super(message, cause); } Modified: trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/VersionGenerator.java =================================================================== --- trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/VersionGenerator.java 2008-02-04 14:46:14 UTC (rev 627) +++ trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/VersionGenerator.java 2008-02-04 14:47:21 UTC (rev 628) @@ -25,26 +25,33 @@ import java.util.Arrays; import java.util.Collections; - /** - * A Version generator - * + * A Version generator. + * * @author chemit */ public class VersionGenerator { - /** la taille maximum d'une version générée */ + /** la taille maximum d'une version générée. */ static final int MAX_SIZE = 5; - /** la valeur maximum d'un numéro de version à générer */ + /** la valeur maximum d'un numéro de version à générer. */ static final int MAX_VERSION_NUMBER = 10; - /** le nombre maximum de versions générées dans la méthode {@link #generateVersions()} */ + /** + * le nombre maximum de versions générées dans la méthode + * {@link #generateVersions()}. + */ static final int MAX_NB_VERSIONS = 20; - /** instance statique partagée */ + /** instance statique partagée. */ protected static VersionGenerator instance; + /** + * Gets the single instance of VersionGenerator. + * + * @return single instance of VersionGenerator + */ public static VersionGenerator getInstance() { if (instance == null) { instance = new VersionGenerator(); @@ -52,8 +59,14 @@ return instance; } + /** The r. */ protected Random r; + /** + * Generate version. + * + * @return the version + */ public Version generateVersion() { StringBuilder sb = new StringBuilder(); for (int i = 0, size = generateNotNullAbsInt(MAX_SIZE); i < size; i++) { @@ -62,11 +75,24 @@ return Version.valueOf(sb.substring(1)); } + /** + * Generate versions. + * + * @return the version[] + */ public Version[] generateVersions() { int nb = generateNotNullAbsInt(MAX_NB_VERSIONS); return generateVersions(nb); } + /** + * Generate versions. + * + * @param mandatory + * the mandatory + * + * @return the version[] + */ public Version[] generateVersions(Version mandatory) { int nb = generateNotNullAbsInt(MAX_NB_VERSIONS); Version[] versions = generateVersions(nb); @@ -78,22 +104,46 @@ return list.toArray(new Version[list.size()]); } + /** + * Generate versions. + * + * @param nb + * the nb + * + * @return the version[] + */ public Version[] generateVersions(int nb) { Version[] result = new Version[nb]; result[0] = generateVersion(); - //System.out.println("nb versions :" + nb); - //System.out.println("version 0 :" + result[0]); + // System.out.println("nb versions :" + nb); + // System.out.println("version 0 :" + result[0]); for (int i = 1; i < nb; i++) { result[i] = result[i - 1].incVersion(generateAbsInt(MAX_SIZE)); - //System.out.println("version " + i + " :" + result[i]); + // System.out.println("version " + i + " :" + result[i]); } return result; } + /** + * Generate abs int. + * + * @param max + * the max + * + * @return the int + */ protected int generateAbsInt(int max) { return Math.abs(r.nextInt()) % max; } + /** + * Generate not null abs int. + * + * @param max + * the max + * + * @return the int + */ protected int generateNotNullAbsInt(int max) { int nb = 0; while (nb == 0) { @@ -102,6 +152,9 @@ return nb; } + /** + * Instantiates a new version generator. + */ protected VersionGenerator() { this.r = new Random(); } Modified: trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/attachment/AttachmentHandler.java =================================================================== --- trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/attachment/AttachmentHandler.java 2008-02-04 14:46:14 UTC (rev 627) +++ trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/attachment/AttachmentHandler.java 2008-02-04 14:47:21 UTC (rev 628) @@ -23,15 +23,14 @@ import fr.cemagref.simexplorer.is.storage.SimExplorerStorageException; /** - * Store, retrieve and delete content + * Store, retrieve and delete content. * * @author landais - * */ public abstract class AttachmentHandler { /** - * Store content + * Store content. * * @param entity * DataEntity related to content @@ -39,32 +38,39 @@ * Unique field for content * @param is * Content - * @throws SimExplorerStorageException + * + * @throws SimExplorerStorageException + * the sim explorer storage exception */ public abstract void storeData(MetaData entity, String field, InputStream is) throws SimExplorerStorageException; /** - * Retrieve content + * Retrieve content. * * @param entity * DataEntity related to content * @param field * Unique field for content + * * @return Content - * @throws SimExplorerStorageException + * + * @throws SimExplorerStorageException + * the sim explorer storage exception */ public abstract InputStream retrieveData(MetaData entity, String field) throws SimExplorerStorageException; /** - * Delete content + * Delete content. * * @param entity * DataEntity related to content * @param field * Unique field for content - * @throws SimExplorerStorageException + * + * @throws SimExplorerStorageException + * the sim explorer storage exception */ public abstract void deleteData(MetaData entity, String field) throws SimExplorerStorageException; Modified: trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/attachment/FileSystemAttachmentHandler.java =================================================================== --- trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/attachment/FileSystemAttachmentHandler.java 2008-02-04 14:46:14 UTC (rev 627) +++ trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/attachment/FileSystemAttachmentHandler.java 2008-02-04 14:47:21 UTC (rev 628) @@ -31,26 +31,25 @@ import fr.cemagref.simexplorer.is.storage.util.Config; /** - * File system implementation + * File system implementation. * * @author landais - * */ public class FileSystemAttachmentHandler extends AttachmentHandler { - /** - * Base folder - */ + /** Base folder. */ private static String baseFolder = Config.getProperties().getProperty( "simexplorer.data"); /** - * Retrieve file associated to content Create directories associated to file + * Retrieve file associated to content Create directories associated to + * file. * * @param entity * DataEntity related to content * @param field * Unique field for content + * * @return Instance of file */ private File getFile(MetaData entity, String field) { @@ -77,6 +76,9 @@ return result; } + /* (non-Javadoc) + * @see fr.cemagref.simexplorer.is.storage.attachment.AttachmentHandler#retrieveData(fr.cemagref.simexplorer.is.entities.metadata.MetaData, java.lang.String) + */ @Override public InputStream retrieveData(MetaData entity, String field) throws SimExplorerStorageException { @@ -90,11 +92,13 @@ return fis; } + /* (non-Javadoc) + * @see fr.cemagref.simexplorer.is.storage.attachment.AttachmentHandler#storeData(fr.cemagref.simexplorer.is.entities.metadata.MetaData, java.lang.String, java.io.InputStream) + */ @Override public void storeData(MetaData entity, String field, InputStream is) throws SimExplorerStorageException { - // Simple stream on file try { File file = getFile(entity, field); @@ -121,11 +125,18 @@ } } + /* (non-Javadoc) + * @see fr.cemagref.simexplorer.is.storage.attachment.AttachmentHandler#deleteData(fr.cemagref.simexplorer.is.entities.metadata.MetaData, java.lang.String) + */ @Override public void deleteData(MetaData entity, String field) throws SimExplorerStorageException { - // Simple delete on file - getFile(entity, field).delete(); + try { + // Simple delete on file + getFile(entity, field).delete(); + } catch (Exception e) { + throw new SimExplorerStorageException(e); + } } } Modified: trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/Database.java =================================================================== --- trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/Database.java 2008-02-04 14:46:14 UTC (rev 627) +++ trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/Database.java 2008-02-04 14:47:21 UTC (rev 628) @@ -28,114 +28,136 @@ import fr.cemagref.simexplorer.is.storage.SimExplorerStorageException; /** - * Interface of a database able to manage metadata elements + * Interface of a database able to manage metadata elements. * * @author landais - * */ public abstract class Database implements DatabaseConstants { /** - * Open database connection + * Open database connection. * * @throws SimExplorerStorageException + * the sim explorer storage exception */ public void open() throws SimExplorerStorageException { open(false); } /** - * Open database connection + * Open database connection. * * @param create * Create database + * * @throws SimExplorerStorageException + * the sim explorer storage exception */ - public abstract void open(boolean create) throws SimExplorerStorageException; + public abstract void open(boolean create) + throws SimExplorerStorageException; /** - * Close database connection + * Close database connection. * * @throws SimExplorerStorageException + * the sim explorer storage exception */ public abstract void close() throws SimExplorerStorageException; /** - * Commit pending modifications + * Commit pending modifications. * * @throws SimExplorerStorageException + * the sim explorer storage exception */ public abstract void commit() throws SimExplorerStorageException; // Create / Update /** - * Insert an element into database - * Delete existing element with same id/version if exists + * Insert an element into database Delete existing element with same + * id/version if exists. * * @param element * Element to insert - * @param readers + * @param readers + * the readers + * * @throws SimExplorerStorageException + * the sim explorer storage exception */ - public abstract void insertElement(MetaData element, - List<Reader> readers) throws SimExplorerStorageException; + public abstract void insertElement(MetaData element, List<Reader> readers) + throws SimExplorerStorageException; // Read /** - * Get an element from its id and its version null if not fund + * Get an element from its id and its version null if not fund. * * @param uuid * Id * @param version * version + * * @return Fund element, null if not fund + * * @throws SimExplorerStorageException + * the sim explorer storage exception */ public abstract MetaData getElement(String uuid, Version version) throws SimExplorerStorageException; /** * Get all version of an element thanks to its id <br> - * Empty list if no element with this id + * Empty list if no element with this id. * * @param uuid * Id + * * @return Versions + * * @throws SimExplorerStorageException + * the sim explorer storage exception */ - public abstract List<Version> getVersions(String uuid) throws SimExplorerStorageException; + public abstract List<Version> getVersions(String uuid) + throws SimExplorerStorageException; /** - * Retrieve all elements by id Empty list if no element with this id + * Retrieve all elements by id Empty list if no element with this id. * * @param uuid * Id - * @param onlyLatest + * @param onlyLatest + * the only latest + * * @return Element list + * * @throws SimExplorerStorageException + * the sim explorer storage exception */ public abstract Set<MetaData> findElementsById(String uuid, boolean onlyLatest) throws SimExplorerStorageException; /** * Retrieve elements with specific properties<br> - * Empty list if no element + * Empty list if no element. * * @param properties * Matching properties needed + * * @return Element list + * * @throws SimExplorerStorageException + * the sim explorer storage exception */ - public Set<MetaData> findElementsByProperties( - Map<String, String> properties) throws SimExplorerStorageException { + public Set<MetaData> findElementsByProperties(Map<String, String> properties) + throws SimExplorerStorageException { return findElementsByProperties(properties, 0, -1, 0); } /** * Retrieve elements with specific properties<br> - * Empty list if no element + * Empty list if no element. * * @param properties * Matching properties needed @@ -143,32 +165,40 @@ * Index of first element returned * @param count * Number of elements to return - * @param dateOrder + * @param dateOrder + * the date order + * * @return Element list + * * @throws SimExplorerStorageException + * the sim explorer storage exception */ public abstract Set<MetaData> findElementsByProperties( Map<String, String> properties, int start, int count, int dateOrder) throws SimExplorerStorageException; /** - * Retrieve element count specific properties + * Retrieve element count specific properties. * * @param properties * Matching properties needed + * * @return Number of elements fund + * * @throws SimExplorerStorageException + * the sim explorer storage exception */ public abstract int findElementsByPropertiesCount( Map<String, String> properties) throws SimExplorerStorageException; /** - * Prepare properties for query + * Prepare properties for query. * * @param type * Type of entity wanted * @param onlyLatest * Only wanted elements + * * @return Properties for query */ private Map<String, String> getPropertiesByType(String type, @@ -182,7 +212,7 @@ } /** - * Retrieve elements of a certain type + * Retrieve elements of a certain type. * * @param type * Type wanted @@ -194,25 +224,31 @@ * Number of documents * @param dateOrder * Sorting + * * @return Element list + * * @throws SimExplorerStorageException + * the sim explorer storage exception */ - public Set<MetaData> findElementsByType(String type, - boolean onlyLatest, int start, int count, int dateOrder) + public Set<MetaData> findElementsByType(String type, boolean onlyLatest, + int start, int count, int dateOrder) throws SimExplorerStorageException { return findElementsByProperties(getPropertiesByType(type, onlyLatest), start, count, dateOrder); } /** - * Number of elements of the type + * Number of elements of the type. * * @param type * Type wanted * @param onlyLatest * Only latest elements + * * @return Number of elements + * * @throws SimExplorerStorageException + * the sim explorer storage exception */ public int findElementsByTypeCount(String type, boolean onlyLatest) throws SimExplorerStorageException { @@ -222,31 +258,40 @@ /** * Retrieve elements by content search<br> - * Empty list if no element + * Empty list if no element. * * @param queryText * Searched text - * @param onlyLatest + * @param onlyLatest + * the only latest * @param start * Index of first element returned * @param count * Number of elements to return - * @param dateOrder + * @param dateOrder + * the date order + * * @return Element list + * * @throws SimExplorerStorageException + * the sim explorer storage exception */ - public abstract Set<MetaData> findElementsByContentSearch( - String queryText, boolean onlyLatest, int start, int count, - int dateOrder) throws SimExplorerStorageException; + public abstract Set<MetaData> findElementsByContentSearch(String queryText, + boolean onlyLatest, int start, int count, int dateOrder) + throws SimExplorerStorageException; /** - * Retrieve element count with specific content + * Retrieve element count with specific content. * * @param queryText * Searched text - * @param onlyLatest + * @param onlyLatest + * the only latest + * * @return Number of elements fund + * * @throws SimExplorerStorageException + * the sim explorer storage exception */ public abstract int findElementsByContentSearchCount(String queryText, boolean onlyLatest) throws SimExplorerStorageException; @@ -254,24 +299,29 @@ // Delete /** - * Delete an a specific element + * Delete an a specific element. * * @param element * Element to delete + * * @throws SimExplorerStorageException + * the sim explorer storage exception */ - public void deleteElement(MetaData element) throws SimExplorerStorageException { + public void deleteElement(MetaData element) + throws SimExplorerStorageException { deleteElement(element.getUuid(), element.getVersion()); } /** - * Delete an element by id and version + * Delete an element by id and version. * * @param uuid * Id * @param version * Version + * * @throws SimExplorerStorageException + * the sim explorer storage exception */ public abstract void deleteElement(String uuid, Version version) throws SimExplorerStorageException; Modified: trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/DatabaseConstants.java =================================================================== --- trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/DatabaseConstants.java 2008-02-04 14:46:14 UTC (rev 627) +++ trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/DatabaseConstants.java 2008-02-04 14:47:21 UTC (rev 628) @@ -18,109 +18,84 @@ package fr.cemagref.simexplorer.is.storage.database; /** - * Constants for database implementations + * Constants for database implementations. * * @author landais - * */ public interface DatabaseConstants { + /** The Constant DOT. */ public static final String DOT = "."; - /** - * Field name for id - */ + + /** Field name for id. */ public static final String KEY_UUID = "simexplorer.uuid"; - /** - * Field name for name - */ + + /** Field name for name. */ public static final String KEY_NAME = "simexplorer.name"; - /** - * Field name for type - */ + + /** Field name for type. */ public static final String KEY_TYPE = "simexplorer.type"; - /** - * Field name for description - */ + + /** Field name for description. */ public static final String KEY_DESCRIPTION = "simexplorer.description"; - /** - * Field name for version - */ + + /** Field name for version. */ public static final String KEY_VERSION = "simexplorer.version"; - /** - * Field name for latest - */ + + /** Field name for latest. */ public static final String KEY_LATEST = "simexplorer.latest"; - /** - * - * Field name for creation date - */ + + /** Field name for creation date. */ public static final String KEY_CREATIONDATE = "simexplorer.creationdate"; - /** - * Field name for hash - */ + + /** Field name for hash. */ public static final String KEY_HASH = "simexplorer.hash"; - /** - * Field name for descriptor - */ + + /** Field name for descriptor. */ public static final String KEY_DESCRIPTOR = "simexplorer.descriptor"; - /** - * Field name for descriptor - */ + + /** Field name for descriptor. */ public static final String KEY_DESCRIPTOR_KEY = "key"; - /** - * Field name for descriptor - */ + + /** Field name for descriptor. */ public static final String KEY_DESCRIPTOR_VALUE = "value"; - /** - * Field name for attachment - */ + + /** Field name for attachment. */ public static final String KEY_ATTACHMENT = "simexplorer.attachment"; - /** - * Field name for attachment - */ + + /** Field name for attachment. */ public static final String KEY_ATTACHMENT_FILENAME = "filename"; - /** - * Field name for attachment - */ + + /** Field name for attachment. */ public static final String KEY_ATTACHMENT_HASH = "hash"; - /** - * Field name for attachment - */ + + /** Field name for attachment. */ public static final String KEY_ATTACHMENT_TYPE = "type"; - /** - * Field name for id of parent data - */ + + /** Field name for id of parent data. */ public static final String KEY_PARENTDATA_UUID = "simexplorer.parentdata.uuid"; - /** - * Field name for version of parent data - */ + + /** Field name for version of parent data. */ public static final String KEY_PARENTDATA_VERSION = "simexplorer.parentdata.version"; - /** - * Field name for id of parent version - */ + + /** Field name for id of parent version. */ public static final String KEY_PARENTVERSION_UUID = "simexplorer.parentversion.uuid"; - /** - * Field name for version of parent version - */ + + /** Field name for version of parent version. */ public static final String KEY_PARENTVERSION_VERSION = "simexplorer.parentversion.version"; - /** - * Field name for searchable content - */ + + /** Field name for searchable content. */ public static final String KEY_SEARCHABLE_CONTENT = "simexplorer.searchablecontent"; - /** - * Field name for sorting - */ + + /** Field name for sorting. */ public static final String SORT_DATE_FIELD = KEY_CREATIONDATE; - /** - * No date sort - */ + + /** No date sort. */ public static final int SORT_DATE_NONE = 0; - /** - * Sort element by date (ascending) - */ + + /** Sort element by date (ascending). */ public static final int SORT_DATE_ASCENDING = 1; - /** - * Sort element by date (descending) - */ + + /** Sort element by date (descending). */ public static final int SORT_DATE_DESCENDING = -1; } Modified: trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabase.java =================================================================== --- trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabase.java 2008-02-04 14:46:14 UTC (rev 627) +++ trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabase.java 2008-02-04 14:47:21 UTC (rev 628) @@ -54,7 +54,6 @@ import org.apache.lucene.store.NoLockFactory; import fr.cemagref.simexplorer.is.attachment.Attachment; -import fr.cemagref.simexplorer.is.attachment.ContentType; import fr.cemagref.simexplorer.is.attachment.ContentTypeFactory; import fr.cemagref.simexplorer.is.entities.metadata.MetaData; import fr.cemagref.simexplorer.is.entities.metadata.Version; @@ -64,53 +63,49 @@ import fr.cemagref.simexplorer.is.storage.util.KeyValue; /** - * Lucene implementation + * Lucene implementation. * * @author landais - * */ public class LuceneDatabase extends Database { - /** - * DB folder - */ + /** DB folder. */ private static String dbFolder = Config.getProperties().getProperty( "simexplorer.db"); - /** - * Optimize period - */ + /** Optimize period. */ private static Integer optimizePeriod = new Integer(Config.getProperties() .getProperty("simexplorer.optimizeperiod")); - /** - * Lock factory for Lucene writer - */ + /** Lock factory for Lucene writer. */ private static LockFactory lockFactory = new NoLockFactory(); - /** - * Location of index - */ + + /** Location of index. */ private static Directory directory; - /** - * Index writer - */ + + /** Index writer. */ private static IndexWriter writer = null; - /** - * Pool of searcher - */ + + /** Pool of searcher. */ private static SearcherPool searcherPool = null; - /** - * Searcher that should be used for new queries - */ + + /** Searcher that should be used for new queries. */ private static Searcher cachedSearcher = null; - /** - * Date of latest optimization - */ + + /** Date of latest optimization. */ private static Date lastOptimize = new Date(); + /** The Constant searcherSynchronizer. */ private final static Object searcherSynchronizer = new Object(); + + /** The Constant writerSynchronizer. */ private final static Object writerSynchronizer = new Object(); + /** + * Gets the searcher pool. + * + * @return the searcher pool + */ private SearcherPool getSearcherPool() { if (searcherPool == null) { searcherPool = new SearcherPool(); @@ -119,10 +114,12 @@ } /** - * Retrieve searcher for a new query + * Retrieve searcher for a new query. * * @return Searcher + * * @throws IOException + * Signals that an I/O exception has occurred. */ private Searcher getSearcher() throws IOException { synchronized (searcherSynchronizer) { @@ -138,11 +135,13 @@ } /** - * Release searcher, after the end of a query execution + * Release searcher, after the end of a query execution. * * @param searcher * Searcher to be released + * * @throws IOException + * Signals that an I/O exception has occurred. */ private void releaseSearcher(Searcher searcher) throws IOException { synchronized (searcherSynchronizer) { @@ -151,9 +150,10 @@ } /** - * Called to invalidate reader + * Called to invalidate reader. * * @throws IOException + * Signals that an I/O exception has occurred. */ private void resetReader() throws IOException { synchronized (searcherSynchronizer) { @@ -166,6 +166,9 @@ } } + /* (non-Javadoc) + * @see fr.cemagref.simexplorer.is.storage.database.Database#open(boolean) + */ @Override public void open(boolean create) throws SimExplorerStorageException { if (writer == null) { @@ -201,6 +204,9 @@ } } + /* (non-Javadoc) + * @see fr.cemagref.simexplorer.is.storage.database.Database#close() + */ @Override public void close() throws SimExplorerStorageException { try { @@ -217,9 +223,10 @@ } /** - * Push commit to db + * Push commit to db. * * @throws IOException + * Signals that an I/O exception has occurred. */ private void synchedCommit() throws IOException { synchronized (writerSynchronizer) { @@ -239,6 +246,9 @@ resetReader(); } + /* (non-Javadoc) + * @see fr.cemagref.simexplorer.is.storage.database.Database#commit() + */ @Override public void commit() throws SimExplorerStorageException { try { @@ -249,6 +259,9 @@ } } + /* (non-Javadoc) + * @see fr.cemagref.simexplorer.is.storage.database.Database#insertElement(fr.cemagref.simexplorer.is.entities.metadata.MetaData, java.util.List) + */ @Override public void insertElement(MetaData element, List<Reader> readers) throws SimExplorerStorageException { @@ -274,6 +287,9 @@ } } + /* (non-Javadoc) + * @see fr.cemagref.simexplorer.is.storage.database.Database#getElement(java.lang.String, fr.cemagref.simexplorer.is.entities.metadata.Version) + */ @Override public MetaData getElement(String uuid, Version version) throws SimExplorerStorageException { @@ -300,12 +316,19 @@ } /** + * Gets the hits by id version. + * * @param uuid + * the uuid * @param version + * the version * @param searcher - * @return + * the searcher + * + * @return the hits by id version + * * @throws IOException - * @throws Exception + * Signals that an I/O exception has occurred. */ private Hits getHitsByIdVersion(String uuid, Version version, Searcher searcher) throws IOException { @@ -319,8 +342,12 @@ return hits; } + /* (non-Javadoc) + * @see fr.cemagref.simexplorer.is.storage.database.Database#getVersions(java.lang.String) + */ @Override - public List<Version> getVersions(String uuid) throws SimExplorerStorageException { + public List<Version> getVersions(String uuid) + throws SimExplorerStorageException { // Retrieve all document corresponding to id Map<String, String> properties = new HashMap<String, String>(); properties.put(KEY_UUID, uuid); @@ -352,6 +379,9 @@ return versions; } + /* (non-Javadoc) + * @see fr.cemagref.simexplorer.is.storage.database.Database#findElementsById(java.lang.String, boolean) + */ @Override public Set<MetaData> findElementsById(String uuid, boolean onlyLatest) throws SimExplorerStorageException { @@ -382,6 +412,9 @@ return result; } + /* (non-Javadoc) + * @see fr.cemagref.simexplorer.is.storage.database.Database#findElementsByPropertiesCount(java.util.Map) + */ @Override public int findElementsByPropertiesCount(Map<String, String> properties) throws SimExplorerStorageException { @@ -405,6 +438,9 @@ return result; } + /* (non-Javadoc) + * @see fr.cemagref.simexplorer.is.storage.database.Database#findElementsByProperties(java.util.Map, int, int, int) + */ @Override public Set<MetaData> findElementsByProperties( Map<String, String> properties, int start, int count, int dateOrder) @@ -429,6 +465,9 @@ return result; } + /* (non-Javadoc) + * @see fr.cemagref.simexplorer.is.storage.database.Database#findElementsByContentSearchCount(java.lang.String, boolean) + */ @Override public int findElementsByContentSearchCount(String queryText, boolean onlyLatest) throws SimExplorerStorageException { @@ -461,11 +500,12 @@ } /** - * Retrieve a Lucene Sort for date sorting + * Retrieve a Lucene Sort for date sorting. * * @param dateOrder * sort wanted SORT_DATE_NONE, SORT_DATE_DESCENDING, * SORT_DATE_ASCENDING, + * * @return null if no sort */ private Sort getSortDate(int dateOrder) { @@ -479,6 +519,9 @@ return sort; } + /* (non-Javadoc) + * @see fr.cemagref.simexplorer.is.storage.database.Database#findElementsByContentSearch(java.lang.String, boolean, int, int, int) + */ @Override public Set<MetaData> findElementsByContentSearch(String queryText, boolean onlyLatest, int start, int count, int dateOrder) @@ -512,14 +555,17 @@ } /** - * Retrieve a Lucene Query for a full text search + * Retrieve a Lucene Query for a full text search. * * @param queryText * String to match * @param onlyLatest * Latest flag + * * @return Query + * * @throws ParseException + * the parse exception */ private Query getQueryByContentSearch(String queryText, boolean onlyLatest) throws ParseException { @@ -547,6 +593,9 @@ return query; } + /* (non-Javadoc) + * @see fr.cemagref.simexplorer.is.storage.database.Database#deleteElement(java.lang.String, fr.cemagref.simexplorer.is.entities.metadata.Version) + */ @Override public void deleteElement(String uuid, Version version) throws SimExplorerStorageException { @@ -565,13 +614,19 @@ } /** - * Find all documents matching properties + * Find all documents matching properties. * * @param properties * criteria + * @param searcher + * the searcher + * @param dateOrder + * the date order + * * @return Documents and search handle + * * @throws IOException - * @throws Exception + * Signals that an I/O exception has occurred. */ private Hits findHits(Map<String, String> properties, Searcher searcher, int dateOrder) throws IOException { @@ -587,7 +642,7 @@ } /** - * Convert Lucene documents to real entities + * Convert Lucene documents to real entities. * * @param hits * Document collection @@ -595,8 +650,11 @@ * Index of first document to return * @param count * Number of documents to return + * * @return Entities list + * * @throws Exception + * the exception */ private Set<MetaData> convertHitsToElements(Hits hits, int start, int count) throws Exception { @@ -614,14 +672,17 @@ } /** - * Transform a Lucene document into a LoggableElement thanks to a factory + * Transform a Lucene document into a LoggableElement thanks to a factory. * * @param document * The document to transform + * * @return Instance of element + * * @throws Exception + * the exception */ - @SuppressWarnings({"unchecked"}) + @SuppressWarnings( { "unchecked" }) private MetaData loadLuceneElement(Document document) throws Exception { MetaData element = new MetaData(); @@ -691,7 +752,8 @@ attachment.setFileName(fieldValue); } if (field.equals(KEY_ATTACHMENT_HASH)) { - attachment.setDataHash(Attachment.intFromHexString("0X" + fieldValue)); + attachment.setDataHash(Attachment.intFromHexString("0X" + + fieldValue)); } if (field.equals(KEY_ATTACHMENT_TYPE)) { attachment.setContentType(ContentTypeFactory @@ -725,7 +787,7 @@ } /** - * Add a field to a document + * Add a field to a document. * * @param document * Document to add the field @@ -744,12 +806,14 @@ } /** - * Transform an element to a Lucene document thanks to a factory + * Transform an element to a Lucene document thanks to a factory. * * @param readers + * the readers * @param element - * @return - * @throws Exception + * the element + * + * @return the document */ private Document saveLuceneElement(MetaData element, List<Reader> readers) { Document document = new Document(); Modified: trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/lucene/SearcherPool.java =================================================================== --- trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/lucene/SearcherPool.java 2008-02-04 14:46:14 UTC (rev 627) +++ trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/lucene/SearcherPool.java 2008-02-04 14:47:21 UTC (rev 628) @@ -26,38 +26,34 @@ /** * Pool of searchers, being randomly accessed<br> - * Manage life cycle of searchers + * Manage life cycle of searchers. * * @author landais - * */ public class SearcherPool { /** - * Searcher record + * Searcher record. * * @author landais - * */ - private class SearcherInfo { - /** - * Numbre of queries using this searcher - */ + public class SearcherInfo { + + /** Numbre of queries using this searcher. */ public int count = 0; + /** * If marked, searcher is not valid anymore<br> - * It should be closed upon last query ended + * It should be closed upon last query ended. */ public boolean marked = false; } - /** - * Searchers used by database - */ + /** Searchers used by database. */ Map<Searcher, SearcherInfo> searchers = new HashMap<Searcher, SearcherInfo>(); /** - * Called when a searcher will be used for a query + * Called when a searcher will be used for a query. * * @param searcher * Searcher used @@ -79,13 +75,15 @@ } /** - * Check if searcher should be closed + * Check if searcher should be closed. * * @param searcher * Searcher aiming to be closed * @param searcherInfo * Searcher info related + * * @throws IOException + * Signals that an I/O exception has occurred. */ private void checkClose(Searcher searcher, SearcherInfo searcherInfo) throws IOException { @@ -99,12 +97,13 @@ } /** - * Release a searcher from a query + * Release a searcher from a query. * * @param searcher * Searcher released * * @throws IOException + * Signals that an I/O exception has occurred. */ public void release(Searcher searcher) throws IOException { // Retrieve searcher info @@ -116,10 +115,13 @@ } /** - * Mark searcher as being invalid anymore + * Mark searcher as being invalid anymore. * * @param searcher + * the searcher + * * @throws IOException + * Signals that an I/O exception has occurred. */ public void mark(Searcher searcher) throws IOException { // Retrieve searcher @@ -131,7 +133,7 @@ } /** - * Check if any reader is opened + * Check if any reader is opened. * * @return true if no reader is open */ Modified: trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngine.java =================================================================== --- trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngine.java 2008-02-04 14:46:14 UTC (rev 627) +++ trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngine.java 2008-02-04 14:47:21 UTC (rev 628) @@ -28,199 +28,292 @@ import fr.cemagref.simexplorer.is.entities.metadata.Version; import fr.cemagref.simexplorer.is.storage.SimExplorerStorageException; +/** + * The Interface StorageEngine. + */ @Local public interface StorageEngine { /** - * Open storage + * Open storage. * - * @throws Exception + * @throws SimExplorerStorageException + * the sim explorer storage exception */ public abstract void open() throws SimExplorerStorageException; /** - * Close storage + * Close storage. * - * @throws Exception + * @throws SimExplorerStorageException + * the sim explorer storage exception */ public abstract void close() throws SimExplorerStorageException; /** - * Commit changes to storage + * Commit changes to storage. * - * @throws Exception + * @throws SimExplorerStorageException + * the sim explorer storage exception */ public abstract void commit() throws SimExplorerStorageException; /** - * Save an element to storage + * Save an element to storage. * * @param element * Element to save * @param attachments * Attachments related - * @throws Exception + * @param token + * the token + * + * @throws SimExplorerStorageException + * the sim explorer storage exception */ public abstract void saveElement(String token, MetaData element, - Map<String, InputStream> attachments) throws SimExplorerStorageException; + Map<String, InputStream> attachments) + throws SimExplorerStorageException; /** - * Retrieve an element + * Retrieve an element. * * @param uuid * Id of the element + * @param token + * the token + * * @return The element - * @throws Exception + * + * @throws SimExplorerStorageException + * the sim explorer storage exception */ public abstract MetaData getMetadata(String token, String uuid) throws SimExplorerStorageException; /** * Retrieve versions of an element<br> - * Empty list if no element with this id + * Empty list if no element with this id. * * @param uuid * Id of the element + * @param token + * the token + * * @return List of versions of the element<br> * - * @throws Exception + * @throws SimExplorerStorageException + * the sim explorer storage exception */ public abstract List<Version> getVersions(String token, String uuid) throws SimExplorerStorageException; /** - * Retrieve all version of a metadata + * Retrieve all version of a metadata. * * @param token + * the token * @param uuid - * @return + * the uuid + * + * @return the element versions + * + * @throws SimExplorerStorageException + * the sim explorer storage exception */ - public abstract Set<MetaData> getElementVersions(String token, - String uuid) throws SimExplorerStorageException; + public abstract Set<MetaData> getElementVersions(String token, String uuid) + throws SimExplorerStorageException; /** - * Retrieve an element in a specific version + * Retrieve an element in a specific version. * * @param uuid + * the uuid * @param version - * @return - * @throws Exception + * the version + * @param token + * the token + * + * @return the metadata + * + * @throws SimExplorerStorageException + * the sim explorer storage exception */ public abstract MetaData getMetadata(String token, String uuid, Version version) throws SimExplorerStorageException; /** - * Get data associated to an element + * Get data associated to an element. * * @param entity * Element related * @param field * Data field + * @param token + * the token + * * @return Data stream - * @throws Exception + * + * @throws SimExplorerStorageException + * the sim explorer storage exception */ - public abstract InputStream retrieveData(String token, - MetaData entity, String field) throws SimExplorerStorageException; + public abstract InputStream retrieveData(String token, MetaData entity, + String field) throws SimExplorerStorageException; /** - * Get number of items corresponding to query + * Get number of items corresponding to query. * * @param query + * the query * @param onlyLatest - * @return - * @throws Exception + * the only latest + * @param token + * the token + * + * @return the int + * + * @throws SimExplorerStorageException + * the sim explorer storage exception */ public abstract int findFullTextCount(String token, String query, boolean onlyLatest) throws SimExplorerStorageException; /** - * Retrieve list of items corresponding to query + * Retrieve list of items corresponding to query. * * @param query + * the query * @param onlyLatest + * the only latest * @param indexStart + * the index start * @param count + * the count * @param dateOrder - * @return - * @throws Exception + * the date order + * @param token + * the token + * + * @return the meta data[] + * + * @throws SimExplorerStorageException + * the sim explorer storage exception */ public abstract MetaData[] findFullText(String token, String query, boolean onlyLatest, int indexStart, int count, int dateOrder) throws SimExplorerStorageException; /** - * Retrieve list of items of type wanted + * Retrieve list of items of type wanted. * * @param type + * the type * @param onlyLatest + * the only latest * @param start + * the start * @param count + * the count * @param dateOrder - * @return - * @throws Exception + * the date order + * @param token + * the token + * + * @return the meta data[] + * + * @throws SimExplorerStorageException + * the sim explorer storage exception */ - public abstract MetaData[] findElementsByType(String token, - String type, boolean onlyLatest, int start, int count, int dateOrder) + public abstract MetaData[] findElementsByType(String token, String type, + boolean onlyLatest, int start, int count, int dateOrder) throws SimExplorerStorageException; /** - * Retrieve number of items of type wanted + * Retrieve number of items of type wanted. * * @param type + * the type * @param onlyLatest - * @return - * @throws Exception + * the only latest + * @param token + * the token + * + * @return the int + * + * @throws SimExplorerStorageException + * the sim explorer storage exception */ public abstract int findElementsByTypeCount(String token, String type, boolean onlyLatest) throws SimExplorerStorageException; /** - * Delete elements + * Delete elements. * * @param uuid - * @throws Exception + * the uuid + * @param token + * the token + * + * @throws SimExplorerStorageException + * the sim explorer storage exception */ public abstract void deleteElements(String token, String uuid) throws SimExplorerStorageException; /** - * Delete one element + * Delete one element. * * @param uuid + * the uuid * @param version - * @throws Exception + * the version + * @param token + * the token + * + * @throws SimExplorerStorageException + * the sim explorer storage exception */ public abstract void deleteElement(String token, String uuid, Version version) throws SimExplorerStorageException; /** - * Store temporary data, for stream duplication + * Store temporary data, for stream duplication. * * @param stream * Stream to store + * * @return id for retrieval - * @throws Exception + * + * @throws SimExplorerStorageException + * the sim explorer storage exception */ public abstract String storeTempData(InputStream stream) throws SimExplorerStorageException; /** - * Retrieve temporary data + * Retrieve temporary data. * * @param id * Id associated + * * @return Data stream - * @throws Exception + * + * @throws SimExplorerStorageException + * the sim explorer storage exception */ public abstract InputStream retrieveTempData(String id) throws SimExplorerStorageException; /** - * Delete temporary data + * Delete temporary data. * * @param id - * @throws Exception + * the id + * + * @throws SimExplorerStorageException + * the sim explorer storage exception */ - public abstract void deleteTempData(String id) throws SimExplorerStorageException; + public abstract void deleteTempData(String id) + throws SimExplorerStorageException; } \ No newline at end of file Modified: trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngineImpl.java =================================================================== --- trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngineImpl.java 2008-02-04 14:46:14 UTC (rev 627) +++ trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngineImpl.java 2008-02-04 14:47:21 UTC (rev 628) @@ -27,7 +27,6 @@ import java.util.UUID; import fr.cemagref.simexplorer.is.attachment.Attachment; -import fr.cemagref.simexplorer.is.attachment.ContentType; import fr.cemagref.simexplorer.is.entities.metadata.MetaData; import fr.cemagref.simexplorer.is.entities.metadata.Version; import fr.cemagref.simexplorer.is.storage.SimExplorerStorageException; @@ -37,32 +36,26 @@ import fr.cemagref.simexplorer.is.storage.database.lucene.LuceneDatabase; /** - * Handle data storage and indexing + * Handle data storage and indexing. * * @author landais - * */ public class StorageEngineImpl implements StorageEngine { - /** - * Indexing - */ + /** Indexing. */ protected Database database; - /** - * Storage - */ + /** Storage. */ protected AttachmentHandler attachmentHandler; - /** - * Metadata handling temporary data - */ + /** Metadata handling temporary data. */ private MetaData mdTmp; + /** The opened. */ private boolean opened = false; /** - * Default constructor with default implementations of storage and indexing + * Default constructor with default implementations of storage and indexing. */ public StorageEngineImpl() { super(); @@ -106,7 +99,8 @@ * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngine#saveElement(fr.cemagref.simexplorer.is.entities.metadata.MetaData, java.util.Map) */ public void saveElement(String token, MetaData element, - Map<String, InputStream> attachments) throws SimExplorerStorageException { + Map<String, InputStream> attachments) + throws SimExplorerStorageException { // Save all attachments in system for (Map.Entry<String, InputStream> entry : attachments.entrySet()) { @@ -149,6 +143,16 @@ database.insertElement(element, readers); } + /** + * Find attachment. + * + * @param uniqueId + * the unique id + * @param attachments + * the attachments + * + * @return the attachment + */ private Attachment findAttachment(String uniqueId, List<Attachment> attachments) { for (Attachment attachment : attachments) { @@ -270,7 +274,8 @@ /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngine#storeTempData(java.io.InputStream) */ - public String storeTempData(InputStream stream) throws SimExplorerStorageException { + public String storeTempData(InputStream stream) + throws SimExplorerStorageException { String id = UUID.randomUUID().toString(); attachmentHandler.storeData(mdTmp, id, stream); return id; @@ -279,7 +284,8 @@ /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngine#retrieveTempData(java.lang.String) */ - public InputStream retrieveTempData(String id) throws SimExplorerStorageException { + public InputStream retrieveTempData(String id) + throws SimExplorerStorageException { InputStream is = attachmentHandler.retrieveData(mdTmp, id); return is; } @@ -291,6 +297,9 @@ attachmentHandler.deleteData(mdTmp, id); } + /* (non-Javadoc) + * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngine#getElementVersions(java.lang.String, java.lang.String) + */ public Set<MetaData> getElementVersions(String token, String uuid) throws SimExplorerStorageException { return database.findElementsById(uuid, false); Modified: trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/util/Config.java =================================================================== --- trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/util/Config.java 2008-02-04 14:46:14 UTC (rev 627) +++ trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/util/Config.java 2008-02-04 14:47:21 UTC (rev 628) @@ -24,15 +24,28 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +/** + * The Class Config. + */ public class Config { + /** The Constant log. */ private static final Log log = LogFactory.getLog(Config.class); + /** The properties. */ private static Properties properties = null; + + /** The properties location. */ private static String propertiesLocation = "/properties/config.properties"; + /** + * Inits the properties. + * + * @throws IOException + * Signals that an I/O exception has occurred. + */ private static void initProperties() throws IOException { - log.info("Loading properties "+propertiesLocation); + log.info("Loading properties " + propertiesLocation); properties = new Properties(); @@ -46,6 +59,11 @@ } } + /** + * Gets the properties. + * + * @return the properties + */ public static Properties getProperties() { if (properties == null) { try { @@ -59,10 +77,22 @@ return properties; } + /** + * Sets the properties. + * + * @param properties + * the new properties + */ public static void setProperties(Properties properties) { Config.properties = properties; } + /** + * Sets the properties location. + * + * @param propertiesLocation + * the new properties location + */ public static void setPropertiesLocation(String propertiesLocation) { Config.propertiesLocation = propertiesLocation; setProperties(null); Modified: trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/util/KeyValue.java =================================================================== --- trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/util/KeyValue.java 2008-02-04 14:46:14 UTC (rev 627) +++ trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/util/KeyValue.java 2008-02-04 14:47:21 UTC (rev 628) @@ -17,24 +17,51 @@ * ##% */ package fr.cemagref.simexplorer.is.storage.util; +/** + * The Class KeyValue. + */ public class KeyValue { + /** The key. */ private String key; + /** The value. */ private String value; + /** + * Gets the key. + * + * @return the key + */ public String getKey() { return key; } + /** + * Sets the key. + * + * @param key + * the new key + */ public void setKey(String key) { this.key = key; } + /** + * Gets the value. + * + * @return the value + */ public String getValue() { return value; } + /** + * Sets the value. + * + * @param value + * the new value + */ public void setValue(String value) { this.value = value; } Modified: trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/util/ZipStreamEncoder.java =================================================================== --- trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/util/ZipStreamEncoder.java 2008-02-04 14:46:14 UTC (rev 627) +++ trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/util/ZipStreamEncoder.java 2008-02-04 14:47:21 UTC (rev 628) @@ -25,15 +25,31 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; +/** + * The Class ZipStreamEncoder. + */ public class ZipStreamEncoder extends Thread { + /** The Constant BUFFER. */ static final int BUFFER = 2048; + /** The files. */ private Map<String, InputStream> files; + + /** The os. */ private PipedOutputStream os; + /** The zos. */ private ZipOutputStream zos; + /** + * Instantiates a new zip stream encoder. + * + * @param files + * the files + * @param os + * the os + */ public ZipStreamEncoder(Map<String, InputStream> files, PipedOutputStream os) { super(); this.files = files; @@ -44,6 +60,10 @@ zos.setLevel(Deflater.BEST_COMPRESSION); } + /* (non-Javadoc) + * @see java.lang.Thread#run() + */ + @Override public void run() { byte data[] = new byte[BUFFER]; try { Modified: trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/VersionGeneratorTest.java =================================================================== --- trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/VersionGeneratorTest.java 2008-02-04 14:46:14 UTC (rev 627) +++ trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/VersionGeneratorTest.java 2008-02-04 14:47:21 UTC (rev 628) @@ -22,36 +22,65 @@ /** * VersionGenerator Tester. - * + * * @author chemit * @version 1.0 - * @since <pre>02/02/2008</pre> + * @since + * + * <pre> + * 02 / 02 / 2008 + * </pre> */ public class VersionGeneratorTest extends TestCase { + /** The generator. */ VersionGenerator generator; + /** + * Instantiates a new version generator test. + * + * @param name + * the name + */ public VersionGeneratorTest(String name) { super(name); } + /* (non-Javadoc) + * @see junit.framework.TestCase#setUp() + */ @Override public void setUp() throws Exception { super.setUp(); generator = VersionGenerator.getInstance(); } + /* (non-Javadoc) + * @see junit.framework.TestCase#tearDown() + */ @Override public void tearDown() throws Exception { super.tearDown(); generator = null; } + /** + * Test generate version. + * + * @throws Exception + * the exception + */ public void testGenerateVersion() throws Exception { Version version = generator.generateVersion(); assertTrue(version.getLength() < VersionGenerator.MAX_SIZE); } + /** + * Test generate versions. + * + * @throws Exception + * the exception + */ public void testGenerateVersions() throws Exception { Version[] version = generator.generateVersions(); assertTrue(version.length < VersionGenerator.MAX_NB_VERSIONS); Modified: trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseLoadMassTestCase.java =================================================================== --- trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseLoadMassTestCase.java 2008-02-04 14:46:14 UTC (rev 627) +++ trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseLoadMassTestCase.java 2008-02-04 14:47:21 UTC (rev 628) @@ -31,18 +31,40 @@ import fr.cemagref.simexplorer.is.storage.MetaDataGenerator; import fr.cemagref.simexplorer.is.storage.util.Config; +/** + * The Class LuceneDatabaseLoadMassTestCase. + */ public class LuceneDatabaseLoadMassTestCase extends TestCase { + /** The database. */ private Database database; + + /** The r. */ private Random r = new Random(); + + /** The mdg. */ private MetaDataGenerator mdg = new MetaDataGenerator(); + /** The strings init. */ private static boolean stringsInit = false; + + /** The cs. */ private static int cs; + + /** The randomstrings. */ private static String[] randomstrings; + /** The valid chars. */ private static String validChars = "abcdefghijklmnopqrstuvwxyz"; + /** + * Generate string. + * + * @param length + * the length + * + * @return the string + */ private String generateString(int length) { StringBuffer result = new StringBuffer(); @@ -54,6 +76,9 @@ return result.toString(); } + /** + * Initialize strings. + */ private void initializeStrings() { if (!stringsInit) { @@ -72,11 +97,20 @@ initializeStrings(); } */ + /** + * Instantiates a new lucene database load mass test case. + * + * @param name + * the name + */ public LuceneDatabaseLoadMassTestCase(String name) { super(name); initializeStrings(); } + /* (non-Javadoc) + * @see junit.framework.TestCase#setUp() + */ @Override protected void setUp() throws Exception { super.setUp(); @@ -85,12 +119,21 @@ // database.open(); } + /* (non-Javadoc) + * @see junit.framework.TestCase#tearDown() + */ @Override protected void tearDown() throws Exception { super.tearDown(); database.close(); } + /** + * Test mass insert. + * + * @throws Exception + * the exception + */ public void testMassInsert() throws Exception { database.open(true); @@ -149,6 +192,12 @@ System.out.println("Content size : " + contentSize); } + /** + * Test mass search paginated. + * + * @throws Exception + * the exception + */ public void testMassSearchPaginated() throws Exception { database.open(); @@ -165,8 +214,8 @@ int start = count / 2; int length = Math.min(200, Math.min(count, Math.max(1, count / 4))); - Set<MetaData> metaDatas = database - .findElementsByContentSearch(key, false, start, length, 1); + Set<MetaData> metaDatas = database.findElementsByContentSearch(key, + false, start, length, 1); System.out.println(key + " (" + start + " " + length + ") : " + metaDatas.size()); Modified: trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseTestCase.java =================================================================== --- trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseTestCase.java 2008-02-04 14:46:14 UTC (rev 627) +++ trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseTestCase.java 2008-02-04 14:47:21 UTC (rev 628) @@ -35,14 +35,27 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +/** + * The Class LuceneDatabaseTestCase. + */ public class LuceneDatabaseTestCase extends TestCase { - private static final Log log = LogFactory.getLog(LuceneDatabaseTestCase.class); + /** The Constant log. */ + private static final Log log = LogFactory + .getLog(LuceneDatabaseTestCase.class); + + /** The database. */ private Database database; // private ElementGenerator elementGenerator; + /** The mdg. */ private MetaDataGenerator mdg = new MetaDataGenerator(); + + /** The r. */ private Random r = new Random(); + /* (non-Javadoc) + * @see junit.framework.TestCase#setUp() + */ @Override protected void setUp() throws Exception { super.setUp(); @@ -52,12 +65,21 @@ // elementGenerator = new ElementGenerator(); } + /* (non-Javadoc) + * @see junit.framework.TestCase#tearDown() + */ @Override protected void tearDown() throws Exception { super.tearDown(); database.close(); } + /** + * Test insert element get element. + * + * @throws Exception + * the exception + */ public void testInsertElementGetElement() throws Exception { MetaData me = mdg.generateMetaDataEntity(); database.insertElement(me, new ArrayList<Reader>()); @@ -68,6 +90,12 @@ database.commit(); } + /** + * Test index add find elements by content search. + * + * @throws Exception + * the exception + */ public void testIndexAddFindElementsByContentSearch() throws Exception { MetaData me = mdg.generateMetaDataEntity(); @@ -88,6 +116,12 @@ assertEquals(1, mesCount); } + /** + * Test get versions. + * + * @throws Exception + * the exception + */ public void testGetVersions() throws Exception { MetaData[] mes = mdg.generateVersionnedMetaDataEntity(); for (MetaData me : mes) { @@ -100,10 +134,16 @@ Collections.sort(versions); for (int i = 0; i < mes.length; i++) { MetaData me = mes[i]; - assertEquals(me.getVersion(),versions.get(i)); + assertEquals(me.getVersion(), versions.get(i)); } } + /** + * Test find elements by id. + * + * @throws Exception + * the exception + */ public void testFindElementsById() throws Exception { MetaData[] mes = mdg.generateVersionnedMetaDataEntity(); for (MetaData me : mes) { @@ -111,11 +151,17 @@ } database.commit(); - Set<MetaData> elements = database.findElementsById(mes[0] - .getUuid(), false); + Set<MetaData> elements = database.findElementsById(mes[0].getUuid(), + false); assertEquals(elements.size(), mes.length); } + /** + * Test find elements by properties. + * + * @throws Exception + * the exception + */ public void testFindElementsByProperties() throws Exception { MetaData me = mdg.generateMetaDataEntity(); @@ -123,18 +169,30 @@ database.commit(); } + /** + * Test delete elements. + */ public void testDeleteElements() { log.warn("Not yet implemented"); } + /** + * Test delete element string version. + */ public void testDeleteElementStringVersion() { log.warn("Not yet implemented"); } + /** + * Test get element latest version. + */ public void testGetElementLatestVersion() { log.warn("Not yet implemented"); } + /** + * Test delete element meta data entity. + */ public void testDeleteElementMetaDataEntity() { log.warn("Not yet implemented"); } Modified: trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseThread.java =================================================================== --- trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseThread.java 2008-02-04 14:46:14 UTC (rev 627) +++ trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseThread.java 2008-02-04 14:47:21 UTC (rev 628) @@ -26,14 +26,23 @@ import fr.cemagref.simexplorer.is.storage.database.Database; import fr.cemagref.simexplorer.is.storage.MetaDataGenerator; +/** + * The Class LuceneDatabaseThread. + */ public class LuceneDatabaseThread extends Thread { + /** The database. */ private Database database; + + /** The id thread lucene. */ private int idThreadLucene; + /** The mdg. */ private MetaDataGenerator mdg = new MetaDataGenerator(); /** + * Gets the database. + * * @return the database */ public Database getDatabase() { @@ -41,6 +50,8 @@ } /** + * Sets the database. + * * @param database * the database to set */ @@ -48,6 +59,9 @@ this.database = database; } + /* (non-Javadoc) + * @see java.lang.Thread#run() + */ @Override public void run() { int npass = 10; @@ -70,6 +84,15 @@ } + /** + * Search elements. + * + * @param id + * the id + * + * @throws Exception + * the exception + */ private void searchElements(String id) throws Exception { Set<MetaData> mde = database.findElementsById(id, true); if (mde.isEmpty()) { @@ -77,6 +100,17 @@ } } + /** + * Insert elements. + * + * @param ipass + * the ipass + * + * @return the string + * + * @throws Exception + * the exception + */ private String insertElements(int ipass) throws Exception { String id = null; @@ -97,6 +131,8 @@ } /** + * Gets the id thread lucene. + * * @return the idThreadLucene */ public int getIdThreadLucene() { @@ -104,6 +140,8 @@ } /** + * Sets the id thread lucene. + * * @param idThreadLucene * the idThreadLucene to set */ Modified: trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseThreadsMassTestCase.java =================================================================== --- trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseThreadsMassTestCase.java 2008-02-04 14:46:14 UTC (rev 627) +++ trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseThreadsMassTestCase.java 2008-02-04 14:47:21 UTC (rev 628) @@ -21,10 +21,17 @@ import fr.cemagref.simexplorer.is.storage.util.Config; import junit.framework.TestCase; +/** + * The Class LuceneDatabaseThreadsMassTestCase. + */ public class LuceneDatabaseThreadsMassTestCase extends TestCase { + /** The database. */ private Database database; + /* (non-Javadoc) + * @see junit.framework.TestCase#setUp() + */ @Override protected void setUp() throws Exception { super.setUp(); @@ -33,12 +40,21 @@ database.open(true); } + /* (non-Javadoc) + * @see junit.framework.TestCase#tearDown() + */ @Override protected void tearDown() throws Exception { super.tearDown(); database.close(); } + /** + * Test lucene database threads. + * + * @throws Exception + * the exception + */ public void testLuceneDatabaseThreads() throws Exception { int nthreads = 5; Modified: trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneSimpleTest.java =================================================================== --- trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneSimpleTest.java 2008-02-04 14:46:14 UTC (rev 627) +++ trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneSimpleTest.java 2008-02-04 14:47:21 UTC (rev 628) @@ -34,6 +34,9 @@ import java.io.File; +/** + * The Class LuceneSimpleTest. + */ public class LuceneSimpleTest extends TestCase { /* @@ -46,12 +49,16 @@ * hits.doc(i); System.out.println(doc.get("simexplorer.creationdate")); } * System.out.println(hits.length()); } */ - String indexDir="/tmp/indextest/"; + /** The index dir. */ + String indexDir = "/tmp/indextest/"; + /* (non-Javadoc) + * @see junit.framework.TestCase#tearDown() + */ @Override protected void tearDown() throws Exception { super.tearDown(); - if (indexDir!=null) { + if (indexDir != null) { File dir = new File(indexDir); File[] files = dir.listFiles(); for (File file : files) { @@ -61,6 +68,12 @@ } } + /** + * Test lucene simple. + * + * @throws Exception + * the exception + */ public void testLuceneSimple() throws Exception { IndexWriter writer;