1 |
|
/*
|
2 |
|
package unitest;
|
3 |
|
|
4 |
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
5 |
|
import eu.dnetlib.repo.manager.config.RepoManagerContextLoaderListener;
|
6 |
|
import org.apache.commons.lang.StringEscapeUtils;
|
7 |
|
import org.junit.Test;
|
8 |
|
import org.junit.runner.RunWith;
|
9 |
|
import org.springframework.context.annotation.ComponentScan;
|
10 |
|
import org.springframework.test.context.ContextConfiguration;
|
11 |
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
12 |
|
|
13 |
|
import java.io.IOException;
|
14 |
|
import java.io.UnsupportedEncodingException;
|
15 |
|
import java.net.URL;
|
16 |
|
import java.net.URLEncoder;
|
17 |
|
import java.util.Map;
|
18 |
|
|
19 |
|
@RunWith(SpringJUnit4ClassRunner.class)
|
20 |
|
@ContextConfiguration(classes = RepoManagerContextLoaderListener.class)
|
21 |
|
public class PiwikTest {
|
22 |
|
|
23 |
|
String analyticsURL = "https://analytics.openaire.eu/addsite.php?";
|
24 |
|
|
25 |
|
@Test
|
26 |
|
public void enableMetricsRepo1(){
|
27 |
|
|
28 |
|
String officialName = "BỘ SƯU TẬP SỐ";
|
29 |
|
String repoWebsite = "http://www.vnulib.edu.vn:8000/dspace/";
|
30 |
|
|
31 |
|
enableMetrics(officialName, repoWebsite, analyticsURL);
|
32 |
|
|
33 |
|
}
|
34 |
|
|
35 |
|
@Test
|
36 |
|
public void enableMetricsRepo2(){
|
37 |
|
|
38 |
|
String officialName = "ILC4CLARIN repository of language resources and tools";
|
39 |
|
String repoWebsite = "https://dspace-clarin-it.ilc.cnr.it/repository/xmlui";
|
40 |
|
|
41 |
|
enableMetrics(officialName, repoWebsite, analyticsURL);
|
42 |
|
}
|
43 |
|
|
44 |
|
@Test
|
45 |
|
public void enableMetricsRepo3(){
|
46 |
|
|
47 |
|
String officialName = "ANSTO Publications Online";
|
48 |
|
String repoWebsite = "http://apo.ansto.gov.au/dspace/";
|
49 |
|
|
50 |
|
enableMetrics(officialName, repoWebsite, analyticsURL);
|
51 |
|
}
|
52 |
|
|
53 |
|
private void enableMetrics(String officialName, String repoWebsite, String analyticsURL) {
|
54 |
|
String url;
|
55 |
|
try {
|
56 |
|
url = analyticsURL + "siteName=" + URLEncoder.encode(officialName, "UTF-8") + "&url="
|
57 |
|
+ URLEncoder.encode(repoWebsite, "UTF-8");
|
58 |
|
url = StringEscapeUtils.escapeJava(url);
|
59 |
|
|
60 |
|
Map map = null;
|
61 |
|
String siteId = null;
|
62 |
|
|
63 |
|
URL u = new URL(url);
|
64 |
|
map = new ObjectMapper().readValue(u, Map.class);
|
65 |
|
if(map.get("value")!=null) {
|
66 |
|
siteId = map.get("value").toString();
|
67 |
|
}
|
68 |
|
} catch (Exception e) {
|
69 |
|
e.printStackTrace();
|
70 |
|
}
|
71 |
|
}
|
72 |
|
}*/
|
Removing unused files