/** * Checks if the text configuration for the input/output files is present. * If not - silently returns. If present checks if the input file is allowed to be scheduled. * @param jobParams scheduling job parameters * @throws SchedulerException the configuration is recognized but the file can't be scheduled, is a folder or doesn't exist. */ @Override public void validateJobParams( Map<String, Serializable> jobParams ) throws SchedulerException { final Object streamProviderObj = jobParams.get( RESERVEDMAPKEY_STREAMPROVIDER ); if ( streamProviderObj instanceof String ) { String inputFilePath = null; final String inputOutputString = (String) streamProviderObj; final String[] tokens = inputOutputString.split( ":" ); if ( !ArrayUtils.isEmpty( tokens ) && tokens.length == 2 ) { inputFilePath = tokens[ 0 ].split( "=" )[ 1 ].trim(); if ( StringUtils.isNotBlank( inputFilePath ) ) { final IUnifiedRepository repository = PentahoSystem.get( IUnifiedRepository.class ); final RepositoryFile repositoryFile = repository.getFile( inputFilePath ); if ( ( repositoryFile == null ) || repositoryFile.isFolder() || !repositoryFile.isSchedulable() ) { throw new SchedulerException( Messages.getInstance().getString( "QuartzScheduler.ERROR_0008_SCHEDULING_IS_NOT_ALLOWED" ) ); } } } } } }
@Override public Object answer( InvocationOnMock invocationOnMock ) throws Throwable { final RepositoryFile repositoryFile = Mockito.mock( RepositoryFile.class ); final String param = (String) invocationOnMock.getArguments()[ 0 ]; if ( "/home/admin/notexist.ktr".equals( param ) ) { return null; } if ( "/home/admin".equals( param ) ) { Mockito.when( repositoryFile.isFolder() ).thenReturn( true ); } if ( "/home/admin/notallowed.ktr".equals( param ) ) { Mockito.when( repositoryFile.isFolder() ).thenReturn( false ); Mockito.when( repositoryFile.isSchedulable() ).thenReturn( false ); } if ( "/home/admin/allowed.ktr".equals( param ) ) { Mockito.when( repositoryFile.isFolder() ).thenReturn( false ); Mockito.when( repositoryFile.isSchedulable() ).thenReturn( true ); } return repositoryFile; } } );
setMetadataItemForFile( session, PentahoJcrConstants.PHO_CONTENTCREATOR, file.getCreatorId(), metadataNode ); setMetadataItemForFile( session, RepositoryFile.SCHEDULABLE_KEY, Boolean.toString( file.isSchedulable() ), metadataNode );
setMetadataItemForFile( session, RepositoryFile.SCHEDULABLE_KEY, Boolean.toString( file.isSchedulable() ), metaNode ); fileNode.addMixin( pentahoJcrConstants.getMIX_LOCKABLE() );
public Builder( final RepositoryFile other ) { this( other.getName() ); synchronized ( other ) { this.id( other.getId() ).path( other.getPath() ).createdDate( other.getCreatedDate() ).creatorId( other.getCreatorId() ).fileSize( other.getFileSize() ).folder( other.isFolder() ).lastModificationDate( other.getLastModifiedDate() ).versioned( other.isVersioned() ).hidden( other.isHidden() ).schedulable( other.isSchedulable() ).versionId( other.getVersionId() ).locked( other.isLocked() ).lockDate( other.getLockDate() ).lockOwner( other.getLockOwner() ).lockMessage( other.getLockMessage() ).title( other.getTitle() ).description( other.getDescription() ).locale( other.getLocale() ).originalParentFolderPath( other.getOriginalParentFolderPath() ).deletedDate( other.getDeletedDate() ).localePropertiesMap( other.getLocalePropertiesMap() ).aclNode( other.isAclNode() ); } }