use of org.pentaho.platform.api.repository2.unified.IRepositoryFileData in project pentaho-platform by pentaho.
the class MockUnifiedRepository method updateFile.
@Override
public RepositoryFile updateFile(final RepositoryFile file, final IRepositoryFileData data, final String versionMessage) {
Validate.isTrue(!file.isFolder());
if (!hasAccess(file.getId(), EnumSet.of(WRITE))) {
throw new AccessDeniedException("access denied");
}
FileRecord fileRecord = idManager.getFileById(file.getId());
fileRecord.setFile(new RepositoryFile.Builder(file).title(findTitle(file)).description(findDesc(file)).build());
IRepositoryFileData oldData = fileRecord.getData();
fileRecord.setData(data);
process(fileRecord, oldData);
if (file.isVersioned()) {
versionManager.createVersion(fileRecord.getFile().getId(), currentUserProvider.getUser(), versionMessage, new Date());
}
return fileRecord.getFile();
}
use of org.pentaho.platform.api.repository2.unified.IRepositoryFileData in project pentaho-platform by pentaho.
the class MockUnifiedRepository method createFile.
@Override
public RepositoryFile createFile(final Serializable parentFolderId, final RepositoryFile file, final IRepositoryFileData data, final RepositoryFileAcl acl, final String versionMessage) {
Validate.isTrue(!file.isFolder());
if (!hasAccess(parentFolderId, EnumSet.of(WRITE))) {
throw new AccessDeniedException("access denied");
}
FileRecord parentFolder = idManager.getFileById(parentFolderId);
RepositoryFile fileFromRepo = new RepositoryFile.Builder(file).path(parentFolder.getPath() + RepositoryFile.SEPARATOR + file.getName()).title(findTitle(file)).description(findDesc(file)).build();
RepositoryFileAcl aclFromRepo = new RepositoryFileAcl.Builder(acl).build();
FileRecord fileRecord = new FileRecord(fileFromRepo, data, aclFromRepo, new HashMap<String, Serializable>());
idManager.register(fileRecord);
process(fileRecord, null);
parentFolder.addChild(fileRecord);
if (file.isVersioned()) {
versionManager.createVersion(fileRecord.getFile().getId(), currentUserProvider.getUser(), versionMessage, new Date());
}
return fileRecord.getFile();
}
Aggregations