1 /*
2 * Copyright (C) 2003-2008 eXo Platform SAS.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Affero General Public License
6 * as published by the Free Software Foundation; either version 3
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see<http://www.gnu.org/licenses/>.
16 */
17 package org.exoplatform.ecm.resolver;
18
19 import java.io.InputStream;
20
21 import javax.jcr.Node;
22 import javax.jcr.Session;
23
24 import org.exoplatform.services.jcr.ext.common.SessionProvider;
25 import org.exoplatform.services.wcm.utils.WCMCoreUtils;
26
27 /**
28 * Created by The eXo Platform SAS.
29 *
30 * @author : Hoa.Pham hoa.pham@exoplatform.com Jun 23, 2008
31 */
32 public class NTFileResourceResolver extends JCRResourceResolver {
33
34 /**
35 * Instantiates a new nT file resource resolver.
36 *
37 * @param workspace the workspace
38 */
39 public NTFileResourceResolver(String workspace) {
40 super(workspace);
41 }
42
43 /**
44 * @param url URL must be like: jcr:uuid with uuid is node uiid of the file
45 * @see org.exoplatform.resolver.ResourceResolver#getInputStream(java.lang.String)
46 */
47 public InputStream getInputStream(String url) throws Exception {
48 SessionProvider provider = WCMCoreUtils.getSystemSessionProvider();
49 Session session = provider.getSession(workspace, WCMCoreUtils.getRepository());
50 String fileUUID = removeScheme(url);
51 Node node = session.getNodeByUUID(fileUUID);
52 return node.getNode("jcr:content").getProperty("jcr:data").getStream();
53 }
54 }