001package org.nuxeo.template.jaxrs.context; 002 003import org.nuxeo.ecm.core.api.DocumentModel; 004import org.nuxeo.runtime.api.Framework; 005import org.nuxeo.template.api.context.DocumentWrapper; 006 007public class JAXRSExtensions { 008 009 protected final DocumentModel doc; 010 011 protected final DocumentWrapper nuxeoWrapper; 012 013 protected final String templateName; 014 015 public JAXRSExtensions(DocumentModel doc, DocumentWrapper nuxeoWrapper, String templateName) { 016 this.doc = doc; 017 this.nuxeoWrapper = nuxeoWrapper; 018 this.templateName = templateName; 019 } 020 021 protected static String getContextPathProperty() { 022 return Framework.getProperty("org.nuxeo.ecm.contextPath", "/nuxeo"); 023 } 024 025 public String getResourceUrl(String resourceName) { 026 StringBuffer sb = new StringBuffer(getContextPathProperty()); 027 sb.append("/site/templates/doc/"); 028 sb.append(doc.getId()); 029 sb.append("/resource/"); 030 sb.append(templateName); 031 sb.append("/"); 032 sb.append(resourceName); 033 return sb.toString(); 034 } 035}