use of org.pentaho.di.repository.RepositoryObject in project pentaho-kettle by pentaho.
the class PurRepository_GetObjectInformation_IT method getObjectInformation_InvalidRepositoryId_ExceptionIsHandled.
@Test
public void getObjectInformation_InvalidRepositoryId_ExceptionIsHandled() throws Exception {
IUnifiedRepository unifiedRepository = mock(IUnifiedRepository.class);
when(unifiedRepository.getFileById(any(Serializable.class))).thenThrow(new RuntimeException("unknown id"));
purRepository.setTest(unifiedRepository);
RepositoryObject information = purRepository.getObjectInformation(new StringObjectId("invalid id"), RepositoryObjectType.JOB);
assertNull("Should return null if file was not found", information);
}
use of org.pentaho.di.repository.RepositoryObject in project pentaho-kettle by pentaho.
the class JobEntryTransDialog method selectTransformation.
private void selectTransformation() {
RepositoryObject repositoryObject = DialogHelper.selectRepositoryObject("*.ktr", log);
if (repositoryObject != null) {
String path = DialogUtils.getPath(jobMeta.getRepositoryDirectory().getPath(), repositoryObject.getRepositoryDirectory().getPath());
String fullPath = (path.equals("/") ? "/" : path + "/") + repositoryObject.getName();
wPath.setText(fullPath);
}
}
use of org.pentaho.di.repository.RepositoryObject in project pentaho-kettle by pentaho.
the class JobEntryTransDialog method getByReferenceData.
private void getByReferenceData(ObjectId transObjectId) {
try {
RepositoryObject transInf = rep.getObjectInformation(transObjectId, RepositoryObjectType.TRANSFORMATION);
String path = DialogUtils.getPath(jobMeta.getRepositoryDirectory().getPath(), transInf.getRepositoryDirectory().getPath());
String fullPath = Const.NVL(path, "") + "/" + Const.NVL(transInf.getName(), "");
wPath.setText(fullPath);
} catch (KettleException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "JobEntryTransDialog.Exception.UnableToReferenceObjectId.Title"), BaseMessages.getString(PKG, "JobEntryTransDialog.Exception.UnableToReferenceObjectId.Message"), e);
}
}
use of org.pentaho.di.repository.RepositoryObject in project pentaho-kettle by pentaho.
the class PurRepository method getObjectInformation.
@Override
public RepositoryObject getObjectInformation(ObjectId objectId, RepositoryObjectType objectType) throws KettleException {
try {
RepositoryFile repositoryFile;
try {
repositoryFile = pur.getFileById(objectId.getId());
} catch (Exception e) {
// javax.jcr.Session throws exception, if a node with specified ID does not exist
// see http://jira.pentaho.com/browse/BISERVER-12758
log.logError("Error when trying to obtain a file by id: " + objectId.getId(), e);
return null;
}
if (repositoryFile == null) {
return null;
}
RepositoryFileAcl repositoryFileAcl = pur.getAcl(repositoryFile.getId());
String parentPath = getParentPath(repositoryFile.getPath());
String name = repositoryFile.getTitle();
String description = repositoryFile.getDescription();
Date modifiedDate = repositoryFile.getLastModifiedDate();
// String creatorId = repositoryFile.getCreatorId();
String ownerName = repositoryFileAcl != null ? repositoryFileAcl.getOwner().getName() : "";
boolean deleted = isDeleted(repositoryFile);
RepositoryDirectoryInterface directory = findDirectory(parentPath);
return new RepositoryObject(objectId, name, directory, ownerName, modifiedDate, objectType, description, deleted);
} catch (Exception e) {
throw new KettleException("Unable to get object information for object with id=" + objectId, e);
}
}
use of org.pentaho.di.repository.RepositoryObject in project pentaho-kettle by pentaho.
the class PurRepository method getChildren.
@Override
public List<RepositoryObjectInterface> getChildren(String path, String filter) {
RepositoryRequest repoRequest = new RepositoryRequest();
repoRequest.setDepth(-1);
repoRequest.setChildNodeFilter("*" + filter + "*");
repoRequest.setIncludeAcls(false);
repoRequest.setTypes(FILES_TYPE_FILTER.FILES_FOLDERS);
repoRequest.setPath(path);
repoRequest.setShowHidden(false);
List<RepositoryFile> repositoryFiles = pur.getChildren(repoRequest);
List<RepositoryObjectInterface> repositoryElementInterfaces = new ArrayList<>();
for (RepositoryFile repositoryFile : repositoryFiles) {
if (repositoryFile.isFolder()) {
RepositoryDirectoryInterface repositoryDirectory = new RepositoryDirectory();
repositoryDirectory.setName(repositoryFile.getName());
repositoryDirectory.setObjectId(() -> repositoryFile.getId().toString());
repositoryElementInterfaces.add(repositoryDirectory);
} else {
RepositoryObject repositoryObject = new RepositoryObject();
repositoryObject.setName(repositoryFile.getName());
repositoryObject.setObjectId(() -> repositoryFile.getId().toString());
RepositoryObjectType repositoryObjectType = RepositoryObjectType.UNKNOWN;
if (repositoryFile.getName().endsWith(".ktr")) {
repositoryObjectType = RepositoryObjectType.TRANSFORMATION;
}
if (repositoryFile.getName().endsWith(".kjb")) {
repositoryObjectType = RepositoryObjectType.JOB;
}
repositoryObject.setObjectType(repositoryObjectType);
repositoryElementInterfaces.add(repositoryObject);
}
}
return repositoryElementInterfaces;
}
Aggregations