cancel
Showing results for 
Search instead for 
Did you mean: 

Validate instance of Alfresco and its services

developer_resea
Champ in-the-making
Champ in-the-making
Hello,

     I am trying integrate Alfresco and a java web application, therefore a requeriment is manage the conexion with Alfresco Server. I can use apache HTTP Components (HttpClient) for validate the conexión to the server hosting Alfresco and if the wsdl of the services are available. My doubts and questions are: Is this enough? What other validations should be done?

Thanks and regards,
1 REPLY 1

jcustovic
Champ in-the-making
Champ in-the-making
I use this code to check if alfresco is up and I had no problems with it. If alfresco is up its services are up. To check services use web service to try to authenticate: AuthenticationUtils.startSession(alfrescoUsername, alfrescoPassword).

public boolean isAlfrescoReachable(String url) {
      if (url == null || url.isEmpty()) throw new IllegalArgumentException("Url must not be null or empty.");
      try {
         URL url = new URL(url); // Url to alfresco app example. http://localhost:8080/alfresco
         HttpURLConnection urlConnect = (HttpURLConnection) url.openConnection();
         urlConnect.setConnectTimeout(10000);
         urlConnect.setReadTimeout(15000);
         int responseCode = urlConnect.getResponseCode();
         log.debug("Alfresco response code " + responseCode);
         if (responseCode != HttpURLConnection.HTTP_OK) {
            // Everyting ok
            return true;
         } else {
            // Depends on status code but probably ok
         }
      } catch (UnknownHostException e) {
         log.debug(e, e);
         return false;
      } catch (IOException e) {
         log.debug(e, e);
         return false;
      }
      return true;
    }