org.pentaho.di.core.util.EnvUtil Java Examples
The following examples show how to use
org.pentaho.di.core.util.EnvUtil.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JPanelTransformation.java From nordpos with GNU General Public License v3.0 | 6 votes |
@Override public void init(AppView app) throws BeanFactoryException { this.app = app; // dlSystem = (DataLogicSystem) app.getBean(DataLogicSystem.class.getName()); // hostProp = dlSystem.getResourceAsProperties(app.getProperties() + "/properties"); this.app.waitCursorBegin(); try { KettleEnvironment.init(false); EnvUtil.environmentInit(); } catch (KettleException ex) { MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.syncerror"), ex); msg.show(this); } this.app.waitCursorEnd(); }
Example #2
Source File: PluginFolder.java From pentaho-kettle with Apache License 2.0 | 6 votes |
/** * Create a list of plugin folders based on the specified xml sub folder * * @param xmlSubfolder * the sub-folder to consider for XML plugin files or null if it's not applicable. * @return The list of plugin folders found */ public static List<PluginFolderInterface> populateFolders( String xmlSubfolder ) { List<PluginFolderInterface> pluginFolders = new ArrayList<>(); String folderPaths = EnvUtil.getSystemProperty( "KETTLE_PLUGIN_BASE_FOLDERS" ); if ( folderPaths == null ) { folderPaths = Const.DEFAULT_PLUGIN_BASE_FOLDERS; } String[] folders = folderPaths.split( "," ); // for each folder in the list of plugin base folders // add an annotation and xml path for searching // trim the folder - we don't need leading and trailing spaces for ( String folder : folders ) { folder = folder.trim(); pluginFolders.add( new PluginFolder( folder, false, true ) ); if ( !Utils.isEmpty( xmlSubfolder ) ) { pluginFolders.add( new PluginFolder( folder + File.separator + xmlSubfolder, true, false ) ); } } return pluginFolders; }
Example #3
Source File: LanguageChoice.java From pentaho-kettle with Apache License 2.0 | 6 votes |
private void loadSettings() throws IOException { Properties properties = new Properties(); FileInputStream fis = new FileInputStream( getSettingsFilename() ); try { properties.load( fis ); } finally { try { fis.close(); } catch ( IOException ignored ) { // Ignore closure exceptions } } String defaultLocaleStr = properties.getProperty( STRING_DEFAULT_LOCALE, Const.DEFAULT_LOCALE.toString() ); defaultLocale = EnvUtil.createLocale( defaultLocaleStr ); }
Example #4
Source File: SlaveServerJobStatus.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public String getXML() throws KettleException { // See PDI-15781 boolean sendResultXmlWithStatus = EnvUtil.getSystemProperty( "KETTLE_COMPATIBILITY_SEND_RESULT_XML_WITH_FULL_STATUS", "N" ).equalsIgnoreCase( "Y" ); StringBuilder xml = new StringBuilder(); xml.append( XMLHandler.openTag( XML_TAG ) ).append( Const.CR ); xml.append( " " ).append( XMLHandler.addTagValue( "jobname", jobName ) ); xml.append( " " ).append( XMLHandler.addTagValue( "id", id ) ); xml.append( " " ).append( XMLHandler.addTagValue( "status_desc", statusDescription ) ); xml.append( " " ).append( XMLHandler.addTagValue( "error_desc", errorDescription ) ); xml.append( " " ).append( XMLHandler.addTagValue( "log_date", XMLHandler.date2string( logDate ) ) ); xml.append( " " ).append( XMLHandler.addTagValue( "logging_string", XMLHandler.buildCDATA( loggingString ) ) ); xml.append( " " ).append( XMLHandler.addTagValue( "first_log_line_nr", firstLoggingLineNr ) ); xml.append( " " ).append( XMLHandler.addTagValue( "last_log_line_nr", lastLoggingLineNr ) ); if ( result != null ) { String resultXML = sendResultXmlWithStatus ? result.getXML() : result.getBasicXml(); xml.append( resultXML ); } xml.append( XMLHandler.closeTag( XML_TAG ) ); return xml.toString(); }
Example #5
Source File: LogMessage.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private void lookupSubject() { // Derive the subject from the registry // LoggingObjectInterface loggingObject = LoggingRegistry.getInstance().getLoggingObject( logChannelId ); boolean detailedLogTurnOn = "Y".equals( EnvUtil.getSystemProperty( Const.KETTLE_LOG_MARK_MAPPINGS ) ) ? true : false; if ( loggingObject != null ) { if ( !detailedLogTurnOn ) { subject = loggingObject.getObjectName(); } else { subject = getDetailedSubject( loggingObject ); } copy = loggingObject.getObjectCopy(); } }
Example #6
Source File: PropertyAuthenticationProviderParserTest.java From pentaho-hadoop-shims with Apache License 2.0 | 5 votes |
@BeforeClass public static void beforeClass() throws KettleException { PluginRegistry.addPluginType( TwoWayPasswordEncoderPluginType.getInstance() ); PluginRegistry.init(); String passwordEncoderPluginID = Const.NVL( EnvUtil.getSystemProperty( Const.KETTLE_PASSWORD_ENCODER_PLUGIN ), "Kettle" ); Encr.init( passwordEncoderPluginID ); }
Example #7
Source File: XMLHandler.java From pentaho-kettle with Apache License 2.0 | 5 votes |
/** * Load a file into an XML document * * @param fileObject The fileObject to load into a document * @param systemID Provide a base for resolving relative URIs. * @param ignoreEntities Ignores external entities and returns an empty dummy. * @param namespaceAware support XML namespaces. * @return the Document if all went well, null if an error occured! */ public static Document loadXMLFile( FileObject fileObject, String systemID, boolean ignoreEntities, boolean namespaceAware ) throws KettleXMLException { //[PDI-18528] Retry opening the inputstream on first error. Because of the way DefaultFileContent handles open streams, //in multithread executions, the stream could be closed by another stream without notice. The retry is a way to recover the stream. int reties = Const.toInt( EnvUtil.getSystemProperty( Const.KETTLE_RETRY_OPEN_XML_STREAM ), DEFAULT_RETRY_ATTEMPTS ); if ( reties < 0 ) { reties = 0; } int attempts = 0; Exception lastException = null; while ( attempts <= reties ) { try { return loadXMLFile( KettleVFS.getInputStream( fileObject ), systemID, ignoreEntities, namespaceAware ); } catch ( Exception ex ) { lastException = ex; try { java.lang.Thread.sleep( 1000 ); } catch ( InterruptedException e ) { //Sonar squid S2142 requires the handling of the InterruptedException instead of ignoring it Thread.currentThread().interrupt(); } } attempts++; } throw new KettleXMLException( "Unable to read file [" + fileObject.toString() + "]", lastException ); }
Example #8
Source File: ValueMetaAndDataTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Test @PrepareForTest( { EnvUtil.class } ) public void testLoadXML() throws ParseException, KettleXMLException { PowerMockito.mockStatic( EnvUtil.class ); Mockito.when( EnvUtil.getSystemProperty( Const.KETTLE_DEFAULT_DATE_FORMAT ) ) .thenReturn( "yyyy-MM-dd HH:mm:ss.SSS" ); ValueMetaAndData valueMetaAndData = new ValueMetaAndData( Mockito.mock( ValueMetaInterface.class ), new Object() ); List<PluginInterface> pluginTypeList = new ArrayList<>(); PluginInterface plugin = Mockito.mock( PluginInterface.class ); Mockito.when( plugin.getName() ).thenReturn( "3" ); String[] ids = { "3" }; Mockito.when( plugin.getIds() ).thenReturn( ids ); pluginTypeList.add( plugin ); Mockito.when( pluginRegistry.getPlugins( ValueMetaPluginType.class ) ).thenReturn( pluginTypeList ); ValueMetaFactory.pluginRegistry = pluginRegistry; String testData = "2010/01/01 00:00:00.000"; Node node = XMLHandler.loadXMLString( "<value>\n" + " <name/>\n" + " <type>3</type>\n" + " <text>" + testData + "</text>\n" + " <length>-1</length>\n" + " <precision>-1</precision>\n" + " <isnull>N</isnull>\n" + " <mask/>\n" + "</value>", "value" ); valueMetaAndData.loadXML( node ); Assert.assertEquals( valueMetaAndData.getValueData(), new SimpleDateFormat( ValueMetaBase.COMPATIBLE_DATE_FORMAT_PATTERN ).parse( testData ) ); }
Example #9
Source File: S3CsvInputDialog.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private void setAwsCredentials( S3CsvInputMeta meta ) { /* For legacy transformations containing AWS S3 access credentials, {@link Const#KETTLE_USE_AWS_DEFAULT_CREDENTIALS} can force Spoon to use * the Amazon Default Credentials Provider Chain instead of using the credentials embedded in the transformation metadata. */ if ( !ValueMetaBase.convertStringToBoolean( Const.NVL( EnvUtil.getSystemProperty( Const.KETTLE_USE_AWS_DEFAULT_CREDENTIALS ), "N" ) ) ) { meta.setAwsAccessKey( transMeta.environmentSubstitute( Const.NVL( inputMeta.getAwsAccessKey(), "" ) ) ); meta.setAwsSecretKey( transMeta.environmentSubstitute( Const.NVL( inputMeta.getAwsSecretKey(), "" ) ) ); } }
Example #10
Source File: S3CsvInputMeta.java From pentaho-kettle with Apache License 2.0 | 5 votes |
/** * For legacy transformations containing AWS S3 access credentials, {@link Const#KETTLE_USE_AWS_DEFAULT_CREDENTIALS} can force Spoon to use * the Amazon Default Credentials Provider Chain instead of using the credentials embedded in the transformation metadata. * * @return true if {@link Const#KETTLE_USE_AWS_DEFAULT_CREDENTIALS} is true or AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are not specified */ public boolean getUseAwsDefaultCredentials() { if ( ValueMetaBase.convertStringToBoolean( Const.NVL( EnvUtil.getSystemProperty( Const.KETTLE_USE_AWS_DEFAULT_CREDENTIALS ), "N" ) ) ) { return true; } else if ( StringUtil.isEmpty( awsAccessKey ) && StringUtil.isEmpty( awsSecretKey ) ) { return true; } return false; }
Example #11
Source File: S3CsvInputMetaTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@BeforeClass public static void once() throws KettleException { PluginRegistry.addPluginType( TwoWayPasswordEncoderPluginType.getInstance() ); PluginRegistry.init( true ); String passwordEncoderPluginID = Const.NVL( EnvUtil.getSystemProperty( Const.KETTLE_PASSWORD_ENCODER_PLUGIN ), "Kettle" ); Encr.init( passwordEncoderPluginID ); }
Example #12
Source File: S3CsvInputMetaTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Test public void getUseAwsDefaultCredentialsOverrideCredentials() { S3CsvInputMeta meta = new S3CsvInputMeta(); meta.setAwsAccessKey( TEST_ACCESS_KEY_ENCRYPTED ); meta.setAwsSecretKey( TEST_AWS_SECRET_KEY_ENCRYPTED ); when( EnvUtil.getSystemProperty( Const.KETTLE_USE_AWS_DEFAULT_CREDENTIALS ) ).thenReturn( "Y" ); assertTrue( meta.getUseAwsDefaultCredentials() ); }
Example #13
Source File: SalesforceConnectionIT.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUpClass() throws KettleException { PluginRegistry.addPluginType( TwoWayPasswordEncoderPluginType.getInstance() ); PluginRegistry.init(); String passwordEncoderPluginID = Const.NVL( EnvUtil.getSystemProperty( Const.KETTLE_PASSWORD_ENCODER_PLUGIN ), "Kettle" ); Encr.init( passwordEncoderPluginID ); }
Example #14
Source File: SalesforceUpdateMetaTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUpBeforeClass() throws KettleException { PluginRegistry.addPluginType( ValueMetaPluginType.getInstance() ); PluginRegistry.addPluginType( TwoWayPasswordEncoderPluginType.getInstance() ); PluginRegistry.init( true ); String passwordEncoderPluginID = Const.NVL( EnvUtil.getSystemProperty( Const.KETTLE_PASSWORD_ENCODER_PLUGIN ), "Kettle" ); Encr.init( passwordEncoderPluginID ); }
Example #15
Source File: SalesforceUpdateTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUpBeforeClass() throws KettleException { PluginRegistry.addPluginType( TwoWayPasswordEncoderPluginType.getInstance() ); PluginRegistry.init(); String passwordEncoderPluginID = Const.NVL( EnvUtil.getSystemProperty( Const.KETTLE_PASSWORD_ENCODER_PLUGIN ), "Kettle" ); Encr.init( passwordEncoderPluginID ); }
Example #16
Source File: SalesforceDeleteMetaTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUpBeforeClass() throws KettleException { PluginRegistry.addPluginType( ValueMetaPluginType.getInstance() ); PluginRegistry.addPluginType( TwoWayPasswordEncoderPluginType.getInstance() ); PluginRegistry.init( true ); String passwordEncoderPluginID = Const.NVL( EnvUtil.getSystemProperty( Const.KETTLE_PASSWORD_ENCODER_PLUGIN ), "Kettle" ); Encr.init( passwordEncoderPluginID ); }
Example #17
Source File: SalesforceUpsertTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUpBeforeClass() throws KettleException { PluginRegistry.addPluginType( TwoWayPasswordEncoderPluginType.getInstance() ); PluginRegistry.init(); String passwordEncoderPluginID = Const.NVL( EnvUtil.getSystemProperty( Const.KETTLE_PASSWORD_ENCODER_PLUGIN ), "Kettle" ); Encr.init( passwordEncoderPluginID ); }
Example #18
Source File: SalesforceUpsertMetaTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUpBeforeClass() throws KettleException { PluginRegistry.addPluginType( ValueMetaPluginType.getInstance() ); PluginRegistry.addPluginType( TwoWayPasswordEncoderPluginType.getInstance() ); PluginRegistry.init( true ); String passwordEncoderPluginID = Const.NVL( EnvUtil.getSystemProperty( Const.KETTLE_PASSWORD_ENCODER_PLUGIN ), "Kettle" ); Encr.init( passwordEncoderPluginID ); }
Example #19
Source File: SalesforceMetaTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUpBeforeClass() throws KettleException { PluginRegistry.addPluginType( ValueMetaPluginType.getInstance() ); PluginRegistry.addPluginType( TwoWayPasswordEncoderPluginType.getInstance() ); PluginRegistry.init( true ); String passwordEncoderPluginID = Const.NVL( EnvUtil.getSystemProperty( Const.KETTLE_PASSWORD_ENCODER_PLUGIN ), "Kettle" ); Encr.init( passwordEncoderPluginID ); }
Example #20
Source File: SalesforceConnectionTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUpClass() throws KettleException { PluginRegistry.addPluginType( TwoWayPasswordEncoderPluginType.getInstance() ); PluginRegistry.init(); String passwordEncoderPluginID = Const.NVL( EnvUtil.getSystemProperty( Const.KETTLE_PASSWORD_ENCODER_PLUGIN ), "Kettle" ); Encr.init( passwordEncoderPluginID ); }
Example #21
Source File: SalesforceInputMetaTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUpBeforeClass() throws KettleException { PluginRegistry.addPluginType( ValueMetaPluginType.getInstance() ); PluginRegistry.addPluginType( TwoWayPasswordEncoderPluginType.getInstance() ); PluginRegistry.init( true ); String passwordEncoderPluginID = Const.NVL( EnvUtil.getSystemProperty( Const.KETTLE_PASSWORD_ENCODER_PLUGIN ), "Kettle" ); Encr.init( passwordEncoderPluginID ); }
Example #22
Source File: SalesforceInsertMetaTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUpBeforeClass() throws KettleException { PluginRegistry.addPluginType( ValueMetaPluginType.getInstance() ); PluginRegistry.addPluginType( TwoWayPasswordEncoderPluginType.getInstance() ); PluginRegistry.init( true ); String passwordEncoderPluginID = Const.NVL( EnvUtil.getSystemProperty( Const.KETTLE_PASSWORD_ENCODER_PLUGIN ), "Kettle" ); Encr.init( passwordEncoderPluginID ); }
Example #23
Source File: SalesforceInsertTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUpBeforeClass() throws KettleException { PluginRegistry.addPluginType( TwoWayPasswordEncoderPluginType.getInstance() ); PluginRegistry.init(); String passwordEncoderPluginID = Const.NVL( EnvUtil.getSystemProperty( Const.KETTLE_PASSWORD_ENCODER_PLUGIN ), "Kettle" ); Encr.init( passwordEncoderPluginID ); }
Example #24
Source File: PDI_10836_Test.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUpBeforeClass() throws KettleException { PluginRegistry.addPluginType( TwoWayPasswordEncoderPluginType.getInstance() ); PluginRegistry.init(); String passwordEncoderPluginID = Const.NVL( EnvUtil.getSystemProperty( Const.KETTLE_PASSWORD_ENCODER_PLUGIN ), "Kettle" ); Encr.init( passwordEncoderPluginID ); }
Example #25
Source File: MQTTConsumerMetaTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUpBeforeClass() throws KettleException { PluginRegistry.addPluginType( TwoWayPasswordEncoderPluginType.getInstance() ); PluginRegistry.init( true ); String passwordEncoderPluginID = Const.NVL( EnvUtil.getSystemProperty( Const.KETTLE_PASSWORD_ENCODER_PLUGIN ), "Kettle" ); Encr.init( passwordEncoderPluginID ); }
Example #26
Source File: Kitchen.java From pentaho-kettle with Apache License 2.0 | 5 votes |
/** * Configure the central log store from the provided command line options * * @param maxLogLinesOption Option for maximum log lines * @param maxLogTimeoutOption Option for log timeout * @throws KettleException Error parsing command line arguments */ public static void configureLogging( final CommandLineOption maxLogLinesOption, final CommandLineOption maxLogTimeoutOption ) throws KettleException { int maxLogLines = parseIntArgument( maxLogLinesOption, 0 ); if ( Utils.isEmpty( maxLogLinesOption.getArgument() ) ) { maxLogLines = Const.toInt( EnvUtil.getSystemProperty( Const.KETTLE_MAX_LOG_SIZE_IN_LINES ), 5000 ); } int maxLogTimeout = parseIntArgument( maxLogTimeoutOption, 0 ); if ( Utils.isEmpty( maxLogTimeoutOption.getArgument() ) ) { maxLogTimeout = Const.toInt( EnvUtil.getSystemProperty( Const.KETTLE_MAX_LOG_TIMEOUT_IN_MINUTES ), 1440 ); } KettleLogStore.init( maxLogLines, maxLogTimeout ); }
Example #27
Source File: TextFileInputUtils.java From pentaho-kettle with Apache License 2.0 | 5 votes |
/** * * Returns in the first position a line; ; * on the second position how many lines from file were read to get a full line * */ public static final TextFileLine getLine( LogChannelInterface log, InputStreamReader reader, EncodingType encodingType, int fileFormatType, StringBuilder line, String regex, long lineNumberInFile ) throws KettleFileException { String sline = getLine( log, reader, encodingType, fileFormatType, line ); boolean lenientEnclosureHandling = ValueMetaBase.convertStringToBoolean( Const.NVL( EnvUtil.getSystemProperty( Const.KETTLE_COMPATIBILITY_TEXT_FILE_INPUT_USE_LENIENT_ENCLOSURE_HANDLING ), "N" ) ); if ( !lenientEnclosureHandling ) { while ( sline != null ) { /* Check that the number of enclosures in a line is even. If not even it means that there was an enclosed line break. We need to read the next line(s) to get the remaining data in this row. */ if ( checkPattern( sline, regex ) % 2 == 0 ) { return new TextFileLine( sline, lineNumberInFile, null ); } String nextLine = getLine( log, reader, encodingType, fileFormatType, line ); if ( nextLine == null ) { break; } sline = sline + nextLine; lineNumberInFile++; } } return new TextFileLine( sline, lineNumberInFile, null ); }
Example #28
Source File: GetPropertiesServletTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@BeforeClass public static void beforeClass() throws KettleException { PluginRegistry.addPluginType( TwoWayPasswordEncoderPluginType.getInstance() ); PluginRegistry.init(); String passwordEncoderPluginID = Const.NVL( EnvUtil.getSystemProperty( Const.KETTLE_PASSWORD_ENCODER_PLUGIN ), "Kettle" ); Encr.init( passwordEncoderPluginID ); }
Example #29
Source File: JobEntryHTTPTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@BeforeClass public static void beforeClass() throws KettleException { PluginRegistry.addPluginType( TwoWayPasswordEncoderPluginType.getInstance() ); PluginRegistry.init(); String passwordEncoderPluginID = Const.NVL( EnvUtil.getSystemProperty( Const.KETTLE_PASSWORD_ENCODER_PLUGIN ), "Kettle" ); Encr.init( passwordEncoderPluginID ); }
Example #30
Source File: JobEntrySNMPTrapTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@BeforeClass public static void beforeClass() throws KettleException { PluginRegistry.addPluginType( TwoWayPasswordEncoderPluginType.getInstance() ); PluginRegistry.init(); String passwordEncoderPluginID = Const.NVL( EnvUtil.getSystemProperty( Const.KETTLE_PASSWORD_ENCODER_PLUGIN ), "Kettle" ); Encr.init( passwordEncoderPluginID ); }