@@ -0,0 +1,3485 @@
+/*%0A * Zayf (Zanata at your Fingertips) - a Zanata client for unstable connections%0A * Copyright (C) 2012  Alister Symons and David Mason%0A * %0A * This library is free software; you can redistribute it and/or%0A * modify it under the terms of the GNU Lesser General Public%0A * License as published by the Free Software Foundation; either%0A * version 2.1 of the License, or (at your option) any later version.%0A * %0A * This library is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU%0A * Lesser General Public License for more details.%0A * %0A * You should have received a copy of the GNU Lesser General Public%0A * License along with this library; if not, write to the Free Software%0A * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA%0A */%0Apackage org.davidmason.zayf.rest;%0A%0A//standard libs%0Aimport java.net.URI;%0Aimport java.net.URL;%0Aimport java.util.List;%0A%0A//zanata-rest-client%0Aimport org.zanata.rest.client.ZanataProxyFactory;%0A%0A//zanata-common-api%0Aimport org.zanata.rest.dto.VersionInfo;%0Aimport org.zanata.rest.dto.Project;%0Aimport org.zanata.rest.client.IProjectResource;%0Aimport org.zanata.rest.client.ITranslationResources;%0Aimport org.zanata.rest.dto.resource.ResourceMeta;%0A%0A//resteasy-jaxrs%0Aimport org.jboss.resteasy.client.ClientResponse;%0A%0A/**%0A * Provides a proxy to a Zanata server%0A */%0Apublic class ServerProxy%0A%7B%0A%0A   private URI serverURI;%0A   private String userName;%0A   private String apiKey;%0A%0A   private ZanataProxyFactory requestFactory;%0A%0A   /**%0A    * Create a new server proxy for a given server%0A    * %0A    * @param serverURI%0A    *           the base URI for the server%0A    * @param userName%0A    *           valid username for the given server%0A    * @param apiKey%0A    *           api key for the given username on the given server%0A    */%0A   public ServerProxy(URI serverURI, String userName, String apiKey)%0A   %7B%0A      this.serverURI = serverURI;%0A      this.userName = userName;%0A      this.apiKey = apiKey;%0A%0A      requestFactory = new ZanataProxyFactory(serverURI, userName, apiKey,%0A                                              new VersionInfo(%221.5.0%22, %22unknown%22));%0A      /*%0A              new ZanataProxyFactory(new URL(%22http://localhost:8080/zanata/%22).toURI(), %0A                                     %22admin%22,%0A                                     %22REDACTED%22, %0A                                     new VersionInfo(%221.5.0%22, %22unknown%22));%0A      */%0A   %7D%0A%0A   /**%0A    * Get a list of documents in a particular project-version%0A    * %0A    * @param projectSlug%0A    *           identifying slug for project%0A    * @param versionSlug%0A    *           identifying slug for version within project%0A    * @return a list of all documents in the project-version, or an empty list%0A    *         if no documents are in the project-version%0A    */%0A   public List%3CResourceMeta%3E getDocList(String projectSlug, String versionSlug)%0A   %7B%0A      ITranslationResources translationResources =%0A            requestFactory.getTranslationResources(projectSlug, versionSlug);%0A      ClientResponse%3CList%3CResourceMeta%3E%3E getResponse = translationResources.get(null);%0A      if (getResponse.getStatus() %3E= 399)%0A      %7B%0A         //FIXME use more specific exception class%0A         throw new RuntimeException(%22Error response code for document list request: %22%0A                                    + getResponse.getStatus());%0A      %7D%0A      return getResponse.getEntity();%0A   %7D%0A%0A%7D%0A

add basic implementation of server proxy