View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    * 
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.jetspeed.om.page.psml;
18  
19  import org.apache.jetspeed.om.page.Link;
20  
21  /***
22   * <p>
23   * Link
24   * </p>
25   * <p>
26   *
27   * </p>
28   * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
29   * @version $Id: LinkImpl.java 516448 2007-03-09 16:25:47Z ate $
30   *
31   */
32  public class LinkImpl extends DocumentImpl implements Link 
33  {
34      
35      private String skin;
36  
37      private String target;
38      
39      /***
40       * <p>
41       * getType
42       * </p>
43       *
44       * @see org.apache.jetspeed.om.page.Document#getType()
45       * @return
46       */
47      public String getType()
48      {       
49          return DOCUMENT_TYPE;
50      }
51  
52      /* (non-Javadoc)
53       * @see org.apache.jetspeed.om.page.Link#getSkin()
54       */
55      public String getSkin()
56      {
57          return skin;
58      }
59  
60      /* (non-Javadoc)
61       * @see org.apache.jetspeed.om.page.Link#setSkin(java.lang.String)
62       */
63      public void setSkin( String skin )
64      {
65          this.skin = skin;
66      }
67  
68      /***
69       * @return Returns the target.
70       */
71      public String getTarget()
72      {
73          return target;
74      }
75      
76      /***
77       * @param target The target to set.
78       */
79      public void setTarget( String target )
80      {
81          this.target = target;
82      }
83  
84      /***
85       * <p>
86       * grantViewActionAccess
87       * </p>
88       *
89       * @return granted access for view action
90       */
91      public boolean grantViewActionAccess()
92      {
93          // always allow links that reference absolute urls since these
94          // are probably not a security related concern but rather
95          // should always be viewable, (subject to folder access)
96          String hrefUrl = getUrl();
97          return ((hrefUrl != null) && (hrefUrl.startsWith("http://") || hrefUrl.startsWith("https://")));
98      }
99  
100     /***
101      * unmarshalled - notification that this instance has been
102      *                loaded from the persistent store
103      */
104     public void unmarshalled()
105     {
106         // notify super class implementation
107         super.unmarshalled();
108 
109         // default title of pages to name
110         if (getTitle() == null)
111         {
112             setTitle(getTitleName());
113         }
114     }
115 }