001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau.examples.rest.dto;
014
015import org.apache.juneau.jsonschema.annotation.ExternalDocs;
016import org.apache.juneau.dto.*;
017import org.apache.juneau.examples.rest.petstore.dto.*;
018import org.apache.juneau.html.annotation.*;
019import org.apache.juneau.http.annotation.*;
020import org.apache.juneau.rest.*;
021import org.apache.juneau.rest.annotation.*;
022import org.apache.juneau.rest.helper.*;
023import org.apache.juneau.rest.widget.*;
024
025/**
026 * Sample REST resource for rendering predefined label beans.
027 *
028 * <ul class='seealso'>
029 *    <li class='extlink'>{@source}
030 * </ul>
031 */
032@RestResource(
033   path="/predefinedLabels",
034   title="Predefined Label Beans",
035   description="Shows examples of predefined label beans",
036   swagger=@ResourceSwagger(
037      contact=@Contact(name="Juneau Developer",email="dev@juneau.apache.org"),
038      license=@License(name="Apache 2.0",url="http://www.apache.org/licenses/LICENSE-2.0.html"),
039      version="2.0",
040      termsOfService="You are on your own.",
041      externalDocs=@ExternalDocs(description="Apache Juneau",url="http://juneau.apache.org")
042   )
043)
044@HtmlDocConfig(
045   widgets={
046      ContentTypeMenuItem.class,
047      ThemeMenuItem.class
048   },
049   navlinks={
050      "up: request:/..",
051      "options: servlet:/?method=OPTIONS",
052      "$W{ContentTypeMenuItem}",
053      "$W{ThemeMenuItem}",
054      "source: $C{Source/gitHub}/org/apache/juneau/examples/rest/dto/$R{servletClassSimple}.java"
055   }
056)
057public class PredefinedLabelsResource extends BasicRestServlet {
058   private static final long serialVersionUID = 1L;
059
060   /**
061    * Returns the list of child resource descriptions.
062    *
063    * @return The list of child resource descriptions.
064    */
065   @RestMethod
066   public ResourceDescriptions get() {
067      return new ResourceDescriptions()
068         .append("beanDescription", "BeanDescription")
069         .append("htmlLinks", "HtmlLink")
070      ;
071   }
072
073   /**
074    * Returns the bean description of the {@link Pet} class.
075    *
076    * @return The bean description of the {@link Pet} class.
077    */
078   @RestMethod
079   public BeanDescription getBeanDescription() {
080      return new BeanDescription(Pet.class);
081   }
082
083   /**
084    * Returns a list of hyperlinked strings.
085    *
086    * @return A list of hyperlinked strings.
087    */
088   @RestMethod
089   public LinkString[] getHtmlLinks() {
090      return new LinkString[] {
091         new LinkString("apache", "http://apache.org"),
092         new LinkString("juneau", "http://juneau.apache.org")
093      };
094   }
095}