refs #437: Accounting Manager - List of Keys for Filters

https://support.d4science.org/issues/437

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-analytics@119163 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2015-09-29 14:25:58 +00:00
parent 096d4e503f
commit a974a8824b
7 changed files with 97 additions and 5 deletions

View File

@ -9,7 +9,7 @@
<groupId>org.gcube.accounting</groupId> <groupId>org.gcube.accounting</groupId>
<artifactId>accounting-analytics</artifactId> <artifactId>accounting-analytics</artifactId>
<version>1.0.1-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
<name>accounting-analytics</name> <name>accounting-analytics</name>
<scm> <scm>

View File

@ -19,7 +19,7 @@ public class Info {
protected JSONObject value; protected JSONObject value;
/** /**
* @param date the date * @param calendar the date
* @param value the JSON value * @param value the JSON value
*/ */
public Info(Calendar calendar, JSONObject value) { public Info(Calendar calendar, JSONObject value) {
@ -36,7 +36,7 @@ public class Info {
} }
/** /**
* @param date the date to set * @param calendar the date to set
*/ */
public void setCalendar(Calendar calendar) { public void setCalendar(Calendar calendar) {
this.calendar = calendar; this.calendar = calendar;

View File

@ -14,7 +14,11 @@ public class NoAvailableScopeException extends Exception {
*/ */
private static final long serialVersionUID = -327144230654860518L; private static final long serialVersionUID = -327144230654860518L;
/**
* Constructs a new exception with {@code null} as its detail message.
* The cause is not initialized, and may subsequently be initialized by a
* call to {@link #initCause}.
*/
public NoAvailableScopeException() { public NoAvailableScopeException() {
super(); super();
} }
@ -30,10 +34,36 @@ public class NoAvailableScopeException extends Exception {
super(message); super(message);
} }
/**
* Constructs a new exception with the specified cause and a detail
* message of <tt>(cause==null ? null : cause.toString())</tt> (which
* typically contains the class and detail message of <tt>cause</tt>).
* This constructor is useful for exceptions that are little more than
* wrappers for other throwables (for example, {@link
* java.security.PrivilegedActionException}).
*
* @param cause the cause (which is saved for later retrieval by the
* {@link #getCause()} method). (A <tt>null</tt> value is
* permitted, and indicates that the cause is nonexistent or
* unknown.)
*/
public NoAvailableScopeException(Throwable cause) { public NoAvailableScopeException(Throwable cause) {
super(cause); super(cause);
} }
/**
* Constructs a new exception with the specified detail message and
* cause. <p>Note that the detail message associated with
* {@code cause} is <i>not</i> automatically incorporated in
* this exception's detail message.
*
* @param message the detail message (which is saved for later retrieval
* by the {@link #getMessage()} method).
* @param cause the cause (which is saved for later retrieval by the
* {@link #getCause()} method). (A <tt>null</tt> value is
* permitted, and indicates that the cause is nonexistent or
* unknown.)
*/
public NoAvailableScopeException(String message, Throwable cause) { public NoAvailableScopeException(String message, Throwable cause) {
super(message, cause); super(message, cause);
} }

View File

@ -14,18 +14,57 @@ public class NoUsableAccountingPersistenceQueryFound extends Exception {
*/ */
private static final long serialVersionUID = -327144230654860518L; private static final long serialVersionUID = -327144230654860518L;
/**
* Constructs a new exception with {@code null} as its detail message.
* The cause is not initialized, and may subsequently be initialized by a
* call to {@link #initCause}.
*/
public NoUsableAccountingPersistenceQueryFound() { public NoUsableAccountingPersistenceQueryFound() {
super(); super();
} }
/**
* Constructs a new exception with the specified detail message. The
* cause is not initialized, and may subsequently be initialized by
* a call to {@link #initCause}.
*
* @param message the detail message. The detail message is saved for
* later retrieval by the {@link #getMessage()} method.
*/
public NoUsableAccountingPersistenceQueryFound(String message) { public NoUsableAccountingPersistenceQueryFound(String message) {
super(message); super(message);
} }
/**
* Constructs a new exception with the specified cause and a detail
* message of <tt>(cause==null ? null : cause.toString())</tt> (which
* typically contains the class and detail message of <tt>cause</tt>).
* This constructor is useful for exceptions that are little more than
* wrappers for other throwables (for example, {@link
* java.security.PrivilegedActionException}).
*
* @param cause the cause (which is saved for later retrieval by the
* {@link #getCause()} method). (A <tt>null</tt> value is
* permitted, and indicates that the cause is nonexistent or
* unknown.)
*/
public NoUsableAccountingPersistenceQueryFound(Throwable cause) { public NoUsableAccountingPersistenceQueryFound(Throwable cause) {
super(cause); super(cause);
} }
/**
* Constructs a new exception with the specified detail message and
* cause. <p>Note that the detail message associated with
* {@code cause} is <i>not</i> automatically incorporated in
* this exception's detail message.
*
* @param message the detail message (which is saved for later retrieval
* by the {@link #getMessage()} method).
* @param cause the cause (which is saved for later retrieval by the
* {@link #getCause()} method). (A <tt>null</tt> value is
* permitted, and indicates that the cause is nonexistent or
* unknown.)
*/
public NoUsableAccountingPersistenceQueryFound(String message, Throwable cause) { public NoUsableAccountingPersistenceQueryFound(String message, Throwable cause) {
super(message, cause); super(message, cause);
} }

View File

@ -57,5 +57,9 @@ public abstract class AccountingPersistenceQuery {
*/ */
public abstract Set<String> getKeys(@SuppressWarnings("rawtypes") Class<? extends AggregatedUsageRecord> usageRecordType) throws Exception; public abstract Set<String> getKeys(@SuppressWarnings("rawtypes") Class<? extends AggregatedUsageRecord> usageRecordType) throws Exception;
/**
* Close the connection to persistence
* @throws Exception if the close fails
*/
public abstract void close() throws Exception; public abstract void close() throws Exception;
} }

View File

@ -11,14 +11,26 @@ import org.gcube.common.resources.gcore.ServiceEndpoint;
*/ */
public class AccountingPersistenceQueryConfiguration extends AccountingPersistenceConfiguration { public class AccountingPersistenceQueryConfiguration extends AccountingPersistenceConfiguration {
/**
* Default Constructor
*/
public AccountingPersistenceQueryConfiguration(){ public AccountingPersistenceQueryConfiguration(){
super(); super();
} }
/**
* @param uri the URI of the persistence
* @param username the username to connect to persistence
* @param password the password to connect to persistence
*/
public AccountingPersistenceQueryConfiguration(URI uri, String username, String password){ public AccountingPersistenceQueryConfiguration(URI uri, String username, String password){
super(uri, username, password); super(uri, username, password);
} }
/**
* @param persistenceClassName The classname of the persistence to instantiate
* @throws Exception if fails
*/
public AccountingPersistenceQueryConfiguration(String persistenceClassName) throws Exception{ public AccountingPersistenceQueryConfiguration(String persistenceClassName) throws Exception{
super.init(); super.init();
ServiceEndpoint serviceEndpoint = getServiceEndpoint(SERVICE_ENDPOINT_CATEGORY, SERVICE_ENDPOINT_NAME, persistenceClassName); ServiceEndpoint serviceEndpoint = getServiceEndpoint(SERVICE_ENDPOINT_CATEGORY, SERVICE_ENDPOINT_NAME, persistenceClassName);

View File

@ -26,10 +26,17 @@ public abstract class AccountingPersistenceQueryFactory {
accountingPersistenceQueries = new HashMap<String, AccountingPersistenceQuery>(); accountingPersistenceQueries = new HashMap<String, AccountingPersistenceQuery>();
} }
/**
* @return AccountingPersistenceQuery instance
* @throws NoAvailableScopeException if no configuration is found on IS for
* the current scope
* @throws NoUsableAccountingPersistenceQueryFound if fails to instantiate
* the #AccountingPersistenceQuery
*/
public synchronized static AccountingPersistenceQuery getInstance() throws NoAvailableScopeException, NoUsableAccountingPersistenceQueryFound { public synchronized static AccountingPersistenceQuery getInstance() throws NoAvailableScopeException, NoUsableAccountingPersistenceQueryFound {
String scope = ScopeProvider.instance.get(); String scope = ScopeProvider.instance.get();
if(scope==null){ if(scope==null){
new NoAvailableScopeException(); throw new NoAvailableScopeException();
} }
AccountingPersistenceQuery accountingPersistenceQuery = accountingPersistenceQueries.get(scope); AccountingPersistenceQuery accountingPersistenceQuery = accountingPersistenceQueries.get(scope);