This commit is contained in:
Massimiliano Assante 2019-09-17 17:55:53 +02:00
parent 7ad9ab3f43
commit 18a451138f
3 changed files with 15 additions and 10 deletions

View File

@ -1,4 +1,8 @@
<ReleaseNotes>
<Changeset component="org.gcube.portlet.user.my-vres.2-6-0"
date="2019-09-17">
<Change>It provides part of the gcube oAuth2 service with capability to be deployed on a multi instance cluster, it no longer posts the temporary code to the oAuth service, it places it in the memcahced cluster.</Change>
</Changeset>
<Changeset component="org.gcube.portlet.user.my-vres.2-5-0"
date="2017-11-03">
<Change>Ported to GWT 2.8.1

View File

@ -3,7 +3,6 @@ package org.gcube.portlet.user.my_vres.server;
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.List;
@ -17,6 +16,7 @@ import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
import org.slf4j.LoggerFactory;
import net.spy.memcached.KetamaConnectionFactory;
import net.spy.memcached.MemcachedClient;
/**
@ -43,8 +43,8 @@ public class DistributedCacheClient {
private DistributedCacheClient(){
List<InetSocketAddress> addrs = discoverHostOfServiceEndpoint();
try {
mClient = new MemcachedClient(addrs);
} catch (IOException e) {
mClient = new MemcachedClient(new KetamaConnectionFactory(), addrs);
} catch (Exception e) {
e.printStackTrace();
}
}

View File

@ -36,6 +36,7 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.liferay.portal.service.UserLocalServiceUtil;
import net.spy.memcached.MemcachedClient;
import net.spy.memcached.internal.OperationFuture;
/**
* The server side implementation of the RPC service.
@ -45,9 +46,7 @@ import net.spy.memcached.MemcachedClient;
public class MyVREsServiceImpl extends RemoteServiceServlet implements MyVREsService {
private static final Logger _log = LoggerFactory.getLogger(MyVREsServiceImpl.class);
/**
*
*/
public static final String CACHED_VOS = "CACHED_VRES";
/**
* needed when querying for authorised services in authentication
@ -96,7 +95,6 @@ public class MyVREsServiceImpl extends RemoteServiceServlet implements MyVREsSer
LinkedHashMap<String, ArrayList<VRE>> toReturn = new LinkedHashMap<String, ArrayList<VRE>>();
List<VirtualGroup> currentSiteVGroups = gm.getVirtualGroups(ManagementUtils.getSiteGroupIdFromServletRequest(getThreadLocalRequest().getServerName()));
for (VirtualGroup vg : currentSiteVGroups) {
String gName = vg.getName();
@ -349,6 +347,7 @@ public class MyVREsServiceImpl extends RemoteServiceServlet implements MyVREsSer
*/
@SuppressWarnings("unchecked")
private boolean authorizeApplication(String infrastructureName, String qToken, String tempCode, String clientId, String redirectURL) {
OperationFuture<Boolean> writeOp = null;
try {
//instance the client if first time
if (entries == null)
@ -361,12 +360,14 @@ public class MyVREsServiceImpl extends RemoteServiceServlet implements MyVREsSer
object.put("redirect_uri", redirectURL);
object.put("client_id", clientId);
String JSONData = object.toJSONString();
entries.set(tempCode, CACHE_SECONDS_EXPIRATION, JSONData);
writeOp = entries.set(tempCode, CACHE_SECONDS_EXPIRATION, JSONData);
} catch (Exception e) {
e.printStackTrace();
return false;
return writeOp.getStatus().isSuccess();
}
return true;
return writeOp.getStatus().isSuccess();
}