accounting-dashboard/src/main/java/org/gcube/portlets/user/accountingdashboard/server/AccountingDashboardServiceI...

62 lines
1.8 KiB
Java

package org.gcube.portlets.user.accountingdashboard.server;
import javax.servlet.ServletException;
import org.gcube.portlets.user.accountingdashboard.client.rpc.AccountingDashboardService;
import org.gcube.portlets.user.accountingdashboard.server.util.ServiceCredentials;
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);
throw new ServiceException(e.getLocalizedMessage(), e);
}
}
}