Skip to content

Commit

Permalink
[BACKLOG-10649] don't check trans when empty filename, npe with objec…
Browse files Browse the repository at this point in the history
…tId (#2904)
  • Loading branch information
Tiago Ferreira authored and mdamour1976 committed Sep 8, 2016
1 parent b761993 commit 0c0d717
Showing 1 changed file with 27 additions and 12 deletions.
Expand Up @@ -331,7 +331,9 @@ public void shellClosed( ShellEvent e ) {
private void checkInvalidMapping() {
if ( injectTransMeta == null ) {
try {
loadTransformation();
if ( !loadTransformation() ) {
return;
}
} catch ( KettleException e ) {
showErrorOnLoadTransformationDialog( e );
return;
Expand Down Expand Up @@ -1083,12 +1085,19 @@ private void validateTrans() {
}
}

private void loadTransformation() throws KettleException {
private boolean loadTransformation() throws KettleException {
switch ( specificationMethod ) {
case FILENAME:
if ( Const.isEmpty( wFilename.getText() ) ) {
return false;
}
loadFileTrans( wFilename.getText() );
break;
case REPOSITORY_BY_NAME:
if ( Const.isEmpty( wDirectory.getText() ) && Const.isEmpty( wTransname.getText() ) ) {
return false;
}

String realDirectory = transMeta.environmentSubstitute( wDirectory.getText() );
String realTransname = transMeta.environmentSubstitute( wTransname.getText() );

Expand All @@ -1104,12 +1113,16 @@ private void loadTransformation() throws KettleException {
loadRepositoryTrans( realTransname, repdir );
break;
case REPOSITORY_BY_REFERENCE:
if ( referenceObjectId == null ) {
return false;
}
injectTransMeta = repository.loadTransformation( referenceObjectId, null ); // load the last version
injectTransMeta.clearChanged();
break;
default:
break;
}
return true;
}

public void setActive() {
Expand Down Expand Up @@ -1170,17 +1183,19 @@ public void getData() {
case REPOSITORY_BY_REFERENCE:
referenceObjectId = metaInjectMeta.getTransObjectId();
wByReference.setText( "" );
try {
RepositoryObject transInf =
repository.getObjectInformation(
metaInjectMeta.getTransObjectId(), RepositoryObjectType.TRANSFORMATION );
if ( transInf != null ) {
getByReferenceData( transInf );
if ( referenceObjectId != null ) {
try {
RepositoryObject transInf =
repository.getObjectInformation( metaInjectMeta.getTransObjectId(),
RepositoryObjectType.TRANSFORMATION );
if ( transInf != null ) {
getByReferenceData( transInf );
}
} catch ( KettleException e ) {
new ErrorDialog( shell,
BaseMessages.getString( PKG, "MetaInjectDialog.Exception.UnableToReferenceObjectId.Title" ),
BaseMessages.getString( PKG, "MetaInjectDialog.Exception.UnableToReferenceObjectId.Message" ), e );
}
} catch ( KettleException e ) {
new ErrorDialog( shell,
BaseMessages.getString( PKG, "MetaInjectDialog.Exception.UnableToReferenceObjectId.Title" ),
BaseMessages.getString( PKG, "MetaInjectDialog.Exception.UnableToReferenceObjectId.Message" ), e );
}
break;
default:
Expand Down

0 comments on commit 0c0d717

Please sign in to comment.