89 lines
3.0 KiB
Java
89 lines
3.0 KiB
Java
package org.gcube.portlets.widgets.githubconnector.server;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import javax.servlet.ServletException;
|
|
import javax.servlet.http.HttpSession;
|
|
|
|
import org.gcube.application.framework.accesslogger.library.impl.AccessLogger;
|
|
import org.gcube.application.framework.core.session.ASLSession;
|
|
import org.gcube.portlets.widgets.githubconnector.client.rpc.GitHubConnectorService;
|
|
import org.gcube.portlets.widgets.githubconnector.server.git.GitConnectorService;
|
|
import org.gcube.portlets.widgets.githubconnector.shared.exception.ServiceException;
|
|
import org.gcube.portlets.widgets.githubconnector.shared.git.GitHubRepository;
|
|
import org.gcube.portlets.widgets.githubconnector.shared.git.credential.GitHubCredential;
|
|
import org.gcube.portlets.widgets.githubconnector.shared.session.UserInfo;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
|
|
|
/**
|
|
* The server side implementation of the RPC service.
|
|
*/
|
|
@SuppressWarnings("serial")
|
|
public class GitHubConnectorServiceImpl extends RemoteServiceServlet implements
|
|
GitHubConnectorService {
|
|
public static AccessLogger accountinglog = AccessLogger.getAccessLogger();
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(GitHubConnectorServiceImpl.class);
|
|
|
|
@Override
|
|
public void init() throws ServletException {
|
|
super.init();
|
|
logger.info("GitHubConnectorServiceImpl started!");
|
|
|
|
}
|
|
|
|
/**
|
|
*
|
|
* {@inheritDoc}
|
|
*
|
|
*/
|
|
@Override
|
|
public UserInfo hello() throws ServiceException {
|
|
try {
|
|
HttpSession session = this.getThreadLocalRequest().getSession();
|
|
ASLSession aslSession = SessionUtil.getASLSession(session);
|
|
logger.debug("hello()");
|
|
UserInfo userInfo = new UserInfo(aslSession.getUsername(),
|
|
aslSession.getGroupId(), aslSession.getGroupName(),
|
|
aslSession.getScope(), aslSession.getScopeName(),
|
|
aslSession.getUserEmailAddress(),
|
|
aslSession.getUserFullName());
|
|
logger.debug("UserInfo: " + userInfo);
|
|
return userInfo;
|
|
} catch (ServiceException e) {
|
|
e.printStackTrace();
|
|
throw e;
|
|
} catch (Throwable e) {
|
|
e.printStackTrace();
|
|
logger.error("Hello(): " + e.getLocalizedMessage(), e);
|
|
throw new ServiceException(e.getLocalizedMessage(), e);
|
|
}
|
|
|
|
}
|
|
|
|
@Override
|
|
public ArrayList<GitHubRepository> getRepositories(String repositoryOwner, GitHubCredential gitHubCredential)
|
|
throws ServiceException {
|
|
try {
|
|
HttpSession session = this.getThreadLocalRequest().getSession();
|
|
ASLSession aslSession = SessionUtil.getASLSession(session);
|
|
logger.debug("getRepository(): "+gitHubCredential);
|
|
GitConnectorService gitConnectorService=new GitConnectorService(aslSession.getUsername(), gitHubCredential);
|
|
return gitConnectorService.getRepositories(repositoryOwner);
|
|
} catch (ServiceException e) {
|
|
e.printStackTrace();
|
|
throw e;
|
|
} catch (Throwable e) {
|
|
e.printStackTrace();
|
|
logger.error("Hello(): " + e.getLocalizedMessage(), e);
|
|
throw new ServiceException(e.getLocalizedMessage(), e);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|