package com.terradue.warhol;

/*
 *    Copyright 2011-2012 Terradue srl
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

import org.w3._2005.atom.Feed;

import com.sun.jersey.api.client.Client;
import com.terradue.warhol.settings.Catalogue;

public final class CatalogueConnector
{

    private static final String ATOM_XML = "application/atom+xml";

    private final Client restClient;

    public CatalogueConnector( Catalogue catalogue )
    {
        restClient = null;
    }

    Feed parse( String uri )
    {
        return restClient.resource( uri ).accept( ATOM_XML ).get( Feed.class );
    }

}

@@ -654,16 +654,92 @@
 e.%0A */%0A%0A
+import static com.terradue.warhol.lang.Preconditions.checkNotNullArgument;%0A%0A
 import o
@@ -849,16 +849,147 @@
 talogue;
+%0Aimport com.terradue.warhol.traverse.CatalogueTraverseHandler;%0Aimport com.terradue.warhol.traverse.CatalogueTraverseHandlerBuilder;
 %0A%0Apublic
@@ -1091,16 +1091,56 @@
 +xml%22;%0A%0A
+    private final Catalogue catalogue;%0A%0A
     priv
@@ -1240,25 +1240,564 @@
     
-restClient = null
+this.catalogue = checkNotNullArgument( catalogue, %22Impossible to initialize a CatalogueConnector froma  null Catalogue%22 );%0A        restClient = null;%0A    %7D%0A%0A    public CatalogueTraverseHandlerBuilder traverse()%0A    %7B%0A        return new CatalogueTraverseHandlerBuilder()%0A        %7B%0A%0A            @Override%0A            public void with( CatalogueTraverseHandler traverseHandler )%0A            %7B%0A                traverseHandler = checkNotNullArgument( traverseHandler, %22Impossible to traverse the Catalogue %3C%25s%3E with a null handler%22 );%0A%0A%0A            %7D%0A%0A        %7D
 ;%0A  

store locally the Catalogue refernce