use of org.codehaus.enunciate.Facet in project data-access by pentaho.
the class DatabaseDialectService method getDatabaseDialectsWS.
/**
* Get a list of the database dialects
*
* @return IDatabaseDialectList containing the database dialects
*/
@GET
@Path("/getDatabaseDialects")
@Produces({ APPLICATION_JSON })
@Facet(name = "Unsupported")
public IDatabaseDialectList getDatabaseDialectsWS() {
IDatabaseDialectList value = new DefaultDatabaseDialectList();
value.setDialects(super.getDatabaseDialects());
return value;
}
use of org.codehaus.enunciate.Facet in project pentaho-platform by pentaho.
the class UserRoleDaoResource method assignAllUsersToRole.
/**
* Associates all user to a particular role
*
* @param tenantPath (tenant path where the user exist, null of empty string assumes default tenant)
* @param roleName (role name)
* @return
*/
@PUT
@Path("/assignAllUsersToRole")
@Consumes({ MediaType.WILDCARD })
@Facet(name = "Unsupported")
public Response assignAllUsersToRole(@QueryParam("tenant") String tenantPath, @QueryParam("roleName") String roleName) {
IUserRoleDao roleDao = getUserRoleDao();
Set<String> assignedUserNames = new HashSet<String>();
for (IPentahoUser pentahoUser : roleDao.getUsers(getTenant(tenantPath))) {
assignedUserNames.add(pentahoUser.getUsername());
}
roleDao.setRoleMembers(getTenant(tenantPath), roleName, assignedUserNames.toArray(new String[0]));
if (assignedUserNames.contains(getSession().getName())) {
updateRolesForCurrentSession();
}
return Response.ok().build();
}
use of org.codehaus.enunciate.Facet in project pentaho-platform by pentaho.
the class FileResource method doIsParameterizable.
/**
* Determines whether a selected file supports parameters or not
*
* @param pathId Colon separated path for the repository file.
*
* @return ("true" or "false")
* @throws FileNotFoundException
*/
@GET
@Path("{pathId : .+}/parameterizable")
@Produces(MediaType.TEXT_PLAIN)
@Facet(name = "Unsupported")
@StatusCodes({ @ResponseCode(code = 200, condition = "Successfully get the file or directory."), @ResponseCode(code = 404, condition = "Failed to find the file or resource.") })
public // have to accept anything for browsers to work
String doIsParameterizable(@PathParam("pathId") String pathId) throws FileNotFoundException {
boolean hasParameterUi = false;
RepositoryFile repositoryFile = getRepository().getFile(fileService.idToPath(pathId));
if (repositoryFile != null) {
try {
hasParameterUi = hasParameterUi(repositoryFile);
} catch (NoSuchBeanDefinitionException e) {
// Do nothing.
}
}
boolean hasParameters = false;
if (hasParameterUi) {
try {
IContentGenerator parameterContentGenerator = getContentGenerator(repositoryFile);
if (parameterContentGenerator != null) {
ByteArrayOutputStream outputStream = getByteArrayOutputStream();
parameterContentGenerator.setOutputHandler(new SimpleOutputHandler(outputStream, false));
parameterContentGenerator.setMessagesList(new ArrayList<String>());
Map<String, IParameterProvider> parameterProviders = new HashMap<String, IParameterProvider>();
SimpleParameterProvider parameterProvider = getSimpleParameterProvider();
parameterProvider.setParameter("path", encode(repositoryFile.getPath()));
parameterProvider.setParameter("renderMode", "PARAMETER");
parameterProviders.put(IParameterProvider.SCOPE_REQUEST, parameterProvider);
parameterContentGenerator.setParameterProviders(parameterProviders);
parameterContentGenerator.setSession(getSession());
parameterContentGenerator.createContent();
if (outputStream.size() > 0) {
Document document = parseText(outputStream.toString());
// exclude all parameters that are of type "system", xactions set system params that have to be ignored.
@SuppressWarnings("rawtypes") List nodes = document.selectNodes("parameters/parameter");
for (int i = 0; i < nodes.size() && !hasParameters; i++) {
Element elem = (Element) nodes.get(i);
if (elem.attributeValue("name").equalsIgnoreCase("output-target") && elem.attributeValue("is-mandatory").equalsIgnoreCase("true")) {
hasParameters = true;
continue;
}
Element attrib = (Element) elem.selectSingleNode("attribute[@namespace='http://reporting.pentaho" + ".org/namespaces/engine/parameter-attributes/core' and @name='role']");
if (attrib == null || !"system".equals(attrib.attributeValue("value"))) {
hasParameters = true;
}
}
}
}
} catch (Exception e) {
logger.error(getMessagesInstance().getString("FileResource.PARAM_FAILURE", e.getMessage()), e);
}
}
return Boolean.toString(hasParameters);
}
use of org.codehaus.enunciate.Facet in project pentaho-platform by pentaho.
the class PluginResource method readFile.
/**
* Retrieve the file from the selected plugin. This file is a static file (i.e javascript, html, css etc)
*
* @param pluginId (Plugin ID of the selected Plugin)
* @param path (Path of the file being retrieved. This is a colon separated path to the plugin file. This
* is usually a static file like a javascript, image or html
* @return
* @throws IOException
*/
@GET
@Path("/files/{path : .+}")
@Produces(WILDCARD)
@Facet(name = "Unsupported")
public Response readFile(@PathParam("pluginId") String pluginId, @PathParam("path") String path) throws IOException {
List<String> pluginRestPerspectives = pluginManager.getPluginRESTPerspectivesForId(pluginId);
// $NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
boolean useCache = "true".equals(pluginManager.getPluginSetting(pluginId, "settings/cache", "false"));
// $NON-NLS-1$
String maxAge = (String) pluginManager.getPluginSetting(pluginId, "settings/max-age", null);
// /scheduler)
if (!pluginRestPerspectives.contains(path) && maxAge != null && !"0".equals(maxAge)) {
// $NON-NLS-1$
// $NON-NLS-1$ //$NON-NLS-2$
httpServletResponse.setHeader("Cache-Control", "max-age=" + maxAge);
}
if (!pluginManager.getRegisteredPlugins().contains(pluginId)) {
return Response.status(Status.NOT_FOUND).build();
}
if (!pluginManager.isPublic(pluginId, path)) {
return Response.status(Status.FORBIDDEN).build();
}
InputStream isTmp;
try {
isTmp = getCacheBackedStream(pluginId, path, useCache);
} catch (FileNotFoundException e) {
return Response.status(Status.NOT_FOUND).build();
} catch (IllegalArgumentException e) {
return Response.status(Status.BAD_REQUEST).build();
}
final InputStream is = isTmp;
StreamingOutput streamingOutput = new StreamingOutput() {
public void write(OutputStream output) throws IOException {
try {
IOUtils.copy(is, output);
} finally {
IOUtils.closeQuietly(is);
}
}
};
MediaType mediaType = MediaType.WILDCARD_TYPE;
String mimeType = MimeHelper.getMimeTypeFromFileName(path);
if (mimeType != null) {
try {
mediaType = MediaType.valueOf(mimeType);
} catch (IllegalArgumentException iae) {
// $NON-NLS-1$
logger.warn(MessageFormat.format("PluginFileResource.UNDETERMINED_MIME_TYPE", path));
}
}
return Response.ok(streamingOutput, mediaType).build();
}
use of org.codehaus.enunciate.Facet in project pentaho-platform by pentaho.
the class RepositoryPublishResource method writeFileWithEncodedNameWithOptions.
@POST
@Path("/fileWithOptions")
@Consumes({ MediaType.MULTIPART_FORM_DATA })
@Produces(MediaType.TEXT_PLAIN)
@StatusCodes({ @ResponseCode(code = 200, condition = "Successfully publish the file."), @ResponseCode(code = 403, condition = "Failure to publish the file due to permissions."), @ResponseCode(code = 422, condition = "Failure to publish the file due to failed validation."), @ResponseCode(code = 500, condition = "Failure to publish the file due to a server error.") })
@Facet(name = "Unsupported")
public Response writeFileWithEncodedNameWithOptions(@FormDataParam("properties") String properties, @FormDataParam("importPath") String pathId, @FormDataParam("fileUpload") InputStream fileContents, @FormDataParam("fileUpload") FormDataContentDisposition fileInfo) {
try (ByteArrayInputStream bios = new ByteArrayInputStream(properties.getBytes())) {
Optional<Properties> fileProperties = Optional.of(new Properties());
fileProperties.get().loadFromXML(bios);
return writeFile(pathId, fileContents, fileInfo, fileProperties);
} catch (IOException e) {
logger.error(e);
return buildServerErrorResponse(PlatformImportException.PUBLISH_GENERAL_ERROR);
}
}
Aggregations