%@ taglib prefix='c' uri='http://java.sun.com/jstl/core' %><%@
page language="java"
import="org.springframework.security.ui.AbstractProcessingFilter,
org.springframework.security.ui.webapp.AuthenticationProcessingFilter,
org.springframework.security.AuthenticationException,
org.pentaho.platform.uifoundation.component.HtmlComponent,
org.pentaho.platform.engine.core.system.PentahoSystem,
org.pentaho.platform.engine.core.solution.ActionInfo,
org.pentaho.platform.util.messages.LocaleHelper,
org.pentaho.platform.util.web.SimpleUrlFactory,
org.pentaho.platform.api.engine.IPentahoSession,
org.pentaho.platform.api.engine.IUITemplater,
org.pentaho.platform.api.repository.ISolutionRepository,
org.pentaho.platform.api.repository.ISolutionRepositoryService,
org.pentaho.platform.web.http.PentahoHttpSessionHelper,
org.pentaho.platform.web.jsp.messages.Messages,
org.pentaho.platform.web.http.request.HttpRequestParameterProvider,
org.pentaho.platform.web.http.session.HttpSessionParameterProvider,
org.dom4j.*,
java.util.*,
org.apache.commons.lang.StringEscapeUtils"
%>
Pentaho Platform
<%
response.setCharacterEncoding(LocaleHelper.getSystemEncoding());
HttpSession httpSession = request.getSession();
boolean doSplash = httpSession.getAttribute( "dopentahosplash" ) == null || "true".equals( request.getParameter("splash") );
doSplash = false;
httpSession.setAttribute( "dopentahosplash", "false" );
String baseUrl = PentahoSystem.getApplicationContext().getBaseUrl();
IPentahoSession userSession = PentahoHttpSessionHelper.getPentahoSession( request );
HttpRequestParameterProvider requestParameters = new HttpRequestParameterProvider( request );
HttpSessionParameterProvider sessionParameters = new HttpSessionParameterProvider( userSession );
String hrefUrl = baseUrl; //$NON-NLS-1$
String onClick = ""; //$NON-NLS-1$
String thisUrl = baseUrl + "Navigate?"; //$NON-NLS-1$
SimpleUrlFactory urlFactory = new SimpleUrlFactory( thisUrl );
ArrayList messages = new ArrayList();
ISolutionRepositoryService repoService = PentahoSystem.get(ISolutionRepositoryService.class, userSession);
String solution = request.getParameter("solution");
String path = request.getParameter("path");
org.w3c.dom.Document doc = repoService.getSolutionRepositoryDoc(userSession, null);
javax.xml.transform.dom.DOMSource source = new javax.xml.transform.dom.DOMSource(doc);
javax.xml.transform.stream.StreamResult result = new javax.xml.transform.stream.StreamResult(new java.io.StringWriter());
javax.xml.transform.TransformerFactory.newInstance().newTransformer().transform(source, result);
String theXML = result.getWriter().toString();
Document document = DocumentHelper.parseText(theXML);
if ("".equals(solution)) { //$NON-NLS-1$
solution = null;
}
if ("".equals(path)) { //$NON-NLS-1$
path = null;
}
// display correct back button, one level up...
StringBuffer addlLists = new StringBuffer();
String displayPath = "Solution Repository";
if (solution != null && path != null) {
displayPath = solution + " / " + path;
} else if (solution != null) {
displayPath = solution;
}
String dispId = "nav_" + displayPath.replaceAll("\\W","_");
%><%!
public static String getElementText(Element parentElement, String childElement) {
List elements = parentElement.elements(childElement);
if (elements.size() == 0) return null;
return ((Element)elements.get(0)).getTextTrim();
}
%>
- <%= displayPath %>
<%
// find solution / path
List elements = null;
if (solution == null) {
elements = document.getRootElement().elements("file");
} else {
if (path == null) {
Element solutionElement = (Element)document.getRootElement().selectSingleNode("file[@name='" + solution +"']");
elements = solutionElement.elements("file");
} else {
Element parent = null ;
parent = (Element)document.getRootElement().selectSingleNode("file[@name='" + solution +"']");
String paths[] = path.split("/");
for (int i = 0; i < paths.length; i++) {
parent = (Element)parent.selectSingleNode("file[@name='"+paths[i]+"']");
}
elements = parent.elements("file");
}
}
// sort elements
List sortedElements = new ArrayList(elements);
Collections.sort(sortedElements, new Comparator() {
public int compare(Object o1, Object o2) {
Element e1 = (Element)o1;
Element e2 = (Element)o2;
String title1 = e1.attributeValue("name"); // getElementText(e1, "title");
String title2 = e2.attributeValue("name"); // getElementText(e2, "title");
return title1.compareTo(title2);
}
});
for (int i = 0; i < sortedElements.size(); i++) {
Element file = (Element)sortedElements.get(i);
if (file.attributeValue("visible").equals("false")) {
continue;
}
String filesolution = solution;
if (solution == null) {
filesolution = file.attributeValue("name");
}
String filetitle = file.attributeValue("localized-name");
if (filetitle !=null) {
if (filetitle.length() > 2 && filetitle.charAt(2) == '.') {
filetitle = filetitle.substring(3);
} else if (filetitle.length() > 3 && filetitle.charAt(3) == '.') {
filetitle = filetitle.substring(4);
}
}
String filepath = "";
if (solution != null && path != null) {
filepath = path;
}
if (file.attributeValue("isDirectory").equals("true")) {
if (solution != null) {
filepath = file.attributeValue("name");
if (path != null) {
filepath = path + "/" + filepath;
}
}
%>- <%= filetitle %>
<%
} else if (file.attributeValue("name").endsWith(".xaction")) {
String filedesc = file.attributeValue("description");
String filename = file.attributeValue("name");
String fileauthor = file.attributeValue("author");
String href = (filesolution + "/" + filepath +"/" + filename).replaceAll(" ", "_");
%>- <%= filetitle %>
<%
addlLists.append("");
addlLists.append("- Title
");
addlLists.append("- " + filetitle+ "
");
addlLists.append("- Description
");
addlLists.append("- " + filedesc + "
");
// addlLists.append("- Author
");
// addlLists.append("- " + fileauthor + "
");
addlLists.append("- Actions
");
addlLists.append("- Run
");
addlLists.append("
\n\n");
} else if (file.attributeValue("url") != null) {
String filename = file.attributeValue("name");
String fileurl = file.attributeValue("url");
String href = (filesolution + "/" + filepath +"/" + filename).replaceAll(" ", "_");
%>- <%= filetitle %>
<%
} else {
%>- Dunno : <%= file.asXML() %>
<%
}
}
%>
<%= addlLists.toString() %>