Compare commits
4 commits
32972d2046
...
a1833ddd0b
Author | SHA1 | Date | |
---|---|---|---|
a1833ddd0b | |||
611b962171 | |||
af44628def | |||
70387d3cfd |
3 changed files with 91 additions and 12 deletions
|
@ -52,20 +52,36 @@ public class GiteaAPI
|
|||
*/
|
||||
public GiteaAPI(final String url, final String token) throws IOException, ParseException
|
||||
{
|
||||
this.url = StringUtils.removeEnd(url, "/");
|
||||
this.token = token;
|
||||
try
|
||||
{
|
||||
this.url = StringUtils.removeEnd(url, "/");
|
||||
this.token = token;
|
||||
|
||||
//
|
||||
String json = IOUtils.toString(new URL(this.url + "/api/v1/admin/users?limit=100000&token=" + token), Charset.defaultCharset());
|
||||
this.users = (JSONArray) (new JSONParser().parse(json));
|
||||
//
|
||||
String json = IOUtils.toString(new URL(this.url + "/api/v1/admin/users?limit=100000&token=" + token), Charset.defaultCharset());
|
||||
this.users = (JSONArray) (new JSONParser().parse(json));
|
||||
|
||||
//
|
||||
json = IOUtils.toString(new URL(this.url + "/api/v1/admin/orgs?limit=100000&token=" + token), Charset.defaultCharset());
|
||||
this.organizations = (JSONArray) (new JSONParser().parse(json));
|
||||
//
|
||||
json = IOUtils.toString(new URL(this.url + "/api/v1/admin/orgs?limit=100000&token=" + token), Charset.defaultCharset());
|
||||
this.organizations = (JSONArray) (new JSONParser().parse(json));
|
||||
|
||||
//
|
||||
json = IOUtils.toString(new URL(this.url + "/api/v1/repos/search?limit=100000&token=" + token), Charset.defaultCharset());
|
||||
this.repositories = (JSONArray) ((JSONObject) (new JSONParser().parse(json))).get("data");
|
||||
//
|
||||
json = IOUtils.toString(new URL(this.url + "/api/v1/repos/search?limit=100000&token=" + token), Charset.defaultCharset());
|
||||
this.repositories = (JSONArray) ((JSONObject) (new JSONParser().parse(json))).get("data");
|
||||
}
|
||||
catch (IOException exception)
|
||||
{
|
||||
String message = exception.getMessage();
|
||||
if (message.matches(".*token=\\w+.*"))
|
||||
{
|
||||
message = message.replaceAll("token=\\w+", "token=*******");
|
||||
throw new IOException(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -143,7 +143,7 @@ public class GiteaProber
|
|||
}
|
||||
catch (IOException | ParseException exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
System.out.println("Error using GiteaAPI: " + exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -100,6 +100,69 @@ public class GSLProber
|
|||
result.set(Long.valueOf(value), "metrics.gsl.authors", timemarks);
|
||||
}
|
||||
|
||||
// gsl.articles.tags
|
||||
value = properties.getProperty("gsl.tags");
|
||||
if (NumberUtils.isDigits(value))
|
||||
{
|
||||
result.set(Long.valueOf(value), "metrics.gsl.tags", timemarks);
|
||||
}
|
||||
|
||||
// gsl.articles.words
|
||||
value = properties.getProperty("gsl.words");
|
||||
if (NumberUtils.isDigits(value))
|
||||
{
|
||||
result.set(Long.valueOf(value), "metrics.gsl.words", timemarks);
|
||||
}
|
||||
|
||||
// gsl.articles.quotes
|
||||
value = properties.getProperty("gsl.quotes");
|
||||
if (NumberUtils.isDigits(value))
|
||||
{
|
||||
result.set(Long.valueOf(value), "metrics.gsl.quotes", timemarks);
|
||||
}
|
||||
|
||||
// gsl.articles.paragraphs
|
||||
value = properties.getProperty("gsl.paragraphs");
|
||||
if (NumberUtils.isDigits(value))
|
||||
{
|
||||
result.set(Long.valueOf(value), "metrics.gsl.paragraphs", timemarks);
|
||||
}
|
||||
|
||||
// gsl.articles.links
|
||||
value = properties.getProperty("gsl.links");
|
||||
if (NumberUtils.isDigits(value))
|
||||
{
|
||||
result.set(Long.valueOf(value), "metrics.gsl.links", timemarks);
|
||||
}
|
||||
|
||||
// gsl.articles.links.online
|
||||
value = properties.getProperty("gsl.online");
|
||||
if (NumberUtils.isDigits(value))
|
||||
{
|
||||
result.set(Long.valueOf(value), "metrics.gsl.online", timemarks);
|
||||
}
|
||||
|
||||
// gsl.articles.lists
|
||||
value = properties.getProperty("gsl.lists");
|
||||
if (NumberUtils.isDigits(value))
|
||||
{
|
||||
result.set(Long.valueOf(value), "metrics.gsl.lists", timemarks);
|
||||
}
|
||||
|
||||
// gsl.articles.lists.items
|
||||
value = properties.getProperty("gsl.items");
|
||||
if (NumberUtils.isDigits(value))
|
||||
{
|
||||
result.set(Long.valueOf(value), "metrics.gsl.items", timemarks);
|
||||
}
|
||||
|
||||
// gsl_articles.images
|
||||
value = properties.getProperty("gsl.images");
|
||||
if (NumberUtils.isDigits(value))
|
||||
{
|
||||
result.set(Long.valueOf(value), "metrics.gsl.authors", timemarks);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue