See if Alfresco Server is available

拟墨画扇 提交于 2020-01-17 06:21:31

问题


I am working with Alfresco and sometimes the server is down for low space or other problem , the thing is with my serverURL i want to check if he is available (Alfresco Server) i thought to make a ping but the adresse is to complexe for a simple ping ex : http://127.0.0.1:8084/alfresco/api/-default-/public/cmis/versions/1.0/atom
I am working in a J2EE Project


回答1:


Hi i want to say that the part of the answer where given by @Gagravarr

public void pingADR() throws UnknownHostException, IOException {
String url = "http://127.0.0.1:8084/alfresco/service/api/server";
String status = getStatus(url);
System.out.println(url + "\t\tStatus:" + status);
}

and to see if it's available

public static String getStatus(String url) throws IOException {

    String result = "";
    try {
        URL siteURL = new URL(url);
        HttpURLConnection connection = (HttpURLConnection) siteURL
                .openConnection();
        connection.setRequestMethod("GET");
        connection.connect();

        int code = connection.getResponseCode();
        if (code == 200) {
            result = "Green";
        }
    } catch (Exception e) {
        result = "->Red<-";
    }
    return result;
}

I found this answer in a very helpful web site, Hope that will help other people



来源:https://stackoverflow.com/questions/38504722/see-if-alfresco-server-is-available

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!