Author: echatellier Date: 2010-06-02 14:50:50 +0200 (Wed, 02 Jun 2010) New Revision: 80 Url: http://nuiton.org/repositories/revision/wikitty/80 Log: Quick update javadoc, type fix, visibility changes... Removed: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyDAO.java Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/BusinessEntity.java trunk/wikitty-api/src/main/java/org/nuiton/wikitty/Criteria.java trunk/wikitty-api/src/main/java/org/nuiton/wikitty/ExtensionFactory.java trunk/wikitty-api/src/main/java/org/nuiton/wikitty/FacetTopic.java trunk/wikitty-api/src/main/java/org/nuiton/wikitty/FieldFactory.java trunk/wikitty-api/src/main/java/org/nuiton/wikitty/FieldType.java trunk/wikitty-api/src/main/java/org/nuiton/wikitty/JGroupsCacheNotifier.java trunk/wikitty-api/src/main/java/org/nuiton/wikitty/PagedResult.java trunk/wikitty-api/src/main/java/org/nuiton/wikitty/Wikitty.java trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyException.java trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyExtension.java trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyExtensionMigration.java trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyExtensionMigrationRename.java trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyExtensionStorage.java trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyImportExportService.java trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyProxy.java trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittySearchEngin.java trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyServiceImpl.java trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyServiceInMemory.java trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyStorage.java trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyTransaction.java trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/BusinessEntity.java =================================================================== --- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/BusinessEntity.java 2010-06-02 12:14:24 UTC (rev 79) +++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/BusinessEntity.java 2010-06-02 12:50:50 UTC (rev 80) @@ -33,80 +33,98 @@ // FIXME poussin 20100528 voir si cette interface est reellement necessaire. On pourra renommer BusinessEntityWikitty en BusinessEntity public interface BusinessEntity extends Serializable, Cloneable { + /** + * Return wikitty id (uuid). + * + * @return wikitty id + */ public String getWikittyId(); + + /** + * Return wikitty version (x.y). + * + * @return wikitty version + */ public String getWikittyVersion(); + /** - * Only framework can use this method - * @param version + * Only framework can use this method. + * + * @param version version to set */ public void setWikittyVersion(String version); /** - * Return list of all extension for this object - * @return + * Return list of all extension for this object. + * + * @return extension names */ public Collection<String> getExtensionNames(); /** - * Return list of all field for this object - * @param ext - * @return + * Return list of all field for this object. + * + * @param ext extension to get fields + * @return fields collections */ public Collection<String> getExtensionFields(String ext); /** - * Return field value for the specifique extension and field - * @param ext - * @param fieldName - * @return + * Return field value for the specific extension and field. + * + * @param ext extension + * @param fieldName field name + * @return field value */ public Object getField(String ext, String fieldName); /** - * set field value for the specifique extension and field. + * Set field value for the specific extension and field. + * * This method don't check the type of value for this field. - * @param ext - * @param fieldName - * @param value - * @return + * + * @param ext extension + * @param fieldName field name + * @param value value to set */ public void setField(String ext, String fieldName, Object value); /** - * Return the field type - * @param ext - * @param fieldName - * @return + * Return the field type. + * + * @param ext extension + * @param fieldName field name + * @return feild type */ public FieldType getFieldType(String ext, String fieldName); /** - * Ajoute un listener gloable + * Add {@link PropertyChangeListener}. * - * @param listener le listener à ajouter + * @param listener listener to add */ void addPropertyChangeListener(PropertyChangeListener listener); /** - * Supprime un listener globable. + * Remove {@link PropertyChangeListener}. * - * @param listener le listener à supprimer + * @param listener listener to remove */ void removePropertyChangeListener(PropertyChangeListener listener); /** - * Ajoute un listener sur la propriété {@code propertyName} + * Add {@link PropertyChangeListener} on {@code propertyName}. * - * @param propertyName le nom de la propriété - * @param listener le listener à ajouter + * @param propertyName property name + * @param listener listener to add */ void addPropertyChangeListener(String propertyName, PropertyChangeListener listener); /** - * Supprime un listener sur la propriété {@code propertyName} + * Remove {@link PropertyChangeListener} on {@code propertyName} * - * @param propertyName le nom de la propriété - * @param listener le listener à supprimer + * @param propertyName property name + * @param listener listener listener to remove */ void removePropertyChangeListener(String propertyName, PropertyChangeListener listener); Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/Criteria.java =================================================================== --- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/Criteria.java 2010-06-02 12:14:24 UTC (rev 79) +++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/Criteria.java 2010-06-02 12:50:50 UTC (rev 80) @@ -28,8 +28,6 @@ import java.util.Arrays; import java.util.List; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.nuiton.wikitty.search.Restriction; /** @@ -52,63 +50,63 @@ /** serialVersionUID. */ private static final long serialVersionUID = 2590223960861630283L; - /** to use log facility, just put in your code: log.info(\"...\"); */ - static private Log log = LogFactory.getLog(Criteria.class); + /** Use to not limit result. */ + static final public int ALL_ELEMENTS = -1; - /** Use to not limit result */ - static public int ALL_ELEMENTS = -1; + /** Search on all extension. */ + static final public String ALL_EXTENSIONS = "*"; - /** Search on all extension */ - static public String ALL_EXTENSIONS = "*"; + /** Search on all values. */ + static final public String ALL_VALUES = "*"; - /** Search on all values */ - static public String ALL_VALUES = "*"; + /** Separator between extension name, field name and type. */ + static final public String SEPARATOR = "."; - /** Separator between extension name, field name and type */ - static public String SEPARATOR = "."; - /** * Criteria can have name this help for presentation and is very - * useful for facet created by criteria + * useful for facet created by criteria. */ protected String name; - /** All restriction on fields */ - private Restriction restriction; + /** All restriction on fields. */ + protected Restriction restriction; - /** First index to get result */ - private int firstIndex = 0; - /** Last index to get result */ - private int endIndex = ALL_ELEMENTS; + /** First index to get result. */ + protected int firstIndex = 0; + /** Last index to get result. */ + protected int endIndex = ALL_ELEMENTS; - /** Facet on criteria */ - private List<Criteria> facetCriteria; - /** Facet on field */ - private List<String> facetField; + /** Facet on criteria. */ + protected List<Criteria> facetCriteria; + /** Facet on field. */ + protected List<String> facetField; - /** Sort ascending on fields */ - private List<String> sortAscending; - /** Sort descending on fields */ - private List<String> sortDescending; + /** Sort ascending on fields. */ + protected List<String> sortAscending; + /** Sort descending on fields. */ + protected List<String> sortDescending; /** - * Default constuctor + * Default constructor. */ public Criteria() { } /** - * Create named criteria - * @param name + * Create named criteria. + * + * @param name criteria name */ public Criteria(String name) { + this(); this.name = name; } /** - * Deserialize xml to criteria - * @param xml - * @return criteria + * Deserialize xml to criteria. + * + * @param xml xml to deserialize + * @return criteria criteria */ public static Criteria fromXML(String xml) { InputStream inputStream = new ByteArrayInputStream(xml.getBytes()); @@ -118,8 +116,9 @@ } /** - * Serialize criteria to xml - * @param criteria + * Serialize criteria to xml. + * + * @param criteria criteria to serialize * @return xml string */ public static String toXML(Criteria criteria) { Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/ExtensionFactory.java =================================================================== --- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/ExtensionFactory.java 2010-06-02 12:14:24 UTC (rev 79) +++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/ExtensionFactory.java 2010-06-02 12:50:50 UTC (rev 80) @@ -6,13 +6,13 @@ public class ExtensionFactory { - private String name; - private String version; - private String requiredExtension; + protected String name; + protected String version; + protected String requiredExtension; - private LinkedHashMap<String, FieldType> fields; + protected LinkedHashMap<String, FieldType> fields; - private ExtensionFactory(String name, String version) { + protected ExtensionFactory(String name, String version) { this.name = name; this.version = version; this.fields = new LinkedHashMap<String, FieldType>(); Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/FacetTopic.java =================================================================== --- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/FacetTopic.java 2010-06-02 12:14:24 UTC (rev 79) +++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/FacetTopic.java 2010-06-02 12:50:50 UTC (rev 80) @@ -17,10 +17,7 @@ package org.nuiton.wikitty; - import java.io.Serializable; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; /** * @@ -32,13 +29,13 @@ */ public class FacetTopic implements Serializable { - /** to use log facility, just put in your code: log.info(\"...\"); */ - static private Log log = LogFactory.getLog(FacetTopic.class); + /** serialVersionUID. */ + private static final long serialVersionUID = 1408493244549775810L; - private static final long serialVersionUID = 1L; - protected String facetName; + protected String topicName; + protected int count; public FacetTopic(String facetName, String topicName, int count) { Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/FieldFactory.java =================================================================== --- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/FieldFactory.java 2010-06-02 12:14:24 UTC (rev 79) +++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/FieldFactory.java 2010-06-02 12:50:50 UTC (rev 80) @@ -7,12 +7,12 @@ public class FieldFactory { - private ExtensionFactory parentFactory; - private String fieldName; - private TYPE type; - private int minOccur = 0, maxOccur = 1; - private boolean unique = false; - private Map<String, String> tagValues = new HashMap<String, String>(); + protected ExtensionFactory parentFactory; + protected String fieldName; + protected TYPE type; + protected int minOccur = 0, maxOccur = 1; + protected boolean unique = false; + protected Map<String, String> tagValues = new HashMap<String, String>(); public FieldFactory(ExtensionFactory parentFactory, String fieldName, TYPE type) { this.parentFactory = parentFactory; @@ -30,7 +30,7 @@ return parentFactory.extension(); } - private void append() { + protected void append() { FieldType fieldType = new FieldType(type, minOccur, maxOccur, unique, minOccur > 0); for (Map.Entry<String, String> entry : tagValues.entrySet()) { String tag = entry.getKey(); @@ -59,5 +59,4 @@ tagValues.put(tag, value); return this; } - } Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/FieldType.java =================================================================== --- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/FieldType.java 2010-06-02 12:14:24 UTC (rev 79) +++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/FieldType.java 2010-06-02 12:50:50 UTC (rev 80) @@ -17,7 +17,6 @@ package org.nuiton.wikitty; - import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; @@ -26,9 +25,6 @@ import java.util.Map; import java.util.Set; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - /** * * @author poussin @@ -39,11 +35,14 @@ */ public class FieldType implements Serializable { + /** serialVersionUID. */ + private static final long serialVersionUID = -4375308750387837026L; + static public enum TYPE { BOOLEAN, DATE, NUMERIC, STRING, WIKITTY; /** - * convert string to TYPE, this methode accept not trimed and not well + * convert string to TYPE, this method accept not trimed and not well * cased string (difference with valueOf) * @param name * @return TYPE else exception is throw @@ -54,18 +53,13 @@ } } - /** to use log facility, just put in your code: log.info(\"...\"); */ - static private Log log = LogFactory.getLog(FieldType.class); - - private static final long serialVersionUID = 1L; - public static final int NOLIMIT = Integer.MAX_VALUE; - TYPE type; - int lowerBound; - int upperBound; - boolean unique = false; - boolean notNull = false; + protected TYPE type; + protected int lowerBound; + protected int upperBound; + protected boolean unique = false; + protected boolean notNull = false; /** used to store tag/value used by client side ex: editor=xhtml */ Map<String, String> tagValues = new HashMap<String, String>(); @@ -80,9 +74,7 @@ } public FieldType(TYPE type, int lowerBound, int upperBound, boolean unique, boolean notNull) { - this.type = type; - this.lowerBound = lowerBound; - this.upperBound = upperBound; + this(type, lowerBound, upperBound); this.unique = unique; this.notNull = notNull; } @@ -109,17 +101,19 @@ } /** - * Return true if this field have upperBound > 1 - * @return + * Return true if this field have upperBound > 1. + * + * @return {@code true} is field is collection */ public boolean isCollection() { return upperBound > 1; } /** - * Return string definition for this field + * Return string definition for this field. + * * @param name field name used for definition - * @return + * @return field definition */ public String toDefinition(String name) { String result = type + " " + name; @@ -142,7 +136,7 @@ /** * Convert value in argument in right type for this FieldType. Don't support - * collection + * collection. * * @param value value to convert * @return object in type of this FieldType @@ -168,10 +162,12 @@ /** * Return a valid value for this field. + * * @param value is casted if possible to an actual correct value. - * @return + * @return value validity + * @throws WikittyException if value can't be obtained */ - public Object getValidValue( Object value ) throws WikittyException { + public Object getValidValue(Object value) throws WikittyException { if (value == null && isNotNull()) { throw new WikittyException("Value can't be null for this field"); } @@ -192,7 +188,7 @@ } // copy all value in new collections - for ( Object o : (Collection) value ) { + for ( Object o : (Collection<?>) value ) { col.add( getContainedValidObject(o) ); } result = col; @@ -203,7 +199,8 @@ } /** - * test if value in argument is valide for this field type + * Test if value in argument is valid for this field type. + * * @param value to test * @return true if value is valid */ Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/JGroupsCacheNotifier.java =================================================================== --- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/JGroupsCacheNotifier.java 2010-06-02 12:14:24 UTC (rev 79) +++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/JGroupsCacheNotifier.java 2010-06-02 12:50:50 UTC (rev 80) @@ -20,8 +20,6 @@ import java.io.Serializable; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter.DEFAULT; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jgroups.Channel; Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/PagedResult.java =================================================================== --- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/PagedResult.java 2010-06-02 12:14:24 UTC (rev 79) +++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/PagedResult.java 2010-06-02 12:50:50 UTC (rev 80) @@ -17,7 +17,6 @@ package org.nuiton.wikitty; - import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; @@ -25,11 +24,11 @@ import java.util.List; import java.util.Map; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - /** - * + * Paged result containing result collection and facet topics. + * + * @param <T> paged result value type + * * @author poussin * @version $Revision$ * @@ -38,11 +37,9 @@ */ public class PagedResult<T> implements Serializable { - /** to use log facility, just put in your code: log.info(\"...\"); */ - static private Log log = LogFactory.getLog(PagedResult.class); + /** serialVersionUID. */ + private static final long serialVersionUID = 8518774558223121855L; - private static final long serialVersionUID = 1L; - /** indice element in global search result */ protected int firstIndice; /** total number of result if we call the query for all possible result */ @@ -64,18 +61,20 @@ } /** - * Converte all result to the wanted type and return new PagedResult with + * Convert all result to the wanted type and return new PagedResult with * this new result list. If some result don't have the right extension (clazz) * this extension is automatically added if autoconvert is true. Else - * an exception is throwed when result without extension is found. + * an exception is thrown when result without extension is found. * - * When you used autoconvert = false, you have a potentialy probleme when + * When you used autoconvert = false, you have a potentially problem when * you have modified a BusinessEntity to have new extension and all your * wikitty object are not uptodate in database. - * - * @param clazz + * + * @param <E> class to cast into + * @param clazz class + * @param wikittyService wikitty service * @param autoconvert - * @return + * @return new PagedResult */ public <E extends BusinessEntityWikitty> PagedResult<E> cast( WikittyService wikittyService, Class<E> clazz, boolean autoconvert) { @@ -128,8 +127,9 @@ } /** - * Return name of all facet used in query - * @return + * Return name of all facet used in query. + * + * @return result's facets names */ public Collection<String> getFacetNames() { Collection<String> result = facets.keySet(); @@ -137,9 +137,10 @@ } /** - * Return all topic for the specified facet + * Return all topic for the specified facet. + * * @param facetName name of the wanted facet - * @return + * @return facet's topics */ public List<FacetTopic> getTopic(String facetName) { List<FacetTopic> result = facets.get(facetName); @@ -147,39 +148,49 @@ } /** - * Get map represent facets - * @return + * Get map represent facets. + * + * @return all facets */ public Map<String, List<FacetTopic>> getFacets() { return facets; } /** - * Return the firstIndice element in result or throw an exception if no element - * available - * @return + * Return the first element in result + * + * Can throw an exception if no element available + * @return first element */ public T getFirst() { T result = get(0); return result; } + /** + * Return element at index. + * + * @param i index + * @return element at index + */ public T get(int i) { T result = results.get(i); return result; } /** - * Return unmodifiable list of all result - * @return + * Return unmodifiable list of all result. + * + * @return all results */ public List<T> getAll() { return results; } /** - * Return the number of result in this object - * @return + * Return the number of result in this object. + * + * @return result number */ public int size() { int result = results.size(); Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/Wikitty.java =================================================================== --- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/Wikitty.java 2010-06-02 12:14:24 UTC (rev 79) +++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/Wikitty.java 2010-06-02 12:50:50 UTC (rev 80) @@ -44,17 +44,16 @@ */ public class Wikitty implements Serializable { - private static final long serialVersionUID = 1L; + /** serialVersionUID. */ + private static final long serialVersionUID = 4910886672760691052L; - /** - * technical id for this wikitty object. id must be never null - */ + /** Technical id for this wikitty object. id must be never null. */ protected String id; - /** current version of this wikitty object */ + /** Current version of this wikitty object. */ protected String version = WikittyUtil.DEFAULT_VERSION; - /** if not null, date of deletion, if date this object is marked as deleted */ + /** If not null, date of deletion, if date this object is marked as deleted. */ protected Date deleteDate = null; /** @@ -88,7 +87,7 @@ this(null); } - public Wikitty(String id){ + public Wikitty(String id) { if(id == null) { this.id = WikittyUtil.genUID(); } else { Deleted: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyDAO.java =================================================================== --- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyDAO.java 2010-06-02 12:14:24 UTC (rev 79) +++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyDAO.java 2010-06-02 12:50:50 UTC (rev 80) @@ -1,193 +0,0 @@ -package org.nuiton.wikitty; - -import java.lang.reflect.ParameterizedType; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -// FIXME poussin 20100528 verifier que cette class ne sert bien a rien et la supprimee -// Certaine methode ont ete commentee, car si on supprime la classe, ca ne sert a rien -// de la maintenir -@Deprecated -public class WikittyDAO<E extends BusinessEntityWikitty> { - - protected static Log log = LogFactory.getLog( WikittyDAO.class ); - - private WikittyProxy proxy; - private Class<E> clazz; - - public WikittyDAO() { - clazz = getActualClassType(); - } - - private Class<E> getActualClassType() { - ParameterizedType type = (ParameterizedType)this.getClass().getGenericSuperclass(); - Class<E> clazz = (Class<E>)type.getActualTypeArguments()[0]; - return clazz; - } - - public void addLabel(String wikittyId, String label) { - proxy.addLabel(wikittyId, label); - } - -// public String asyncExportAllByCriteria(Criteria criteria) { -// return proxy.asyncExportAllByCriteria(criteria); -// } -// -// public String asyncExportAllByExample(E e) { -// return proxy.asyncExportAllByExample(e); -// } -// -// public String asyncImportFromUri(String uri) { -// return proxy.asyncImportFromUri(uri); -// } -// -// public void cancelJob(String jobId) { -// proxy.cancelJob(jobId); -// } - - public void delete(Collection<String> ids) { - proxy.delete(ids); - } - - public void delete(String id) { - proxy.delete(id); - } - - public boolean equals(Object obj) { - return proxy.equals(obj); - } - - public Set<String> findAllAppliedLabels(String wikittyId) { - return proxy.findAllAppliedLabels(wikittyId); - } - - public PagedResult<E> findAll() { - return proxy.findAllByCriteria(clazz, null); - } - - public PagedResult<E> findAllByCriteria(Criteria criteria) { - return proxy.findAllByCriteria(clazz, criteria); - } - - public PagedResult<E> findAllByExample(E e, int firstIndex, int endIndex, String... fieldFacet) { - return proxy.findAllByExample(e, firstIndex, endIndex, fieldFacet); - } - - public PagedResult<Wikitty> findAllByLabel(String label, int firstIndex, int endIndex) { - return proxy.findAllByLabel(label, firstIndex, endIndex); - } - - public E findByCriteria(Criteria criteria) { - return proxy.findByCriteria(clazz, criteria); - } - - public E findByExample(E e) { - return proxy.findByExample(e); - } - - public Wikitty findByLabel(String label) { - return proxy.findByLabel(label); - } - -// public void freeJobResource(String jobId) { -// proxy.freeJobResource(jobId); -// } - - public WikittyService getWikittyService() { - return proxy.getWikittyService(); - } - - public int hashCode() { - return proxy.hashCode(); - } - -// public JobState infoJob(String jobId) { -// return proxy.infoJob(jobId); -// } - - public List<E> restore(List<String> id) { - return proxy.restore(clazz, id, true); - } - - public E restore(String id) { - return proxy.restore(clazz, id, true); - } - - public <E extends BusinessEntity> E restore(String id,Class<E> clazz ) { - return proxy.restore(clazz, id); - } - - public Tree restoreTree(String wikittyId) { - return proxy.restoreTree(wikittyId); - } - - public Map.Entry<E, Integer> restoreNode(String wikittyId) { - return restoreNode(wikittyId, null); - } - - public Map.Entry<E, Integer> restoreNode(String wikittyId, Criteria filter) { - Class<E> clazz = getActualClassType(); - return proxy.restoreNode(clazz, wikittyId, filter, true); - } - - public Map<E, Integer> restoreChildren(String wikittyId) { - return restoreChildren(wikittyId, null); - } - - public Map<E, Integer> restoreChildren(String wikittyId, Criteria filter) { - Class<E> clazz = getActualClassType(); - return proxy.restoreChildren(clazz, wikittyId, filter, true); - } - - public Wikitty restoreVersion(String wikittyId, String version) { - return proxy.restoreVersion(wikittyId, version); - } - - public boolean hasType(String wikittyId) { - Class<E> clazz = getActualClassType(); - return proxy.hasType(clazz, wikittyId); - } - - public void setWikittyService(WikittyService wikittyService) { - proxy.setWikittyService(wikittyService); - } - - public E store(E e) { - return proxy.store(e); - } - - public List<E> store(List<E> objets) { - return proxy.store(objets); - } - -// public String syncExportAllByCriteria(Criteria criteria) { -// return proxy.syncExportAllByCriteria(criteria); -// } -// -// public String syncExportAllByExample(E e) { -// return proxy.syncExportAllByExample(e); -// } -// -// public void syncImportFromUri(String uri) { -// proxy.syncImportFromUri(uri); -// } -// -// public void syncImportFromXml(String xml) { -// proxy.syncImportFromXml(xml); -// } - - public String toString() { - return proxy.toString(); - } - - public void setProxy(WikittyProxy proxy) { - this.proxy = proxy; - } - - -} Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyException.java =================================================================== --- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyException.java 2010-06-02 12:14:24 UTC (rev 79) +++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyException.java 2010-06-02 12:50:50 UTC (rev 80) @@ -18,7 +18,8 @@ package org.nuiton.wikitty; /** - * + * Wikitty exception. + * * @author poussin * @version $Revision$ * Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyExtension.java =================================================================== --- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyExtension.java 2010-06-02 12:14:24 UTC (rev 79) +++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyExtension.java 2010-06-02 12:50:50 UTC (rev 80) @@ -24,9 +24,6 @@ import java.util.Map; import java.util.Set; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - /** * * @author poussin @@ -37,14 +34,10 @@ */ public class WikittyExtension implements Serializable { - /** to use log facility, just put in your code: log.info(\"...\"); */ - static private Log log = LogFactory.getLog(WikittyExtension.class); + /** serialVersionUID. */ + private static final long serialVersionUID = -3598621577607442972L; - private static final long serialVersionUID = 1L; - - /** - * Name of this extension. - */ + /** Name of this extension. */ protected String name; /** @@ -63,7 +56,7 @@ protected String version = WikittyUtil.DEFAULT_VERSION; /** used to store tag/value used by client side ex: updatedDate=101212 */ - Map<String, String> tagValues = new HashMap<String, String>(); + protected Map<String, String> tagValues = new HashMap<String, String>(); /** * fields use ordered map, to keep order insertion of field @@ -72,16 +65,13 @@ */ protected LinkedHashMap<String, FieldType> fields = new LinkedHashMap<String, FieldType>(); - protected WikittyExtension() { - } - public WikittyExtension(String name) { if (name == null) { throw new IllegalArgumentException("Name must not be null"); } this.name = name; } - + public WikittyExtension(String name, String version, String requires, LinkedHashMap<String, FieldType> fields) { if (name == null) { @@ -123,10 +113,11 @@ } /** - * compute id for extension name and version in argument - * @param name - * @param version - * @return + * Compute id for extension name and version in argument. + * + * @param name extension name + * @param version extension version + * @return extension string id */ static public String computeId(String name, String version) { String result = name + "[" + version + "]"; Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyExtensionMigration.java =================================================================== --- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyExtensionMigration.java 2010-06-02 12:14:24 UTC (rev 79) +++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyExtensionMigration.java 2010-06-02 12:50:50 UTC (rev 80) @@ -17,7 +17,6 @@ package org.nuiton.wikitty; - import java.util.HashMap; import java.util.Map; Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyExtensionMigrationRename.java =================================================================== --- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyExtensionMigrationRename.java 2010-06-02 12:14:24 UTC (rev 79) +++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyExtensionMigrationRename.java 2010-06-02 12:50:50 UTC (rev 80) @@ -37,7 +37,7 @@ static private Log log = LogFactory.getLog(WikittyExtensionMigrationRename.class); - public static String TAG_RENAME = "renameFrom"; + public static final String TAG_RENAME = "renameFrom"; /** * Recursively add extension with requires ones (orderer). Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyExtensionStorage.java =================================================================== --- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyExtensionStorage.java 2010-06-02 12:14:24 UTC (rev 79) +++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyExtensionStorage.java 2010-06-02 12:50:50 UTC (rev 80) @@ -83,12 +83,15 @@ * @param name extension name to restore * @param version extension version to restore * @return an extension + * @throws WikittyException if exception during restore */ WikittyExtension restore(WikittyTransaction transaction, String name, String version) throws WikittyException; /** - * Remove all extensions + * Remove all extensions. + * + * @param transaction transaction */ public void clear(WikittyTransaction transaction); Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyImportExportService.java =================================================================== --- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyImportExportService.java 2010-06-02 12:14:24 UTC (rev 79) +++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyImportExportService.java 2010-06-02 12:50:50 UTC (rev 80) @@ -32,8 +32,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.FutureTask; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; + import org.nuiton.wikitty.importexport.ExportTask; import org.nuiton.wikitty.importexport.ImportExportCSV; import org.nuiton.wikitty.importexport.ImportExportMethod; @@ -43,7 +42,8 @@ import org.nuiton.wikitty.search.Search; /** - * + * Import/export service. + * * @author poussin * @version $Revision$ * @@ -52,9 +52,6 @@ */ public class WikittyImportExportService { - /** to use log facility, just put in your code: log.info(\"...\"); */ - static private Log log = LogFactory.getLog(WikittyImportExportService.class); - static public enum FORMAT { XML(new ImportExportXML()), CSV(new ImportExportCSV()); @@ -72,16 +69,17 @@ // FIXME poussin 20090902 next 3 variables must be read from configuration file /** number of thread used to import/export task */ - protected int MAX_IMPORT_EXPORT_THREAD = 1; + protected static final int MAX_IMPORT_EXPORT_THREAD = 1; /** directory path where export asynchronous file are stored */ - protected String EXPORT_DIRECTORY = "/tmp/"; + protected static final String EXPORT_DIRECTORY = "/tmp/"; /** url used by client to retrieve export file when job is ended */ - protected String EXPORT_URL = "file:///tmp/"; + protected static final String EXPORT_URL = "file:///tmp/"; /** Executor that do import export task */ protected ExecutorService importExportExecutor = // TODO poussin 20090902 do thread number configurable Executors.newFixedThreadPool(MAX_IMPORT_EXPORT_THREAD); + /** contains all import or export task, key is job id send to client */ protected Map<String, Future<String>> importExportTask = new HashMap<String, Future<String>>(); @@ -130,8 +128,10 @@ } /** - * - * @param e + * Asynchronous export by example. + * + * @param format export format + * @param e sample * @return job id */ public String asyncExportAllByExample(FORMAT format, BusinessEntityWikitty e) { @@ -141,9 +141,11 @@ } /** - * - * @param e - * @return xml string + * Synchronous export by example. + * + * @param format export format + * @param e sample + * @return export string */ public String syncExportAllByExample(FORMAT format, BusinessEntityWikitty e) { Criteria criteria = Search.query(e.getWikitty()).criteria(); @@ -151,6 +153,13 @@ return result; } + /** + * Asynchronous export by criteria. + * + * @param format export format + * @param criteria criteria + * @return export as string + */ public String asyncExportAllByCriteria(FORMAT format, Criteria criteria) { try { String jobId = UUID.randomUUID().toString(); @@ -169,6 +178,13 @@ } } + /** + * Synchronous export by criteria. + * + * @param format export format + * @param criteria criteria + * @return export as string + */ public String syncExportAllByCriteria(FORMAT format, Criteria criteria) { StringWriter result = new StringWriter(); ExportTask task = new ExportTask(ws, format, criteria, result); @@ -176,6 +192,12 @@ return result.toString(); } + /** + * Return job information. + * + * @param jobId job id + * @return job state + */ public JobState infoJob(String jobId) { try { Future<String> future = importExportTask.get(jobId); @@ -195,7 +217,7 @@ } public void cancelJob(String jobId) { - Future future = importExportTask.get(jobId); + Future<String> future = importExportTask.get(jobId); future.cancel(true); // true to kill process, perhaps to strong ? } Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyProxy.java =================================================================== --- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyProxy.java 2010-06-02 12:14:24 UTC (rev 79) +++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyProxy.java 2010-06-02 12:50:50 UTC (rev 80) @@ -62,8 +62,10 @@ /** * Store to WikittyService objects. - * @param objets list of BeanDto - * @return + * + * @param <E> object type + * @param objets list + * @return updated objects list */ public <E extends BusinessEntity> List<E> store(List<E> objets) { // prepare data to send to service @@ -86,6 +88,7 @@ /** * Restore wikitty entity with specified id or {@code null} if entity can't be found. * + * @param <E> object type * @param clazz entity class * @param id entity id * @param checkExtension if true check that Wikitty result has all extension @@ -94,7 +97,7 @@ */ public <E extends BusinessEntity> E restore(Class<E> clazz, String id, boolean checkExtension) { E result = null; - HashSet extNames = null; + HashSet<String> extNames = null; try { Wikitty wikitty = wikittyService.restore(id); if(wikitty == null) { @@ -128,6 +131,7 @@ /** * Restore wikitty entity with specified id or {@code null} if entity can't be found. * + * @param <E> object type * @param clazz entity class * @param id entity id * @return wikitty entity with specified id or {@code null} if entity can't be found @@ -138,11 +142,13 @@ } /** - * - * @param clazz - * @param id + * Restore wikitty entity with specified id or {@code null} if entity can't be be found. + * + * @param <E> object type + * @param clazz entity class + * @param id entity id * @param checkExtension if true check that Wikitty result has all extension - * @return + * @return wikitty entity with specified id or {@code null} if entity can't be found */ public <E extends BusinessEntity> List<E> restore( Class<E> clazz, List<String> id, boolean checkExtension) { @@ -150,7 +156,7 @@ List<Wikitty> wikitties = wikittyService.restore(id); List<E> result = new ArrayList<E>(); for (Wikitty w : wikitties) { - HashSet extNames = null; + HashSet<String> extNames = null; if (checkExtension) { extNames = new HashSet<String>(w.getExtensionNames()); } @@ -212,11 +218,11 @@ * Search object that correspond to criteria and that have all extension * needed by BusinessEntity (clazz). If criteria is null, find all extensions * else if crtiteria is empty return nothing. - * @param clazz - * @param criteria - * @param firstIndex - * @param endIndex - * @return + * + * @param <E> object type + * @param clazz entity class + * @param criteria criteria + * @return paged result */ public <E extends BusinessEntity> PagedResult<E> findAllByCriteria( Class<E> clazz, Criteria criteria) { Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittySearchEngin.java =================================================================== --- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittySearchEngin.java 2010-06-02 12:14:24 UTC (rev 79) +++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittySearchEngin.java 2010-06-02 12:50:50 UTC (rev 80) @@ -59,7 +59,7 @@ * and is processed without any other kind of treatment. * * @param idList list of ids to delete - * @return <code>UpdateResponse</code>> + * @return <code>UpdateResponse</code> * @throws WikittyException */ public void delete(Collection<String> idList) throws WikittyException; Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyServiceImpl.java =================================================================== --- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyServiceImpl.java 2010-06-02 12:14:24 UTC (rev 79) +++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyServiceImpl.java 2010-06-02 12:50:50 UTC (rev 80) @@ -138,8 +138,9 @@ } /** - * Store and index wikitties object - * @param wikitty + * Store and index wikitties object. + * + * @param wikitties */ @Override public UpdateResponse store(Collection<Wikitty> wikitties) { @@ -158,8 +159,9 @@ } /** - * Store and index wikitties object - * @param wikitty + * Store and index wikitties object. + * + * @param wikitties */ @Override public UpdateResponse store(Collection<Wikitty> wikitties, boolean disableAutoVersionIncrement) { @@ -217,9 +219,9 @@ } /** - * Save just one extension - * @param ext - * @throws java.io.IOException + * Save several extension. + * + * @param exts */ @Override public UpdateResponse storeExtension(Collection<WikittyExtension> exts) { @@ -262,10 +264,12 @@ WikittyExtension result = getExtensionStorage().restore(transaction, name, version); return result; } + /** - * Load extension from id. Id is 'name[version]' - * @param id - * @return + * Load extension from id. Id is 'name[version]'. + * + * @param id extension id to restore + * @return extension */ @Override public WikittyExtension restoreExtension(String id) { @@ -845,7 +849,10 @@ * * @param bean * @return + * + * @deprecated since bean removal */ + @Deprecated protected static void fillBeanAttributes(TreeNode fromBean, TreeNodeBean toBean) { String beanId = fromBean.getWikittyId(); toBean.id = beanId; @@ -867,7 +874,10 @@ * * @param impl * @return + * + * @deprecated since bean removal */ + @Deprecated public static TreeNode toBean(TreeNodeImpl impl) { if (impl == null) return null; TreeNodeBean bean = new TreeNodeBean(); Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyServiceInMemory.java =================================================================== --- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyServiceInMemory.java 2010-06-02 12:14:24 UTC (rev 79) +++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyServiceInMemory.java 2010-06-02 12:50:50 UTC (rev 80) @@ -43,7 +43,7 @@ import org.nuiton.wikitty.search.Restriction; /** - * In memory implementation of WikittyService, currently used for test only + * In memory implementation of WikittyService, currently used for test only. * * @author poussin * @version $Revision$ Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyStorage.java =================================================================== --- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyStorage.java 2010-06-02 12:14:24 UTC (rev 79) +++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyStorage.java 2010-06-02 12:50:50 UTC (rev 80) @@ -18,7 +18,6 @@ package org.nuiton.wikitty; import java.util.Collection; -import java.util.List; /** * WikittyStorage is used to abstract data and extension storage in WikittyService. @@ -32,58 +31,76 @@ public interface WikittyStorage { /** - * Store wikitty in storage + * Store wikitty in storage. + * + * @param transaction transaction + * @param wikitties wikitty collection + * @param disableAutoVersionIncrement + * * @return information usefull for client side update data */ public UpdateResponse store(WikittyTransaction transaction, Collection<Wikitty> wikitties, boolean disableAutoVersionIncrement); /** - * Return true if id exists in storage - * @param id - * @return + * Return true if id exists in storage. + * + * @param transaction transaction + * @param id id to check + * @return {@code true} if wikitty id exists */ public boolean exists(WikittyTransaction transaction, String id); /** - * Return true if wikitty object with this id are marked deleted - * @param id - * @return + * Return true if wikitty object with this id are marked deleted. + * + * @param transaction transaction + * @param id id to check + * @return {@code true} if wikitty id is deleted */ public boolean isDeleted(WikittyTransaction transaction, String id); /** - * Restore list of wikitty object, if wikitty not found an exception is throw + * Restore list of wikitty object. + * + * @param transaction transaction * @param id list of wikitty id * @param fqFieldName list of field that must be loaded, other fields - * can be not loaded - * @return + * can be not loaded + * @return found wikitty + * @throws WikittyException if wikitty not found */ public Wikitty restore(WikittyTransaction transaction, String id, String ... fqFieldName) throws WikittyException; /** - * Delete all object with id argument. If id is not valid or don't exist - * throw an exception + * Delete all object with id argument. + * + * @param transaction transaction * @param idList - * @return + * @return delete response + * @throws WikittyException If id is not valid or don't exist. */ public UpdateResponse delete(WikittyTransaction transaction, Collection<String> idList) throws WikittyException; /** - * Scan all wikitties with specific scanner, even if the wikitty is deleted + * Scan all wikitties with specific scanner, even if the wikitty is deleted. + * + * @param transaction transaction * @param scanner scanner */ void scanWikitties(WikittyTransaction transaction, Scanner scanner); /** - * Call each time wikitty is scan + * Call each time wikitty is scan. */ public static interface Scanner { void scan(Wikitty wikitty); } /** - * Remove all wikitty + * Remove all wikitty. + * + * @param transaction transaction */ public void clear(WikittyTransaction transaction); Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyTransaction.java =================================================================== --- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyTransaction.java 2010-06-02 12:14:24 UTC (rev 79) +++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyTransaction.java 2010-06-02 12:50:50 UTC (rev 80) @@ -14,7 +14,7 @@ public class WikittyTransaction { /** to use log facility, just put in your code: log.info(\"...\"); */ - static private Log log = LogFactory.getLog(WikittyServiceImpl.class); + static private Log log = LogFactory.getLog(WikittyTransaction.class); protected Map<Object, Object> tagValues; @@ -41,7 +41,9 @@ public void begin() { UserTransaction userTransaction = getUserTransaction(); try { - log.debug("Begin transaction"); + if (log.isDebugEnabled()) { + log.debug("Begin transaction"); + } userTransaction.setTransactionTimeout(3600); // FIXME: jru 20100115 error in service if call during lot of times userTransaction.begin(); } catch (Exception eee) { @@ -53,7 +55,9 @@ UserTransaction userTransaction = getUserTransaction(); try { - log.debug("Commit transaction"); + if (log.isDebugEnabled()) { + log.debug("Commit transaction"); + } userTransaction.commit(); } catch (Exception eee) { throw new WikittyException("Error on commit JTA transaction", eee); @@ -65,7 +69,9 @@ try { if(userTransaction.getStatus() != Status.STATUS_NO_TRANSACTION && userTransaction.getStatus() != Status.STATUS_UNKNOWN) { - log.debug("Rollback transaction"); + if (log.isDebugEnabled()) { + log.debug("Rollback transaction"); + } userTransaction.rollback(); } } catch (Exception eee) { Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java =================================================================== --- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java 2010-06-02 12:14:24 UTC (rev 79) +++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java 2010-06-02 12:50:50 UTC (rev 80) @@ -42,13 +42,12 @@ import org.apache.commons.logging.LogFactory; /** + * Util static method for wikitty. * - * Util static method for wikitty - * * @author poussin * @version $Revision$ * - * Last update: $Date$ by : $Author$ + * Last update: $Date$ by : $Author$ */ public class WikittyUtil { @@ -66,6 +65,9 @@ static final public SimpleDateFormat solrDateFormat = new SolrDateFormat(); public static class SolrDateFormat extends SimpleDateFormat { + /** serialVersionUID. */ + private static final long serialVersionUID = 8840047015546468704L; + public SolrDateFormat() { super(DATE_FORMAT, CANONICAL_LOCALE); setTimeZone(CANONICAL_TZ); @@ -81,7 +83,7 @@ // TODO poussin 20090902 use spring configuration to add mapping in this // variable /** contains mapping between interface and concret class that must be used */ - static public Map<Class, Class> interfaceToClass = new HashMap<Class, Class>(); + static public Map<Class<?>, Class<?>> interfaceToClass = new HashMap<Class<?>, Class<?>>(); /** * Pattern for tag value: tag="value" or tag=value. value can contains '"' @@ -106,10 +108,8 @@ * parse FieldType definition and return field name. All field information * are stored in fieldType object passed in argument * - * @param def - * string field definition - * @param fieldType - * object used to put parsed information + * @param def string field definition + * @param fieldType object used to put parsed information * @return field name parsed in definition */ static public String parseField(String def, FieldType fieldType) { @@ -194,12 +194,12 @@ } /** - * Create map from string representation + * Create map from string representation. * * ex: "String name", "Wikitty children[0-*]" * - * @param definitions - * @return + * @param definitions extension definition + * @return extensions map */ public static LinkedHashMap<String, FieldType> buildFieldMapExtension( String... definitions) { @@ -207,7 +207,9 @@ for (String def : definitions) { FieldType fieldType = new FieldType(); String name = WikittyUtil.parseField(def, fieldType); - log.debug("parse " + def + " => " + fieldType.toDefinition(name)); + if (log.isDebugEnabled()) { + log.debug("parse " + def + " => " + fieldType.toDefinition(name)); + } result.put(name, fieldType); } return result; @@ -217,7 +219,7 @@ * if version if null return 0 else version If version is not in format * <major>.<minor>, ".0" is added to the version * - * @param version + * @param version version * @return the normalized version */ public static String normalizeVersion(String version) { @@ -231,7 +233,14 @@ } /** - * return true if v1 and v2 are egals 1.2.0 et 1.2 ne sont pas egaux + * Return true if v1 and v2 are equals. + * + * 1.2.0 et 1.2 ne sont pas egaux + * + * @param v1 version + * @param v2 version + * + * @return {@code true} if v1 == v2 */ public static boolean versionEquals(String v1, String v2) { if (v1 == null || v2 == null) { @@ -241,11 +250,11 @@ } /** - * return true if v1 greater than v2 + * Return true if v1 greater than v2. * - * @param v1 - * @param v2 - * @return + * @param v1 version + * @param v2 version + * @return {@code true} if v1 > v2 */ public static boolean versionGreaterThan(String v1, String v2) { if (v1 != null && v2 == null) { @@ -267,10 +276,9 @@ } /** - * increment minor version. + * Increment minor version. * - * @param version - * version as 3.1 where 1 is minor and 3 major + * @param v version as 3.1 where 1 is minor and 3 major * @return incremented minor number (3.1 -> 3.2) */ static public String incrementMinorRevision(String v) { @@ -294,8 +302,7 @@ /** * increment major version. * - * @param version - * version as 3.2 where 2 is minor and 3 major + * @param v version as 3.2 where 2 is minor and 3 major * @return incremented major number and reset minor number (3.2 -> 4.0) */ static public String incrementMajorRevision(String v) { @@ -355,12 +362,12 @@ // } /** + * Get value as BigDecimal. * - * @param value - * null and empty string are casted to '0' value. - * @throws WikittyException - * on NumberFormatException or if value object can't be casted - * to number. + * @param value null and empty string are casted to '0' value. + * @throws WikittyException on NumberFormatException or if value object can't be casted to number. + * + * @return value as BigDecimal */ static public BigDecimal toBigDecimal(Object value) { BigDecimal result = null; @@ -381,11 +388,14 @@ } /** - * Convert object to boolean: - null => false - 0 => false - numeric => true - * - object.toString() == false => false - other => true + * Convert object to boolean: + * <ul> + * <li>- null => false - 0 => false - numeric => true + * <li>- object.toString() == false => false - other => true + * </ul> * - * @param value - * @return + * @param value value + * @return value as boolean */ static public boolean toBoolean(Object value) { boolean result = false; @@ -431,7 +441,9 @@ try { result = solrDateFormat.parse(value.toString()); } catch (ParseException eee) { - log.debug("Can't parse date, i try with next parser", eee); + if (log.isDebugEnabled()) { + log.debug("Can't parse date, i try with next parser", eee); + } } if (result == null) { @@ -445,13 +457,12 @@ } /** - * return wikitty id and not wikitty objet because this method can be call + * Return wikitty id and not wikitty objet because this method can be call * on server or client side and it's better to keep conversion between id * and objet to the caller * * @param value * @return id of wikitty object or null - * @throws org.nuiton.wikitty.WikittyException */ static public String toWikitty(Object value) { String result = null; @@ -471,9 +482,11 @@ } /** + * Convert value to list. * - * @param <E> - * @param clazz + * @param <E> elements type + * @param value value to convert + * @param clazz element class * @return unmodifiable list */ static public <E> List<E> toList(Object value, Class<E> clazz) { @@ -490,12 +503,10 @@ } /** - * Convert object o for indexation + * Convert object o for indexation. * - * @param field - * field description - * @param o - * field value + * @param field field description + * @param o field value * @return solr representation */ static public String toString(FieldType field, Object o) { @@ -517,12 +528,10 @@ /** - * convert string field representation to correct value type + * Convert string field representation to correct value type. * - * @param field - * field description - * @param s - * string value + * @param field field description + * @param s string value * @return object in type of field */ static public Object fromString(FieldType field, String s) { @@ -545,13 +554,13 @@ } /** - * return class of argument, if argument is null, return null + * Return class of argument, if argument is null, return null. * * @param value * @return class of value or null */ - static public Class getClass(Object value) { - Class result = null; + static public Class<?> getClass(Object value) { + Class<?> result = null; if (value != null) { result = value.getClass(); } @@ -565,25 +574,23 @@ * <p> * clazz parameter must be child of WikittyDto or business interface * - * @param clazz - * class of the new instance - * @return + * @param <E> element type + * + * @param clazz class of the new instance + * @return new instance of clazz */ static public <E extends BusinessEntity> E newInstance(Class<E> clazz) { try { - Class clazzInstanciable = clazz; + Class<?> clazzInstanciable = clazz; if (clazzInstanciable.isInterface()) { - log - .debug(String - .format( - "Argument '%s' is interface looking for implementation", + log.debug(String.format("Argument '%s' is interface looking for implementation", clazzInstanciable.getName())); // looking for implementation of this interface if (interfaceToClass.containsKey(clazz)) { clazzInstanciable = interfaceToClass.get(clazz); } else { // default use xxxImpl.class - clazzInstanciable = clazz.forName(clazz.getName() + "Impl"); + clazzInstanciable = Class.forName(clazz.getName() + "Impl"); } } @@ -594,7 +601,7 @@ .getName())); } - E result = (E) clazzInstanciable.newInstance(); + E result = (E)clazzInstanciable.newInstance(); return result; } catch (Exception eee) { @@ -608,29 +615,26 @@ * <p> * clazz parameter must be child of WikittyDto or business interface * - * @param clazz - * class of the new instance - * @param w - * wikitty object to use internaly for in new instance - * @return + * + * @param <E> entity type + * @param wikittyService wikitty service + * @param clazz class of the new instance + * @param w wikitty object to use internaly for in new instance + * @return new instance */ - // E extends BeanDto to permit business interface as parameter static public <E extends BusinessEntity> E newInstance( WikittyService wikittyService, Class<E> clazz, Wikitty w) { try { - Class clazzInstanciable = clazz; + Class<?> clazzInstanciable = clazz; if (clazzInstanciable.isInterface()) { - log - .debug(String - .format( - "Argument '%s' is interface looking for implementation", + log.debug(String.format("Argument '%s' is interface looking for implementation", clazzInstanciable.getName())); // looking for implementation of this interface if (interfaceToClass.containsKey(clazz)) { clazzInstanciable = interfaceToClass.get(clazz); } else { // default use xxxImpl.class - clazzInstanciable = clazz.forName(clazz.getName() + "Impl"); + clazzInstanciable = Class.forName(clazz.getName() + "Impl"); } } @@ -645,7 +649,7 @@ if (w != null) { try { // try to find constructor with wikitty argument - Constructor cons = clazzInstanciable + Constructor<?> cons = clazzInstanciable .getConstructor(Wikitty.class); Object[] parms = { null }; result = (E) cons.newInstance(parms); @@ -711,13 +715,12 @@ } /** - * Try to cast obj to class passed in arguement + * Try to cast obj to class passed in argument. * - * @param obj - * object to cast - * @param clazz - * new type of object - * @return the same object but casted to class wanted, except for primitif + * @param <E> element type + * @param obj object to cast + * @param clazz new type of object + * @return the same object but casted to class wanted, except for primitive * where is new object if obj BigDecimal */ public static <E> E cast(Object obj, Class<E> clazz) { @@ -801,10 +804,8 @@ * Convert WikittyDto (dto that encapsulate Wikitty) to BeanDto (dto without * internaly wikitty) * - * @param clazz - * target object clazz - * @param w - * source object + * @param clazz target object clazz + * @param w source object * @return */ public static <E extends BusinessEntityBean> E wikittyToBean(
participants (1)
-
echatellier@users.nuiton.org