mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
- extracting utility methods from sample website into generalized extension functions that can be used from xsl, freemarker (i hope), and jsp. they all use AVMRemote to access data and each context has it's own adapter. - implemented callout functions from xsl. able to load multiple documents and traverse them. - removed QNames from TemplatingService and added them to WCMModel. this will break edit on any existing assets - you'll have to create new ones that have the right properties. still not happy with model since besides not having child associations in place, i don't have a way of differentiating between the generated xmls and the other generated assets. major bug. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4138 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
65 lines
2.1 KiB
Java
65 lines
2.1 KiB
Java
/*
|
|
* Copyright (C) 2005 Alfresco, Inc.
|
|
*
|
|
* Licensed under the Mozilla Public License version 1.1
|
|
* with a permitted attribution clause. You may obtain a
|
|
* copy of the License at
|
|
*
|
|
* http://www.alfresco.org/legal/license.txt
|
|
*
|
|
* Unless required by applicable law or agreed to in writing,
|
|
* software distributed under the License is distributed on an
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
|
* either express or implied. See the License for the specific
|
|
* language governing permissions and limitations under the
|
|
* License.
|
|
*/
|
|
package org.alfresco.web.templating.extension;
|
|
|
|
import org.alfresco.jndi.AVMFileDirContext;
|
|
import org.w3c.dom.Document;
|
|
import org.xml.sax.SAXException;
|
|
import javax.servlet.ServletContext;
|
|
import java.io.IOException;
|
|
import java.util.Map;
|
|
|
|
public class ServletContextExtensionFunctionsAdapter
|
|
extends ExtensionFunctions
|
|
{
|
|
|
|
private final ServletContext servletContext;
|
|
|
|
public ServletContextExtensionFunctionsAdapter(final ServletContext servletContext)
|
|
{
|
|
super(AVMFileDirContext.getAVMRemote());
|
|
this.servletContext = servletContext;
|
|
}
|
|
|
|
private String toAVMPath(String path)
|
|
{
|
|
// The real_path will look somethign like this:
|
|
// /alfresco.avm/avm.alfresco.localhost/$-1$alfreco-guest-main:/appBase/avm_webapps/my_webapp
|
|
path = this.servletContext.getRealPath(path);
|
|
|
|
// The avm_path to the root of the context will look something like this:
|
|
// alfreco-guest-main:/appBase/avm_webapps/my_webapp
|
|
path = path.substring(path.indexOf('$', path.indexOf('$') + 1) + 1);
|
|
path = path.replace('\\','/');
|
|
return path;
|
|
}
|
|
|
|
public Document getXMLDocument(final String path)
|
|
throws IOException,
|
|
SAXException
|
|
{
|
|
return super.getXMLDocument(this.toAVMPath(path));
|
|
}
|
|
|
|
public Map<String, Document> getXMLDocuments(final String templateTypeName,
|
|
final String path)
|
|
throws IOException,
|
|
SAXException
|
|
{
|
|
return super.getXMLDocuments(templateTypeName, this.toAVMPath(path));
|
|
}
|
|
} |