git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@131245 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
c23b53df2f
commit
f71a86ad74
|
@ -20,7 +20,6 @@
|
||||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
|
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||||
|
|
|
@ -21,11 +21,14 @@ Authors
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
|
||||||
* Luca Frosini (luca.frosini-AT-isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy).
|
* Luca Frosini (luca.frosini-AT-isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy).
|
||||||
|
* Alessandro Pieve (alessandro.pieve-AT-isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy).
|
||||||
|
|
||||||
|
|
||||||
Maintainers
|
Maintainers
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
* Luca Frosini (luca.frosini-AT-isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy).
|
* Luca Frosini (luca.frosini-AT-isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy).
|
||||||
|
* Alessandro Pieve (alessandro.pieve-AT-isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy).
|
||||||
|
|
||||||
|
|
||||||
Download information
|
Download information
|
||||||
|
|
1
pom.xml
1
pom.xml
|
@ -56,7 +56,6 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.data.publishing</groupId>
|
<groupId>org.gcube.data.publishing</groupId>
|
||||||
<artifactId>document-store-lib</artifactId>
|
<artifactId>document-store-lib</artifactId>
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.resources.discovery</groupId>
|
<groupId>org.gcube.resources.discovery</groupId>
|
||||||
|
|
|
@ -12,6 +12,7 @@ import org.gcube.accounting.datamodel.validations.validators.ValidOperationResul
|
||||||
import org.gcube.common.authorization.client.Constants;
|
import org.gcube.common.authorization.client.Constants;
|
||||||
import org.gcube.common.authorization.library.AuthorizationEntry;
|
import org.gcube.common.authorization.library.AuthorizationEntry;
|
||||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.documentstore.exception.InvalidValueException;
|
import org.gcube.documentstore.exception.InvalidValueException;
|
||||||
import org.gcube.documentstore.records.Record;
|
import org.gcube.documentstore.records.Record;
|
||||||
import org.gcube.documentstore.records.implementation.AbstractRecord;
|
import org.gcube.documentstore.records.implementation.AbstractRecord;
|
||||||
|
@ -20,6 +21,7 @@ import org.gcube.documentstore.records.implementation.validations.annotations.No
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||||
*
|
*
|
||||||
|
@ -30,7 +32,7 @@ public abstract class BasicUsageRecord extends AbstractRecord implements UsageRe
|
||||||
* Generated Serial Version UID
|
* Generated Serial Version UID
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -2060728578456796388L;
|
private static final long serialVersionUID = -2060728578456796388L;
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(BasicUsageRecord.class);
|
private static Logger logger = LoggerFactory.getLogger(BasicUsageRecord.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,28 +41,33 @@ public abstract class BasicUsageRecord extends AbstractRecord implements UsageRe
|
||||||
*/
|
*/
|
||||||
@Deprecated @MoveToRecordType
|
@Deprecated @MoveToRecordType
|
||||||
public static final String USAGE_RECORD_TYPE = "usageRecordType";
|
public static final String USAGE_RECORD_TYPE = "usageRecordType";
|
||||||
|
|
||||||
@RequiredField @NotEmpty
|
@RequiredField @NotEmpty
|
||||||
public static final String CONSUMER_ID = UsageRecord.CONSUMER_ID;
|
public static final String CONSUMER_ID = UsageRecord.CONSUMER_ID;
|
||||||
|
|
||||||
@RequiredField @NotEmpty
|
@RequiredField @NotEmpty
|
||||||
public static final String SCOPE = UsageRecord.SCOPE;
|
public static final String SCOPE = UsageRecord.SCOPE;
|
||||||
|
|
||||||
@RequiredField @ValidOperationResult
|
@RequiredField @ValidOperationResult
|
||||||
public static final String OPERATION_RESULT = UsageRecord.OPERATION_RESULT;
|
public static final String OPERATION_RESULT = UsageRecord.OPERATION_RESULT;
|
||||||
|
|
||||||
public static String getScopeFromToken(){
|
public static String getScopeFromToken(){
|
||||||
String token = SecurityTokenProvider.instance.get();
|
|
||||||
AuthorizationEntry authorizationEntry;
|
String scope =ScopeProvider.instance.get();
|
||||||
try {
|
if (scope==null){
|
||||||
authorizationEntry = Constants.authorizationService().get(token);
|
String token = SecurityTokenProvider.instance.get();
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
AuthorizationEntry authorizationEntry;
|
||||||
|
try {
|
||||||
|
authorizationEntry = Constants.authorizationService().get(token);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
scope = authorizationEntry.getContext();
|
||||||
}
|
}
|
||||||
String scope = authorizationEntry.getContext();
|
|
||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize variable
|
* Initialize variable
|
||||||
*/
|
*/
|
||||||
|
@ -73,7 +80,7 @@ public abstract class BasicUsageRecord extends AbstractRecord implements UsageRe
|
||||||
logger.warn("Unable to automaticcally set the scope using scope provider. The record will not be valid if the scope will not be explicitly set.");
|
logger.warn("Unable to automaticcally set the scope using scope provider. The record will not be valid if the scope will not be explicitly set.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BasicUsageRecord(){
|
public BasicUsageRecord(){
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
@ -97,8 +104,8 @@ public abstract class BasicUsageRecord extends AbstractRecord implements UsageRe
|
||||||
public void setConsumerId(String consumerId) throws InvalidValueException {
|
public void setConsumerId(String consumerId) throws InvalidValueException {
|
||||||
setResourceProperty(CONSUMER_ID, consumerId);
|
setResourceProperty(CONSUMER_ID, consumerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@ -106,7 +113,7 @@ public abstract class BasicUsageRecord extends AbstractRecord implements UsageRe
|
||||||
public String getScope() {
|
public String getScope() {
|
||||||
return (String) this.resourceProperties.get(SCOPE);
|
return (String) this.resourceProperties.get(SCOPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@ -114,7 +121,7 @@ public abstract class BasicUsageRecord extends AbstractRecord implements UsageRe
|
||||||
public void setScope(String scope) throws InvalidValueException {
|
public void setScope(String scope) throws InvalidValueException {
|
||||||
setResourceProperty(SCOPE, scope);
|
setResourceProperty(SCOPE, scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@ -127,7 +134,7 @@ public abstract class BasicUsageRecord extends AbstractRecord implements UsageRe
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
* @throws InvalidValueException
|
* @throws InvalidValueException
|
||||||
|
|
|
@ -48,17 +48,27 @@ public abstract class AbstractServiceUsageRecord extends BasicUsageRecord {
|
||||||
public static final String SERVICE_NAME = "serviceName";
|
public static final String SERVICE_NAME = "serviceName";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* KEY for : Service Name
|
* KEY for : Called Method
|
||||||
*/
|
*/
|
||||||
@RequiredField @NotEmpty
|
@RequiredField @NotEmpty
|
||||||
public static final String CALLED_METHOD = "calledMethod";
|
public static final String CALLED_METHOD = "calledMethod";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* KEY for : Service Name
|
* KEY for : Duration
|
||||||
*/
|
*/
|
||||||
@RequiredField @ValidLong
|
@RequiredField @ValidLong
|
||||||
public static final String DURATION = "duration";
|
public static final String DURATION = "duration";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* KEY for : callerQualifier
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@RequiredField @NotEmpty
|
||||||
|
public static final String CALLERQUALIFIER = "callerQualifier";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public AbstractServiceUsageRecord(){
|
public AbstractServiceUsageRecord(){
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
@ -124,4 +134,13 @@ public abstract class AbstractServiceUsageRecord extends BasicUsageRecord {
|
||||||
public void setDuration(Long duration) throws InvalidValueException {
|
public void setDuration(Long duration) throws InvalidValueException {
|
||||||
setResourceProperty(DURATION, duration);
|
setResourceProperty(DURATION, duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*Add a new field*/
|
||||||
|
public String getCallerQualifier() {
|
||||||
|
return (String) this.resourceProperties.get(CALLERQUALIFIER);
|
||||||
|
}
|
||||||
|
public void setCallerQualifier(String callerQualifier) throws InvalidValueException {
|
||||||
|
setResourceProperty(CALLERQUALIFIER, callerQualifier);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,6 +85,15 @@ public abstract class AbstractStorageUsageRecord extends BasicUsageRecord {
|
||||||
@NotEmptyIfNotNull
|
@NotEmptyIfNotNull
|
||||||
public static final String QUALIFIER = "qualifier";
|
public static final String QUALIFIER = "qualifier";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* KEY for : callerQualifier
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
@NotEmptyIfNotNull
|
||||||
|
public static final String CALLERQUALIFIER = "callerQualifier";
|
||||||
|
*/
|
||||||
public AbstractStorageUsageRecord() {
|
public AbstractStorageUsageRecord() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
@ -184,4 +193,13 @@ public abstract class AbstractStorageUsageRecord extends BasicUsageRecord {
|
||||||
setResourceProperty(QUALIFIER, qualifier);
|
setResourceProperty(QUALIFIER, qualifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*Add a new field*/
|
||||||
|
/*
|
||||||
|
public String getCallerQualifier() {
|
||||||
|
return (String) this.resourceProperties.get(CALLERQUALIFIER);
|
||||||
|
}
|
||||||
|
public void setCallerQualifier(String callerQualifier) throws InvalidValueException {
|
||||||
|
setResourceProperty(CALLERQUALIFIER, callerQualifier);
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue