List of usage examples for org.apache.commons.vfs2 FileSystem getAttribute
Object getAttribute(String attrName) throws FileSystemException;
From source file:org.pentaho.reporting.designer.extensions.pentaho.drilldown.PentahoParameterRefreshHandler.java
private static String getParameterServicePath(final AuthenticationData loginData, final PentahoPathModel pathModel) { try {//ww w .j av a2 s. c o m final FileObject fileSystemRoot = PublishUtil.createVFSConnection(VFS.getManager(), loginData); final FileSystem fileSystem = fileSystemRoot.getFileSystem(); // as of version 3.7 we do not need to check anything other than that the version information is there // later we may have to add additional checks in here to filter out known broken versions. final String localPath = pathModel.getLocalPath(); final FileObject object = fileSystemRoot.resolveFile(localPath); final FileContent content = object.getContent(); final String majorVersionText = (String) fileSystem.getAttribute(WebSolutionFileSystem.MAJOR_VERSION); if (StringUtils.isEmpty(majorVersionText) == false) { final String paramService = (String) content.getAttribute("param-service-url"); if (StringUtils.isEmpty(paramService)) { return null; } if (paramService.startsWith("http://") || paramService.startsWith("https://")) { return paramService; } try { // Encode the URL (must use URI as URL encoding doesn't work on spaces correctly) final URL target = new URL(loginData.getUrl()); final String host; if (target.getPort() != -1) { host = target.getHost() + ":" + target.getPort(); } else { host = target.getHost(); } return target.getProtocol() + "://" + host + paramService; } catch (MalformedURLException e) { UncaughtExceptionsModel.getInstance().addException(e); return null; } } final String extension = IOUtils.getInstance().getFileExtension(localPath); if (".prpt".equals(extension)) { logger.debug( "Ancient pentaho system detected: parameter service does not deliver valid parameter values"); final String name = pathModel.getName(); final String path = pathModel.getPath(); final String solution = pathModel.getSolution(); final FastMessageFormat messageFormat = new FastMessageFormat( "/content/reporting/?renderMode=XML&solution={0}&path={1}&name={2}"); messageFormat.setNullString(""); return loginData.getUrl() + messageFormat.format(new Object[] { solution, path, name }); } logger.debug("Ancient pentaho system detected: We will not have access to a working parameter service"); return null; } catch (FileSystemException e) { UncaughtExceptionsModel.getInstance().addException(e); return null; } }