JAL-1925 update source version in license
[jalview.git] / src / jalview / ws / dbsources / PDBRestClient.java
index 09c10ef..16b3f55 100644 (file)
@@ -1,5 +1,26 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b2)
+ * Copyright (C) 2015 The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
 package jalview.ws.dbsources;
 
+import jalview.util.MessageManager;
 import jalview.ws.uimodel.PDBRestRequest;
 import jalview.ws.uimodel.PDBRestResponse;
 import jalview.ws.uimodel.PDBRestResponse.PDBResponseSummary;
@@ -22,7 +43,6 @@ import com.sun.jersey.api.client.WebResource;
 import com.sun.jersey.api.client.config.ClientConfig;
 import com.sun.jersey.api.client.config.DefaultClientConfig;
 
-
 /**
  * A rest client for querying the Search endpoing of the PDB REST API
  * 
@@ -59,7 +79,6 @@ public class PDBRestClient
               .getFieldToSortBy().trim().isEmpty()) ? "" : (pdbRestRequest
               .getFieldToSortBy() + (pdbRestRequest.isAscending() ? " asc"
               : " desc"));
-
       // Build request parameters for the REST Request
       WebResource webResource = client.resource(PDB_SEARCH_ENDPOINT)
               .queryParam("wt", "json").queryParam("fl", wantedFields)
@@ -103,16 +122,17 @@ public class PDBRestClient
       String exceptionMsg = e.getMessage();
       if (exceptionMsg.contains("SocketException"))
       {
-        throw new Exception(
-                "Jalview is unable to detect an internet connection");
         // No internet connection
+        throw new Exception(
+                MessageManager
+                        .getString("exception.unable_to_detect_internet_connection"));
       }
       else if (exceptionMsg.contains("UnknownHostException"))
       {
-        throw new Exception(
-                "Jalview is unable to reach the host server \'www.ebi.ac.uk\'. "
-                        + "\nPlease ensure that you are connected to the internet and try again.");
         // The server 'www.ebi.ac.uk' is unreachable
+        throw new Exception(
+                MessageManager
+                        .getString("exception.pdb_server_unreachable"));
       }
       else
       {
@@ -127,11 +147,12 @@ public class PDBRestClient
     switch (code)
     {
     case 410:
-      message = "PDB Rest Service no longer exists!";
+      message = MessageManager
+              .getString("exception.pdb_rest_service_no_longer_available");
       break;
     case 403:
     case 404:
-      message = "The requested resource could not be found";
+      message = MessageManager.getString("exception.resource_not_be_found");
       break;
     case 408:
     case 409:
@@ -141,7 +162,7 @@ public class PDBRestClient
     case 503:
     case 504:
     case 505:
-      message = "There seems to be an error from the PDB Rest API server.";
+      message = MessageManager.getString("exception.pdb_server_error");
       break;
 
     default:
@@ -398,4 +419,4 @@ public class PDBRestClient
       return name;
     }
   }
-}
\ No newline at end of file
+}