public InputSource resolveDTDEntity( final String publicId, final String systemId ) throws IOException { int idx = systemId.lastIndexOf( '/' ); String dtdName = systemId.substring( idx + 1 ); String fullPath = PentahoSystem.getApplicationContext().getSolutionPath( "system/dtd/" + dtdName ); //$NON-NLS-1$ File theFile = new File( fullPath ); if ( theFile.canRead() ) { InputStream xslIS = new BufferedInputStream( new FileInputStream( theFile ) ); InputSource source = new InputSource( xslIS ); return source; } return null; }
/** * Create a String containing the complete path to the system folder in the repository, and append the parameter * <code>path</code> to it. * * @param path * String containing the path of a file relative to the system folder in the repository * @return String containing the path */ protected String getAbsolutePath( final String path ) { return PentahoSystem.getApplicationContext().getSolutionPath( "system" + File.separator + path ); //$NON-NLS-1$ }
public InputSource resolveEntity( final String publicId, final String systemId ) throws SAXException, IOException { int idx = systemId.lastIndexOf( '/' ); String dtdName = systemId.substring( idx + 1 ); String fullPath = PentahoSystem.getApplicationContext().getSolutionPath( "system/dtd/" + dtdName ); //$NON-NLS-1$ File theFile = new File( fullPath ); if ( theFile.canRead() ) { InputStream xslIS = new BufferedInputStream( new FileInputStream( theFile ) ); InputSource source = new InputSource( xslIS ); return source; } return null; }
protected String getRelativeSolutionPath() { String relativePath = PentahoSystem.getSystemSetting( "file-upload-defaults/relative-path", String.valueOf( FileUtils.DEFAULT_RELATIVE_UPLOAD_FILE_PATH ) ); //$NON-NLS-1$ return PentahoSystem.getApplicationContext().getSolutionPath( relativePath ); }
public ModelInfo generateFields( String project, String filename, int rowLimit, String delimiter, String enclosure, int headerRows, boolean doData, boolean doColumns, String encoding ) throws Exception { String path; if ( filename.endsWith( ".tmp" ) ) { //$NON-NLS-1$ path = PentahoSystem.getApplicationContext().getSolutionPath( TMP_FILE_PATH ); } else { String relativePath = PentahoSystem.getSystemSetting( "file-upload-defaults/relative-path", String.valueOf( DEFAULT_RELATIVE_UPLOAD_FILE_PATH ) ); //$NON-NLS-1$ path = PentahoSystem.getApplicationContext().getSolutionPath( relativePath ); } String fileLocation = path + filename; return generateFields( project, fileLocation, filename, rowLimit, delimiter, enclosure, headerRows, doData, doColumns, encoding ); }
public static String getFolderPath( String project ) { String folderPath = PentahoSystem.getSystemSetting( SETTINGS_FILE, FILES_PATH, null ); if ( folderPath != null ) { folderPath = PentahoSystem.getApplicationContext().getSolutionPath( folderPath + project ); } return folderPath; }
public static String getTmpFolderPath( String project ) { String folderPath = PentahoSystem.getSystemSetting( SETTINGS_FILE, TEMP_FILES_PATH, null ); if ( folderPath != null ) { folderPath = PentahoSystem.getApplicationContext().getSolutionPath( folderPath + project ); } return folderPath; }
public static String getUploadDir() { if ( upload_dir == null ) { IApplicationContext context = PentahoSystem.getApplicationContext(); if ( context != null ) { upload_dir = PentahoSystem.getApplicationContext().getSolutionPath( "system/tmp" ); } else { return ""; } } return upload_dir; }
.getSolutionPath( "system/quartz/h2-quartz-schema-updated.sql" ).replace( '\\', '/' ); File f = new File( quartzInitializationScriptPath ); if ( f.exists() ) {
public String getDescription() { return Messages .getInstance() .getString( "SettingsPublisher.USER_DESCRIPTION", PentahoSystem.getApplicationContext().getSolutionPath( "system" ).replace( '\\', '/' ) ); //$NON-NLS-1$ //$NON-NLS-2$ }
public Properties getSystemSettingsProperties( final String path ) { String fullPath = PentahoSystem.getApplicationContext().getSolutionPath( "system" + File.separator + path ); //$NON-NLS-1$ File propsFile = new File( fullPath ); if ( !propsFile.exists() ) { return null; } try { Properties props = new Properties(); InputStream fileInputStream = new BufferedInputStream( new FileInputStream( propsFile ) ); try { props.load( fileInputStream ); return props; } finally { fileInputStream.close(); } } catch ( FileNotFoundException e ) { SystemSettings.logger.error( Messages.getInstance().getErrorString( "SystemSettings.ERROR_0003_FAILED_INITIALIZE", path ), e ); //$NON-NLS-1$ } catch ( IOException ioe ) { SystemSettings.logger.error( Messages.getInstance().getErrorString( "SystemSettings.ERROR_0003_FAILED_INITIALIZE", path ), ioe ); //$NON-NLS-1$ } return null; }
public String getEncoding( String fileName ) throws Exception { String path; if ( fileName.endsWith( ".tmp" ) ) { //$NON-NLS-1$ path = PentahoSystem.getApplicationContext().getSolutionPath( TMP_FILE_PATH ); } else { String relativePath = PentahoSystem.getSystemSetting( "file-upload-defaults/relative-path", String.valueOf( DEFAULT_RELATIVE_UPLOAD_FILE_PATH ) ); //$NON-NLS-1$ path = PentahoSystem.getApplicationContext().getSolutionPath( relativePath ); } String fileLocation = path + fileName; String encoding; try { byte[] bytes = new byte[ 1024 ]; InputStream inputStream = new FileInputStream( new File( fileLocation ) ); inputStream.read( bytes ); CharsetDetector charsetDetector = new CharsetDetector(); charsetDetector.setText( bytes ); CharsetMatch charsetMatch = charsetDetector.detect(); encoding = charsetMatch.getName(); inputStream.close(); } catch ( Exception e ) { log.error( e ); throw e; } return encoding; }
File f = new File( PentahoSystem.getApplicationContext().getSolutionPath( "system/plugin.properties" ) ); if ( f.exists() ) { is = new FileInputStream( f );
public static long getLastModifiedDate( String filePath, Locale locale ) { if ( filePath.startsWith( "system" ) ) { File file = null; filePath = PentahoSystem.getApplicationContext().getSolutionPath( filePath ); if ( locale == null ) { file = new File( filePath );
String path = PentahoSystem.getApplicationContext().getSolutionPath( relativePath ); String TMP_FILE_PATH = File.separatorChar + "system" + File.separatorChar + File.separatorChar + "tmp" + File.separatorChar; String sysTmpDir = PentahoSystem.getApplicationContext().getSolutionPath( TMP_FILE_PATH ); LogicalModel logicalModel = domain.getLogicalModels().get( 0 ); String modelState = (String) logicalModel.getProperty( "datasourceModel" ); //$NON-NLS-1$
String path = PentahoSystem.getApplicationContext().getSolutionPath( relativePath ); File pathDir = new File( path ); File tempDir = new File( PentahoSystem.getApplicationContext().getSolutionPath( "system/tmp" ) ); if ( tempDir.exists() == false ) { tempDir.mkdir();
public static String getSystemInput( final String inputName, final IRuntimeContext context ) { int i = TemplateUtil.SystemInputs.indexOf( inputName ); switch ( i ) { case 0: { // User return context.getSession().getName(); } case 1: { // Relative URL return PentahoRequestContextHolder.getRequestContext().getContextPath(); } case 2: { // Solution return PentahoSystem.getApplicationContext().getSolutionPath( "" ); //$NON-NLS-1$ } case 3: { // Fully Qualified Server URL return PentahoSystem.getApplicationContext().getFullyQualifiedServerURL(); } } return null; }
public ModelInfo getFileContents( String project, String name, String delimiter, String enclosure, int rows, boolean isFirstRowHeader, String encoding ) throws Exception { String path; if ( name.endsWith( ".tmp" ) ) { //$NON-NLS-1$ path = PentahoSystem.getApplicationContext().getSolutionPath( TMP_FILE_PATH ); } else { String relativePath = PentahoSystem.getSystemSetting( "file-upload-defaults/relative-path", String.valueOf( DEFAULT_RELATIVE_UPLOAD_FILE_PATH ) ); //$NON-NLS-1$ path = PentahoSystem.getApplicationContext().getSolutionPath( relativePath ); } String fileLocation = path + name; ModelInfo result = new ModelInfo(); CsvFileInfo fileInfo = new CsvFileInfo(); fileInfo.setTmpFilename( name ); result.setFileInfo( fileInfo ); fileInfo.setContents( getLinesList( fileLocation, rows, encoding ) ); fileInfo.setDelimiter( delimiter ); fileInfo.setEnclosure( enclosure ); fileInfo.setHeaderRows( 0 ); // now try to generate some columns return result; }
String path = PentahoSystem.getApplicationContext().getSolutionPath( relativePath ); LogicalModel logicalModel = domain.getLogicalModels().get( 0 ); String modelState = (String) logicalModel.getProperty( "datasourceModel" );
public BusinessData loadBusinessData( String domainId, String modelId ) throws DatasourceServiceException { Domain domain = getMetadataDomainRepository().getDomain( domainId ); List<List<String>> data = null; if ( domain.getPhysicalModels().get( 0 ) instanceof InlineEtlPhysicalModel ) { InlineEtlPhysicalModel model = (InlineEtlPhysicalModel) domain.getPhysicalModels().get( 0 ); String relativePath = PentahoSystem.getSystemSetting( "file-upload-defaults/relative-path", String.valueOf( CsvTransformGenerator.DEFAULT_RELATIVE_UPLOAD_FILE_PATH ) ); //$NON-NLS-1$ String csvFileLoc = PentahoSystem.getApplicationContext().getSolutionPath( relativePath ); data = DatasourceServiceHelper.getCsvDataSample( csvFileLoc + model.getFileLocation(), model.getHeaderPresent(), model.getDelimiter(), model.getEnclosure(), 5 ); } else { SqlPhysicalModel model = (SqlPhysicalModel) domain.getPhysicalModels().get( 0 ); String query = model.getPhysicalTables().get( 0 ).getTargetTable(); SerializedResultSet resultSet = DatasourceServiceHelper.getSerializeableResultSet( model.getDatasource().getDatabaseName(), query, 5, PentahoSessionHolder.getSession() ); data = resultSet.getData(); } return new BusinessData( domain, data ); }