use of org.codehaus.enunciate.jaxrs.StatusCodes in project pentaho-kettle by pentaho.
the class PurgeResource method doDeleteRevisions.
/**
* Provides a utility for purging files and/or revision history for the DI server.
*
* <p>
* <b>Example Request:</b><br>
* POST /pur-repository-plugin/api/purge/path:to:file/purge
* </p>
*
* @param pathId
* Colon separated path for the repository file. Processing of files will occur under this path. Exception:
* If purgeSharedObject=true other files may be affected as well.
* @param purgeFiles
* If true, files will be purged completely. This options erases files and all history. This effectively
* disables all parameters effecting revisions since all revisions will be deleted unconditionally.
* @param purgeRevisions
* If true, all revisions to the targeted files will be purged. The current state of the file will be
* retained.
* @param purgeSharedObjects
* If true, Shared objects will also be targeted by the purge operation. This does not replace the pathId and
* fileFilter processing, but rather, is in addition to that processing. If it is desired to purge shared
* objects only without effecting other files, then set the pathId to a single space character. Some examples
* of shared objects database connections, Slave Servers, Cluster Schemas, and partition Schemas.
* @param versionCount
* If present, the number of historical revisions to keep. If there are more revisions for a file than
* versionCount, the older ones will be removed.
* @param purgeBeforeDate
* If set, remove all version history created prior to this date.
* @param fileFilter
* The file filter to be applied when determining what files are affected by the purge. This filter is used
* by the <code>tree</code> endpoint to determine what files to return. The fileFilter is a list of allowed
* names of files separated by the pipe (|) character. Each file name in the filter may be a full name or a
* partial name with one or more wildcard characters ("*"). (eg: *.ktr|*.kjb returns all files with a ktr or
* kjb extension).
* @param logLevelName
* The standard name for the log level (ie: INFO, DEBUG)
* @return A text file containing a log of the service execution.
*/
@POST
@Path("{pathId : .+}/purge")
@StatusCodes({ @ResponseCode(code = 200, condition = "Successfully purged specified target"), @ResponseCode(code = 500, condition = "Something failed when attempting to purge "), @ResponseCode(code = 404, condition = "Invalid path") })
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces({ WILDCARD })
public Response doDeleteRevisions(@PathParam("pathId") String pathId, @DefaultValue("false") @FormDataParam("purgeFiles") boolean purgeFiles, @DefaultValue("false") @FormDataParam("purgeRevisions") boolean purgeRevisions, @DefaultValue("false") @FormDataParam("purgeSharedObjects") boolean purgeSharedObjects, @DefaultValue("-1") @FormDataParam("versionCount") int versionCount, @FormDataParam("purgeBeforeDate") Date purgeBeforeDate, @DefaultValue("*") @FormDataParam("fileFilter") String fileFilter, @DefaultValue("INFO") @FormDataParam("logLevel") String logLevelName) {
// A version count of 0 is illegal.
if (versionCount == 0) {
return Response.serverError().build();
}
if (purgeRevisions && (versionCount > 0 || purgeBeforeDate != null)) {
purgeRevisions = false;
}
IPurgeService purgeService = new UnifiedRepositoryPurgeService(this.repository);
Level logLevel = Level.toLevel(logLevelName);
PurgeUtilitySpecification purgeSpecification = new PurgeUtilitySpecification();
purgeSpecification.setPath(idToPath(pathId));
purgeSpecification.setPurgeFiles(purgeFiles);
purgeSpecification.setPurgeRevisions(purgeRevisions);
purgeSpecification.setSharedObjects(purgeSharedObjects);
purgeSpecification.setVersionCount(versionCount);
purgeSpecification.setBeforeDate(purgeBeforeDate);
purgeSpecification.setFileFilter(fileFilter);
purgeSpecification.setLogLevel(logLevel);
// Initialize the logger
ByteArrayOutputStream purgeUtilityStream = new ByteArrayOutputStream();
PurgeUtilityLogger.createNewInstance(purgeUtilityStream, purgeSpecification.getPath(), logLevel);
try {
purgeService.doDeleteRevisions(purgeSpecification);
} catch (Exception e) {
PurgeUtilityLogger.getPurgeUtilityLogger().error(e);
return Response.ok(encodeOutput(purgeUtilityStream), MediaType.TEXT_HTML).build();
}
return Response.ok(encodeOutput(purgeUtilityStream), MediaType.TEXT_HTML).build();
}
use of org.codehaus.enunciate.jaxrs.StatusCodes in project pentaho-metaverse by pentaho.
the class AnalyzerInfoService method getSupportedJobEntries.
/**
* Gets a list of all implementations of {@link JobEntryInterface} with a custom {@link IJobEntryAnalyzer}
* that produces lineage. Any step not found in this list will fall back to using
* {@link org.pentaho.metaverse.analyzer.kettle.jobentry.GenericJobEntryMetaAnalyzer}.
*
* <p><b>Example Request:</b><br />
* GET pentaho-di/osgi/cxf/lineage/info/entries
* </p>
*
* @return List of {@link AnalyzerInfo}
*
* <p><b>Example Response:</b></p>
* <pre function="syntax.js">
* [ { meta: "JobEntryTrans" } ]
* </pre>
*/
@GET
@Path("/entries")
@Produces({ MediaType.APPLICATION_JSON })
@StatusCodes({ @ResponseCode(code = OK, condition = "Successfully listed the supported job entries"), @ResponseCode(code = SERVER_ERROR, condition = "Server Error.") })
public Response getSupportedJobEntries() {
List<AnalyzerInfo> analyzers = new ArrayList<>();
for (IJobEntryAnalyzer analyzer : getJobEntryAnalyzerProvider().getAnalyzers()) {
Set<Class<? extends JobEntryInterface>> supportedEntries = analyzer.getSupportedEntries();
for (Class<? extends JobEntryInterface> supportedEntry : supportedEntries) {
AnalyzerInfo info = new AnalyzerInfo(supportedEntry.getSimpleName());
analyzers.add(info);
}
}
Collections.sort(analyzers, new AnalyzerInfoComparator());
return Response.ok(analyzers).build();
}
use of org.codehaus.enunciate.jaxrs.StatusCodes in project pentaho-metaverse by pentaho.
the class AnalyzerInfoService method getSupportedSteps.
/**
* Gets a list of all implementations of {@link BaseStepMeta} with a custom {@link IStepAnalyzer}
* that produces lineage. Any step not found in this list will fall back to using
* {@link org.pentaho.metaverse.analyzer.kettle.step.GenericStepMetaAnalyzer}.
*
* <p><b>Example Request:</b><br />
* GET pentaho-di/osgi/cxf/lineage/info/steps
* </p>
*
* @return List of {@link AnalyzerInfo}
*
* <p><b>Example Response:</b></p>
* <pre function="syntax.js">
* [ { meta: "CalculatorMeta" }, { meta: "CsvInputMeta" }, { meta: "ExcelInputMeta" } ]
* </pre>
*/
@GET
@Path("/steps")
@Produces({ MediaType.APPLICATION_JSON })
@StatusCodes({ @ResponseCode(code = OK, condition = "Successfully listed the supported steps"), @ResponseCode(code = SERVER_ERROR, condition = "Server Error.") })
public Response getSupportedSteps() {
List<AnalyzerInfo> analyzers = new ArrayList<>();
for (IStepAnalyzer analyzer : getStepAnalyzerProvider().getAnalyzers()) {
Set<Class<? extends BaseStepMeta>> supportedSteps = analyzer.getSupportedSteps();
for (Class<? extends BaseStepMeta> supportedStep : supportedSteps) {
AnalyzerInfo info = new AnalyzerInfo(supportedStep.getSimpleName());
analyzers.add(info);
}
}
Collections.sort(analyzers, new AnalyzerInfoComparator());
return Response.ok(analyzers).build();
}
use of org.codehaus.enunciate.jaxrs.StatusCodes in project pentaho-platform by pentaho.
the class UserRoleDaoResource method deleteRoles.
/**
* Delete role(s) from the platform. This endpoint is only available to users with administrative privileges.
*
* <p><b>Example Request:</b><br />
* PUT pentaho/api/userroledao/deleteRoles?roleNames=role1%09
* </p>
*
* @param roleNames List of tab (\t) separated role names, must be valid roles.
* @return Response containing the result of the operation.
*/
@PUT
@Path("/deleteRoles")
@Consumes({ MediaType.WILDCARD })
@StatusCodes({ @ResponseCode(code = 200, condition = "Successfully deleted the list of roles."), @ResponseCode(code = 403, condition = "Only users with administrative privileges can access this method."), @ResponseCode(code = 500, condition = "The system was unable to delete the roles passed in.") })
public Response deleteRoles(@QueryParam("roleNames") String roleNames) {
try {
userRoleDaoService.deleteRoles(roleNames);
updateRolesForCurrentSession();
return Response.ok().build();
} catch (SecurityException e) {
throw new WebApplicationException(Response.Status.FORBIDDEN);
} catch (UncategorizedUserRoleDaoException e) {
throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
}
}
use of org.codehaus.enunciate.jaxrs.StatusCodes 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));
}
Aggregations