001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.jetspeed.om.page.impl;
018:
019: import java.util.Collection;
020:
021: import org.apache.jetspeed.om.page.Link;
022: import org.apache.jetspeed.om.page.PageMetadataImpl;
023: import org.apache.jetspeed.page.document.impl.DocumentImpl;
024:
025: /**
026: * LinkImpl
027: *
028: * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
029: * @version $Id$
030: */
031: public class LinkImpl extends DocumentImpl implements Link {
032: private String skin;
033: private String target;
034: private String url;
035:
036: public LinkImpl() {
037: super (new LinkSecurityConstraintsImpl());
038: }
039:
040: /* (non-Javadoc)
041: * @see org.apache.jetspeed.page.document.impl.NodeImpl#newPageMetadata(java.util.Collection)
042: */
043: public PageMetadataImpl newPageMetadata(Collection fields) {
044: PageMetadataImpl pageMetadata = new PageMetadataImpl(
045: LinkMetadataLocalizedFieldImpl.class);
046: pageMetadata.setFields(fields);
047: return pageMetadata;
048: }
049:
050: /* (non-Javadoc)
051: * @see org.apache.jetspeed.om.page.impl.BaseElementImpl#grantViewActionAccess()
052: */
053: public boolean grantViewActionAccess() {
054: // always allow links that reference absolute urls since these
055: // are probably not a security related concern but rather
056: // should always be viewable, (subject to folder access)
057: String hrefUrl = getUrl();
058: return ((hrefUrl != null) && (hrefUrl.startsWith("http://") || hrefUrl
059: .startsWith("https://")));
060: }
061:
062: /* (non-Javadoc)
063: * @see org.apache.jetspeed.page.document.Node#getUrl()
064: */
065: public String getUrl() {
066: return url;
067: }
068:
069: /* (non-Javadoc)
070: * @see org.apache.jetspeed.om.page.Link#setUrl(java.lang.String)
071: */
072: public void setUrl(String url) {
073: this .url = url;
074: }
075:
076: /* (non-Javadoc)
077: * @see org.apache.jetspeed.om.page.Link#getSkin()
078: */
079: public String getSkin() {
080: return skin;
081: }
082:
083: /* (non-Javadoc)
084: * @see org.apache.jetspeed.om.page.Link#setSkin(java.lang.String)
085: */
086: public void setSkin(String skin) {
087: this .skin = skin;
088: }
089:
090: /* (non-Javadoc)
091: * @see org.apache.jetspeed.om.page.Link#getTarget()
092: */
093: public String getTarget() {
094: return target;
095: }
096:
097: /* (non-Javadoc)
098: * @see org.apache.jetspeed.om.page.Link#setTarget(java.lang.String)
099: */
100: public void setTarget(String target) {
101: this .target = target;
102: }
103:
104: /* (non-Javadoc)
105: * @see org.apache.jetspeed.page.document.Node#getType()
106: */
107: public String getType() {
108: return DOCUMENT_TYPE;
109: }
110: }
|