refs #200: Create accouting-lib library
https://support.d4science.org/issues/200 Fixing validators git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@115254 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
6d4780e151
commit
4db4ebba0a
|
@ -17,10 +17,10 @@ import java.util.Map.Entry;
|
|||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.accounting.datamodel.validations.Aggregated;
|
||||
import org.gcube.accounting.datamodel.validations.FieldValidator;
|
||||
import org.gcube.accounting.datamodel.validations.Required;
|
||||
import org.gcube.accounting.datamodel.validations.ValidityChecker;
|
||||
import org.gcube.accounting.datamodel.decorators.AggregatedField;
|
||||
import org.gcube.accounting.datamodel.decorators.RequiredField;
|
||||
import org.gcube.accounting.datamodel.decorators.ValidatorAction;
|
||||
import org.gcube.accounting.datamodel.decorators.ValidatorField;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.NotEmpty;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.NotEmptyIfNotNull;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.ValidLong;
|
||||
|
@ -37,29 +37,29 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
|
|||
|
||||
private static Logger logger = LoggerFactory.getLogger(RawUsageRecord.class);
|
||||
|
||||
@Required @NotEmpty
|
||||
@RequiredField @NotEmpty
|
||||
public static final String ID = "id";
|
||||
@Required @NotEmpty
|
||||
@RequiredField @NotEmpty
|
||||
public static final String CREATOR_ID = "creatorId";
|
||||
@Required @NotEmpty
|
||||
@RequiredField @NotEmpty
|
||||
public static final String CONSUMER_ID = "consumerId";
|
||||
@Required @ValidLong
|
||||
@RequiredField @ValidLong
|
||||
public static final String CREATION_TIME = "creationTime";
|
||||
@Aggregated @ValidLong
|
||||
@AggregatedField @ValidLong
|
||||
protected static final String START_TIME = "startTime";
|
||||
@Aggregated @ValidLong
|
||||
@AggregatedField @ValidLong
|
||||
protected static final String END_TIME = "endTime";
|
||||
@Required @NotEmpty
|
||||
@RequiredField @NotEmpty
|
||||
protected static final String RESOURCE_TYPE = "resourceType";
|
||||
@Required @NotEmpty
|
||||
@RequiredField @NotEmpty
|
||||
public static final String RESOURCE_SCOPE = "resourceScope";
|
||||
@NotEmpty
|
||||
protected static final String RESOURCE_OWNER = "resourceOwner";
|
||||
@Aggregated @NotEmptyIfNotNull
|
||||
@AggregatedField @NotEmptyIfNotNull
|
||||
protected static final String AGGREGATED_ID = "aggregatedId";
|
||||
@NotEmptyIfNotNull
|
||||
protected static final String AGGREGATED_USAGE_RECORD_ID = "aggregatedUsageRecordId";
|
||||
@Required @ValidOperationResult
|
||||
@RequiredField @ValidOperationResult
|
||||
public static final String OPERATION_RESULT = "operationResult";
|
||||
|
||||
/**
|
||||
|
@ -72,7 +72,7 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
|
|||
*/
|
||||
protected Map<String, Serializable> resourceSpecificProperties;
|
||||
|
||||
protected final Map<String, List<FieldValidator>> validation;
|
||||
protected final Map<String, List<ValidatorAction>> validation;
|
||||
|
||||
protected void initializeValidation() {
|
||||
logger.debug("Initializing Field Validators");
|
||||
|
@ -84,12 +84,12 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
|
|||
} catch (Exception e) {
|
||||
continue;
|
||||
}
|
||||
List<FieldValidator> fieldValidators = new ArrayList<FieldValidator>();
|
||||
List<ValidatorAction> fieldValidators = new ArrayList<ValidatorAction>();
|
||||
validation.put(keyString, fieldValidators);
|
||||
for (Annotation annotation : field.getAnnotations()){
|
||||
if (annotation.annotationType().isAnnotationPresent(ValidityChecker.class)){
|
||||
Class<? extends FieldValidator> managedClass = ((ValidityChecker)annotation.annotationType().getAnnotation(ValidityChecker.class)).managed();
|
||||
FieldValidator validator;
|
||||
if (annotation.annotationType().isAnnotationPresent(ValidatorField.class)){
|
||||
Class<? extends ValidatorAction> managedClass = ((ValidatorField)annotation.annotationType().getAnnotation(ValidatorField.class)).managed();
|
||||
ValidatorAction validator;
|
||||
try {
|
||||
validator = managedClass.newInstance();
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
|
@ -104,7 +104,7 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
|
|||
|
||||
protected RawUsageRecord(){
|
||||
this.resourceSpecificProperties = new HashMap<String, Serializable>();
|
||||
this.validation = new HashMap<String, List<FieldValidator>>();
|
||||
this.validation = new HashMap<String, List<ValidatorAction>>();
|
||||
initializeValidation();
|
||||
this.resourceSpecificProperties.put(ID, UUID.randomUUID().toString());
|
||||
this.resourceSpecificProperties.put(RESOURCE_TYPE, this.getClass().getSimpleName());
|
||||
|
@ -113,7 +113,7 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
|
|||
}
|
||||
|
||||
protected RawUsageRecord(Map<String, Serializable> properties) throws InvalidValueException {
|
||||
this.validation = new HashMap<String, List<FieldValidator>>();
|
||||
this.validation = new HashMap<String, List<ValidatorAction>>();
|
||||
initializeValidation();
|
||||
setResourceSpecificProperties(properties);
|
||||
}
|
||||
|
@ -391,9 +391,9 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
|
|||
|
||||
protected Serializable validateField(String key, Serializable serializable) throws InvalidValueException {
|
||||
Serializable checkedValue = serializable;
|
||||
List<FieldValidator> fieldValidators = validation.get(key);
|
||||
List<ValidatorAction> fieldValidators = validation.get(key);
|
||||
if(fieldValidators!=null){
|
||||
for(FieldValidator fieldValidator : fieldValidators){
|
||||
for(ValidatorAction fieldValidator : fieldValidators){
|
||||
checkedValue = fieldValidator.validate(checkedValue);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.accounting.datamodel.validations;
|
||||
package org.gcube.accounting.datamodel.decorators;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
@ -10,7 +10,7 @@ import org.gcube.accounting.datamodel.UsageRecord;
|
|||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
*/
|
||||
public interface DeprecationAction {
|
||||
public interface AggregatedAction {
|
||||
|
||||
public Serializable manage(String key, Serializable manage, UsageRecord usageRecord);
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.accounting.datamodel.validations;
|
||||
package org.gcube.accounting.datamodel.decorators;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
|
@ -7,6 +7,6 @@ import java.lang.annotation.Target;
|
|||
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Required {
|
||||
public @interface AggregatedField {
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.accounting.datamodel.decorators;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.accounting.datamodel.UsageRecord;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
*/
|
||||
public interface DeprecatedAction {
|
||||
|
||||
public Serializable manage(String key, Serializable manage, UsageRecord usageRecord);
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.accounting.datamodel.validations;
|
||||
package org.gcube.accounting.datamodel.decorators;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Inherited;
|
||||
|
@ -11,6 +11,6 @@ import java.lang.annotation.Target;
|
|||
@Inherited
|
||||
public @interface DeprecatedField {
|
||||
|
||||
Class<? extends DeprecationAction> action();
|
||||
Class<? extends DeprecatedAction> action();
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.accounting.datamodel.validations;
|
||||
package org.gcube.accounting.datamodel.decorators;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
|
@ -7,6 +7,6 @@ import java.lang.annotation.Target;
|
|||
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Aggregated {
|
||||
public @interface RequiredField {
|
||||
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.accounting.datamodel.validations;
|
||||
package org.gcube.accounting.datamodel.decorators;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
@ -10,7 +10,7 @@ import org.gcube.accounting.exception.InvalidValueException;
|
|||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
*/
|
||||
public interface FieldValidator {
|
||||
public interface ValidatorAction {
|
||||
|
||||
/**
|
||||
* Validate (and convert if needed) the provided property
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.accounting.datamodel.validations;
|
||||
package org.gcube.accounting.datamodel.decorators;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Inherited;
|
||||
|
@ -16,8 +16,8 @@ import java.lang.annotation.Target;
|
|||
@Target(ElementType.ANNOTATION_TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Inherited
|
||||
public @interface ValidityChecker {
|
||||
public @interface ValidatorField {
|
||||
|
||||
Class<? extends FieldValidator> managed();
|
||||
Class<? extends ValidatorAction> managed();
|
||||
}
|
||||
|
|
@ -7,8 +7,8 @@ import java.util.Calendar;
|
|||
|
||||
import org.gcube.accounting.datamodel.RawUsageRecord;
|
||||
import org.gcube.accounting.datamodel.SingleUsageRecord;
|
||||
import org.gcube.accounting.datamodel.validations.DeprecatedField;
|
||||
import org.gcube.accounting.datamodel.validations.Required;
|
||||
import org.gcube.accounting.datamodel.decorators.DeprecatedField;
|
||||
import org.gcube.accounting.datamodel.decorators.RequiredField;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.NotEmpty;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.ValidInteger;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.ValidLong;
|
||||
|
@ -30,15 +30,15 @@ public class JobUsageRecord extends RawUsageRecord implements SingleUsageRecord
|
|||
completed, failed
|
||||
};
|
||||
|
||||
@Required @NotEmpty
|
||||
@RequiredField @NotEmpty
|
||||
public static final String JOB_ID = "jobId";
|
||||
@Required @NotEmpty
|
||||
@RequiredField @NotEmpty
|
||||
public static final String JOB_QUALIFIER = "jobQualifier";
|
||||
@Required @NotEmpty
|
||||
@RequiredField @NotEmpty
|
||||
public static final String JOB_NAME = "jobName";
|
||||
@Required @ValidLong
|
||||
@RequiredField @ValidLong
|
||||
public static final String JOB_START_TIME = "jobStartTime";
|
||||
@Required @ValidLong
|
||||
@RequiredField @ValidLong
|
||||
public static final String JOB_END_TIME = "jobEndTime";
|
||||
|
||||
@DeprecatedField(action=ConvertToOperationResult.class) @NotEmpty //TODO
|
||||
|
|
|
@ -5,8 +5,8 @@ package org.gcube.accounting.datamodel.implementations;
|
|||
|
||||
import org.gcube.accounting.datamodel.RawUsageRecord;
|
||||
import org.gcube.accounting.datamodel.SingleUsageRecord;
|
||||
import org.gcube.accounting.datamodel.validations.DeprecatedField;
|
||||
import org.gcube.accounting.datamodel.validations.Required;
|
||||
import org.gcube.accounting.datamodel.decorators.DeprecatedField;
|
||||
import org.gcube.accounting.datamodel.decorators.RequiredField;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.NotEmpty;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.NotEmptyIfNotNull;
|
||||
import org.gcube.accounting.datamodel.validations.validators.WarningAlert;
|
||||
|
@ -26,9 +26,9 @@ public class PortletUsageRecord extends RawUsageRecord implements SingleUsageRec
|
|||
@DeprecatedField(action=WarningAlert.class) @NotEmptyIfNotNull
|
||||
protected static final String USER_ID = "userId";
|
||||
|
||||
@Required @NotEmpty
|
||||
@RequiredField @NotEmpty
|
||||
public static final String PORTLET_ID = "portletId";
|
||||
@Required @NotEmpty
|
||||
@RequiredField @NotEmpty
|
||||
public static final String OPERATION_ID = "operationId";
|
||||
// TODO More
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@ package org.gcube.accounting.datamodel.implementations;
|
|||
|
||||
import org.gcube.accounting.datamodel.RawUsageRecord;
|
||||
import org.gcube.accounting.datamodel.SingleUsageRecord;
|
||||
import org.gcube.accounting.datamodel.validations.DeprecatedField;
|
||||
import org.gcube.accounting.datamodel.validations.Required;
|
||||
import org.gcube.accounting.datamodel.decorators.DeprecatedField;
|
||||
import org.gcube.accounting.datamodel.decorators.RequiredField;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.NotEmpty;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.ValidIP;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.ValidInteger;
|
||||
|
@ -26,11 +26,11 @@ public class ServiceUsageRecord extends RawUsageRecord implements SingleUsageRec
|
|||
|
||||
@ValidIP
|
||||
public static final String CALLER_IP = "callerIP";
|
||||
@Required @NotEmpty
|
||||
@RequiredField @NotEmpty
|
||||
public static final String CALLER_SCOPE = "callerScope";
|
||||
@Required @NotEmpty
|
||||
@RequiredField @NotEmpty
|
||||
public static final String REF_HOST = "refHost";
|
||||
@Required @NotEmpty
|
||||
@RequiredField @NotEmpty
|
||||
public static final String REF_VM = "refVM";
|
||||
@DeprecatedField(action=WarningAlert.class) @NotEmpty
|
||||
public static final String DOMAIN = "domain";
|
||||
|
|
|
@ -5,7 +5,7 @@ package org.gcube.accounting.datamodel.implementations;
|
|||
|
||||
import org.gcube.accounting.datamodel.RawUsageRecord;
|
||||
import org.gcube.accounting.datamodel.SingleUsageRecord;
|
||||
import org.gcube.accounting.datamodel.validations.Required;
|
||||
import org.gcube.accounting.datamodel.decorators.RequiredField;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.NotEmpty;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.NotEmptyIfNotNull;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.ValidIP;
|
||||
|
@ -28,7 +28,7 @@ public class StorageUsageUsageRecord extends RawUsageRecord implements SingleUsa
|
|||
public static final String PROVIDER_ID = "providerId";
|
||||
@NotEmptyIfNotNull
|
||||
public static final String OBJECT_URI = "objectURI";
|
||||
@Required @NotEmpty
|
||||
@RequiredField @NotEmpty
|
||||
public static final String OPERATION_TYPE = "operationType";
|
||||
@NotEmpty
|
||||
public static final String QUALIFIER = "qualifier";
|
||||
|
|
|
@ -7,8 +7,8 @@ import java.util.Calendar;
|
|||
|
||||
import org.gcube.accounting.datamodel.RawUsageRecord;
|
||||
import org.gcube.accounting.datamodel.SingleUsageRecord;
|
||||
import org.gcube.accounting.datamodel.validations.DeprecatedField;
|
||||
import org.gcube.accounting.datamodel.validations.Required;
|
||||
import org.gcube.accounting.datamodel.decorators.DeprecatedField;
|
||||
import org.gcube.accounting.datamodel.decorators.RequiredField;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.NotEmpty;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.ValidInteger;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.ValidLong;
|
||||
|
@ -31,17 +31,17 @@ public class TaskUsageRecord extends RawUsageRecord implements SingleUsageRecord
|
|||
completed, failed
|
||||
};
|
||||
|
||||
@Required @NotEmpty
|
||||
@RequiredField @NotEmpty
|
||||
public static final String JOB_ID = "jobId";
|
||||
@Required @NotEmpty
|
||||
@RequiredField @NotEmpty
|
||||
public static final String REF_HOST = "refHost";
|
||||
@Required @NotEmpty
|
||||
@RequiredField @NotEmpty
|
||||
public static final String REF_VM = "refVM";
|
||||
@DeprecatedField(action=WarningAlert.class)
|
||||
protected static final String DOMAIN = "domain";
|
||||
@Required @ValidLong
|
||||
@RequiredField @ValidLong
|
||||
public static final String USAGE_START_TIME = "usageStartTime";
|
||||
@Required @ValidLong
|
||||
@RequiredField @ValidLong
|
||||
public static final String USAGE_END_TIME = "usageEndTime";
|
||||
@DeprecatedField(action=ConvertToOperationResult.class) @NotEmpty
|
||||
public static final String USAGE_PHASE = "usagePhase";
|
||||
|
|
|
@ -5,12 +5,12 @@ import java.lang.annotation.Retention;
|
|||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.gcube.accounting.datamodel.validations.ValidityChecker;
|
||||
import org.gcube.accounting.datamodel.decorators.ValidatorField;
|
||||
import org.gcube.accounting.datamodel.validations.validators.NotEmptyValidator;
|
||||
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@ValidityChecker(managed=NotEmptyValidator.class)
|
||||
@ValidatorField(managed=NotEmptyValidator.class)
|
||||
public @interface NotEmpty {
|
||||
|
||||
}
|
||||
|
|
|
@ -5,12 +5,12 @@ import java.lang.annotation.Retention;
|
|||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.gcube.accounting.datamodel.validations.ValidityChecker;
|
||||
import org.gcube.accounting.datamodel.decorators.ValidatorField;
|
||||
import org.gcube.accounting.datamodel.validations.validators.NotEmptyIfNotNullValidator;
|
||||
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@ValidityChecker(managed=NotEmptyIfNotNullValidator.class)
|
||||
@ValidatorField(managed=NotEmptyIfNotNullValidator.class)
|
||||
public @interface NotEmptyIfNotNull {
|
||||
|
||||
}
|
||||
|
|
|
@ -5,12 +5,12 @@ import java.lang.annotation.Retention;
|
|||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.gcube.accounting.datamodel.validations.ValidityChecker;
|
||||
import org.gcube.accounting.datamodel.decorators.ValidatorField;
|
||||
import org.gcube.accounting.datamodel.validations.validators.NotNullValidator;
|
||||
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@ValidityChecker(managed=NotNullValidator.class)
|
||||
@ValidatorField(managed=NotNullValidator.class)
|
||||
public @interface NotNull {
|
||||
|
||||
}
|
||||
|
|
|
@ -5,12 +5,12 @@ import java.lang.annotation.Retention;
|
|||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.gcube.accounting.datamodel.validations.ValidityChecker;
|
||||
import org.gcube.accounting.datamodel.decorators.ValidatorField;
|
||||
import org.gcube.accounting.datamodel.validations.validators.ValidIPValidator;
|
||||
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@ValidityChecker(managed=ValidIPValidator.class)
|
||||
@ValidatorField(managed=ValidIPValidator.class)
|
||||
public @interface ValidIP {
|
||||
|
||||
}
|
||||
|
|
|
@ -5,12 +5,12 @@ import java.lang.annotation.Retention;
|
|||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.gcube.accounting.datamodel.validations.ValidityChecker;
|
||||
import org.gcube.accounting.datamodel.decorators.ValidatorField;
|
||||
import org.gcube.accounting.datamodel.validations.validators.ValidIntegerValidator;
|
||||
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@ValidityChecker(managed=ValidIntegerValidator.class)
|
||||
@ValidatorField(managed=ValidIntegerValidator.class)
|
||||
public @interface ValidInteger {
|
||||
|
||||
}
|
||||
|
|
|
@ -5,12 +5,12 @@ import java.lang.annotation.Retention;
|
|||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.gcube.accounting.datamodel.validations.ValidityChecker;
|
||||
import org.gcube.accounting.datamodel.decorators.ValidatorField;
|
||||
import org.gcube.accounting.datamodel.validations.validators.ValidLongValidator;
|
||||
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@ValidityChecker(managed=ValidLongValidator.class)
|
||||
@ValidatorField(managed=ValidLongValidator.class)
|
||||
public @interface ValidLong {
|
||||
|
||||
}
|
||||
|
|
|
@ -5,12 +5,12 @@ import java.lang.annotation.Retention;
|
|||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.gcube.accounting.datamodel.validations.ValidityChecker;
|
||||
import org.gcube.accounting.datamodel.decorators.ValidatorField;
|
||||
import org.gcube.accounting.datamodel.validations.validators.ValidOperationResultValidator;
|
||||
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@ValidityChecker(managed=ValidOperationResultValidator.class)
|
||||
@ValidatorField(managed=ValidOperationResultValidator.class)
|
||||
public @interface ValidOperationResult {
|
||||
|
||||
}
|
||||
|
|
|
@ -6,13 +6,13 @@ package org.gcube.accounting.datamodel.validations.validators;
|
|||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.accounting.datamodel.UsageRecord;
|
||||
import org.gcube.accounting.datamodel.validations.DeprecationAction;
|
||||
import org.gcube.accounting.datamodel.decorators.DeprecatedAction;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
*
|
||||
*/
|
||||
public class ConvertToOperationResult implements DeprecationAction {
|
||||
public class ConvertToOperationResult implements DeprecatedAction {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
|
|
|
@ -3,10 +3,10 @@ package org.gcube.accounting.datamodel.validations.validators;
|
|||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.accounting.datamodel.validations.FieldValidator;
|
||||
import org.gcube.accounting.datamodel.decorators.ValidatorAction;
|
||||
import org.gcube.accounting.exception.InvalidValueException;
|
||||
|
||||
public class NotEmptyValidator implements FieldValidator{
|
||||
public class NotEmptyValidator implements ValidatorAction{
|
||||
|
||||
private static final String ERROR = "Is Empty";
|
||||
|
||||
|
|
|
@ -2,10 +2,10 @@ package org.gcube.accounting.datamodel.validations.validators;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.accounting.datamodel.validations.FieldValidator;
|
||||
import org.gcube.accounting.datamodel.decorators.ValidatorAction;
|
||||
import org.gcube.accounting.exception.InvalidValueException;
|
||||
|
||||
public class NotNullValidator implements FieldValidator {
|
||||
public class NotNullValidator implements ValidatorAction {
|
||||
|
||||
private static final String ERROR = "Is Null";
|
||||
|
||||
|
|
|
@ -4,12 +4,12 @@ import java.io.Serializable;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.gcube.accounting.datamodel.validations.FieldValidator;
|
||||
import org.gcube.accounting.datamodel.decorators.ValidatorAction;
|
||||
import org.gcube.accounting.exception.InvalidValueException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class ValidIPValidator implements FieldValidator{
|
||||
public class ValidIPValidator implements ValidatorAction{
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(ValidIPValidator.class);
|
||||
|
||||
|
|
|
@ -2,11 +2,11 @@ package org.gcube.accounting.datamodel.validations.validators;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.accounting.datamodel.validations.FieldValidator;
|
||||
import org.gcube.accounting.datamodel.decorators.ValidatorAction;
|
||||
import org.gcube.accounting.exception.InvalidValueException;
|
||||
|
||||
|
||||
public class ValidIntegerValidator implements FieldValidator {
|
||||
public class ValidIntegerValidator implements ValidatorAction {
|
||||
|
||||
private static final String ERROR = String.format("Not Instance of %s", Integer.class.getSimpleName());
|
||||
|
||||
|
|
|
@ -2,11 +2,11 @@ package org.gcube.accounting.datamodel.validations.validators;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.accounting.datamodel.validations.FieldValidator;
|
||||
import org.gcube.accounting.datamodel.decorators.ValidatorAction;
|
||||
import org.gcube.accounting.exception.InvalidValueException;
|
||||
|
||||
|
||||
public class ValidLongValidator implements FieldValidator {
|
||||
public class ValidLongValidator implements ValidatorAction {
|
||||
|
||||
private static final String ERROR = String.format("Not Instance of %s", Integer.class.getSimpleName());
|
||||
|
||||
|
|
|
@ -3,10 +3,10 @@ package org.gcube.accounting.datamodel.validations.validators;
|
|||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.accounting.datamodel.UsageRecord.OperationResult;
|
||||
import org.gcube.accounting.datamodel.validations.FieldValidator;
|
||||
import org.gcube.accounting.datamodel.decorators.ValidatorAction;
|
||||
import org.gcube.accounting.exception.InvalidValueException;
|
||||
|
||||
public class ValidOperationResultValidator implements FieldValidator {
|
||||
public class ValidOperationResultValidator implements ValidatorAction {
|
||||
|
||||
private static final String ERROR = String.format("Not Instance of %s", OperationResult.class.getSimpleName());
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ package org.gcube.accounting.datamodel.validations.validators;
|
|||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.accounting.datamodel.UsageRecord;
|
||||
import org.gcube.accounting.datamodel.validations.DeprecationAction;
|
||||
import org.gcube.accounting.datamodel.decorators.DeprecatedAction;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -14,7 +14,7 @@ import org.slf4j.LoggerFactory;
|
|||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
*
|
||||
*/
|
||||
public class WarningAlert implements DeprecationAction {
|
||||
public class WarningAlert implements DeprecatedAction {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(WarningAlert.class);
|
||||
|
||||
|
|
Loading…
Reference in New Issue