Search in sources :

Example 31 with Facet

use of org.codehaus.enunciate.Facet in project pentaho-platform by pentaho.

the class RepositoryPublishResource method writeFileWithEncodedName.

/**
 * Publishes the file to the provided path in the repository. The file will be overwritten if {@code overwriteFile}
 * is {@code true}.
 *
 * This method should be used instead of
 * {@linkplain #writeFile(String, InputStream, Boolean, FormDataContentDisposition)}. Contrary to
 * {@linkplain FileResource} convention, it expects {@code pathId} <b>not</b> to be separated by colons, but to be
 * simply encoded with {@linkplain java.net.URLEncoder}. Also it expects {@code pathId} to be a well-formatted
 * Unix-style path with no slash at the end.
 *
 * Examples of correct {@code pathId}:
 * <ul>
 *   <li><tt>%2Fpublic%2Fmyfile.txt</tt></li>
 *   <li><tt>%2Fpublic%2Fmyfile</tt></li>
 *   <li><tt>%2Fpublic%2Fmyfile</tt></li>
 *   <li><tt>%2Fpublic%2Fmyfile%22quoted%22</tt></li>
 * </ul>
 *
 * @param pathId        slash-separated path for the repository file
 * @param fileContents  input stream containing the data
 * @param overwriteFile flag to determine whether to overwrite the existing file in the repository or not
 * @param fileInfo      file information (Currently not being used).
 *
 * @return A jax-rs Response object with the appropriate status code, header, and body.
 */
@POST
@Path("/file")
@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 writeFileWithEncodedName(@FormDataParam("importPath") String pathId, @FormDataParam("fileUpload") InputStream fileContents, @FormDataParam("overwriteFile") Boolean overwriteFile, @FormDataParam("fileUpload") FormDataContentDisposition fileInfo) {
    Optional<Properties> fileProperties = Optional.of(new Properties());
    fileProperties.get().setProperty("overwriteFile", String.valueOf(overwriteFile));
    return writeFile(pathId, fileContents, fileInfo, fileProperties);
}
Also used : Properties(java.util.Properties) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) StatusCodes(org.codehaus.enunciate.jaxrs.StatusCodes) Facet(org.codehaus.enunciate.Facet)

Example 32 with Facet

use of org.codehaus.enunciate.Facet in project pentaho-platform by pentaho.

the class RepositoryResource method getExecutableTypes.

/**
 * Retrieves the list of supported content type in the platform
 *
 * @return list of <code> ExecutableFileTypeDto </code>
 */
@Path("/executableTypes")
@GET
@Produces({ APPLICATION_XML, APPLICATION_JSON })
@Facet(name = "Unsupported")
public Response getExecutableTypes() {
    ArrayList<ExecutableFileTypeDto> executableTypes = new ArrayList<ExecutableFileTypeDto>();
    for (String contentType : pluginManager.getContentTypes()) {
        IContentInfo contentInfo = pluginManager.getContentTypeInfo(contentType);
        ExecutableFileTypeDto executableFileType = new ExecutableFileTypeDto();
        executableFileType.setDescription(contentInfo.getDescription());
        executableFileType.setExtension(contentInfo.getExtension());
        executableFileType.setTitle(contentInfo.getTitle());
        executableFileType.setCanSchedule(hasOperationId(contentInfo.getOperations(), "SCHEDULE_NEW"));
        executableFileType.setCanEdit(hasOperationId(contentInfo.getOperations(), "EDIT"));
        executableTypes.add(executableFileType);
    }
    final GenericEntity<List<ExecutableFileTypeDto>> entity = new GenericEntity<List<ExecutableFileTypeDto>>(executableTypes) {
    };
    return Response.ok(entity).build();
}
Also used : IContentInfo(org.pentaho.platform.api.engine.IContentInfo) GenericEntity(javax.ws.rs.core.GenericEntity) ExecutableFileTypeDto(org.pentaho.platform.repository2.unified.webservices.ExecutableFileTypeDto) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Facet(org.codehaus.enunciate.Facet)

Example 33 with Facet

use of org.codehaus.enunciate.Facet in project pentaho-platform by pentaho.

the class RootResource method doGetDocs.

@GET
@Path("docs")
@Facet(name = "Unsupported")
public Response doGetDocs() throws URISyntaxException {
    String fqurl = PentahoSystem.getApplicationContext().getFullyQualifiedServerURL();
    // $NON-NLS-1$
    URI uri = new URI(fqurl + "docs/InformationMap.jsp");
    return Response.temporaryRedirect(uri).build();
}
Also used : URI(java.net.URI) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET) Facet(org.codehaus.enunciate.Facet)

Example 34 with Facet

use of org.codehaus.enunciate.Facet in project pentaho-platform by pentaho.

the class SessionResource method setredirect.

@GET
@Path("/setredirect")
@Produces(TEXT_PLAIN)
@Facet(name = "Unsupported")
public Response setredirect() {
    IPentahoSession pentahoSession = PentahoSessionHolder.getSession();
    pentahoSession.setAttribute("redirect", true);
    return Response.ok().type(MediaType.TEXT_PLAIN).build();
}
Also used : IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Facet(org.codehaus.enunciate.Facet)

Example 35 with Facet

use of org.codehaus.enunciate.Facet in project pentaho-platform by pentaho.

the class SystemRefreshResource method flushMondrianSchemaCache.

@GET
@Path("/mondrianSingleSchemaCache")
@Produces({ MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON })
@Facet(name = "Unsupported")
public Response flushMondrianSchemaCache(@QueryParam("name") String name) {
    if (canAdminister()) {
        IPentahoSession pentahoSession = PentahoSessionHolder.getSession();
        if (canAdminister()) {
            IOlapService olapService = // $NON-NLS-1$
            PentahoSystem.get(IOlapService.class, "IOlapService", pentahoSession);
            olapService.flush(pentahoSession, name);
        }
        return Response.ok().type(MediaType.TEXT_PLAIN).build();
    } else {
        return Response.status(UNAUTHORIZED).build();
    }
}
Also used : IOlapService(org.pentaho.platform.plugin.action.olap.IOlapService) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Facet(org.codehaus.enunciate.Facet)

Aggregations

Facet (org.codehaus.enunciate.Facet)48 Path (javax.ws.rs.Path)43 Produces (javax.ws.rs.Produces)33 GET (javax.ws.rs.GET)29 ArrayList (java.util.ArrayList)12 Consumes (javax.ws.rs.Consumes)12 POST (javax.ws.rs.POST)8 PentahoAccessControlException (org.pentaho.platform.api.engine.PentahoAccessControlException)8 PUT (javax.ws.rs.PUT)7 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)6 IUserRoleDao (org.pentaho.platform.api.engine.security.userroledao.IUserRoleDao)6 Response (javax.ws.rs.core.Response)5 IDatabaseConnection (org.pentaho.database.model.IDatabaseConnection)5 HashSet (java.util.HashSet)4 StringTokenizer (java.util.StringTokenizer)4 StatusCodes (org.codehaus.enunciate.jaxrs.StatusCodes)4 IPluginManager (org.pentaho.platform.api.engine.IPluginManager)4 IMondrianCatalogService (org.pentaho.platform.plugin.action.mondrian.catalog.IMondrianCatalogService)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 IOException (java.io.IOException)3