use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.
the class KettleFileRepository method createRepositoryDirectory.
@Override
public RepositoryDirectoryInterface createRepositoryDirectory(RepositoryDirectoryInterface parentDirectory, String directoryPath) throws KettleException {
String folder = calcDirectoryName(parentDirectory);
String newFolder = folder;
if (folder.endsWith("/")) {
newFolder += directoryPath;
} else {
newFolder += "/" + directoryPath;
}
FileObject parent = KettleVFS.getFileObject(newFolder);
try {
parent.createFolder();
} catch (FileSystemException e) {
throw new KettleException("Unable to create folder " + newFolder, e);
}
// Incremental change of the directory structure...
//
RepositoryDirectory newDir = new RepositoryDirectory(parentDirectory, directoryPath);
parentDirectory.addSubdirectory(newDir);
newDir.setObjectId(new StringObjectId(calcObjectId(newDir)));
return newDir;
}
use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.
the class KettleFileRepository method loadRepositoryDirectoryTree.
public RepositoryDirectoryInterface loadRepositoryDirectoryTree(RepositoryDirectoryInterface dir) throws KettleException {
try {
String folderName = calcDirectoryName(dir);
FileObject folder = KettleVFS.getFileObject(folderName);
for (FileObject child : folder.getChildren()) {
if (child.getType().equals(FileType.FOLDER)) {
if (!child.isHidden() || !repositoryMeta.isHidingHiddenFiles()) {
if (!".meta".equals(child.getName().getBaseName())) {
RepositoryDirectory subDir = new RepositoryDirectory(dir, child.getName().getBaseName());
subDir.setObjectId(new StringObjectId(calcObjectId(subDir)));
dir.addSubdirectory(subDir);
loadRepositoryDirectoryTree(subDir);
}
}
}
}
return dir;
} catch (Exception e) {
throw new KettleException("Unable to load the directory tree from this file repository", e);
}
}
use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryMetaStore method deleteElementType.
@Override
public void deleteElementType(String namespace, IMetaStoreElementType elementType) throws MetaStoreException, MetaStoreDependenciesExistsException {
try {
Collection<RowMetaAndData> elementTypeRows = delegate.getElements(new LongObjectId(new StringObjectId(elementType.getId())));
if (!elementTypeRows.isEmpty()) {
List<String> dependencies = new ArrayList<String>();
for (RowMetaAndData elementTypeRow : elementTypeRows) {
Long elementTypeId = elementTypeRow.getInteger(KettleDatabaseRepository.FIELD_ELEMENT_TYPE_ID_ELEMENT_TYPE);
dependencies.add(Long.toString(elementTypeId));
}
throw new MetaStoreDependenciesExistsException(dependencies, "The namespace to delete, '" + namespace + "' is not empty");
}
delegate.deleteElementType(new LongObjectId(new StringObjectId(elementType.getId())));
repository.commit();
} catch (MetaStoreDependenciesExistsException e) {
throw e;
} catch (Exception e) {
repository.rollback();
throw new MetaStoreException(e);
}
}
use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryMetaStore method deleteElement.
@Override
public void deleteElement(String namespace, IMetaStoreElementType elementType, String elementId) throws MetaStoreException {
try {
IMetaStoreElementType type = getElementTypeByName(namespace, elementType.getName());
if (type == null) {
throw new MetaStoreException("Unable to find element type with name '" + elementType.getName() + "'");
}
delegate.deleteElement(new LongObjectId(new StringObjectId(elementId)));
repository.commit();
} catch (Exception e) {
repository.rollback();
throw new MetaStoreException("Unable to delete element with id '" + elementId + "' of type '" + elementType.getName() + "'", e);
}
}
use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositorySecurityProviderTest method testSaveUserInfo_Passes.
private void testSaveUserInfo_Passes(String login, String expectedLogin, String existing) throws Exception {
doReturn(new StringObjectId(existing)).when(repository.userDelegate).getUserID(eq(existing));
provider.saveUserInfo(new UserInfo(login));
ArgumentCaptor<UserInfo> captor = ArgumentCaptor.forClass(UserInfo.class);
verify(repository.userDelegate).saveUserInfo(captor.capture());
assertEquals("UserInfo should be passed", expectedLogin, captor.getValue().getLogin());
}
Aggregations