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:
parent
096d4e503f
commit
a974a8824b
2
pom.xml
2
pom.xml
|
@ -9,7 +9,7 @@
|
|||
|
||||
<groupId>org.gcube.accounting</groupId>
|
||||
<artifactId>accounting-analytics</artifactId>
|
||||
<version>1.0.1-SNAPSHOT</version>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<name>accounting-analytics</name>
|
||||
|
||||
<scm>
|
||||
|
|
|
@ -19,7 +19,7 @@ public class Info {
|
|||
protected JSONObject value;
|
||||
|
||||
/**
|
||||
* @param date the date
|
||||
* @param calendar the date
|
||||
* @param value the JSON 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) {
|
||||
this.calendar = calendar;
|
||||
|
|
|
@ -14,7 +14,11 @@ public class NoAvailableScopeException extends Exception {
|
|||
*/
|
||||
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() {
|
||||
super();
|
||||
}
|
||||
|
@ -30,10 +34,36 @@ public class NoAvailableScopeException extends Exception {
|
|||
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) {
|
||||
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) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
|
|
@ -14,18 +14,57 @@ public class NoUsableAccountingPersistenceQueryFound extends Exception {
|
|||
*/
|
||||
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() {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
|
|
@ -57,5 +57,9 @@ public abstract class AccountingPersistenceQuery {
|
|||
*/
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -11,14 +11,26 @@ import org.gcube.common.resources.gcore.ServiceEndpoint;
|
|||
*/
|
||||
public class AccountingPersistenceQueryConfiguration extends AccountingPersistenceConfiguration {
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
*/
|
||||
public AccountingPersistenceQueryConfiguration(){
|
||||
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){
|
||||
super(uri, username, password);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param persistenceClassName The classname of the persistence to instantiate
|
||||
* @throws Exception if fails
|
||||
*/
|
||||
public AccountingPersistenceQueryConfiguration(String persistenceClassName) throws Exception{
|
||||
super.init();
|
||||
ServiceEndpoint serviceEndpoint = getServiceEndpoint(SERVICE_ENDPOINT_CATEGORY, SERVICE_ENDPOINT_NAME, persistenceClassName);
|
||||
|
|
|
@ -26,10 +26,17 @@ public abstract class AccountingPersistenceQueryFactory {
|
|||
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 {
|
||||
String scope = ScopeProvider.instance.get();
|
||||
if(scope==null){
|
||||
new NoAvailableScopeException();
|
||||
throw new NoAvailableScopeException();
|
||||
}
|
||||
|
||||
AccountingPersistenceQuery accountingPersistenceQuery = accountingPersistenceQueries.get(scope);
|
||||
|
|
Loading…
Reference in New Issue