@Override public void saveRepositoryDirectory( final RepositoryDirectoryInterface dir ) throws KettleException { // id of root dir is null--check for it if ( "/".equals( dir.getParent().getName() ) ) { throw new KettleException( BaseMessages.getString( PKG, "PurRepository.FailedDirectoryCreation.Message" ) ); } readWriteLock.writeLock().lock(); try { RepositoryFile newFolder = pur.createFolder( dir.getParent().getObjectId() != null ? dir.getParent().getObjectId().getId() : null, new RepositoryFile.Builder( dir.getName() ).folder( true ).build(), null ); dir.setObjectId( new StringObjectId( newFolder.getId().toString() ) ); } catch ( Exception e ) { throw new KettleException( "Unable to save repository directory with path [" + getPath( null, dir, null ) + "]", e ); } finally { readWriteLock.writeLock().unlock(); } }
@Override public void createNamespace( String namespace ) throws MetaStoreException { if ( namespaceExists( namespace ) ) { throw new MetaStoreNamespaceExistsException( "Namespace '" + namespace + "' can not be created, it already exists" ); } RepositoryFile namespaceFolder = new RepositoryFile.Builder( namespace ).folder( true ).versioned( false ).build(); pur.createFolder( namespacesFolder.getId(), namespaceFolder, "Created namespace" ); }
@Override public void createElementType( String namespace, IMetaStoreElementType elementType ) throws MetaStoreException { RepositoryFile namespaceFile = validateNamespace( namespace ); IMetaStoreElementType existingType = getElementTypeByName( namespace, elementType.getName() ); if ( existingType != null ) { throw new MetaStoreElementTypeExistsException( Collections.singletonList( existingType ), "Can not create element type with id '" + elementType.getId() + "' because it already exists" ); } RepositoryFile elementTypeFile = new RepositoryFile.Builder( elementType.getName() ).folder( true ).versioned( false ).build(); RepositoryFile folder = pur.createFolder( namespaceFile.getId(), elementTypeFile, null ); elementType.setId( folder.getId().toString() ); // In this folder there is a hidden file which contains the description // and the other future properties of the element type // RepositoryFile detailsFile = new RepositoryFile.Builder( ELEMENT_TYPE_DETAILS_FILENAME ).folder( false ).title( ELEMENT_TYPE_DETAILS_FILENAME ).description( elementType.getDescription() ).hidden( true ).build(); DataNode dataNode = getElementTypeDataNode( elementType ); pur.createFile( folder.getId(), detailsFile, new NodeRepositoryFileData( dataNode ), null ); elementType.setMetaStoreName( getName() ); }
public RepositoryFile call() throws Exception { return delegatee.createFolder( parentFolderId, file, acl, versionMessage ); } }, Messages.getInstance().getString( "ExceptionLoggingDecorator.createFolder", file.getName() ) ); //$NON-NLS-1$
public RepositoryFile call() throws Exception { return delegatee.createFolder( parentFolderId, file, versionMessage ); } }, Messages.getInstance().getString( "ExceptionLoggingDecorator.createFolder", file.getName() ) ); //$NON-NLS-1$
public RepositoryFileDto createFolder( String parentFolderId, RepositoryFileDto file, String versionMessage ) { RepositoryFile newFile = repo.createFolder( parentFolderId, repositoryFileAdapter.unmarshal( file ), versionMessage ); return newFile != null ? repositoryFileAdapter.marshal( newFile ) : null; }
public RepositoryFileDto createFolderWithAcl( String parentFolderId, RepositoryFileDto file, RepositoryFileAclDto acl, String versionMessage ) { RepositoryFile newFile = repo.createFolder( parentFolderId, repositoryFileAdapter.unmarshal( file ), repositoryFileAclAdapter .unmarshal( acl ), versionMessage ); return newFile != null ? repositoryFileAdapter.marshal( newFile ) : null; }
public RepositoryFile getFolder( final String path, final RepositoryFileAcl acl, final boolean createIfNotExist, final boolean createParents, final String versionMessage ) { RepositoryFile folder = repository.getFile( path ); if ( null == folder && createIfNotExist ) { final String parentPath = RepositoryFilenameUtils.getFullPathNoEndSeparator( path ); if ( !parentPath.equals( path ) ) { final RepositoryFile parentFolder = getFolder( parentPath, acl, createParents, createParents, versionMessage ); if ( null != parentFolder ) { final String folderName = RepositoryFilenameUtils.getName( path ); folder = new RepositoryFile.Builder( folderName ).path( path ).folder( true ).build(); if ( null != acl ) { folder = repository.createFolder( parentFolder.getId(), folder, acl, versionMessage ); } else { folder = repository.createFolder( parentFolder.getId(), folder, versionMessage ); } } } } return folder; }
/** * Stubs a {@code createFolder} call. */ public static void stubCreateFolder( final IUnifiedRepository repo, final String path ) { final String parentPath = StringUtils.substringBeforeLast( path, RepositoryFile.SEPARATOR ); doReturn( makeFileObject( path, true ) ).when( repo ).createFolder( eq( makeIdObject( parentPath ) ), argThat( isLikeFile( makeFolderObject( path, false ) ) ), anyString() ); }
repository.createFolder( parentFolder.getId(), new RepositoryFile.Builder( folderName ).folder( true ) .build(), null );
public void setUp() throws Exception { IUnifiedRepository repository = new MockUnifiedRepository( new MockUnifiedRepository.SpringSecurityCurrentUserProvider() ); datasourceMgmtService = new JcrBackedDatasourceMgmtService( repository, new DatabaseDialectService() ); datasourceMgmtWebService = new DefaultDatasourceMgmtWebService( datasourceMgmtService ); dbConnectionAdapter = new DatabaseConnectionAdapter(); SecurityContextHolder.getContext() .setAuthentication( new UsernamePasswordAuthenticationToken( MockUnifiedRepository.root().getName(), null, new ArrayList<GrantedAuthority>() ) ); repository.createFolder( repository.getFile( "/etc" ).getId(), new RepositoryFile.Builder( FOLDER_PDI ).folder( true ).build(), new RepositoryFileAcl.Builder( MockUnifiedRepository.root() ).ace( MockUnifiedRepository.everyone(), READ, WRITE ).build(), null ); repository.createFolder( repository.getFile( "/etc/pdi" ).getId(), new RepositoryFile.Builder( FOLDER_DATABASES ) .folder( true ).build(), null ); SecurityContextHolder.getContext().setAuthentication( new UsernamePasswordAuthenticationToken( EXP_LOGIN, null, new ArrayList<GrantedAuthority>() ) ); KettleClientEnvironment.init(); }
@Override protected void setUp() throws Exception { IUnifiedRepository repository = new MockUnifiedRepository( new MockUnifiedRepository.SpringSecurityCurrentUserProvider() ); datasourceMgmtService = new JcrBackedDatasourceMgmtService( repository, new DatabaseDialectService() ); datasourceMgmtWS = new DefaultDatasourceMgmtWebService( datasourceMgmtService ); adapter = new DatasourceMgmtToWebServiceAdapter( datasourceMgmtWS ); SecurityContextHolder.getContext() .setAuthentication( new UsernamePasswordAuthenticationToken( MockUnifiedRepository.root().getName(), null, new ArrayList<GrantedAuthority>() ) ); repository.createFolder( repository.getFile( "/etc" ).getId(), new RepositoryFile.Builder( FOLDER_PDI ).folder( true ).build(), new RepositoryFileAcl.Builder( MockUnifiedRepository.root() ).ace( MockUnifiedRepository.everyone(), READ, WRITE ).build(), null ); repository.createFolder( repository.getFile( "/etc/pdi" ).getId(), new RepositoryFile.Builder( FOLDER_DATABASES ) .folder( true ).build(), null ); SecurityContextHolder.getContext().setAuthentication( new UsernamePasswordAuthenticationToken( EXP_LOGIN, null, new ArrayList<GrantedAuthority>() ) ); KettleClientEnvironment.init(); }