use of org.pentaho.platform.api.repository2.unified.IRepositoryVersionManager in project pentaho-platform by pentaho.
the class DefaultRepositoryVersioningManagerTest method testPartialTrue.
/*
* Test a file set to versioningEnable=True, versionCommentsEnabled=false with various combinations
* of the master switch.
*/
@Test
public void testPartialTrue() {
IRepositoryVersionManager repositoryVersionManager = defaultRepositoryVersionManagerFullTrue;
assertTrue(repositoryVersionManager.isVersioningEnabled(PART_VERSIONING_PATH));
assertFalse(repositoryVersionManager.isVersionCommentEnabled(PART_VERSIONING_PATH));
repositoryVersionManager = defaultRepositoryVersionManagerPartialTrue;
assertTrue(repositoryVersionManager.isVersioningEnabled(PART_VERSIONING_PATH));
assertFalse(repositoryVersionManager.isVersionCommentEnabled(PART_VERSIONING_PATH));
repositoryVersionManager = defaultRepositoryVersionManagerFalse;
assertFalse(repositoryVersionManager.isVersioningEnabled(PART_VERSIONING_PATH));
assertFalse(repositoryVersionManager.isVersionCommentEnabled(PART_VERSIONING_PATH));
}
use of org.pentaho.platform.api.repository2.unified.IRepositoryVersionManager in project pentaho-platform by pentaho.
the class FileResource method doVersioningConfiguration.
/**
* This method is used to determine whether versioning should be active for the given path
*
* <p><b>Example Request:</b><br />
* GET pentaho/api/repo/files/:jmeter-test:test_file_1.ktr/versioningConfiguration
* </pre>
* </p>
*
* @param pathId Colon separated path for the repository file.
*
* @return The Versioning Configuration applicable to the path submitted
*
* <p><b>Example Response:</b></p>
* <pre function="syntax.xml">
* <fileVersioningConfiguration>
* <versionCommentEnabled>true</versionCommentEnabled>
* <versioningEnabled>true</versioningEnabled>
* </fileVersioningConfiguration>
* </pre>
*/
@GET
@Path("{pathId : .+}/versioningConfiguration")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@StatusCodes({ @ResponseCode(code = 200, condition = "Successfully returns the versioning configuration") })
public FileVersioningConfiguration doVersioningConfiguration(@PathParam("pathId") String pathId) {
IRepositoryVersionManager repositoryVersionManager = PentahoSystem.get(IRepositoryVersionManager.class);
String path = FileUtils.idToPath(pathId);
return new FileVersioningConfiguration(repositoryVersionManager.isVersioningEnabled(path), repositoryVersionManager.isVersionCommentEnabled(path));
}
use of org.pentaho.platform.api.repository2.unified.IRepositoryVersionManager in project pentaho-platform by pentaho.
the class RepositoryFileAdapter method toFileDto.
public static RepositoryFileDto toFileDto(final RepositoryFile v, Set<String> memberSet, boolean exclude, boolean includeAcls) {
if (v == null) {
return null;
}
RepositoryFileDto f = new RepositoryFileDto();
// no longer exists, so it returns null
try {
if (include("name", memberSet, exclude)) {
f.name = v.getName();
}
if (include("path", memberSet, exclude)) {
f.path = v.getPath();
}
if (include("hidden", memberSet, exclude)) {
f.hidden = v.isHidden();
}
if (include("aclNode", memberSet, exclude)) {
f.aclNode = v.isAclNode();
}
if (include("createDate", memberSet, exclude)) {
f.createdDate = v.getCreatedDate();
}
if (include("creatorId", memberSet, exclude)) {
f.creatorId = v.getCreatorId();
}
if (include("fileSize", memberSet, exclude)) {
f.fileSize = v.getFileSize();
}
if (include("description", memberSet, exclude)) {
f.description = v.getDescription();
}
if (include("folder", memberSet, exclude)) {
f.folder = v.isFolder();
}
// it must be present or the tree rest service call will error
if (v.getId() != null) {
f.id = v.getId().toString();
}
if (include("lastModifiedDate", memberSet, exclude)) {
f.lastModifiedDate = v.getLastModifiedDate();
}
if (include("locale", memberSet, exclude)) {
f.locale = v.getLocale();
}
if (include("originalParentFolderPath", memberSet, exclude)) {
f.originalParentFolderPath = v.getOriginalParentFolderPath();
}
if (include("deletedDate", memberSet, exclude)) {
f.deletedDate = v.getDeletedDate();
}
if (include("lockDate", memberSet, exclude)) {
f.lockDate = v.getLockDate();
}
if (include("locked", memberSet, exclude)) {
f.locked = v.isLocked();
}
if (include("lockMessage", memberSet, exclude)) {
f.lockMessage = v.getLockMessage();
}
if (include("lockOwner", memberSet, exclude)) {
f.lockOwner = v.getLockOwner();
}
if (include("title", memberSet, exclude)) {
f.title = v.getTitle();
}
if (include("versioned", memberSet, exclude)) {
f.versioned = v.isVersioned();
}
if (include("versionId", memberSet, exclude)) {
if (v.getVersionId() != null) {
f.versionId = v.getVersionId().toString();
}
}
} catch (NullPointerException e) {
getLogger().warn("NullPointerException while reading file attributes, returning null. Probable cause: File does not" + "exist anymore: ");
return null;
}
if (includeAcls) {
if (v.getId() != null) {
try {
f.repositoryFileAclDto = getRepoWs().getAcl(v.getId().toString());
if (f.repositoryFileAclDto.isEntriesInheriting()) {
List<RepositoryFileAclAceDto> aces = getRepoWs().getEffectiveAces(v.getId().toString());
f.repositoryFileAclDto.setAces(aces, f.repositoryFileAclDto.isEntriesInheriting());
}
} catch (Exception e) {
e.printStackTrace();
}
}
if (include("owner", memberSet, exclude)) {
Serializable id = v.getId();
if (id != null) {
RepositoryFileAclDto acl = getRepoWs().getAcl("" + id);
if (acl != null) {
f.owner = acl.getOwner();
}
}
}
}
if (include("locales", memberSet, exclude)) {
if (v.getLocalePropertiesMap() != null) {
f.localePropertiesMapEntries = new ArrayList<LocaleMapDto>();
for (Map.Entry<String, Properties> entry : v.getLocalePropertiesMap().entrySet()) {
LocaleMapDto localeMapDto = new LocaleMapDto();
List<StringKeyStringValueDto> valuesDto = new ArrayList<StringKeyStringValueDto>();
Properties properties = entry.getValue();
if (properties != null) {
for (String propertyName : properties.stringPropertyNames()) {
valuesDto.add(new StringKeyStringValueDto(propertyName, properties.getProperty(propertyName)));
}
}
localeMapDto.setLocale(entry.getKey());
localeMapDto.setProperties(valuesDto);
f.localePropertiesMapEntries.add(localeMapDto);
}
}
}
IRepositoryVersionManager repositoryVersionManager;
try {
repositoryVersionManager = JcrRepositoryFileUtils.getRepositoryVersionManager();
// Not found, must be in Spoon
if (repositoryVersionManager == null) {
return f;
}
} catch (NoClassDefFoundError ex) {
// support tree and child calls.
return f;
}
if (include("versioningEnabled", memberSet, exclude)) {
f.setVersioningEnabled(repositoryVersionManager.isVersioningEnabled(v.getPath()));
}
if (include("versionCommentEnabled", memberSet, exclude)) {
f.setVersionCommentEnabled(repositoryVersionManager.isVersionCommentEnabled(v.getPath()));
}
return f;
}
use of org.pentaho.platform.api.repository2.unified.IRepositoryVersionManager in project pentaho-platform by pentaho.
the class DefaultUnifiedRepositoryAuthorizationIT method setup.
@Before
public void setup() {
IRepositoryVersionManager mockRepositoryVersionManager = mock(IRepositoryVersionManager.class);
when(mockRepositoryVersionManager.isVersioningEnabled(anyString())).thenReturn(true);
when(mockRepositoryVersionManager.isVersionCommentEnabled(anyString())).thenReturn(false);
JcrRepositoryFileUtils.setRepositoryVersionManager(mockRepositoryVersionManager);
}
use of org.pentaho.platform.api.repository2.unified.IRepositoryVersionManager in project pentaho-platform by pentaho.
the class JcrRepositoryFileDaoIT method beforeTest.
@Before
public void beforeTest() {
IRepositoryVersionManager mockRepositoryVersionManager = mock(IRepositoryVersionManager.class);
when(mockRepositoryVersionManager.isVersioningEnabled(anyString())).thenReturn(true);
when(mockRepositoryVersionManager.isVersionCommentEnabled(anyString())).thenReturn(false);
JcrRepositoryFileUtils.setRepositoryVersionManager(mockRepositoryVersionManager);
}
Aggregations