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.impl; 18 19 import java.util.Collection; 20 21 import org.apache.jetspeed.om.page.Link; 22 import org.apache.jetspeed.om.page.PageMetadataImpl; 23 import org.apache.jetspeed.page.document.impl.DocumentImpl; 24 25 /*** 26 * LinkImpl 27 * 28 * @author <a href="mailto:rwatler@apache.org">Randy Watler</a> 29 * @version $Id$ 30 */ 31 public class LinkImpl extends DocumentImpl implements Link 32 { 33 private String skin; 34 private String target; 35 private String url; 36 37 public LinkImpl() 38 { 39 super(new LinkSecurityConstraintsImpl()); 40 } 41 42 /* (non-Javadoc) 43 * @see org.apache.jetspeed.page.document.impl.NodeImpl#newPageMetadata(java.util.Collection) 44 */ 45 public PageMetadataImpl newPageMetadata(Collection fields) 46 { 47 PageMetadataImpl pageMetadata = new PageMetadataImpl(LinkMetadataLocalizedFieldImpl.class); 48 pageMetadata.setFields(fields); 49 return pageMetadata; 50 } 51 52 /* (non-Javadoc) 53 * @see org.apache.jetspeed.om.page.impl.BaseElementImpl#grantViewActionAccess() 54 */ 55 public boolean grantViewActionAccess() 56 { 57 // always allow links that reference absolute urls since these 58 // are probably not a security related concern but rather 59 // should always be viewable, (subject to folder access) 60 String hrefUrl = getUrl(); 61 return ((hrefUrl != null) && (hrefUrl.startsWith("http://") || hrefUrl.startsWith("https://"))); 62 } 63 64 /* (non-Javadoc) 65 * @see org.apache.jetspeed.page.document.Node#getUrl() 66 */ 67 public String getUrl() 68 { 69 return url; 70 } 71 72 /* (non-Javadoc) 73 * @see org.apache.jetspeed.om.page.Link#setUrl(java.lang.String) 74 */ 75 public void setUrl(String url) 76 { 77 this.url = url; 78 } 79 80 /* (non-Javadoc) 81 * @see org.apache.jetspeed.om.page.Link#getSkin() 82 */ 83 public String getSkin() 84 { 85 return skin; 86 } 87 88 /* (non-Javadoc) 89 * @see org.apache.jetspeed.om.page.Link#setSkin(java.lang.String) 90 */ 91 public void setSkin(String skin) 92 { 93 this.skin = skin; 94 } 95 96 /* (non-Javadoc) 97 * @see org.apache.jetspeed.om.page.Link#getTarget() 98 */ 99 public String getTarget() 100 { 101 return target; 102 } 103 104 /* (non-Javadoc) 105 * @see org.apache.jetspeed.om.page.Link#setTarget(java.lang.String) 106 */ 107 public void setTarget(String target) 108 { 109 this.target = target; 110 } 111 112 /* (non-Javadoc) 113 * @see org.apache.jetspeed.page.document.Node#getType() 114 */ 115 public String getType() 116 { 117 return DOCUMENT_TYPE; 118 } 119 }