Upgraded project files

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-insert-storage-se-plugin@149369 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2017-06-09 15:57:34 +00:00
parent c8a24f1bd8
commit 75c49047b9
3 changed files with 30 additions and 30 deletions

View File

@ -12,7 +12,7 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>

View File

@ -1,5 +1,5 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.7 org.eclipse.jdt.core.compiler.source=1.7

View File

@ -1,11 +1,11 @@
package org.gcube.accounting.insert.storage.utils; package org.gcube.accounting.insert.storage.utils;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
@ -15,40 +15,41 @@ import org.slf4j.LoggerFactory;
import com.google.gson.Gson; import com.google.gson.Gson;
/** /**
* Retrieves the list user form the base url of the social-networking service in the scope provided * Retrieves the list user form the base url of the social-networking service in
* @author Alessandro Pieve at ISTI-CNR * the scope provided
* (alessandro.pieve@isti.cnr.it) *
* @author Alessandro Pieve at ISTI-CNR (alessandro.pieve@isti.cnr.it)
*/ */
public class DiscoveryListUser { public class DiscoveryListUser {
private static Logger log = LoggerFactory.getLogger(DiscoveryListUser.class); private static Logger log = LoggerFactory.getLogger(DiscoveryListUser.class);
private List<String> listUser = null; private List<String> listUser = null;
public DiscoveryListUser(String context,String urlService) {
public DiscoveryListUser(String context, String urlService) {
try{ try {
String token =SecurityTokenProvider.instance.get(); String token = SecurityTokenProvider.instance.get();
DiscoveryServiceListUser discoveryList= new DiscoveryServiceListUser(context); DiscoveryServiceListUser discoveryList = new DiscoveryServiceListUser(context);
if (urlService==null){ if (urlService == null) {
urlService=discoveryList.getBasePath()+"="+token; urlService = discoveryList.getBasePath() + "=" + token;
} }
log.debug("service DiscoveryServiceListUser:"+urlService); log.debug("service DiscoveryServiceListUser:" + urlService);
log.debug("scope:{} ,tokend:{}",context,token); log.debug("scope:{} ,tokend:{}", context, token);
String data = getJSON(urlService); String data = getJSON(urlService);
log.debug("data read:{}",data); log.debug("data read:{}", data);
ListUser msg = new Gson().fromJson(data, ListUser.class); ListUser msg = new Gson().fromJson(data, ListUser.class);
//TODO for debug limit a list user: // TODO for debug limit a list user:
listUser=msg.getResult(); listUser = msg.getResult();
} } catch (Exception ex) {
catch (Exception ex) { log.error("DiscoveryListUserException:{}", ex);
log.error("DiscoveryListUserException:{}",ex); throw ex;
throw ex ;
} }
} }
/** /**
* Get the base path of the social networking service * Get the base path of the social networking service
*
* @return * @return
*/ */
public List<String> getListUser() { public List<String> getListUser() {
@ -67,40 +68,39 @@ public class DiscoveryListUser {
c = (HttpURLConnection) u.openConnection(); c = (HttpURLConnection) u.openConnection();
c.setRequestMethod("GET"); c.setRequestMethod("GET");
c.setRequestProperty("Content-length", "0"); c.setRequestProperty("Content-length", "0");
c.setFollowRedirects(true); HttpURLConnection.setFollowRedirects(true);
c.setUseCaches(false); c.setUseCaches(false);
c.setAllowUserInteraction(false); c.setAllowUserInteraction(false);
c.connect(); c.connect();
int status = c.getResponseCode(); int status = c.getResponseCode();
log.debug("status:{}",status); log.debug("status:{}", status);
switch (status) { switch (status) {
case 200: case 200:
case 201: case 201:
BufferedReader br = new BufferedReader(new InputStreamReader(c.getInputStream())); BufferedReader br = new BufferedReader(new InputStreamReader(c.getInputStream()));
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
String line; String line;
while ((line = br.readLine()) != null) { while ((line = br.readLine()) != null) {
sb.append(line+"\n"); sb.append(line + "\n");
} }
br.close(); br.close();
return sb.toString(); return sb.toString();
} }
} catch (MalformedURLException ex) { } catch (MalformedURLException ex) {
log.error("MalformedURLException:{}",ex); log.error("MalformedURLException:{}", ex);
} catch (IOException ex) { } catch (IOException ex) {
log.error("IOException:{}",ex); log.error("IOException:{}", ex);
} finally { } finally {
if (c != null) { if (c != null) {
try { try {
c.disconnect(); c.disconnect();
} catch (Exception ex) { } catch (Exception ex) {
log.error("Exception:{}",ex); log.error("Exception:{}", ex);
} }
} }
} }
return null; return null;
} }
} }