use of org.pentaho.platform.api.repository2.unified.RepositoryFile in project pentaho-kettle by pentaho.
the class PurRepository method getClusterNames.
@Override
public String[] getClusterNames(boolean includeDeleted) throws KettleException {
try {
List<RepositoryFile> children = getAllFilesOfType(null, RepositoryObjectType.CLUSTER_SCHEMA, includeDeleted);
List<String> names = new ArrayList<String>();
for (RepositoryFile file : children) {
names.add(file.getTitle());
}
return names.toArray(new String[0]);
} catch (Exception e) {
throw new KettleException("Unable to get all cluster schema names", e);
}
}
use of org.pentaho.platform.api.repository2.unified.RepositoryFile in project pentaho-kettle by pentaho.
the class PurRepository method getDatabaseNames.
@Override
public String[] getDatabaseNames(boolean includeDeleted) throws KettleException {
try {
List<RepositoryFile> children = getAllFilesOfType(null, RepositoryObjectType.DATABASE, includeDeleted);
List<String> names = new ArrayList<String>(children.size());
for (RepositoryFile file : children) {
names.add(file.getTitle());
}
return names.toArray(new String[0]);
} catch (Exception e) {
throw new KettleException("Unable to get all database names", e);
}
}
use of org.pentaho.platform.api.repository2.unified.RepositoryFile in project pentaho-kettle by pentaho.
the class PurRepository method getDatabaseID.
@Override
public ObjectId getDatabaseID(final String name) throws KettleException {
try {
ObjectId objectId = getObjectId(name, null, RepositoryObjectType.DATABASE, false);
if (objectId == null) {
List<RepositoryFile> allDatabases = getAllFilesOfType(null, RepositoryObjectType.DATABASE, false);
String[] existingNames = new String[allDatabases.size()];
for (int i = 0; i < allDatabases.size(); i++) {
RepositoryFile file = allDatabases.get(i);
existingNames[i] = file.getTitle();
}
int index = DatabaseMeta.indexOfName(existingNames, name);
if (index != -1) {
return new StringObjectId(allDatabases.get(index).getId().toString());
}
}
return objectId;
} catch (Exception e) {
throw new KettleException("Unable to get ID for database [" + name + "]", e);
}
}
use of org.pentaho.platform.api.repository2.unified.RepositoryFile in project pentaho-kettle by pentaho.
the class PurRepository method loadJob.
@Override
public JobMeta loadJob(String jobname, RepositoryDirectoryInterface parentDir, ProgressMonitorListener monitor, String versionId) throws KettleException {
String absPath = null;
try {
absPath = getPath(jobname, parentDir, RepositoryObjectType.JOB);
if (absPath == null) {
// Couldn't resolve path, throw an exception
throw new KettleFileException(BaseMessages.getString(PKG, "PurRepository.ERROR_0003_JOB_NOT_FOUND", jobname));
}
RepositoryFile file = pur.getFile(absPath);
if (versionId != null) {
// need to go back to server to get versioned info
file = pur.getFileAtVersion(file.getId(), versionId);
}
NodeRepositoryFileData data = null;
ObjectRevision revision = null;
data = pur.getDataAtVersionForRead(file.getId(), versionId, NodeRepositoryFileData.class);
revision = getObjectRevision(new StringObjectId(file.getId().toString()), versionId);
JobMeta jobMeta = buildJobMeta(file, parentDir, data, revision);
ExtensionPointHandler.callExtensionPoint(log, KettleExtensionPoint.JobMetaLoaded.id, jobMeta);
return jobMeta;
} catch (Exception e) {
throw new KettleException("Unable to load job from path [" + absPath + "]", e);
}
}
use of org.pentaho.platform.api.repository2.unified.RepositoryFile in project pentaho-kettle by pentaho.
the class PurRepository method saveRepositoryDirectory.
@Override
public void saveRepositoryDirectory(final RepositoryDirectoryInterface dir) throws KettleException {
try {
// id of root dir is null--check for it
if ("/".equals(dir.getParent().getName())) {
throw new KettleException(BaseMessages.getString(PKG, "PurRepository.FailedDirectoryCreation.Message"));
}
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);
}
}
Aggregations