001/* 002 * (C) Copyright 2006-2007 Nuxeo SAS (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Nuxeo - initial API and implementation 016 * 017 * $Id: JOOoConvertPluginImpl.java 18651 2007-05-13 20:28:53Z sfermigier $ 018 */ 019 020package org.nuxeo.ecm.webapp.helpers; 021 022import static org.jboss.seam.ScopeType.SESSION; 023 024import java.io.Serializable; 025 026import org.jboss.seam.annotations.Begin; 027import org.jboss.seam.annotations.In; 028import org.jboss.seam.annotations.Name; 029import org.jboss.seam.annotations.web.RequestParameter; 030import org.jboss.seam.annotations.Scope; 031import org.jboss.seam.annotations.Startup; 032import org.nuxeo.ecm.core.api.DocumentRef; 033import org.nuxeo.ecm.platform.ui.web.api.NavigationContext; 034import org.nuxeo.ecm.platform.ui.web.util.DocumentLocator; 035 036@Startup 037@Name("paralleleNavigationHelper") 038@Scope(SESSION) 039public class ParalleleNavigationHelper implements Serializable { 040 041 private static final long serialVersionUID = 16794309876876L; 042 043 public static final String PARALLELE_URL_PREFIX = "/parallele.faces?"; 044 045 @In(create = true) 046 protected transient NavigationContext navigationContext; 047 048 @In(create = true) 049 ConversationIdGenerator conversationIdGenerator; 050 051 @RequestParameter 052 String docRef; 053 054 // Start a new Main conversation 055 @Begin(id = "#{conversationIdGenerator.nextMainConversationId}") 056 public String navigateToURL() { 057 if (docRef == null) { 058 return null; 059 } 060 return navigationContext.navigateToURL(docRef); 061 } 062 063 public String getCurrentDocumentFullUrl() { 064 String internalURL = navigationContext.getCurrentDocumentFullUrl(); 065 return internalURL.replace(DocumentLocator.URL_PREFIX, PARALLELE_URL_PREFIX); 066 } 067 068 public String getDocumentFullUrl(DocumentRef docRef) { 069 String internalURL = DocumentLocator.getFullDocumentUrl(navigationContext.getCurrentServerLocation(), docRef); 070 return internalURL.replace(DocumentLocator.URL_PREFIX, PARALLELE_URL_PREFIX); 071 } 072 073}