use of org.pentaho.di.repository.pur.PurObjectRevision in project pentaho-kettle by pentaho.
the class RevisionResourceTest method testDoGetVersions.
/**
* @throws Exception
*/
@org.junit.Test
public void testDoGetVersions() throws Exception {
Response response = revisionResource.doGetVersions(MOCK_FILE_PATH);
Object entity = response.getEntity();
// Yeah this gets weird: List, wrapped in a Response, wrapped in GenericEnttiy
List<PurObjectRevision> revisionList = (List<PurObjectRevision>) ((GenericEntity) entity).getEntity();
Assert.assertTrue(revisionList.size() == 1);
Assert.assertTrue(revisionList.get(0).getLogin().equals(MOCK_VERSION_AUTHOR_1));
}
use of org.pentaho.di.repository.pur.PurObjectRevision in project pentaho-kettle by pentaho.
the class RevisionResource method doGetVersions.
/**
* Retrieves the version history of a selected repository file
*
* <p>
* <b>Example Request:</b><br>
* GET /pur-repository-plugin/api/revision/path:to:file/revisions
* </p>
*
* @param pathId
* (colon separated path for the repository file)
*
* <pre function="syntax.xml">
* :path:to:file:id
* </pre>
* @return file revisions objects <code> purObjectRevisions </code>
*
* <pre function="syntax.xml">
* <purObjectRevisions>
* <revision>
* <versionId>1.0</versionId>
* <creationDate>2014-07-22T14:42:46.029-04:00</creationDate>
* <login>admin</login>
* <comment>JMeter test</comment>
* </revision>
* </purObjectRevisions>
* </pre>
*/
@GET
@Path("{pathId : .+}/revisions")
@StatusCodes({ @ResponseCode(code = 200, condition = "Successfully returns list of revisions"), @ResponseCode(code = 500, condition = "Something failed when attempting to retrieve revisions"), @ResponseCode(code = 404, condition = "Invalid path") })
@Produces({ APPLICATION_XML, APPLICATION_JSON })
public Response doGetVersions(@PathParam("pathId") String pathId) {
Serializable fileId = null;
List<ObjectRevision> originalRevisions = null;
RepositoryFile repositoryFile = repository.getFile(FileUtils.idToPath(pathId));
if (repositoryFile != null) {
fileId = repositoryFile.getId();
}
if (fileId != null) {
try {
originalRevisions = revisionService.getRevisions(new StringObjectId(fileId.toString()));
} catch (KettleException e) {
return Response.serverError().build();
}
List<PurObjectRevision> revisions = new ArrayList();
for (ObjectRevision revision : originalRevisions) {
revisions.add((PurObjectRevision) revision);
}
GenericEntity<List<PurObjectRevision>> genericRevisionsEntity = new GenericEntity<List<PurObjectRevision>>(revisions) {
};
return Response.ok(genericRevisionsEntity).build();
} else {
return Response.serverError().build();
}
}
Aggregations