From e444c2e168982b79770069000efb95888753be64 Mon Sep 17 00:00:00 2001 From: Aleksandra Messier Date: Thu, 1 Mar 2018 14:05:56 -0500 Subject: [PATCH] [BACKLOG-21756] Handling of 'Trans Job Entry > Transformation' field (#4996) --- core/pom.xml | 7 ++ .../pentaho/di/core/logging/LogMessage.java | 36 ++++++---- .../org/pentaho/di/core/util/StringUtil.java | 4 +- .../di/core/logging/LogMessageTest.java | 15 ++++- .../pentaho/di/core/util/StringUtilTest.java | 5 +- .../pentaho/di/core/xml/XMLFormatterTest.java | 21 ++++-- engine/pom.xml | 7 ++ .../di/job/JobExecutionConfiguration.java | 9 ++- .../di/job/entries/trans/JobEntryTrans.java | 9 ++- .../trans/messages/messages_en_US.properties | 1 + .../common/BaseStreamStepMetaTest.java | 38 ++++++----- .../di/repository/pur/PurRepository.java | 66 +++++++++++++------ .../pur/messages/messages_en_US.properties | 3 + .../entries/trans/JobEntryTransDialog.java | 25 ++++--- 14 files changed, 173 insertions(+), 73 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index 6d924c501c09..ff1852485534 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -48,6 +48,7 @@ 4.4.1 4.5.3 4.4.6 + 1.5 @@ -512,6 +513,12 @@ ${spring.framework.version} test + + xmlunit + xmlunit + ${xmlunit.version} + test + diff --git a/core/src/main/java/org/pentaho/di/core/logging/LogMessage.java b/core/src/main/java/org/pentaho/di/core/logging/LogMessage.java index c18907b2cda5..c42f144b5511 100644 --- a/core/src/main/java/org/pentaho/di/core/logging/LogMessage.java +++ b/core/src/main/java/org/pentaho/di/core/logging/LogMessage.java @@ -2,7 +2,7 @@ * * Pentaho Data Integration * - * Copyright (C) 2002-2017 by Hitachi Vantara : http://www.pentaho.com + * Copyright (C) 2002-2018 by Hitachi Vantara : http://www.pentaho.com * ******************************************************************************* * @@ -22,6 +22,7 @@ package org.pentaho.di.core.logging; +import org.apache.commons.lang.StringUtils; import org.pentaho.di.core.Const; import java.text.MessageFormat; @@ -29,6 +30,7 @@ import java.util.List; import org.pentaho.di.core.util.EnvUtil; +import org.pentaho.di.core.util.StringUtil; public class LogMessage implements LogMessageInterface { private String logChannelId; @@ -133,14 +135,12 @@ private String formatDetailedSubject( List subjects ) { @Override @Deprecated public String toString() { - if ( message == null ) { + if ( StringUtils.isBlank( message ) ) { return subject; + } else if ( StringUtils.isBlank( subject ) ) { + return getMessage(); } - if ( arguments != null && arguments.length > 0 ) { - return subject + " - " + MessageFormat.format( message, arguments ); - } else { - return subject + " - " + message; - } + return String.format( "%s - %s", subject, getMessage() ); } @Override @@ -158,11 +158,25 @@ public void setLevel( LogLevel level ) { */ @Override public String getMessage() { - if ( arguments != null && arguments.length > 0 ) { - return MessageFormat.format( message, arguments ); - } else { - return message; + String formatted = message; + if ( arguments != null ) { + // get all "tokens" enclosed by curly brackets within the message + final List tokens = new ArrayList<>(); + StringUtil.getUsedVariables( formatted, "{", "}", tokens, true ); + // perform MessageFormat.format( ... ) on each token, if we get an exception, we'll know that we have a + // segment that isn't parsable by MessageFormat, likely a pdi variable name (${foo}) - in this case, we need to + // escape the curly brackets in the message, so that MessageFormat does not complain + for ( final String token : tokens ) { + try { + MessageFormat.format( "{" + token + "}", arguments ); + } catch ( final IllegalArgumentException iar ) { + formatted = formatted.replaceAll( "\\{" + token + "\\}", "\\'{'" + token + "\\'}'" ); + } + } + // now that we have escaped curly brackets in all invalid tokens, we can attempt to format the entire message + formatted = MessageFormat.format( formatted, arguments ); } + return formatted; } /** diff --git a/core/src/main/java/org/pentaho/di/core/util/StringUtil.java b/core/src/main/java/org/pentaho/di/core/util/StringUtil.java index 7397cf31776a..2706e0b7f944 100644 --- a/core/src/main/java/org/pentaho/di/core/util/StringUtil.java +++ b/core/src/main/java/org/pentaho/di/core/util/StringUtil.java @@ -2,7 +2,7 @@ * * Pentaho Data Integration * - * Copyright (C) 2002-2017 by Hitachi Vantara : http://www.pentaho.com + * Copyright (C) 2002-2018 by Hitachi Vantara : http://www.pentaho.com * ******************************************************************************* * @@ -310,7 +310,7 @@ public static String substituteField( String aString, RowMetaInterface rowMeta, * @param includeSystemVariables * also check for system variables. */ - private static void getUsedVariables( String aString, String open, String close, List list, + public static void getUsedVariables( String aString, String open, String close, List list, boolean includeSystemVariables ) { if ( aString == null ) { return; diff --git a/core/src/test/java/org/pentaho/di/core/logging/LogMessageTest.java b/core/src/test/java/org/pentaho/di/core/logging/LogMessageTest.java index 11570f463580..1b6486858002 100644 --- a/core/src/test/java/org/pentaho/di/core/logging/LogMessageTest.java +++ b/core/src/test/java/org/pentaho/di/core/logging/LogMessageTest.java @@ -2,7 +2,7 @@ * * Pentaho Data Integration * - * Copyright (C) 2002-2017 by Hitachi Vantara : http://www.pentaho.com + * Copyright (C) 2002-2018 by Hitachi Vantara : http://www.pentaho.com * ******************************************************************************* * @@ -19,6 +19,7 @@ * limitations under the License. * ******************************************************************************/ + package org.pentaho.di.core.logging; import static org.junit.Assert.assertEquals; @@ -30,6 +31,8 @@ import org.junit.Test; import org.pentaho.di.core.Const; +import java.text.MessageFormat; + /** * @author Tatsiana_Kasiankova * @@ -116,6 +119,13 @@ public void testToString_withOneArgument() throws Exception { assertEquals( "Subject - Log message for Test", msg.toString( ) ); } + @Test + public void testGetMessage() { + LogMessage msg = new LogMessage( "m {0}, {1}, {2}, {3}, {4,number,#.00}, {5} {foe}", "Channel 01", + new Object[] { "Foo", "{abc}", "", null, 123 }, LogLevel.DEBUG ); + assertEquals( "m Foo, {abc}, , null, 123.00, {5} {foe}", msg.getMessage() ); + } + private void turnOnLogMarkMapping() { System.getProperties().put( Const.KETTLE_LOG_MARK_MAPPINGS, "Y" ); } @@ -138,8 +148,7 @@ private static LoggingObjectInterface getTreeLoggingObject() { private static LoggingObjectInterface getLoggingObjectWithOneParent() { LoggingObjectInterface rootLogObject = new SimpleLoggingObject( "ROOT_SUBJECT", LoggingObjectType.SPOON, null ); LoggingObjectInterface transLogObject = - new SimpleLoggingObject( "TRANS_SUBJECT", LoggingObjectType.TRANS, rootLogObject ); + new SimpleLoggingObject( "TRANS_SUBJECT", LoggingObjectType.TRANS, rootLogObject ); return transLogObject; } - } diff --git a/core/src/test/java/org/pentaho/di/core/util/StringUtilTest.java b/core/src/test/java/org/pentaho/di/core/util/StringUtilTest.java index 1146d170fb73..216fea0eb555 100644 --- a/core/src/test/java/org/pentaho/di/core/util/StringUtilTest.java +++ b/core/src/test/java/org/pentaho/di/core/util/StringUtilTest.java @@ -2,7 +2,7 @@ * * Pentaho Data Integration * - * Copyright (C) 2002-2017 by Hitachi Vantara : http://www.pentaho.com + * Copyright (C) 2002-2018 by Hitachi Vantara : http://www.pentaho.com * ******************************************************************************* * @@ -59,6 +59,7 @@ public void testinitCap() { Map createVariables1( String open, String close ) { Map map = new HashMap(); + map.put( "NULL", null ); map.put( "EMPTY", "" ); map.put( "checkcase", "case1" ); map.put( "CheckCase", "case2" ); @@ -87,6 +88,8 @@ Map createVariables1( String open, String close ) { */ public void testSubstituteBasic() { Map map = createVariables1( "${", "}" ); + assertEquals( "|${BAD_KEY}|", StringUtil.substitute( "|${BAD_KEY}|", map, "${", "}" ) ); + assertEquals( "|${NULL}|", StringUtil.substitute( "|${NULL}|", map, "${", "}" ) ); assertEquals( "||", StringUtil.substitute( "|${EMPTY}|", map, "${", "}" ) ); assertEquals( "|case1|", StringUtil.substitute( "|${checkcase}|", map, "${", "}" ) ); assertEquals( "|case2|", StringUtil.substitute( "|${CheckCase}|", map, "${", "}" ) ); diff --git a/core/src/test/java/org/pentaho/di/core/xml/XMLFormatterTest.java b/core/src/test/java/org/pentaho/di/core/xml/XMLFormatterTest.java index 1e926eea5f5f..d0d058f13a70 100644 --- a/core/src/test/java/org/pentaho/di/core/xml/XMLFormatterTest.java +++ b/core/src/test/java/org/pentaho/di/core/xml/XMLFormatterTest.java @@ -2,7 +2,7 @@ * * Pentaho Data Integration * - * Copyright (C) 2016-2017 by Hitachi Vantara : http://www.pentaho.com + * Copyright (C) 2016-2018 by Hitachi Vantara : http://www.pentaho.com * ******************************************************************************* * @@ -21,14 +21,23 @@ ******************************************************************************/ package org.pentaho.di.core.xml; -import static org.junit.Assert.assertEquals; +import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; import java.io.InputStream; import org.apache.commons.io.IOUtils; +import org.junit.BeforeClass; import org.junit.Test; +import org.custommonkey.xmlunit.XMLUnit; + public class XMLFormatterTest { + + @BeforeClass + public static void setupClass() { + XMLUnit.setIgnoreWhitespace( true ); + } + @Test public void test1() throws Exception { String inXml, expectedXml; @@ -40,7 +49,7 @@ public void test1() throws Exception { } String result = XMLFormatter.format( inXml ); - assertEquals( expectedXml, result ); + assertXMLEqual( expectedXml, result ); } @Test @@ -54,7 +63,7 @@ public void test2() throws Exception { } String result = XMLFormatter.format( inXml ); - assertEquals( expectedXml, result ); + assertXMLEqual( expectedXml, result ); } @Test @@ -68,7 +77,7 @@ public void test3() throws Exception { } String result = XMLFormatter.format( inXml ); - assertEquals( expectedXml, result ); + assertXMLEqual( expectedXml, result ); } @Test @@ -82,6 +91,6 @@ public void test4() throws Exception { } String result = XMLFormatter.format( inXml ); - assertEquals( expectedXml, result ); + assertXMLEqual( expectedXml, result ); } } diff --git a/engine/pom.xml b/engine/pom.xml index f9f845902e5e..bff978436128 100644 --- a/engine/pom.xml +++ b/engine/pom.xml @@ -96,6 +96,7 @@ 2.0.8 1.1 2.0.4 + 1.5 @@ -934,6 +935,12 @@ + + xmlunit + xmlunit + ${xmlunit.version} + test + diff --git a/engine/src/main/java/org/pentaho/di/job/JobExecutionConfiguration.java b/engine/src/main/java/org/pentaho/di/job/JobExecutionConfiguration.java index 4591fc147029..6b341c7b87d0 100644 --- a/engine/src/main/java/org/pentaho/di/job/JobExecutionConfiguration.java +++ b/engine/src/main/java/org/pentaho/di/job/JobExecutionConfiguration.java @@ -2,7 +2,7 @@ * * Pentaho Data Integration * - * Copyright (C) 2002-2017 by Hitachi Vantara : http://www.pentaho.com + * Copyright (C) 2002-2018 by Hitachi Vantara : http://www.pentaho.com * ******************************************************************************* * @@ -268,7 +268,10 @@ public void getUsedVariables( JobMeta jobMeta ) { for ( int i = 0; i < vars.size(); i++ ) { String varname = vars.get( i ); if ( !varname.startsWith( Const.INTERNAL_VARIABLE_PREFIX ) ) { - newVariables.put( varname, Const.NVL( variables.get( varname ), sp.getProperty( varname, "" ) ) ); + // add a variable only if it's defined within this configuration or it is a system property + if ( variables.containsKey( varname ) || sp.getProperty( varname ) != null ) { + newVariables.put( varname, Const.NVL( variables.get( varname ), sp.getProperty( varname, "" ) ) ); + } } } // variables.clear(); @@ -705,7 +708,7 @@ public void getUsedArguments( JobMeta jobMeta, String[] commandLineArguments, IM } } } catch ( KettleException ke ) { - log.logBasic( ke.getMessage(), ke ); + // suppress exceptions at this time - we will let the runtime report on any errors } } } diff --git a/engine/src/main/java/org/pentaho/di/job/entries/trans/JobEntryTrans.java b/engine/src/main/java/org/pentaho/di/job/entries/trans/JobEntryTrans.java index a1db4679f0f0..0eda44a7a804 100644 --- a/engine/src/main/java/org/pentaho/di/job/entries/trans/JobEntryTrans.java +++ b/engine/src/main/java/org/pentaho/di/job/entries/trans/JobEntryTrans.java @@ -2,7 +2,7 @@ * * Pentaho Data Integration * - * Copyright (C) 2002-2017 by Hitachi Vantara : http://www.pentaho.com + * Copyright (C) 2002-2018 by Hitachi Vantara : http://www.pentaho.com * ******************************************************************************* * @@ -28,6 +28,7 @@ import java.util.List; import java.util.Map; +import org.apache.commons.lang.StringUtils; import org.pentaho.di.cluster.SlaveServer; import org.pentaho.di.core.CheckResultInterface; import org.pentaho.di.core.Const; @@ -700,7 +701,8 @@ public Result execute( Result result, int nr ) throws KettleException { try { transMeta = getTransMeta( rep, metaStore, this ); } catch ( KettleException e ) { - logError( Const.getStackTracker( e ) ); + logError( BaseMessages.getString( PKG, "JobTrans.Exception.UnableToRunJob", parentJobMeta.getName(), + StringUtils.trim( e.getMessage() ), getName() ), e ); result.setNrErrors( 1 ); result.setResult( false ); return result; @@ -1367,6 +1369,9 @@ public TransMeta getTransMeta( Repository rep, IMetaStore metaStore, VariableSpa } return transMeta; + } catch ( final KettleException ke ) { + // if we get a KettleException, simply re-throw it + throw ke; } catch ( Exception e ) { throw new KettleException( BaseMessages.getString( PKG, "JobTrans.Exception.MetaDataLoad" ), e ); } diff --git a/engine/src/main/resources/org/pentaho/di/job/entries/trans/messages/messages_en_US.properties b/engine/src/main/resources/org/pentaho/di/job/entries/trans/messages/messages_en_US.properties index cf1a6fb6a028..75b8ed26f98b 100644 --- a/engine/src/main/resources/org/pentaho/di/job/entries/trans/messages/messages_en_US.properties +++ b/engine/src/main/resources/org/pentaho/di/job/entries/trans/messages/messages_en_US.properties @@ -79,6 +79,7 @@ JobEntryTransDialog.Exception.UnableToReferenceObjectId.Title=Error JobEntryTransDialog.Exception.UnableToReferenceObjectId.Message=Unable to get information about the referenced object with id={0} JobTrans.Log.OpeningTransByReference=Opening a transformation by reference with id={0} JobTrans.Exception.LogFilenameMissing=Log filename is empty or not specified! +JobTrans.Exception.UnableToRunJob=Unable to run job [{0}]. {1} [{2}] JobTrans.Browse.Label=Browse... JobTrans.Fileformat.TXT=Text files diff --git a/engine/src/test/java/org/pentaho/di/trans/streaming/common/BaseStreamStepMetaTest.java b/engine/src/test/java/org/pentaho/di/trans/streaming/common/BaseStreamStepMetaTest.java index 189bdae34d9d..7bb748a55619 100644 --- a/engine/src/test/java/org/pentaho/di/trans/streaming/common/BaseStreamStepMetaTest.java +++ b/engine/src/test/java/org/pentaho/di/trans/streaming/common/BaseStreamStepMetaTest.java @@ -68,6 +68,10 @@ import static org.pentaho.di.core.util.Assert.assertTrue; import static org.powermock.api.mockito.PowerMockito.when; +import org.custommonkey.xmlunit.XMLUnit; + +import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; + @RunWith ( MockitoJUnitRunner.class ) public class BaseStreamStepMetaTest { @@ -83,6 +87,7 @@ public static void setUpBeforeClass() throws KettleException { String passwordEncoderPluginID = Const.NVL( EnvUtil.getSystemProperty( Const.KETTLE_PASSWORD_ENCODER_PLUGIN ), "Kettle" ); Encr.init( passwordEncoderPluginID ); + XMLUnit.setIgnoreWhitespace( true ); } @Before @@ -180,16 +185,18 @@ public void testSaveLoadXMLWithInjectionList() throws Exception { meta.setBatchSize( "100" ); meta.setTransformationPath( "aPath" ); String xml = meta.getXML(); - assertEquals( - "100" + Const.CR + assertXMLEqual( + "" + Const.CR + + "100" + Const.CR + "Encrypted 2be98afc86aa7f2e4cb79ce10ca97bcce" + Const.CR + "1000" + Const.CR + "aPath" + Const.CR + "" + Const.CR + "one" + Const.CR + "two" + Const.CR - + "" + Const.CR, - xml ); + + "" + Const.CR + + "", + "" + xml + "" ); testRoundTrip( meta ); } @@ -209,19 +216,20 @@ public void testRoundTripXMLWithInjectionList() { @Test - public void testSaveDefaultEmptyConnection() { + public void testSaveDefaultEmptyConnection() throws Exception { StuffStreamMeta meta = new StuffStreamMeta(); String xml = meta.getXML(); - assertEquals( - "1000" + Const.CR - + "Encrypted 2be98afc86aa7f2e4cb79ce10ca97bcce" + Const.CR - + "1000" + Const.CR - + "" + Const.CR - + "" + Const.CR - + "one" + Const.CR - + "two" + Const.CR - + "" + Const.CR, - xml ); + assertXMLEqual( "" + Const.CR + + "1000" + Const.CR + + "Encrypted 2be98afc86aa7f2e4cb79ce10ca97bcce" + Const.CR + + "1000" + Const.CR + + "" + Const.CR + + "" + Const.CR + + "one" + Const.CR + + "two" + Const.CR + + "" + Const.CR + + "" + Const.CR, + "" + xml + "" ); testRoundTrip( meta ); } diff --git a/plugins/pur/core/src/main/java/org/pentaho/di/repository/pur/PurRepository.java b/plugins/pur/core/src/main/java/org/pentaho/di/repository/pur/PurRepository.java index 7e812f2045b8..53572696a50c 100644 --- a/plugins/pur/core/src/main/java/org/pentaho/di/repository/pur/PurRepository.java +++ b/plugins/pur/core/src/main/java/org/pentaho/di/repository/pur/PurRepository.java @@ -1,20 +1,25 @@ -//CHECKSTYLE:FileLength:OFF -/*! -* Copyright 2010 - 2018 Hitachi Vantara. All rights reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -*/ +/*! ****************************************************************************** + * + * Pentaho Data Integration + * + * Copyright (C) 2010-2018 by Hitachi Vantara : http://www.pentaho.com + * + ******************************************************************************* + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ + package org.pentaho.di.repository.pur; @@ -2157,17 +2162,35 @@ public TransMeta loadTransformation( final String transName, final RepositoryDir throws KettleException { String absPath = null; try { - absPath = getPath( transName, parentDir, RepositoryObjectType.TRANSFORMATION ); - if ( absPath == null ) { + // if transName is empty, we cannot load the transformation - the transformation path was likely not provided + // by the user + if ( StringUtils.isBlank( transName ) ) { + throw new KettleFileException( BaseMessages.getString( PKG, + "PurRepository.ERROR_0007_TRANSFORMATION_NAME_MISSING" ) ); + } + try { + absPath = getPath( transName, parentDir, RepositoryObjectType.TRANSFORMATION ); + } catch ( Exception e ) { + // ignore and handle null value below + } + // if absPath is empty, we cannot load the transformation - the path provided by the user was likely defined as a + // variable that is not available at runtime + if ( StringUtils.isBlank( absPath ) ) { // Couldn't resolve path, throw an exception throw new KettleFileException( BaseMessages.getString( PKG, - "PurRepository.ERROR_0002_TRANSFORMATION_NOT_FOUND", transName ) ); + "PurRepository.ERROR_0008_TRANSFORMATION_PATH_INVALID", transName ) ); } RepositoryFile file = pur.getFile( absPath ); if ( versionId != null ) { // need to go back to server to get versioned info file = pur.getFileAtVersion( file.getId(), versionId ); } + // if file is null, we cannot load the transformation - the provided path provided by the user is likely not a + // valid file + if ( file == null ) { + throw new KettleException( BaseMessages.getString( PKG, + "PurRepository.ERROR_0008_TRANSFORMATION_PATH_INVALID", absPath ) ); + } NodeRepositoryFileData data = null; ObjectRevision revision = null; // Additional obfuscation through obscurity @@ -2176,6 +2199,9 @@ public TransMeta loadTransformation( final String transName, final RepositoryDir TransMeta transMeta = buildTransMeta( file, parentDir, data, revision ); ExtensionPointHandler.callExtensionPoint( log, KettleExtensionPoint.TransformationMetaLoaded.id, transMeta ); return transMeta; + } catch ( final KettleException ke ) { + // if we have a KettleException, simply re-throw it + throw ke; } catch ( Exception e ) { throw new KettleException( "Unable to load transformation from path [" + absPath + "]", e ); } diff --git a/plugins/pur/core/src/main/resources/org/pentaho/di/repository/pur/messages/messages_en_US.properties b/plugins/pur/core/src/main/resources/org/pentaho/di/repository/pur/messages/messages_en_US.properties index 89fb5835d1ac..a7877255e530 100644 --- a/plugins/pur/core/src/main/resources/org/pentaho/di/repository/pur/messages/messages_en_US.properties +++ b/plugins/pur/core/src/main/resources/org/pentaho/di/repository/pur/messages/messages_en_US.properties @@ -36,6 +36,9 @@ PurRepository.ERROR_0004_DATABASE_UPDATE_ACCESS_DENIED=Access denied while updat PurRepository.ERROR_0005_INCORRECT_PERMISSION=Unable to export from repository, one of following permissions required: {0} PurRepository.ERROR_0006_UNABLE_TO_RENAME_JOB=Unable to rename Job from "{0}" to "{1}". Job with name "{1}" already exists. PurRepository.ERROR_0006_UNABLE_TO_RENAME_TRANS=Unable to rename Transformation from "{0}" to "{1}". Transformation with name "{1}" already exists. +PurRepository.ERROR_0007_TRANSFORMATION_NAME_MISSING=Please set a transformation for job entry +PurRepository.ERROR_0008_TRANSFORMATION_PATH_INVALID=Transformation [{0}] is invalid. Please set a valid \ + transformation for job entry PurRepository.FailedLogin.Message=Failed to connect to a Pentaho Server Instance. Please check your server connection information and make sure your server is running. PurRepository.BAServerLogin.Message=Connecting to a Pentaho Server repository is not supported at this time. PurRepository.FailedDirectoryCreation.Message=Creation of root directories is not allowed. diff --git a/ui/src/main/java/org/pentaho/di/ui/job/entries/trans/JobEntryTransDialog.java b/ui/src/main/java/org/pentaho/di/ui/job/entries/trans/JobEntryTransDialog.java index 9f456c8a61ce..7587247471c1 100644 --- a/ui/src/main/java/org/pentaho/di/ui/job/entries/trans/JobEntryTransDialog.java +++ b/ui/src/main/java/org/pentaho/di/ui/job/entries/trans/JobEntryTransDialog.java @@ -2,7 +2,7 @@ * * Pentaho Data Integration * - * Copyright (C) 2002-2017 by Hitachi Vantara : http://www.pentaho.com + * Copyright (C) 2002-2018 by Hitachi Vantara : http://www.pentaho.com * ******************************************************************************* * @@ -22,6 +22,9 @@ package org.pentaho.di.ui.job.entries.trans; +import org.apache.commons.lang.StringUtils; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -60,6 +63,7 @@ import org.pentaho.di.trans.TransMeta; import org.pentaho.di.ui.core.ConstUI; import org.pentaho.di.ui.core.dialog.ErrorDialog; +import org.pentaho.di.ui.core.dialog.SimpleMessageDialog; import org.pentaho.di.ui.core.gui.WindowProperty; import org.pentaho.di.ui.core.widget.ComboVar; import org.pentaho.di.ui.job.dialog.JobDialog; @@ -374,7 +378,9 @@ public void getData() { wPath.setText( Const.NVL( jobEntry.getFilename(), "" ) ); break; case REPOSITORY_BY_NAME: - String fullPath = Const.NVL( jobEntry.getDirectory(), "" ) + "/" + Const.NVL( jobEntry.getTransname(), "" ); + String dirPath = Const.NVL( jobEntry.getDirectory(), "" ); + String transPath = Const.NVL( jobEntry.getTransname(), "" ); + String fullPath = ( StringUtils.isBlank( dirPath ) ? "" : dirPath + "/" ) + transPath; wPath.setText( fullPath ); break; case REPOSITORY_BY_REFERENCE: @@ -624,21 +630,20 @@ private void getInfo( JobEntryTrans jet ) throws KettleException { protected void ok() { if ( Utils.isEmpty( wName.getText() ) ) { - MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR ); - mb.setText( BaseMessages.getString( PKG, "System.StepJobEntryNameMissing.Title" ) ); - mb.setMessage( BaseMessages.getString( PKG, "System.JobEntryNameMissing.Msg" ) ); - mb.open(); + final Dialog dialog = new SimpleMessageDialog( shell, + BaseMessages.getString( PKG, "System.StepJobEntryNameMissing.Title" ), + BaseMessages.getString( PKG, "System.JobEntryNameMissing.Msg" ), MessageDialog.ERROR ); + dialog.open(); return; } jobEntry.setName( wName.getText() ); try { getInfo( jobEntry ); - jobEntry.setChanged(); - dispose(); } catch ( KettleException e ) { - new ErrorDialog( shell, BaseMessages.getString( PKG, "JobTrans.Dialog.ErrorShowingTransformation.Title" ), - BaseMessages.getString( PKG, "JobTrans.Dialog.ErrorShowingTransformation.Message" ), e ); + // suppress exceptions at this time - we will let the runtime report on any errors } + jobEntry.setChanged(); + dispose(); } }