2018-07-05 18:29:38 +02:00
|
|
|
package org.gcube.portlets.user.accountingdashboard.server;
|
|
|
|
|
|
|
|
import javax.servlet.ServletException;
|
|
|
|
|
|
|
|
import org.gcube.portlets.user.accountingdashboard.client.rpc.AccountingDashboardService;
|
2018-07-06 17:48:46 +02:00
|
|
|
import org.gcube.portlets.user.accountingdashboard.server.accounting.AccountingService;
|
|
|
|
import org.gcube.portlets.user.accountingdashboard.server.accounting.AccountingServiceType;
|
2018-07-05 18:29:38 +02:00
|
|
|
import org.gcube.portlets.user.accountingdashboard.server.util.ServiceCredentials;
|
2018-07-06 17:48:46 +02:00
|
|
|
import org.gcube.portlets.user.accountingdashboard.shared.data.ScopeData;
|
2018-07-05 18:29:38 +02:00
|
|
|
import org.gcube.portlets.user.accountingdashboard.shared.exception.ServiceException;
|
|
|
|
import org.gcube.portlets.user.accountingdashboard.shared.session.UserInfo;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @author Giancarlo Panichi
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
@SuppressWarnings("serial")
|
|
|
|
public class AccountingDashboardServiceImpl extends RemoteServiceServlet implements AccountingDashboardService {
|
|
|
|
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(AccountingDashboardServiceImpl.class);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public void init() throws ServletException {
|
|
|
|
super.init();
|
|
|
|
logger.info("AccountingDashbord Service started!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* {@inheritDoc}
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public UserInfo hello() throws ServiceException {
|
|
|
|
try {
|
|
|
|
logger.debug("AccountingDashboardServiceImpl hello()");
|
|
|
|
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
|
|
|
|
UserInfo userInfo = new UserInfo(serviceCredentials.getUserName(), serviceCredentials.getGroupId(),
|
|
|
|
serviceCredentials.getGroupName(), serviceCredentials.getScope(), serviceCredentials.getEmail(),
|
|
|
|
serviceCredentials.getFullName());
|
|
|
|
logger.debug("UserInfo: " + userInfo);
|
|
|
|
return userInfo;
|
|
|
|
} catch (ServiceException e) {
|
|
|
|
logger.error(e.getLocalizedMessage(), e);
|
|
|
|
throw e;
|
|
|
|
} catch (Throwable e) {
|
|
|
|
logger.error("Hello(): " + e.getLocalizedMessage(), e);
|
2018-07-06 17:48:46 +02:00
|
|
|
throw new ServiceException("Error retrivieving user credentials: " + e.getLocalizedMessage(), e);
|
2018-07-05 18:29:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-07-06 17:48:46 +02:00
|
|
|
@Override
|
|
|
|
public ScopeData getScopeData() throws ServiceException {
|
|
|
|
try {
|
|
|
|
logger.debug("AccountingDashboardServiceImpl getScopeData()");
|
|
|
|
@SuppressWarnings("unused")
|
|
|
|
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
|
|
|
|
AccountingService as = new AccountingService(AccountingServiceType.PortalContex);
|
2018-07-09 15:00:51 +02:00
|
|
|
ScopeData scopeData = as.getTree(this.getThreadLocalRequest());
|
2018-07-06 17:48:46 +02:00
|
|
|
|
|
|
|
return scopeData;
|
|
|
|
} catch (ServiceException e) {
|
|
|
|
logger.error(e.getLocalizedMessage(), e);
|
|
|
|
throw e;
|
|
|
|
} catch (Throwable e) {
|
|
|
|
logger.error("GetScopeData(): " + e.getLocalizedMessage(), e);
|
|
|
|
throw new ServiceException("Error retrieving scope info: "+e.getLocalizedMessage(), e);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2018-07-05 18:29:38 +02:00
|
|
|
|
|
|
|
}
|