public T getMetaForEntry( Repository rep, IMetaStore metaStore, VariableSpace space ) throws KettleException {
    try {
      T theMeta = null;
      if ( jobEntryBase.getParentJob() != null ) {
        metaFileCache = jobEntryBase.getParentJobMeta().getMetaFileCache(); //Get the cache from the parent or create it
      }
      CurrentDirectoryResolver r = new CurrentDirectoryResolver();
      VariableSpace tmpSpace = r.resolveCurrentDirectory(
        specificationMethod, space, rep, jobEntryBase.getParentJob(), filename );

      final String[] idContainer = new String[ 1 ]; //unigue portion of cache key passed though argument
      switch ( specificationMethod ) {
        case FILENAME:
          String realFilename = tmpSpace.environmentSubstitute( filename );
          try {
            theMeta = attemptLoadMeta( realFilename, rep, metaStore, tmpSpace, null, idContainer );
          } catch ( KettleException e ) {
            // try to load from repository, this trans may have been developed locally and later uploaded to the
            // repository
            if ( rep == null ) {
              theMeta = isTransMeta()
                      ? (T) new TransMeta( realFilename, metaStore, null, true, jobEntryBase.getParentVariableSpace(), null )
                      : (T) new JobMeta( jobEntryBase.getParentVariableSpace(), realFilename, rep, metaStore, null );
            } else {
              theMeta = getMetaFromRepository( rep, r, realFilename, tmpSpace );
            }
            if ( theMeta != null ) {
              idContainer[ 0 ] = realFilename;
            }
          }
          break;
        case REPOSITORY_BY_NAME:
          String realDirectory = tmpSpace.environmentSubstitute( directory != null ? directory : "" );
          String realName = tmpSpace.environmentSubstitute( metaName );

          String metaPath = StringUtil.trimEnd( realDirectory, '/' ) + RepositoryFile.SEPARATOR + StringUtil
            .trimStart( realName, '/' );

          if ( metaPath.startsWith( "file://" ) || metaPath.startsWith( "zip:file://" ) || metaPath.startsWith(
            "hdfs://" ) ) {
            String extension = isTransMeta() ? RepositoryObjectType.TRANSFORMATION.getExtension()
              : RepositoryObjectType.JOB.getExtension();
            if ( !metaPath.endsWith( extension ) ) {
              metaPath = metaPath + extension;
            }
            theMeta = attemptCacheRead( metaPath ); //try to get from the cache first
            if ( theMeta == null ) {
              if ( isTransMeta() ) {
                theMeta =
                  (T) new TransMeta( metaPath, metaStore, null, true, jobEntryBase.getParentVariableSpace(), null );
              } else {
                theMeta = (T) new JobMeta( tmpSpace, metaPath, rep, metaStore, null );
              }
              idContainer[ 0 ] = metaPath;
            }
          } else {
            theMeta = attemptCacheRead( metaPath ); //try to get from the cache first
            if ( theMeta == null ) {
              if ( isTransMeta() ) {
                theMeta = rep == null
                  ? (T) new TransMeta( metaPath, metaStore, null, true, jobEntryBase.getParentVariableSpace(), null )
                  : getMetaFromRepository( rep, r, metaPath, tmpSpace );
              } else {
                theMeta = getMetaFromRepository( rep, r, metaPath, tmpSpace );
              }
              if ( theMeta != null ) {
                idContainer[ 0 ] = metaPath;
              }
            }
          }
          break;
        case REPOSITORY_BY_REFERENCE:
          if ( metaObjectId == null ) {
            if ( isTransMeta() ) {
              throw new KettleException( BaseMessages.getString( persistentClass,
                "JobTrans.Exception.ReferencedTransformationIdIsNull" ) );
            } else {
              throw new KettleException( BaseMessages.getString( persistentClass,
                "JobJob.Exception.ReferencedTransformationIdIsNull" ) );
            }
          }

          if ( rep != null ) {
            theMeta = attemptCacheRead( metaObjectId.toString() ); //try to get from the cache first
            if ( theMeta == null ) {
              // Load the last revision
              if ( isTransMeta() ) {
                theMeta = (T) rep.loadTransformation( metaObjectId, null );
              } else {
                theMeta = (T) rep.loadJob( metaObjectId, null );
              }
              idContainer[ 0 ] = metaObjectId.toString();
            }
          } else {
            throw new KettleException(
              "Could not execute " + friendlyMetaType + " specified in a repository since we're not connected to one" );
          }
          break;
        default:
          throw new KettleException( "The specified object location specification method '"
            + specificationMethod + "' is not yet supported in this " + friendlyMetaType + " entry." );
      }

      cacheMeta( idContainer[ 0 ], theMeta );
      return theMeta;
    } catch ( final KettleException ke ) {
      // if we get a KettleException, simply re-throw it
      throw ke;
    } catch ( Exception e ) {
      throw new KettleException( BaseMessages.getString( persistentClass, "JobTrans.Exception.MetaDataLoad" ), e );
    }
  }
@Test
  //A job getting the JobMeta from the fileSystem
  public void getMetaForEntryAsJobFromFileSystemTest() throws Exception {
    setupJobEntryJob();
    specificationMethod = ObjectLocationSpecificationMethod.FILENAME;
    MetaFileLoaderImpl metaFileLoader = new MetaFileLoaderImpl<JobMeta>( jobEntryBase, specificationMethod );
    JobMeta jobMeta = (JobMeta) metaFileLoader.getMetaForEntry( repository, store, space );

    validateFirstJobMetaAccess( jobMeta );
    jobMeta = (JobMeta) metaFileLoader.getMetaForEntry( repository, store, space );
    validateSecondJobMetaAccess( jobMeta );
  }