accounting-lib/src/main/java/org/gcube/accounting/datamodel/implementations/StorageUsageRecord.java

161 lines
4.5 KiB
Java

/**
*
*/
package org.gcube.accounting.datamodel.implementations;
import java.io.Serializable;
import java.net.URI;
import java.util.Map;
import org.gcube.accounting.datamodel.BasicUsageRecord;
import org.gcube.accounting.datamodel.SingleUsageRecord;
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;
import org.gcube.accounting.datamodel.validations.annotations.ValidLong;
import org.gcube.accounting.datamodel.validations.annotations.ValidOperationType;
import org.gcube.accounting.datamodel.validations.annotations.ValidURI;
import org.gcube.accounting.exception.InvalidValueException;
/**
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*
*/
public class StorageUsageRecord extends BasicUsageRecord implements SingleUsageRecord {
/**
* Generated Serial Version UID
*/
private static final long serialVersionUID = 1381025822586583326L;
public enum OperationType {
CREATE, READ, UPDATE, DELETE, COPY, MOVE
}
@RequiredField @NotEmpty
public static final String RESOURCE_OWNER = "resourceOwner";
@RequiredField @NotEmpty
public static final String RESOURCE_SCOPE = "resourceScope";
/*
@NotEmptyIfNotNull
public static final String PROVIDER_ID = "providerId";
*/
@RequiredField @NotEmptyIfNotNull @ValidURI
public static final String OBJECT_URI = "objectURI";
@RequiredField @ValidOperationType
public static final String OPERATION_TYPE = "operationType";
@RequiredField @NotEmpty
public static final String DATA_TYPE = "dataType";
@RequiredField @ValidLong
public static final String DATA_VOLUME = "dataVolume";
@NotEmpty
public static final String QUALIFIER = "qualifier";
@ValidIP
public static final String CALLER_IP = "callerIP";
public StorageUsageRecord(){
super();
}
public StorageUsageRecord(Map<String, Serializable> properties) throws InvalidValueException {
super(properties);
}
/**
* Return the identity id of the storage resource owner
* @return the identity id of the accounting owner
*/
public String getResourceOwner() {
return (String) this.resourceProperties.get(RESOURCE_OWNER);
}
/**
* Set the identity id of the storage resource owner
* @param ownerID the identity id of the storage resource owner
* @throws InvalidValueException
*/
public void setResourceScope(String owner) throws InvalidValueException {
setResourceProperty(RESOURCE_OWNER, owner);
}
/**
* Return the scope of the storage resource
* @return The scope id of the storage resource
*/
public String getResourceScope() {
return (String) this.resourceProperties.get(RESOURCE_OWNER);
}
/**
* Set the scope of the storage resource
* @param scope the scope of the storage resource
* @throws InvalidValueException
*/
public void setResourceOwner(String scope) throws InvalidValueException {
setResourceProperty(RESOURCE_SCOPE, scope);
}
/*
public String getProviderId() {
return (String) this.resourceProperties.get(PROVIDER_ID);
}
public void setProviderId(String providerId) throws InvalidValueException {
setResourceProperty(PROVIDER_ID, providerId);
}
*/
public URI getObjectURI() {
return (URI) this.resourceProperties.get(OBJECT_URI);
}
public void setObjectURI(URI objectURI) throws InvalidValueException {
setResourceProperty(OBJECT_URI, objectURI);
}
public String getOperationType() {
return (String) this.resourceProperties.get(OPERATION_TYPE);
}
public void setOperationType(String operationType) throws InvalidValueException {
setResourceProperty(OPERATION_TYPE, operationType);
}
public String getDataType() {
return (String) this.resourceProperties.get(DATA_TYPE);
}
public void setDataType(String dataType) throws InvalidValueException {
setResourceProperty(DATA_TYPE, dataType);
}
public long getDataVolume() {
return (Long) this.resourceProperties.get(DATA_VOLUME);
}
public void setDataVolume(long dataVolume) throws InvalidValueException {
setResourceProperty(DATA_VOLUME, dataVolume);
}
public String getQualifier() {
return (String) this.resourceProperties.get(QUALIFIER);
}
public void setQualifier(String qualifier) throws InvalidValueException {
setResourceProperty(QUALIFIER, qualifier);
}
public String getCallerIP() {
return (String) this.resourceProperties.get(CALLER_IP);
}
public void setCallerIP(String callerIP) throws InvalidValueException {
setResourceProperty(CALLER_IP, callerIP);
}
}