001/* 002 * (C) Copyright 2006-2007 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Nuxeo - initial API and implementation 018 * 019 * $Id: DocumentViewCodecManager.java 22535 2007-07-13 14:57:58Z atchertchian $ 020 */ 021 022package org.nuxeo.ecm.platform.url.api; 023 024import java.io.Serializable; 025 026import org.nuxeo.ecm.platform.url.codec.api.DocumentViewCodec; 027 028/** 029 * Service used generate meaningful and permanent urls. 030 * <p> 031 * It handles a set of codecs, used to code/decode a document information between a url and a {@link DocumentView} 032 * instance. 033 * 034 * @author <a href="mailto:at@nuxeo.com">Anahide Tchertchian</a> 035 */ 036public interface DocumentViewCodecManager extends Serializable { 037 038 /** 039 * Returns the default codec name. 040 * <p> 041 * This information is set on codec descriptors. 042 */ 043 String getDefaultCodecName(); 044 045 /** 046 * Returns the {@link DocumentViewCodec} with the given name or {@code null} if ot doesn't exist. 047 * 048 * @since 8.10 049 */ 050 DocumentViewCodec getCodec(String name); 051 052 /** 053 * Returns a DocumentView applying for given url, or null. 054 * <p> 055 * Iterates over registered codecs, starting from the default codec, and if 056 * {@link DocumentViewCodec#handleUrl(String)} returns true, calls 057 * {@link DocumentViewCodec#getDocumentViewFromUrl(String)}. Stops iterating when a codec returns a non-null value. 058 * 059 * @param url the original url from request, including request parameters if any. 060 * @param hasBaseUrl boolean indicating if base url should be removed from given url. 061 * @param baseUrl value of the base url. 062 */ 063 DocumentView getDocumentViewFromUrl(String url, boolean hasBaseUrl, String baseUrl); 064 065 /** 066 * Returns a DocumentView calling {@link DocumentViewCodec#getDocumentViewFromUrl(String, boolean, String)} on codec 067 * with given name. 068 * 069 * @param url the original url from request, including request parameters if any. 070 * @param hasBaseUrl boolean indicating if base url should be removed from given url. 071 * @param baseUrl value of the base url. 072 */ 073 DocumentView getDocumentViewFromUrl(String codecName, String url, boolean hasBaseUrl, String baseUrl); 074 075 /** 076 * Returns an URL applying for given document view, or null. 077 * <p> 078 * Iterates over registered codecs, starting from the default codec, and if 079 * {@link DocumentViewCodec#handleDocumentView(DocumentView)} returns true, calls 080 * {@link DocumentViewCodec#getUrlFromDocumentView(DocumentView)}. Stops iterating when a codec returns a non-null 081 * value. am docView the original document view from request 082 * 083 * @param docView the original document view from request 084 * @param hasBaseUrl boolean indicating if base url should be added to the url returned by the codec. 085 * @param baseUrl value of the base url. 086 */ 087 String getUrlFromDocumentView(DocumentView docView, boolean needBaseUrl, String baseUrl); 088 089 /** 090 * Returns an URL calling {@link DocumentViewCodec#getUrlFromDocumentView(DocumentView) on codec with given name. 091 * 092 * @param docView the original document view from request 093 * @param hasBaseUrl boolean indicating if base url should be added to the url returned by the codec. 094 * @param baseUrl value of the base url. 095 */ 096 String getUrlFromDocumentView(String codecName, DocumentView docView, boolean needBaseUrl, String baseUrl); 097 098}