View Javadoc

1   package com.terradue.jcatalogue.client;
2   
3   /*
4    *    Copyright 2011-2012 Terradue srl
5    *
6    *    Licensed under the Apache License, Version 2.0 (the "License");
7    *    you may not use this file except in compliance with the License.
8    *    You may obtain a copy of the License at
9    *
10   *       http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *    Unless required by applicable law or agreed to in writing, software
13   *    distributed under the License is distributed on an "AS IS" BASIS,
14   *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   *    See the License for the specific language governing permissions and
16   *    limitations under the License.
17   */
18  
19  import static com.terradue.jcatalogue.client.MimeTypes.ATOM_XML;
20  
21  import java.nio.charset.Charset;
22  import java.util.HashMap;
23  import java.util.Locale;
24  import java.util.Map;
25  
26  import lombok.AccessLevel;
27  import lombok.Data;
28  import lombok.EqualsAndHashCode;
29  import lombok.Getter;
30  
31  @Data
32  @EqualsAndHashCode( callSuper = true )
33  public final class CatalogueDescription
34      extends CatalogueEntity
35  {
36  
37      @Getter( AccessLevel.NONE )
38      private final Map<String, OpenSearchUrl> typeUrlTemplates = new HashMap<String, OpenSearchUrl>();
39  
40      private String shortName;
41  
42      private String longName;
43  
44      private String description;
45  
46      private String[] tags;
47  
48      private String contact;
49  
50      private String developer;
51  
52      private String attribution;
53  
54      private String syndicationRight;
55  
56      private boolean adultContent;
57  
58      private Locale language;
59  
60      private Charset inputEncoding;
61  
62      private Charset outputEncoding;
63  
64      public void addOpenSearchUrl( OpenSearchUrl url )
65      {
66          typeUrlTemplates.put( url.getType(), url );
67      }
68  
69      public Iterable<OpenSearchUrl> getOpenSearchUrls()
70      {
71          return typeUrlTemplates.values();
72      }
73  
74      @Override
75      void setCatalogueClient( CatalogueClient catalogueClient )
76      {
77          super.setCatalogueClient( catalogueClient );
78          for ( OpenSearchUrl url : typeUrlTemplates.values() )
79          {
80              url.setCatalogueClient( catalogueClient );
81          }
82      }
83  
84      public Catalogue getCatalogue( Parameter...parameters )
85      {
86          if ( !typeUrlTemplates.containsKey( ATOM_XML ) )
87          {
88              throw new IllegalStateException( "Direct URL invocation supports application/atom+xml only" );
89          }
90  
91          return typeUrlTemplates.get( ATOM_XML ).invoke( parameters );
92      }
93  
94  }