/** * Returns a attribute value for the given domain (namespace) and attribute-name. Some generic attribute domains and * names are defined as constants in the {@link LibRepositoryBoot} class. * * @param domain the attribute domain. * @param key the name of the attribute. * @return the value or null, if the content-entity does not have a value for this attribute. */ public Object getAttribute( final String domain, final String key ) { try { if ( LibRepositoryBoot.REPOSITORY_DOMAIN.equals( domain ) ) { if ( LibRepositoryBoot.SIZE_ATTRIBUTE.equals( key ) ) { return new Long( backend.getContent().getSize() ); } else if ( LibRepositoryBoot.VERSION_ATTRIBUTE.equals( key ) ) { return new Date( backend.getContent().getLastModifiedTime() ); } } } catch ( FileSystemException ex ) { throw new RuntimeException( ex ); } return null; }
timestamp = new Date( file.getContent().getLastModifiedTime() );
java.util.Date lastmodifiedtimedate = new java.util.Date( file.getContent().getLastModifiedTime() ); java.text.DateFormat dateFormat = new SimpleDateFormat( dateformat ); lastmodifiedtime = dateFormat.format( lastmodifiedtimedate );
@Override public List<RepositoryElementMetaInterface> getJobObjects( ObjectId id_directory, boolean includeDeleted ) throws KettleException { try { List<RepositoryElementMetaInterface> list = new ArrayList<RepositoryElementMetaInterface>(); RepositoryDirectoryInterface tree = loadRepositoryDirectoryTree(); RepositoryDirectoryInterface directory = tree.findDirectory( id_directory ); String folderName = calcDirectoryName( directory ); FileObject folder = KettleVFS.getFileObject( folderName ); for ( FileObject child : folder.getChildren() ) { if ( child.getType().equals( FileType.FILE ) ) { if ( !child.isHidden() || !repositoryMeta.isHidingHiddenFiles() ) { String name = child.getName().getBaseName(); if ( name.endsWith( EXT_JOB ) ) { String jobName = name.substring( 0, name.length() - 4 ); ObjectId id = new StringObjectId( calcObjectId( directory, jobName, EXT_JOB ) ); Date date = new Date( child.getContent().getLastModifiedTime() ); list.add( new RepositoryObject( id, jobName, directory, "-", date, RepositoryObjectType.JOB, "", false ) ); } } } } return list; } catch ( Exception e ) { throw new KettleException( "Unable to get list of jobs in folder with id : " + id_directory, e ); } }
@Override public List<RepositoryElementMetaInterface> getTransformationObjects( ObjectId idDirectory, boolean includeDeleted ) throws KettleException { try { List<RepositoryElementMetaInterface> list = new ArrayList<RepositoryElementMetaInterface>(); RepositoryDirectoryInterface tree = loadRepositoryDirectoryTree(); RepositoryDirectoryInterface directory = tree.findDirectory( idDirectory ); String folderName = calcDirectoryName( directory ); FileObject folder = KettleVFS.getFileObject( folderName ); for ( FileObject child : folder.getChildren() ) { if ( child.getType().equals( FileType.FILE ) ) { if ( !child.isHidden() || !repositoryMeta.isHidingHiddenFiles() ) { String name = child.getName().getBaseName(); if ( name.endsWith( EXT_TRANSFORMATION ) ) { String transName = name.substring( 0, name.length() - 4 ); ObjectId id = new StringObjectId( calcObjectId( directory, transName, EXT_TRANSFORMATION ) ); Date date = new Date( child.getContent().getLastModifiedTime() ); list.add( new RepositoryObject( id, transName, directory, "-", date, RepositoryObjectType.TRANSFORMATION, "", false ) ); } } } } return list; } catch ( Exception e ) { throw new KettleException( "Unable to get list of transformations in folder with id : " + idDirectory, e ); } }
@Override public RepositoryObject getObjectInformation( ObjectId objectId, RepositoryObjectType objectType ) throws KettleException { try { String filename = calcDirectoryName( null ); if ( objectId.getId().startsWith( "/" ) ) { filename += objectId.getId().substring( 1 ); } else { filename += objectId.getId(); } FileObject fileObject = KettleVFS.getFileObject( filename ); if ( !fileObject.exists() ) { return null; } FileName fname = fileObject.getName(); String name = fname.getBaseName(); if ( !Utils.isEmpty( fname.getExtension() ) && name.length() > fname.getExtension().length() ) { name = name.substring( 0, name.length() - fname.getExtension().length() - 1 ); } String filePath = fileObject.getParent().getName().getPath(); final FileObject baseDirObject = KettleVFS.getFileObject( repositoryMeta.getBaseDirectory() ); final int baseDirObjectPathLength = baseDirObject.getName().getPath().length(); final String dirPath = baseDirObjectPathLength <= filePath.length() ? filePath.substring( baseDirObjectPathLength ) : "/"; RepositoryDirectoryInterface directory = loadRepositoryDirectoryTree().findDirectory( dirPath ); Date lastModified = new Date( fileObject.getContent().getLastModifiedTime() ); return new RepositoryObject( objectId, name, directory, "-", lastModified, objectType, "", false ); } catch ( Exception e ) { throw new KettleException( "Unable to get object information for object with id=" + objectId, e ); } }
java.util.Date lastmodifiedtimedate = new java.util.Date( file.getContent().getLastModifiedTime() ); java.text.DateFormat dateFormat = new SimpleDateFormat( dateformat ); lastmodifiedtime = dateFormat.format( lastmodifiedtimedate );
/** * Prepare file-dependent data for fill additional fields. */ protected void fillFileAdditionalFields( D data, FileObject file ) throws FileSystemException { data.shortFilename = file.getName().getBaseName(); data.path = KettleVFS.getFilename( file.getParent() ); data.hidden = file.isHidden(); data.extension = file.getName().getExtension(); data.uriName = file.getName().getURI(); data.rootUriName = file.getName().getRootURI(); if ( file.getType().hasContent() ) { data.lastModificationDateTime = new Date( file.getContent().getLastModifiedTime() ); data.size = file.getContent().getSize(); } else { data.lastModificationDateTime = null; data.size = null; } } }
if ( setOriginalModificationDate ) { newFileObject.getContent().setLastModifiedTime( item.getContent().getLastModifiedTime() );
data.lastModificationDateTime = new Date( data.file.getContent().getLastModifiedTime() );
data.lastModificationDateTime = new Date( data.file.getContent().getLastModifiedTime() );
data.lastModificationDateTime = new Date( data.file.getContent().getLastModifiedTime() );
data.lastModificationDateTime = new Date( data.file.getContent().getLastModifiedTime() );
data.lastModificationDateTime = new Date( data.file.getContent().getLastModifiedTime() );
data.lastModificationDateTime = new Date( data.file.getContent().getLastModifiedTime() );
data.lastModificationDateTime = new Date( data.file.getContent().getLastModifiedTime() );
extraData[outputIndex++] = new Date( data.file.getContent().getLastModifiedTime() );
extraData[outputIndex++] = new Date( data.file.getContent().getLastModifiedTime() );
/** * {@inheritDoc} This implementation uses Commons VFS to obtain a * {@code FileObject} and read the date of the last modification. */ @Override protected long getLastModificationDate() { final FileObject file = getFileObject(); try { if (file == null || !file.exists()) { return 0; } return file.getContent().getLastModifiedTime(); } catch (final FileSystemException ex) { log.error("Unable to get last modified time for" + file.getName().getURI(), ex); return 0; } }
/** * Returns the last-modified time of this file. */ @Override protected long doGetLastModifiedTime() throws Exception { return file.getContent().getLastModifiedTime(); }