updated API description
This commit is contained in:
@ -20,7 +20,7 @@ import de.muehlencord.shared.configuration.converter.BooleanStringConverter;
|
||||
/**
|
||||
* A Boolean parameter
|
||||
*
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class BooleanParameter extends Parameter<Boolean> {
|
||||
|
||||
|
||||
@ -18,14 +18,16 @@ package de.muehlencord.shared.configuration;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Specifies a configurable objects.
|
||||
*
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public interface Configuration {
|
||||
|
||||
/**
|
||||
* adds a new parameter to the configuration
|
||||
*
|
||||
* @param <T> the type of the parameter to add
|
||||
* @param p the parameter to add
|
||||
* @throws ConfigurationException if the parameter cannot be added
|
||||
*/
|
||||
@ -34,9 +36,9 @@ public interface Configuration {
|
||||
/**
|
||||
* sets the value of the given parameter
|
||||
*
|
||||
* @param <T>
|
||||
* @param p
|
||||
* @param value
|
||||
* @param <T> the type of the parameter to add
|
||||
* @param p the parameter to add
|
||||
* @param value the value the parameter should have
|
||||
* @throws ConfigurationException if the parameter is not defined
|
||||
*/
|
||||
public <T> void setParameterValue(Parameter<T> p, T value) throws ConfigurationException;
|
||||
@ -44,6 +46,7 @@ public interface Configuration {
|
||||
/**
|
||||
* sets the value of parameter with given name
|
||||
*
|
||||
* @param <T> the type of the parameter to add
|
||||
* @param parameterName parameter to set
|
||||
* @param value value to set
|
||||
* @throws ConfigurationException if the parameter is not defined
|
||||
@ -53,6 +56,7 @@ public interface Configuration {
|
||||
/**
|
||||
* sets the value of the given parameter
|
||||
*
|
||||
* @param <T> the type of the parameter to add
|
||||
* @param p parameter to set
|
||||
* @param value value to set
|
||||
* @throws ConfigurationException if the parameter is not defined
|
||||
@ -71,20 +75,24 @@ public interface Configuration {
|
||||
/**
|
||||
* returns the value of the given parameter
|
||||
*
|
||||
* @param <T> the type of the parameter to add
|
||||
* @param p the parameter to return the value for
|
||||
* @return the value of the given parameter; null if not set
|
||||
*
|
||||
* @throws ConfigurationException if the parameter is not defined or if the value is not set
|
||||
* @throws ConfigurationException if the parameter is not defined or if the
|
||||
* value is not set
|
||||
*/
|
||||
public <T> T getParameterValue(Parameter<T> p) throws ConfigurationException;
|
||||
|
||||
/**
|
||||
* returns the value of the given parameter
|
||||
*
|
||||
* @param <T> the type of the parameter to add
|
||||
* @param parameterName the name of the parameter to return the value for
|
||||
* @return the value of the given parameter; null if not set
|
||||
*
|
||||
* @throws ConfigurationException if the parameter is not defined or if the value is not set
|
||||
* @throws ConfigurationException if the parameter is not defined or if the
|
||||
* value is not set
|
||||
*/
|
||||
public <T> T getParameterValue(String parameterName) throws ConfigurationException;
|
||||
|
||||
@ -98,6 +106,7 @@ public interface Configuration {
|
||||
/**
|
||||
* returns the map of parameters and values
|
||||
*
|
||||
* @param <T> the type of the parameter to add
|
||||
* @return the map of parameters and values
|
||||
*/
|
||||
public <T> Map<Parameter<T>, T> getParameterMap();
|
||||
|
||||
@ -20,7 +20,8 @@ import java.util.Date;
|
||||
|
||||
/**
|
||||
* A Date parameter
|
||||
* @author joern@muehlencord.de
|
||||
*
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class DateParameter extends Parameter<Date> {
|
||||
|
||||
@ -47,7 +48,7 @@ public class DateParameter extends Parameter<Date> {
|
||||
* creates a new parameter object using default string converter
|
||||
*
|
||||
* @param name the name of the parameter
|
||||
* @param mandatory detremines if this is a mandatory parameter or not
|
||||
* @param mandatory determines if this is a mandatory parameter or not
|
||||
*/
|
||||
public DateParameter(String name, boolean mandatory) {
|
||||
super(name, new DateStringConverter(), mandatory);
|
||||
@ -58,7 +59,7 @@ public class DateParameter extends Parameter<Date> {
|
||||
*
|
||||
* @param name the name of the parameter
|
||||
* @param converter the converter object to convert the value of the parameter to string and vice versa
|
||||
* @param mandatory detremines if this is a mandatory parameter or not
|
||||
* @param mandatory determines if this is a mandatory parameter or not
|
||||
*/
|
||||
public DateParameter(String name, StringConverter<Date> converter, boolean mandatory) {
|
||||
super(name, converter, mandatory);
|
||||
|
||||
@ -22,7 +22,7 @@ import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class DefaultConfiguration implements Configuration {
|
||||
|
||||
@ -104,6 +104,7 @@ public class DefaultConfiguration implements Configuration {
|
||||
/**
|
||||
* overrides parameter map with given map
|
||||
*
|
||||
* @param <T> the type of the parameter to add
|
||||
* @param map map to use
|
||||
* @throws ConfigurationException if the parameter is not defined
|
||||
*/
|
||||
|
||||
@ -20,7 +20,7 @@ import de.muehlencord.shared.configuration.converter.IntegerStringConverter;
|
||||
/**
|
||||
* A Integer parameter
|
||||
*
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class IntegerParameter extends Parameter<Integer> {
|
||||
|
||||
|
||||
@ -19,7 +19,8 @@ import de.muehlencord.shared.configuration.converter.StringStringConverter;
|
||||
|
||||
/**
|
||||
* A String parameter
|
||||
* @author joern@muehlencord.de
|
||||
*
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class StringParameter extends Parameter<String> {
|
||||
|
||||
@ -36,6 +37,7 @@ public class StringParameter extends Parameter<String> {
|
||||
* creates a new mandatory parameter object using default string converter
|
||||
*
|
||||
* @param name the name of the parameter
|
||||
* @param defaultValue the default value of the parameter to set.
|
||||
*/
|
||||
public StringParameter(String name, String defaultValue) {
|
||||
super(name, new StringStringConverter(), true);
|
||||
@ -46,7 +48,8 @@ public class StringParameter extends Parameter<String> {
|
||||
* creates a new mandatory parameter object
|
||||
*
|
||||
* @param name the name of the parameter
|
||||
* @param converter the converter object to convert the value of the parameter to string and vice versa
|
||||
* @param converter the converter object to convert the value of the
|
||||
* parameter to string and vice versa
|
||||
*/
|
||||
public StringParameter(String name, StringConverter<String> converter) {
|
||||
super(name, converter, true);
|
||||
@ -66,7 +69,8 @@ public class StringParameter extends Parameter<String> {
|
||||
* creates a new parameter object
|
||||
*
|
||||
* @param name the name of the parameter
|
||||
* @param converter the converter object to convert the value of the parameter to string and vice versa
|
||||
* @param converter the converter object to convert the value of the
|
||||
* parameter to string and vice versa
|
||||
* @param mandatory detremines if this is a mandatory parameter or not
|
||||
*/
|
||||
public StringParameter(String name, StringConverter<String> converter, boolean mandatory) {
|
||||
|
||||
@ -20,7 +20,7 @@ import java.net.URI;
|
||||
|
||||
/**
|
||||
* A URI parameter
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class URIParameter extends Parameter<URI> {
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ package de.muehlencord.shared.configuration;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class ValidationException extends Exception {
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ package de.muehlencord.shared.configuration;
|
||||
/**
|
||||
*
|
||||
* @param <T> the type of the validator
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public interface Validator<T> {
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ import static java.lang.Boolean.parseBoolean;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class BooleanStringConverter implements StringConverter<Boolean> {
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@ import de.muehlencord.shared.configuration.Validator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class IntgerRangeValidator implements Validator<Integer> {
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class StringValueListValidator implements Validator<String> {
|
||||
|
||||
|
||||
@ -34,7 +34,8 @@ import javax.persistence.criteria.Root;
|
||||
/**
|
||||
*
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
* @param <T>
|
||||
* @param <T> the entity this controller will serve. All objects returned are of
|
||||
* this type.
|
||||
*/
|
||||
public abstract class AbstractController<T extends Serializable> extends CommonAbstractController {
|
||||
|
||||
@ -44,16 +45,26 @@ public abstract class AbstractController<T extends Serializable> extends CommonA
|
||||
this.entityClass = clazz;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* * general find methods ***
|
||||
* general find method
|
||||
*
|
||||
* @param id the primary key of the entity to search for.
|
||||
* @return the found entity instance or null if the entity does not exist
|
||||
*/
|
||||
|
||||
@Lock(LockType.READ)
|
||||
public T find(Object id) {
|
||||
return em.find(entityClass, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* general find method with the option to initialize lists/sets of 1:n
|
||||
* relations during the query.
|
||||
*
|
||||
* @param id the primary key of the entity to search for.
|
||||
* @param subGraphItems the name of the subgraph items to initialize.
|
||||
* Typically this is the name of the 1:n set or list.
|
||||
* @return the found entity instance or null if the entity does not exist
|
||||
*/
|
||||
@Lock(LockType.READ)
|
||||
public T find(Object id, String... subGraphItems) {
|
||||
EntityGraph graph = this.em.createEntityGraph(entityClass);
|
||||
@ -68,16 +79,32 @@ public abstract class AbstractController<T extends Serializable> extends CommonA
|
||||
return entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a list of all entities.
|
||||
*
|
||||
* @return a list of all entities.
|
||||
*/
|
||||
@Lock(LockType.READ)
|
||||
public List<T> findAll() {
|
||||
return findAll(new ArrayList<>());
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a list of all entities.
|
||||
*
|
||||
* @param orderFields the list of field names to order the result by.
|
||||
* @return a list of all entities.
|
||||
*/
|
||||
@Lock(LockType.READ)
|
||||
public List<T> findAll(String... orderFields) {
|
||||
return findAll(Arrays.asList(orderFields));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param orderFields the list of field names to order the result by.
|
||||
* @return a list of all entities.
|
||||
*/
|
||||
@Lock(LockType.READ)
|
||||
public List<T> findAll(List<String> orderFields) {
|
||||
final CriteriaBuilder cb = em.getCriteriaBuilder();
|
||||
@ -92,6 +119,14 @@ public abstract class AbstractController<T extends Serializable> extends CommonA
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
/**
|
||||
* searches for entities by specifying a filter map. The map contains a
|
||||
* field name and field value.
|
||||
*
|
||||
* @param filters the filters to apply
|
||||
* @param orderFields the fields to order the result by.
|
||||
* @return a list of found entities.
|
||||
*/
|
||||
@Lock(LockType.READ)
|
||||
public List<T> find(Map<String, Object> filters, List<String> orderFields) {
|
||||
final CriteriaBuilder cb = em.getCriteriaBuilder();
|
||||
@ -109,5 +144,4 @@ public abstract class AbstractController<T extends Serializable> extends CommonA
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -44,20 +44,43 @@ import org.apache.commons.lang3.StringUtils;
|
||||
*/
|
||||
public abstract class CommonAbstractController {
|
||||
|
||||
/**
|
||||
* the entity manager to use
|
||||
*/
|
||||
@Inject
|
||||
@ApplicationPU
|
||||
protected EntityManager em;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param <T> the type of the entity to search for
|
||||
* @param entityClass the entity class to return
|
||||
* @return a list of all entities found
|
||||
*/
|
||||
@Lock(LockType.READ)
|
||||
public <T> List<T> findAll(Class<T> entityClass) {
|
||||
return findAll(entityClass, new ArrayList<>());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param <T> the type of the entity to search for
|
||||
* @param entityClass the entity class to return
|
||||
* @param orderFields the fields to order the result by.
|
||||
* @return a list of all entities found
|
||||
*/
|
||||
@Lock(LockType.READ)
|
||||
public <T> List<T> findAll(Class<T> entityClass, String... orderFields) {
|
||||
return findAll(entityClass, Arrays.asList(orderFields));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param <T> the type of the entity to search for
|
||||
* @param entityClass the entity class to return
|
||||
* @param orderFields the fields to order the result by.
|
||||
* @return a list of all entities found
|
||||
*/
|
||||
@Lock(LockType.READ)
|
||||
public <T> List<T> findAll(Class<T> entityClass, List<String> orderFields) {
|
||||
final CriteriaBuilder cb = em.getCriteriaBuilder();
|
||||
@ -73,6 +96,17 @@ public abstract class CommonAbstractController {
|
||||
}
|
||||
|
||||
/* **** standard crud options *** */
|
||||
/**
|
||||
* updates the audit field of the entity class.
|
||||
*
|
||||
* @param audit the audit to apply
|
||||
* @param onCreate specifies, whether the the update should be applied for a
|
||||
* new entity or not. If yes, then also the createdBy /createdOn fields are
|
||||
* updated. Otherwise these fields are skipped.
|
||||
* @param changedBy the username to apply
|
||||
* @return an updated audit object to use for the updated entity.
|
||||
* @throws ControllerException
|
||||
*/
|
||||
public Audit applyAuditChanges(Audit audit, boolean onCreate, String changedBy) throws ControllerException {
|
||||
if (audit == null) {
|
||||
audit = new Audit();
|
||||
@ -87,6 +121,16 @@ public abstract class CommonAbstractController {
|
||||
return audit;
|
||||
}
|
||||
|
||||
/**
|
||||
* creates an new entity or if the entity already exists updates it
|
||||
*
|
||||
* @param <T> the type of the entity to search for
|
||||
* @param entity the entity to create or update
|
||||
* @param createdBy the username to apply write into the audit history
|
||||
* @return the entity after it has been written to the database.
|
||||
* @throws ControllerException if the the creation or update of the entity
|
||||
* fails.
|
||||
*/
|
||||
@TransactionAttribute(TransactionAttributeType.REQUIRED)
|
||||
@Transactional
|
||||
@Lock(LockType.WRITE)
|
||||
@ -99,6 +143,15 @@ public abstract class CommonAbstractController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* creates an new entity.
|
||||
*
|
||||
* @param <T> the type of the entity to handle
|
||||
* @param entity the entity to create or update
|
||||
* @param createdBy the username to apply write into the audit history
|
||||
* @return the entity after it has been written to the database.
|
||||
* @throws ControllerException if the the creation fails
|
||||
*/
|
||||
@TransactionAttribute(TransactionAttributeType.REQUIRED)
|
||||
@Transactional
|
||||
@Lock(LockType.WRITE)
|
||||
@ -121,6 +174,15 @@ public abstract class CommonAbstractController {
|
||||
return entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* updates an existing entity.
|
||||
*
|
||||
* @param <T> the type of the entity to handle
|
||||
* @param entity the entity to update
|
||||
* @param updatedBy the username to apply write into the audit history
|
||||
* @return the entity after it has been written to the database.
|
||||
* @throws ControllerException if the the updates fails
|
||||
*/
|
||||
private <T extends Serializable> T executeUpdate(T entity, String updatedBy) throws ControllerException {
|
||||
T currentEntity = attach(entity);
|
||||
if (Auditable.class.isAssignableFrom(currentEntity.getClass())) {
|
||||
@ -145,6 +207,15 @@ public abstract class CommonAbstractController {
|
||||
return currentEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* updates an existing entity.
|
||||
*
|
||||
* @param <T> the type of the entity to handle
|
||||
* @param entity the entity to update
|
||||
* @param updatedBy the username to apply write into the audit history
|
||||
* @return the entity after it has been written to the database.
|
||||
* @throws ControllerException if the the updates fails
|
||||
*/
|
||||
@TransactionAttribute(TransactionAttributeType.REQUIRED)
|
||||
@Transactional
|
||||
@Lock(LockType.WRITE)
|
||||
@ -161,6 +232,16 @@ public abstract class CommonAbstractController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an entity from the database. If the entity implements the
|
||||
* {@link EndDateable} interface, the entity is not deleted but marked as
|
||||
* deleted (end date set).
|
||||
*
|
||||
* @param <T> the type of the entity to handle
|
||||
* @param entity the entity to delete
|
||||
* @param deletedBy the username to apply write into the audit history
|
||||
* @throws ControllerException if the deletion fails.
|
||||
*/
|
||||
@TransactionAttribute(TransactionAttributeType.REQUIRED)
|
||||
@Transactional
|
||||
@Lock(LockType.WRITE)
|
||||
@ -174,20 +255,53 @@ public abstract class CommonAbstractController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* attaches the given entity
|
||||
*
|
||||
* @param <T> the type of the entity to handle
|
||||
* @param entity the entity to attach
|
||||
* @return the entity after it has been attached
|
||||
*/
|
||||
public <T extends Serializable> T attach(T entity) {
|
||||
return em.merge(entity);
|
||||
}
|
||||
|
||||
public <T extends Serializable> void refresh (T entity) {
|
||||
/**
|
||||
* Refreshes an entity.
|
||||
*
|
||||
* @param <T> the type of the entity to handle
|
||||
* @param entity the entity after it has been refreshed.
|
||||
*/
|
||||
public <T extends Serializable> void refresh(T entity) {
|
||||
em.refresh(entity);
|
||||
}
|
||||
|
||||
|
||||
/* *** filter methods *** */
|
||||
/**
|
||||
* Creates a filter condition.
|
||||
*
|
||||
* @param <T> the type of the entity to handle
|
||||
* @param cb the CriteriaBuilder to use
|
||||
* @param root the root to use
|
||||
* @param filters the filters to use
|
||||
* @return the created filter condition
|
||||
*/
|
||||
protected <T extends Serializable> Predicate getFilterCondition(CriteriaBuilder cb, Root<T> root, Map<String, Object> filters) {
|
||||
return getFilterCondition(cb, root, filters, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a filter condition.
|
||||
*
|
||||
* @param <T> the type of the entity to handle
|
||||
* @param cb the CriteriaBuilder to use
|
||||
* @param root the root to use
|
||||
* @param filters the filters to use
|
||||
* @param excludeFilters the exclude filters to apply. Entities which match
|
||||
* these filters, are not taken into the result list.
|
||||
* @return the created filter condition
|
||||
*/
|
||||
protected <T extends Serializable> Predicate getFilterCondition(CriteriaBuilder cb, Root<T> root, Map<String, Object> filters, Map<String, Object> excludeFilters) {
|
||||
// Predicate filterCondition = null;
|
||||
// filterCondition = getFilterCondition(filterCondition, cb, root, filters, true);
|
||||
@ -208,14 +322,17 @@ public abstract class CommonAbstractController {
|
||||
}
|
||||
|
||||
/**
|
||||
* extends the given filterCondition by the addtional filters
|
||||
* extends the given filterCondition by the additional filters
|
||||
*
|
||||
* @param <T> the type of the entity to handle
|
||||
* @param filterCondition the current filter condition
|
||||
* @param cb the criteria builder to use
|
||||
* @param root the root of the object to search for
|
||||
* @param filters the filters to apply
|
||||
* @param include if set to true, the filter is used as include filter (equals, in). If set to false, the filter is inverted and used as exclude filter (not equals, not in etc)
|
||||
* @return
|
||||
* @param include if set to true, the filter is used as include filter
|
||||
* (equals, in). If set to false, the filter is inverted and used as exclude
|
||||
* filter (not equals, not in etc)
|
||||
* @return the created filter condition
|
||||
*/
|
||||
protected <T extends Serializable> Predicate getFilterCondition(Predicate filterCondition, CriteriaBuilder cb, Root<T> root, Map<String, Object> filters, boolean include) {
|
||||
String wildCard = "%";
|
||||
@ -301,6 +418,14 @@ public abstract class CommonAbstractController {
|
||||
return filterCondition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a filter condition to an existing condition
|
||||
*
|
||||
* @param cb the builder to use
|
||||
* @param filterCondition the existing filter condition
|
||||
* @param addCondition the condition to add to the existing condition.
|
||||
* @return an updated filter condition.
|
||||
*/
|
||||
protected Predicate addFilterCondition(CriteriaBuilder cb, Predicate filterCondition, Predicate addCondition) {
|
||||
if (addCondition == null) {
|
||||
return filterCondition;
|
||||
@ -327,20 +452,23 @@ public abstract class CommonAbstractController {
|
||||
}
|
||||
|
||||
/**
|
||||
* returns null, if the list is empty or null itself. Returns the one element if there is exactly one element in the list. Otherwise an exception is thrown
|
||||
* returns null, if the list is empty or null itself.Returns the one element
|
||||
* if there is exactly one element in the list. Otherwise an exception is
|
||||
* thrown
|
||||
*
|
||||
* @param resultList
|
||||
* @return
|
||||
* @throws ControllerException
|
||||
* @param <T> the type of the entity to handle
|
||||
* @param entityList the list to validate
|
||||
* @return the one and only element of the provided list
|
||||
* @throws ControllerException if the list contains more than one element.
|
||||
*/
|
||||
public <T> T ensureSingleElement(List<T> resultList) throws ControllerException {
|
||||
if ((resultList == null) || (resultList.isEmpty())) {
|
||||
public <T> T ensureSingleElement(List<T> entityList) throws ControllerException {
|
||||
if ((entityList == null) || (entityList.isEmpty())) {
|
||||
return null;
|
||||
}
|
||||
if (resultList.size() > 1) {
|
||||
if (entityList.size() > 1) {
|
||||
throw new ControllerException(ControllerException.CAUSE_TOO_MANY_ROWS, "More than one element found in list - expected exactly one");
|
||||
}
|
||||
return resultList.get(0);
|
||||
return entityList.get(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -20,7 +20,7 @@ import javax.faces.application.FacesMessage.Severity;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class DefaultUIMessage implements UIMessage {
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ import org.hibernate.usertype.UserType;
|
||||
/**
|
||||
* http://octagen.at/2014/10/postgresql-custom-data-types-enum-in-hibernate/
|
||||
*
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public abstract class GenericEnumType<T, E extends Enum<E>> implements UserType, Serializable {
|
||||
|
||||
|
||||
@ -44,11 +44,6 @@ limitations under the License.
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.enterprisedt</groupId>
|
||||
<artifactId>edtFTPj</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
|
||||
@ -1,253 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Joern Muehlencord (joern@muehlencord.de).
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package de.muehlencord.shared.network.ftp;
|
||||
|
||||
import com.enterprisedt.net.ftp.FTPClient;
|
||||
import com.enterprisedt.net.ftp.FTPConnectMode;
|
||||
import com.enterprisedt.net.ftp.FTPException;
|
||||
import com.enterprisedt.net.ftp.FTPFile;
|
||||
import de.muehlencord.shared.util.StringUtil;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
/**
|
||||
*
|
||||
* @author joern@muehlencord.de
|
||||
*/
|
||||
public class FTPConnection {
|
||||
|
||||
/** the default timeout in ms */
|
||||
public static final int DEFAULTTIMEOUT = 30000;
|
||||
/** the logger object */
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(FTPConnection.class);
|
||||
/** the username to connect with */
|
||||
private String userName;
|
||||
/** the password to connect with */
|
||||
private String password;
|
||||
/** the ftp client to use */
|
||||
private FTPClient client;
|
||||
/** the remote host to connect to */
|
||||
private String remoteHost;
|
||||
/** the locale of the client to use */
|
||||
private Locale clientLocale;
|
||||
|
||||
/**
|
||||
* creates a new ftp connection
|
||||
*
|
||||
* @param remoteHost the host to connect to
|
||||
* @param userName the user to connect with
|
||||
* @param password the password to connect with
|
||||
*/
|
||||
public FTPConnection(String remoteHost, String userName, String password) {
|
||||
this(remoteHost, userName, password, Locale.getDefault());
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a new ftp connection
|
||||
*
|
||||
* @param remoteHost the host to connect to
|
||||
* @param userName the user to connect with
|
||||
* @param password the password to connect with
|
||||
* @param clientLocale the locale to use for the client
|
||||
*/
|
||||
public FTPConnection(String remoteHost, String userName, String password, Locale clientLocale) {
|
||||
this.remoteHost = remoteHost;
|
||||
this.userName = userName;
|
||||
this.password = password;
|
||||
this.clientLocale = clientLocale;
|
||||
}
|
||||
|
||||
/**
|
||||
* connects the ftp client to the remote host
|
||||
*
|
||||
* @throws FTPConnectionException if the command cannot be executed
|
||||
*/
|
||||
public void connect() throws FTPConnectionException {
|
||||
try {
|
||||
client = new FTPClient();
|
||||
client.setConnectMode(FTPConnectMode.PASV);
|
||||
client.setParserLocale(clientLocale);
|
||||
client.setRemoteHost(remoteHost);
|
||||
client.setTimeout(DEFAULTTIMEOUT);
|
||||
client.connect();
|
||||
client.login(userName, password);
|
||||
} catch (Exception ex) {
|
||||
throw new FTPConnectionException("Error while connecting to ftp client. Reason: " + ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
/** disconnects the ftp client from the remote host */
|
||||
public void disconnect() {
|
||||
try {
|
||||
client.quit();
|
||||
} catch (IOException | FTPException ex) {
|
||||
LOGGER.error(ex.getMessage());
|
||||
LOGGER.debug(StringUtil.getStackTraceString(ex));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a list of files (as string) found in the given directory
|
||||
*
|
||||
* @param dir the directory to return the list for
|
||||
* @return a list of files (as string) found in the given directory
|
||||
*
|
||||
* @throws FTPConnectionException if the command cannot be executed
|
||||
*/
|
||||
public List<String> list(String dir) throws FTPConnectionException {
|
||||
List<String> returnValue = new LinkedList<>();
|
||||
try {
|
||||
FTPFile[] files = client.dirDetails(dir);
|
||||
for (FTPFile file : files) {
|
||||
returnValue.add(file.getName());
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LOGGER.error(ex.getMessage());
|
||||
LOGGER.debug(StringUtil.getStackTraceString(ex));
|
||||
throw new FTPConnectionException("Error while getting diretoy listing. Reason: " + ex.getMessage(), ex);
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a list of directories contained in given directory
|
||||
*
|
||||
* @param dir the directory to return the subfolders for
|
||||
* @return a list of subfolders of the given directory
|
||||
*
|
||||
* @throws FTPConnectionException if the command cannot be executed
|
||||
*/
|
||||
public List<String> listDirsOnly(String dir) throws FTPConnectionException {
|
||||
List<String> returnValue = new LinkedList<>();
|
||||
try {
|
||||
FTPFile[] files = client.dirDetails(dir);
|
||||
for (FTPFile file : files) {
|
||||
if (file.isDir()) {
|
||||
returnValue.add(file.getName());
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LOGGER.error(ex.getMessage());
|
||||
LOGGER.debug(StringUtil.getStackTraceString(ex));
|
||||
throw new FTPConnectionException("Error while getting diretoy listing. Reason: " + ex.getMessage(), ex);
|
||||
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a list of files contained in the given folder
|
||||
*
|
||||
* @param dir the directory to list
|
||||
* @return a list of files contained in the given folder
|
||||
*
|
||||
* @throws FTPConnectionException if the command cannot be executed
|
||||
*/
|
||||
public List<String> listFilesOnly(String dir) throws FTPConnectionException {
|
||||
List<String> returnValue = new LinkedList<>();
|
||||
try {
|
||||
FTPFile[] files = client.dirDetails(dir);
|
||||
for (FTPFile file : files) {
|
||||
if (!file.isDir()) {
|
||||
returnValue.add(file.getName());
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LOGGER.error(ex.getMessage());
|
||||
LOGGER.debug(StringUtil.getStackTraceString(ex));
|
||||
throw new FTPConnectionException("Error while getting diretoy listing. Reason: " + ex.getMessage(), ex);
|
||||
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a list of links contained in the given folder
|
||||
*
|
||||
* @param dir the directory to list
|
||||
* @return a list of links contained in the given folder
|
||||
*
|
||||
* @throws FTPConnectionException if the command cannot be executed
|
||||
*/
|
||||
public List<String> listLinksOnly(String dir) throws FTPConnectionException {
|
||||
List<String> returnValue = new LinkedList<>();
|
||||
try {
|
||||
FTPFile[] files = client.dirDetails(dir);
|
||||
for (FTPFile file : files) {
|
||||
if (file.isLink()) {
|
||||
returnValue.add(file.getName());
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LOGGER.error(ex.getMessage());
|
||||
LOGGER.debug(StringUtil.getStackTraceString(ex));
|
||||
throw new FTPConnectionException("Error while getting diretoy listing. Reason: " + ex.getMessage(), ex);
|
||||
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* uploads the given file and stores it under the given remote filename - including path
|
||||
*
|
||||
* @param localFilename the path and filename of the source file
|
||||
* @param remoteFileName the path and filename of the destination file
|
||||
* @throws FTPConnectionException if the command cannot be executed
|
||||
*/
|
||||
public void uploadFile(String localFilename, String remoteFileName) throws FTPConnectionException {
|
||||
|
||||
try {
|
||||
client.setDetectTransferMode(true);
|
||||
if ((remoteFileName != null) && !remoteFileName.equals("")) {
|
||||
client.put(localFilename, remoteFileName, false);
|
||||
} else {
|
||||
File f = new File(localFilename);
|
||||
String remoteName = f.getName();
|
||||
client.put(localFilename, remoteName, false);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LOGGER.error(ex.getMessage());
|
||||
LOGGER.debug(StringUtil.getStackTraceString(ex));
|
||||
throw new FTPConnectionException("Error while uploading file. Reason: " + ex.getMessage(), ex);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* renames a file on the remote host
|
||||
*
|
||||
* @param remoteOldName the current file name
|
||||
* @param remoteNewName the new file name
|
||||
* @throws FTPConnectionException if the command cannot be executed
|
||||
*/
|
||||
public void rename(String remoteOldName, String remoteNewName) throws FTPConnectionException {
|
||||
try {
|
||||
client.rename(remoteOldName, remoteNewName);
|
||||
} catch (Exception ex) {
|
||||
LOGGER.error(ex.getMessage());
|
||||
LOGGER.debug(StringUtil.getStackTraceString(ex));
|
||||
throw new FTPConnectionException("Error while renaming file. Reason: " + ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Joern Muehlencord (joern@muehlencord.de).
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package de.muehlencord.shared.network.ftp;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class FTPConnectionException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 1001347648193052240L;
|
||||
|
||||
|
||||
/**
|
||||
* Constructs an instance of
|
||||
* <code>FTPConnectionException</code> with the specified detail message.
|
||||
*
|
||||
* @param msg the detail message.
|
||||
*/
|
||||
public FTPConnectionException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an instance of
|
||||
* <code>FTPConnectionException</code> with the specified detail message.
|
||||
*
|
||||
* @param msg the detail message.
|
||||
* @param th the causing exception
|
||||
*/
|
||||
public FTPConnectionException(String msg, Throwable th) {
|
||||
super(msg, th);
|
||||
}
|
||||
}
|
||||
@ -36,7 +36,7 @@ import org.slf4j.LoggerFactory;
|
||||
/**
|
||||
* Communication endpoint for posting a messages
|
||||
*
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class HttpLayer {
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ package de.muehlencord.shared.network.http;
|
||||
|
||||
/**
|
||||
* This message is thrown if a message cannot be sent
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class MessageNotSendException extends Exception {
|
||||
|
||||
|
||||
@ -25,9 +25,10 @@ import javax.naming.ldap.InitialLdapContext;
|
||||
import javax.naming.ldap.LdapContext;
|
||||
|
||||
/**
|
||||
* Inits and holds a connection to an ldap address directory
|
||||
* @see javax.naming.ldap.LdapContext;
|
||||
* @author dennis.nobel
|
||||
* Initializes and holds a connection to an LDAP address directory
|
||||
* {@link javax.naming.ldap.LdapContext}
|
||||
*
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class LDAPConnection {
|
||||
|
||||
@ -91,7 +92,7 @@ public class LDAPConnection {
|
||||
}
|
||||
|
||||
/**
|
||||
* intializes connection to AD
|
||||
* initialize connection to AD
|
||||
* @throws NamingException is thrown if connection to LDAP failed
|
||||
*/
|
||||
protected void init() throws NamingException {
|
||||
@ -108,14 +109,21 @@ public class LDAPConnection {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.naming.ldap.LdapContext;
|
||||
* {@link javax.naming.ldap.LdapContext}
|
||||
*
|
||||
* @param name the name to search for
|
||||
* @param filter the filter to apply
|
||||
* @param cons the search controls to use
|
||||
* @return the result returned by the LDAP server
|
||||
* @throws NamingException it the search fails
|
||||
*/
|
||||
public NamingEnumeration<SearchResult> search(String name, String filter, SearchControls cons) throws NamingException {
|
||||
return ldapContext.search(name, filter, cons);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.naming.ldap.LdapContext;
|
||||
* @throws javax.naming.NamingException if the close operation fails
|
||||
* {@link javax.naming.ldap.LdapContext}
|
||||
*/
|
||||
public void close() throws NamingException {
|
||||
if (ldapContext != null) {
|
||||
|
||||
@ -16,9 +16,9 @@
|
||||
package de.muehlencord.shared.network.ldap;
|
||||
|
||||
/**
|
||||
* Represents a contact in ldap address directory
|
||||
* Represents a contact in LDAP address directory
|
||||
*
|
||||
* @author Joern Muehlencord
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class LDAPContact {
|
||||
|
||||
@ -46,6 +46,8 @@ public class LDAPContact {
|
||||
private boolean isEnabled = false;
|
||||
private String distinguishedName = null;
|
||||
|
||||
/* *** getter / setter *** */
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@ -29,38 +29,45 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Connection to ldap server to searh by different values
|
||||
* Connection to LDAP server to search by different values
|
||||
*
|
||||
* @author Joern Muehlencord
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class LDAPSearch {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(LDAPSearch.class);
|
||||
|
||||
/**
|
||||
* the ldap connection to use
|
||||
* the LDAP connection to use
|
||||
*/
|
||||
private LDAPConnection ldapConnection;
|
||||
/**
|
||||
* the search base for all queries
|
||||
*/
|
||||
private String searchBase;
|
||||
private final String searchBase;
|
||||
|
||||
/**
|
||||
* Creates a new instance of a ldap search.
|
||||
* Creates a new instance of a LDAP search.
|
||||
*
|
||||
* <p>
|
||||
* Important: <br> If you want to use ldaps - usually port 636 make sure you provide a trustkeystore in case your ldap server does not use a certificate which can be trusted by the build in root
|
||||
* certificates. (e.g. self signed certificates) </p>
|
||||
* <div>
|
||||
* Important: <br> If you want to use LDAPs - usually port 636 make sure you
|
||||
* provide a trustkeystore in case your LDAP server does not use a
|
||||
* certificate which can be trusted by the build in root certificates. (e.g.
|
||||
* self signed certificates)
|
||||
* </div>
|
||||
*
|
||||
* <p>
|
||||
* To provide access to a trust center you can specify the following parameter to your application by providing the following parameter
|
||||
* <div>
|
||||
* To provide access to a trust center you can specify the following
|
||||
* parameter to your application by providing the following parameter
|
||||
* <pre>
|
||||
* -Djavax.net.ssl.trustStore=/path/to/truststore.keystore
|
||||
* </pre> </p>
|
||||
* </pre>
|
||||
* </div>
|
||||
*
|
||||
* @param url the url of the ldap server to connect to like <code>ldap://ldapserver.your.domain:389</code>
|
||||
* @param searchBase the search base to use - e.g. <code>DC=domain,DC=tld</code>
|
||||
* @param url the url of the LDAP server to connect to like
|
||||
* <code>ldap://ldapserver.your.domain:389</code>
|
||||
* @param searchBase the search base to use - e.g.
|
||||
* <code>DC=domain,DC=tld</code>
|
||||
* @param username the username to connect with
|
||||
* @param password the password to connect with
|
||||
*/
|
||||
@ -73,22 +80,29 @@ public class LDAPSearch {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance of a ldap search.
|
||||
* Creates a new instance of a LDAP search.
|
||||
*
|
||||
* <p>
|
||||
* Important: <br> If you want to use ldaps - usually port 636 make sure you provide a trustkeystore in case your ldap server does not use a certificate which can be trusted by the build in root
|
||||
* certificates. (e.g. self signed certificates) </p>
|
||||
* <div>
|
||||
* Important: <br> If you want to use LDAPs - usually port 636 make sure you
|
||||
* provide a trustkeystore in case your LDAP server does not use a
|
||||
* certificate which can be trusted by the build in root certificates. (e.g.
|
||||
* self signed certificates)
|
||||
* </div>
|
||||
*
|
||||
* <p>
|
||||
* To provide access to a trust center you can specify the following parameter to your application by providing the following parameter
|
||||
* <div>
|
||||
* To provide access to a trust center you can specify the following
|
||||
* parameter to your application by providing the following parameter
|
||||
* <pre>
|
||||
* -Djavax.net.ssl.trustStore=/path/to/truststore.keystore
|
||||
* </pre> </p>
|
||||
* </pre>
|
||||
* </div>
|
||||
*
|
||||
* @param authentication the authentification type to use -e.g. "SIMPLE"
|
||||
* @param url the url of the ldap server to connect to like <code>ldap://ldapserver.your.domain:389</code>
|
||||
* @param url the url of the ldap server to connect to like
|
||||
* <code>ldap://ldapserver.your.domain:389</code>
|
||||
* @param securityProtocol the security protocol to use - e.g. SIMPLE
|
||||
* @param searchBase the search base to use - e.g. <code>DC=domain,DC=tld</code>
|
||||
* @param searchBase the search base to use - e.g.
|
||||
* <code>DC=domain,DC=tld</code>
|
||||
* @param username the username to connect with
|
||||
* @param password the password to connect with
|
||||
*/
|
||||
@ -98,7 +112,10 @@ public class LDAPSearch {
|
||||
}
|
||||
|
||||
/**
|
||||
* execute several init steps, connect to ldap
|
||||
* execute several init steps, connect to LDAP
|
||||
*
|
||||
* @throws de.muehlencord.shared.network.ldap.LDAPException if the
|
||||
* connection cannot be established
|
||||
*/
|
||||
public void init() throws LDAPException {
|
||||
try {
|
||||
@ -109,7 +126,10 @@ public class LDAPSearch {
|
||||
}
|
||||
|
||||
/**
|
||||
* close the ldap connection
|
||||
* close the LDAP connection
|
||||
*
|
||||
* @throws de.muehlencord.shared.network.ldap.LDAPException if an error
|
||||
* during closing appears.
|
||||
*/
|
||||
public void close() throws LDAPException {
|
||||
if (ldapConnection != null) {
|
||||
@ -123,9 +143,9 @@ public class LDAPSearch {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the search base of the ldap connection
|
||||
* Returns the search base of the LDAP connection
|
||||
*
|
||||
* @return the search base of the ldap connection
|
||||
* @return the search base of the LDAP connection
|
||||
*/
|
||||
public String getSearchBase() {
|
||||
return searchBase;
|
||||
@ -135,7 +155,7 @@ public class LDAPSearch {
|
||||
* Searches a contact according to emailaddress in the address directory
|
||||
*
|
||||
* @param email emailaddress to search for
|
||||
* @return ldap contact or null if nothing could be found
|
||||
* @return LDAP contact or null if nothing could be found
|
||||
* @throws LDAPException when search fails
|
||||
*/
|
||||
public LDAPContact searchContactWithEmail(String email) throws LDAPException {
|
||||
@ -182,9 +202,10 @@ public class LDAPSearch {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true, if the given email address can be found in the configured ldap
|
||||
* Returns true, if the given email address can be found in the configured
|
||||
* LDAP.
|
||||
*
|
||||
* @param email the emailaddress to search for
|
||||
* @param email the email address to search for
|
||||
* @return true, if the email address could be found; else false
|
||||
* @throws LDAPException if the search fails
|
||||
*/
|
||||
@ -193,11 +214,16 @@ public class LDAPSearch {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true, if the given email address is member of the given group, specified by the DN
|
||||
* Returns true, if the given email address is member of the given group,
|
||||
* specified by the DN
|
||||
*
|
||||
* @param email the email to validat
|
||||
* @param groupDn the group search base - all members must be found as "member" in this group
|
||||
* @return
|
||||
* @param email the email to validate
|
||||
* @param groupDn the group search base - all members must be found as
|
||||
* "member" in this group
|
||||
* @return true, if the given contact, specified by the email address is
|
||||
* member of the specified group. Otherwise false is returned.
|
||||
*
|
||||
* @throws de.muehlencord.shared.network.ldap.LDAPException
|
||||
*/
|
||||
public boolean isMemberOfGroup(String email, String groupDn) throws LDAPException {
|
||||
boolean returnValue = false;
|
||||
|
||||
@ -36,7 +36,7 @@ import org.slf4j.LoggerFactory;
|
||||
/**
|
||||
* MailReader to connect and work with IMAP mailboxes. Also works with exchange servers.
|
||||
*
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public abstract class DefaultMailReader implements MailReader {
|
||||
|
||||
@ -57,7 +57,7 @@ public abstract class DefaultMailReader implements MailReader {
|
||||
}
|
||||
|
||||
/**
|
||||
* onnects to the mailbox
|
||||
* connects to the mailbox
|
||||
*
|
||||
* @throws MailReaderConnectionException if the connection cannot be established
|
||||
*/
|
||||
@ -486,8 +486,8 @@ public abstract class DefaultMailReader implements MailReader {
|
||||
}
|
||||
|
||||
/**
|
||||
* asures the message can be read even if the underlaying IMAP server does not handle the message correctly. see
|
||||
* http://www.oracle.com/technetwork/java/faq-135477.html for details
|
||||
* ensure the message can be read even if the underlaying IMAP server does not handle the message correctly. see
|
||||
* @see <a href="https://www.oracle.com/technetwork/java/faq-135477.html">https://www.oracle.com/technetwork/java/faq-135477.html</a>
|
||||
*
|
||||
* @param msg the message to read
|
||||
* @return the message in a readable format
|
||||
|
||||
@ -25,7 +25,7 @@ import javax.mail.internet.InternetAddress;
|
||||
/**
|
||||
* A mail message
|
||||
*
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class MailMessage {
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ package de.muehlencord.shared.network.mail;
|
||||
|
||||
/**
|
||||
* Exception used during mail handling
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class MailMessageException extends Exception {
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory;
|
||||
/**
|
||||
* Util class to convert between javax.mail.Message and MailMessage objects
|
||||
*
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public abstract class MailMessageUtils {
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public interface MailReader {
|
||||
|
||||
@ -85,6 +85,8 @@ public interface MailReader {
|
||||
* retrieves the list of messages stored in the given folder
|
||||
*
|
||||
* @param folder the folder to search return the emails for
|
||||
* @param start the number of the first message
|
||||
* @param end the number of the last message
|
||||
* @return list of messages stored in the given folder
|
||||
*
|
||||
* @throws MailReaderException if the message list cannot be retrieved
|
||||
|
||||
@ -22,11 +22,11 @@ package de.muehlencord.shared.network.mail;
|
||||
public class MailReaderConfiguration {
|
||||
|
||||
/**
|
||||
* server for smtp sessions
|
||||
* server for SMTP sessions
|
||||
*/
|
||||
private String smtpHost = null;
|
||||
/**
|
||||
* server for incoming emails - e.g. the imap or pop3 server
|
||||
* server for incoming emails - e.g. the IMAP or pop3 server
|
||||
*/
|
||||
private String readerHost = null;
|
||||
/**
|
||||
@ -47,11 +47,12 @@ public class MailReaderConfiguration {
|
||||
private MailProtocol protocol = null;
|
||||
|
||||
// TODO add checkConfig to asure the config is valid for the reader it is attached to
|
||||
|
||||
/**
|
||||
* creates a new config
|
||||
*
|
||||
* @param mailHost the smtp host to connect to
|
||||
* @param host the mailreader host (imap, exchange, pop, ...) to connect to
|
||||
* @param host the mailreader host (IMAP, exchange, pop, ...) to connect to
|
||||
* @param user the username to connect with
|
||||
* @param pw the password to connect with
|
||||
*/
|
||||
@ -69,6 +70,7 @@ public class MailReaderConfiguration {
|
||||
* @param host the mailreader host (imap, exchange, pop, ...) to connect to
|
||||
* @param user the username to connect with
|
||||
* @param pw the password to connect with
|
||||
* @param email the email address to use for sending emails
|
||||
*/
|
||||
public MailReaderConfiguration(String mailHost, String host, String user, String pw, String email) {
|
||||
this.smtpHost = mailHost;
|
||||
|
||||
@ -17,7 +17,7 @@ package de.muehlencord.shared.network.mail;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class MailReaderConfigurationException extends Exception {
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public abstract class MailReaderConfigurationFactory {
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ import org.slf4j.LoggerFactory;
|
||||
/**
|
||||
* Implementation of MailReader to connect to an IMAP server
|
||||
*
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class ImapMailReader extends DefaultMailReader {
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class ArinWhoisParser extends AbstractWhoisParser implements WhoisParser {
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ import org.apache.commons.net.whois.WhoisClient;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class Whois {
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class WhoisInformation {
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ import java.io.InputStream;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public abstract class BaseTest {
|
||||
|
||||
|
||||
@ -1,166 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Joern Muehlencord (joern@muehlencord.de).
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package de.muehlencord.shared.network.ftp;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class FTPConnectionTest {
|
||||
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(FTPConnectionTest.class.getName());
|
||||
|
||||
/** the properties loaded from the config file */
|
||||
Properties props = null;
|
||||
/** true, if init is complete to execute test */
|
||||
boolean initDone = false;
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
System.out.println("\n[FTPConnectionTest]");
|
||||
URL testConfigURL = FTPConnectionTest.class.getResource("/test.properties");
|
||||
FileInputStream fin = null;
|
||||
try {
|
||||
File file = new File(testConfigURL.toURI());
|
||||
props = new Properties();
|
||||
if ((file == null) || (!file.exists())) {
|
||||
initDone = false;
|
||||
|
||||
} else {
|
||||
fin = new FileInputStream(file);
|
||||
props.load(fin);
|
||||
}
|
||||
if ((props.containsKey("ftp.host")) && (props.containsKey("ftp.user")) && (props.containsKey("ftp.password")) && (props.containsKey("ftp.locale"))) {
|
||||
initDone = true;
|
||||
} else {
|
||||
initDone = false;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
initDone = false;
|
||||
} finally {
|
||||
try {
|
||||
if (fin != null) {
|
||||
fin.close();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
LOGGER.error (ex.toString(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** tests connect / disconnect */
|
||||
@Test
|
||||
public void testConnectAndDisconnect() throws FTPConnectionException {
|
||||
System.out.println("testConnectAndDisconnect");
|
||||
if (initDone) {
|
||||
String remoteHost = props.getProperty("ftp.host");
|
||||
String user = props.getProperty("ftp.user");
|
||||
String password = props.getProperty("ftp.password");
|
||||
Locale locale = new Locale(props.getProperty("ftp.locale"));
|
||||
|
||||
FTPConnection con = new FTPConnection(remoteHost, user, password, locale);
|
||||
con.connect();
|
||||
con.disconnect();
|
||||
System.out.println("executed successfully");
|
||||
} else {
|
||||
System.out.println("Skipped because config is not complete");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void testList() throws FTPConnectionException {
|
||||
System.out.println("list");
|
||||
String dir = "";
|
||||
FTPConnection instance = null;
|
||||
List expResult = null;
|
||||
List result = instance.list(dir);
|
||||
assertEquals(expResult, result);
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void testListDirsOnly() throws FTPConnectionException {
|
||||
System.out.println("listDirsOnly");
|
||||
String dir = "";
|
||||
FTPConnection instance = null;
|
||||
List expResult = null;
|
||||
List result = instance.listDirsOnly(dir);
|
||||
assertEquals(expResult, result);
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void testListFilesOnly() throws FTPConnectionException {
|
||||
System.out.println("listFilesOnly");
|
||||
String dir = "";
|
||||
FTPConnection instance = null;
|
||||
List expResult = null;
|
||||
List result = instance.listFilesOnly(dir);
|
||||
assertEquals(expResult, result);
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void testListLinksOnly() throws FTPConnectionException {
|
||||
System.out.println("listLinksOnly");
|
||||
String dir = "";
|
||||
FTPConnection instance = null;
|
||||
List expResult = null;
|
||||
List result = instance.listLinksOnly(dir);
|
||||
assertEquals(expResult, result);
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void testUploadFile() throws FTPConnectionException {
|
||||
System.out.println("uploadFile");
|
||||
String localFilename = "";
|
||||
String remoteFileName = "";
|
||||
FTPConnection instance = null;
|
||||
instance.uploadFile(localFilename, remoteFileName);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void testRename() throws FTPConnectionException {
|
||||
System.out.println("rename");
|
||||
String remoteOldName = "";
|
||||
String remoteNewName = "";
|
||||
FTPConnection instance = null;
|
||||
instance.rename(remoteOldName, remoteNewName);
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
}
|
||||
@ -38,8 +38,7 @@ public class HttpLayerTest extends BaseTest {
|
||||
String[] value = {"Hello World!", "Hello World again"};
|
||||
map.put("message", value);
|
||||
|
||||
HttpLayer httpLayer = new HttpLayer(
|
||||
"http://localhost:8080/HttpPostListener/HttpPostListener");
|
||||
HttpLayer httpLayer = new HttpLayer("http://localhost:8080/HttpPostListener/HttpPostListener");
|
||||
httpLayer.post(map);
|
||||
}
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class MailMessageUtilsTest extends BaseTest {
|
||||
|
||||
|
||||
183
pom.xml
183
pom.xml
@ -22,6 +22,7 @@ limitations under the License.
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>shared</name>
|
||||
|
||||
<modules>
|
||||
<module>configuration</module>
|
||||
<module>network</module>
|
||||
@ -34,10 +35,43 @@ limitations under the License.
|
||||
</modules>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:https://jomu.timelord.de/git/jomu/shared/</connection>
|
||||
<developerConnection>scm:git:https://jomu.timelord.de/git/jomu/shared/</developerConnection>
|
||||
<url>https://jomu.timelord.de/git/jomu/shared/</url>
|
||||
<tag>HEAD</tag>
|
||||
</scm>
|
||||
|
||||
<issueManagement>
|
||||
<system>Gitea</system>
|
||||
<url>https://jomu.timelord.de/git/jomu/shared/issues</url>
|
||||
</issueManagement>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<name>Joern Muehlencord</name>
|
||||
<email>joern@muehlencord.de</email>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>ossrh</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>ossrh</id>
|
||||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
<properties>
|
||||
<!-- project setup -->
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
@ -68,11 +102,6 @@ limitations under the License.
|
||||
<artifactId>shared-jeeutil</artifactId>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.muehlencord.sf</groupId>
|
||||
<artifactId>filter</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
@ -157,13 +186,6 @@ limitations under the License.
|
||||
<version>7.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.enterprisedt</groupId>
|
||||
<artifactId>edtFTPj</artifactId>
|
||||
<version>1.5.3</version> <!--FIXME - requires update -->
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.lambdaworks</groupId>
|
||||
<artifactId>scrypt</artifactId>
|
||||
@ -207,18 +229,6 @@ limitations under the License.
|
||||
<artifactId>omnifaces</artifactId>
|
||||
<version>3.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.faces</groupId>
|
||||
<artifactId>jsf-api</artifactId>
|
||||
<version>2.2.20</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.el</groupId>
|
||||
<artifactId>javax.el-api</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
@ -237,25 +247,106 @@ limitations under the License.
|
||||
<version>5.5.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>2.28.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-junit-jupiter</artifactId>
|
||||
<version>2.28.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</dependencyManagement>
|
||||
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>release</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- deploy artifacts to maven repository -->
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>1.6.8</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<serverId>ossrh</serverId>
|
||||
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
|
||||
<autoReleaseAfterClose>true</autoReleaseAfterClose>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- ensure sources are build so they are also uploaded -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar-no-fork</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- ensure java doc is built -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.1.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- create license file -->
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>license-maven-plugin</artifactId>
|
||||
<version>1.14</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>download-licenses</id>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>download-licenses</goal>
|
||||
<goal>add-third-party</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<licensesOutputDirectory>${licenses.dir}</licensesOutputDirectory>
|
||||
<outputDirectory>${licenses.dir}</outputDirectory>
|
||||
<licenseMerges>
|
||||
<licenseMerge>The Apache Software License, Version 2.0|Apache 2|Apache License, Version 2.0|Apache Public License 2.0</licenseMerge>
|
||||
</licenseMerges>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- sign jar archives -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<version>1.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>sign</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<!-- build archive -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
@ -266,27 +357,21 @@ limitations under the License.
|
||||
<showDeprecation>true</showDeprecation>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>jaxb2-maven-plugin</artifactId>
|
||||
<version>2.5.0</version>
|
||||
</plugin>
|
||||
|
||||
<!-- build maven ejb artifacts -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-ejb-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<!-- switched to com.helger.maven - need to revert back to org.codehaus.mojo when jaxws-maven-plugin with JDK11 support has been released -->
|
||||
<groupId>com.helger.maven</groupId>
|
||||
<artifactId>jaxws-maven-plugin</artifactId>
|
||||
<version>2.6.2</version>
|
||||
</plugin>
|
||||
|
||||
<!-- create new releases -->
|
||||
<plugin>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
<version>2.5.3</version>
|
||||
</plugin>
|
||||
|
||||
<!-- control junit tests from maven build -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
@ -294,6 +379,8 @@ limitations under the License.
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
|
||||
@ -35,16 +35,6 @@ limitations under the License.
|
||||
<artifactId>shiro-web</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.faces</groupId>
|
||||
<artifactId>jsf-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.el</groupId>
|
||||
<artifactId>javax.el-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax</groupId>
|
||||
<artifactId>javaee-api</artifactId>
|
||||
|
||||
@ -25,7 +25,7 @@ import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class DateUtil {
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@ import java.util.Locale;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public abstract class OSUtil {
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ package de.muehlencord.shared.util;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class SecurityException extends Exception {
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ package de.muehlencord.shared.util;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class StringEncodingException extends Exception {
|
||||
|
||||
|
||||
@ -19,13 +19,12 @@ import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.text.ParseException;
|
||||
import java.util.HashMap;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public abstract class StringUtil {
|
||||
|
||||
@ -72,15 +71,11 @@ public abstract class StringUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* fills s with blanks if s < length
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* fills s with blanks if s < length
|
||||
*
|
||||
* @param length the needed length for this field
|
||||
* @param s the field to extend with blanks
|
||||
* @return s extended by trainling blanks. s.length == length
|
||||
* @return s extended by trailing blanks. s.length == length
|
||||
*/
|
||||
public static String getBlankedString(int length, String s) {
|
||||
if (s == null) {
|
||||
@ -100,7 +95,7 @@ public abstract class StringUtil {
|
||||
*
|
||||
* @param content the string to get the value from
|
||||
* @param keyWord1 the starting keyword
|
||||
* @param keyWord2 the end keywod
|
||||
* @param keyWord2 the end keyword
|
||||
* @return the string between keyword1 and keyword2
|
||||
* @throws ParseException if the value cannot be determined - e.g. if one of the keywords is not found
|
||||
*/
|
||||
|
||||
@ -23,7 +23,7 @@ import java.util.Map;
|
||||
/**
|
||||
* Defines possbile file Byte Order Marks used in files.
|
||||
*
|
||||
* @see http://en.wikipedia.org/wiki/Byte-order_mark
|
||||
* @see <a href="https://en.wikipedia.org/wiki/Byte-order_mark">https://en.wikipedia.org/wiki/Byte-order_mark</a>
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class BOM {
|
||||
|
||||
@ -29,7 +29,7 @@ public class BOMStripperInputStream extends PushbackInputStream {
|
||||
/**
|
||||
* List of all possible BOMS
|
||||
*
|
||||
* @see http://en.wikipedia.org/wiki/Byte-order_mark for details
|
||||
* @see <a href="https://en.wikipedia.org/wiki/Byte-order_mark">https://en.wikipedia.org/wiki/Byte-order_mark</a>
|
||||
*/
|
||||
protected static final int[][] BOMS = {
|
||||
BOM.BOM_UTF32_BE,
|
||||
|
||||
@ -19,7 +19,7 @@ import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class FileHandlingException extends Exception implements Serializable {
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public abstract class FileUtil {
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ import java.io.InputStream;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public abstract class DefaultTest {
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test;
|
||||
/**
|
||||
* Basic StringUtilTests
|
||||
*
|
||||
* @author joern@muehlencord.de
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class StringUtilTest extends DefaultTest {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user