01: /*
02: * Copyright 2005 Pentaho Corporation. All rights reserved.
03: * This software was developed by Pentaho Corporation and is provided under the terms
04: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
05: * this file except in compliance with the license. If you need a copy of the license,
06: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
07: * BI Platform. The Initial Developer is Pentaho Corporation.
08: *
09: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
10: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
11: * the license for the specific language governing your rights and limitations.
12: *
13: * Created Mar 14, 2006
14: * @author wseyler
15: */
16:
17: package org.pentaho.ui.component;
18:
19: import java.util.List;
20:
21: import org.apache.commons.logging.Log;
22: import org.apache.commons.logging.LogFactory;
23: import org.dom4j.Document;
24: import org.dom4j.DocumentHelper;
25: import org.pentaho.core.repository.ISolutionRepository;
26: import org.pentaho.core.session.IPentahoSession;
27: import org.pentaho.core.solution.ISolutionFile;
28: import org.pentaho.core.solution.SolutionReposUtil.ISolutionFilter;
29: import org.pentaho.core.system.PentahoSystem;
30: import org.pentaho.core.ui.IPentahoUrlFactory;
31: import org.pentaho.messages.Messages;
32: import org.pentaho.ui.XmlComponent;
33:
34: import com.pentaho.repository.dbbased.solution.RepositoryFile;
35: import com.pentaho.security.SecurityUtils;
36:
37: public class SolutionTreeUIComponent extends XmlComponent implements
38: ISolutionFilter {
39:
40: private static final long serialVersionUID = 1L;
41:
42: private static final Log logger = LogFactory
43: .getLog(SolutionTreeUIComponent.class);
44:
45: protected IPentahoSession session = null;
46:
47: public SolutionTreeUIComponent(IPentahoUrlFactory urlFactory,
48: List messages, IPentahoSession session) {
49: super (urlFactory, messages, null);
50: this .session = session;
51: setXsl("text/html", "xmlTree.xsl"); //$NON-NLS-1$ //$NON-NLS-2$
52: setXslProperty(
53: "baseUrl", urlFactory.getDisplayUrlBuilder().getUrl()); //$NON-NLS-1$
54: }
55:
56: public boolean keepFile(ISolutionFile solutionFile,
57: int actionOperation) {
58: return SecurityUtils.canHaveACLS((RepositoryFile) solutionFile);
59: }
60:
61: public Document getXmlContent() {
62: if (SecurityUtils.isPentahoAdministrator(session)) {
63: try {
64: ISolutionRepository repository = PentahoSystem
65: .getSolutionRepository(session);
66: return repository.getSolutionTree(
67: ISolutionRepository.ACTION_ADMIN, this );
68: } catch (Exception e) {
69: Document document = DocumentHelper.createDocument();
70: document
71: .addElement("error").setText(Messages.getString("SolutionTreeUIComponent.ERROR_0001_PERMISSIONS_NOT_SUPPORTED")); //$NON-NLS-1$ //$NON-NLS-2$
72: return document;
73: }
74: } else {
75: return null;
76: }
77: }
78:
79: public Log getLogger() {
80: return logger;
81: }
82:
83: public boolean validate() {
84: return true;
85: }
86:
87: }
|