1 /** 2 * This file Copyright (c) 2009-2016 Magnolia International 3 * Ltd. (http://www.magnolia-cms.com). All rights reserved. 4 * 5 * 6 * This file is dual-licensed under both the Magnolia 7 * Network Agreement and the GNU General Public License. 8 * You may elect to use one or the other of these licenses. 9 * 10 * This file is distributed in the hope that it will be 11 * useful, but AS-IS and WITHOUT ANY WARRANTY; without even the 12 * implied warranty of MERCHANTABILITY or FITNESS FOR A 13 * PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT. 14 * Redistribution, except as permitted by whichever of the GPL 15 * or MNA you select, is prohibited. 16 * 17 * 1. For the GPL license (GPL), you can redistribute and/or 18 * modify this file under the terms of the GNU General 19 * Public License, Version 3, as published by the Free Software 20 * Foundation. You should have received a copy of the GNU 21 * General Public License, Version 3 along with this program; 22 * if not, write to the Free Software Foundation, Inc., 51 23 * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 24 * 25 * 2. For the Magnolia Network Agreement (MNA), this file 26 * and the accompanying materials are made available under the 27 * terms of the MNA which accompanies this distribution, and 28 * is available at http://www.magnolia-cms.com/mna.html 29 * 30 * Any modifications to this file must keep this entire header 31 * intact. 32 * 33 */ 34 package info.magnolia.link; 35 36 import java.util.regex.Pattern; 37 38 import info.magnolia.cms.core.Content; 39 import info.magnolia.cms.core.NodeData; 40 41 /** 42 * Factory processing various input into the Link objects and back. 43 * For parsing html and converting multiple link instances on the fly use {@link LinkUtil}. 44 * 45 * @deprecated Since 5.0 use LinkUtil. 46 */ 47 public class LinkFactory { 48 private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LinkFactory.class); 49 50 /** 51 * Creates new link from the content node. 52 * @param node Target content for the link. 53 * @return Link pointing to the provided content 54 * @deprecated Since 5.0 use LinkUtil.createLinkInstance(Content) instead. 55 */ 56 public static Link createLink(Content node) { 57 return LinkUtil.createLinkInstance(node); 58 } 59 60 /** 61 * Creates new link from the node data. 62 * @param nodeData Target node data for the link. 63 * @return Link pointing to the provided node data. 64 * @deprecated Since 5.0 use LinkUtil.createLinkInstance(NodeData) instead. 65 */ 66 public static Link createLink(NodeData nodeData) throws LinkException{ 67 return LinkUtil.createLinkInstance(nodeData); 68 } 69 70 /** 71 * Creates link to the content denoted by repository and uuid. 72 * @param repository Parent repository of the content of interest. 73 * @param uuid UUID of the content to create link to. 74 * @return link to the content with provided UUID. 75 * @deprecated Since 5.0 use LinkUtil.createLinkInstance(String, String) instead. 76 */ 77 public static Link createLink(String repository, String uuid) throws LinkException { 78 return LinkUtil.createLinkInstance(repository, uuid); 79 } 80 81 /** 82 * Creates link to the content identified by the repository and path. Link will use specified extension and will also contain the anchor and parameters if specified. 83 * @param repository Source repository for the content. 84 * @param path Path to the content of interest. 85 * @param extension Optional extension to be used in the link 86 * @param anchor Optional link anchor. 87 * @param parameters Optional link parameters. 88 * @return Link pointing to the content denoted by repository and path including extension, anchor and parameters if such were provided. 89 * 90 * @deprecated Since 5.0 use info.magnolia.link.LinkUtil.createLink(String, String, String, String, String) 91 */ 92 public static Link createLink(String repository, String path, String extension, String anchor, String parameters) throws LinkException { 93 return LinkUtil.createLinkInstance(repository, path, extension, anchor, parameters); 94 } 95 96 /** 97 * Creates link based on provided parameters. Should the uuid be non existent or the fallback handle invalid, creates nonetheless an <em>"undefined"</em> {@link Link} object, 98 * pointing to the non existing uuid so that broken link detection tools can find it. 99 * @param uuid UUID of the content 100 * @param repository Content repository name. 101 * @param fallbackHandle Optional fallback content handle. 102 * @param nodeDataName Content node data name for binary data. 103 * @param extension Optional link extension. 104 * @param anchor Optional link anchor. 105 * @param parameters Optional link parameters. 106 * @return Link pointing to the content denoted by uuid and repository. Link is created using all provided optional values if present. 107 * 108 * @deprecated Since 5.0 use info.magnolia.link.LinkUtil.createLinkInstance(String, String, String, String, String, String, String) instead. 109 */ 110 public static Link createLink(String uuid, String repository, String fallbackHandle, String nodeDataName, String extension, String anchor, String parameters) throws LinkException { 111 return LinkUtil.createLinkInstance(uuid, repository, fallbackHandle, nodeDataName, extension, anchor, parameters); 112 } 113 114 /** 115 * Parses UUID link pattern string and converts it into a Link object. 116 * @param uuidLink String containing reference to content as a UUID link pattern. 117 * @return Link to content referenced in the provided text. 118 * @deprecated Since 5.0 use info.magnolia.link.LinkUtil.parseUUIDLink(String) instead. 119 */ 120 public static Link parseUUIDLink(String uuidLink) throws LinkException{ 121 return LinkUtil.parseUUIDLink(uuidLink); 122 } 123 124 /** 125 * Parses provided URI to the link. 126 * @param link URI representing path to piece of content 127 * @return Link pointing to the content represented by provided URI 128 * @deprecated Since 5.0 use info.magnolia.link.LinkUtil.parseLink(String) instead. 129 */ 130 public static Link parseLink(String link) throws LinkException{ 131 return LinkUtil.parseLink(link); 132 } 133 134 /** 135 * Converts provided Link to an UUID link pattern. 136 * @param link Link to convert. 137 * @return UUID link pattern representation of provided link. 138 * @deprecated Since 5.0 use info.magnolia.link.LinkUtil.toPattern(Link) instead. 139 */ 140 public static String toPattern(Link link) { 141 return LinkUtil.toPattern(link); 142 } 143 144 /** 145 * Pattern to find a magnolia formatted uuid link. 146 * @deprecated Since 5.0. 147 */ 148 public static Pattern UUID_PATTERN = LinkUtil.UUID_PATTERN; 149 150 /** 151 * Pattern to find a link. 152 * @deprecated Since 5.0. 153 */ 154 public static final Pattern LINK_PATTERN = LinkUtil.LINK_PATTERN; 155 }