Example usage for javax.servlet.http HttpServletResponse SC_NO_CONTENT

List of usage examples for javax.servlet.http HttpServletResponse SC_NO_CONTENT

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletResponse SC_NO_CONTENT.

Prototype

int SC_NO_CONTENT

To view the source code for javax.servlet.http HttpServletResponse SC_NO_CONTENT.

Click Source Link

Document

Status code (204) indicating that the request succeeded but that there was no new information to return.

Usage

From source file:org.opencastproject.archive.base.endpoint.ArchiveRestEndpointBase.java

@POST
@Path("add")
@RestQuery(name = "add", description = "Adds a mediapackage to the episode service.", restParameters = {
        @RestParameter(name = "mediapackage", isRequired = true, type = RestParameter.Type.TEXT, defaultValue = "${this.sampleMediaPackage}", description = "The media package to add to the search index.") }, reponses = {
                @RestResponse(description = "The mediapackage was added, no content to return.", responseCode = HttpServletResponse.SC_NO_CONTENT),
                @RestResponse(description = "There has been an internal error and the mediapackage could not be added", responseCode = HttpServletResponse.SC_INTERNAL_SERVER_ERROR) }, returnDescription = "No content is returned.")
public Response add(@FormParam("mediapackage") final MediaPackageImpl mediaPackage) {
    return handleException(new Function0<Response>() {
        @Override/*from www  .j  a v a  2  s.  c  om*/
        public Response apply() {
            getArchive().add(mediaPackage);
            return noContent();
        }
    });
}

From source file:org.opencastproject.episode.endpoint.EpisodeRestService.java

@DELETE
@Path("delete/{id}")
@RestQuery(name = "remove", description = "Remove an episode from the archive.", pathParameters = {
        @RestParameter(name = "id", isRequired = true, type = RestParameter.Type.STRING, description = "The media package ID to remove from the archive.") }, reponses = {
                @RestResponse(description = "The mediapackage was removed, no content to return.", responseCode = HttpServletResponse.SC_NO_CONTENT),
                @RestResponse(description = "There has been an internal error and the mediapackage could not be deleted", responseCode = HttpServletResponse.SC_INTERNAL_SERVER_ERROR) }, returnDescription = "No content is returned.")
public Response delete(@PathParam("id") String mediaPackageId)
        throws EpisodeServiceException, NotFoundException {
    try {/*from www .  jav a  2 s  .com*/
        if (mediaPackageId != null && episodeService.delete(mediaPackageId))
            return Response.noContent().build();
        else
            throw new NotFoundException();
    } catch (Exception e) {
        throw new WebApplicationException(e, Response.Status.BAD_REQUEST);
    }
}

From source file:com.sun.faban.harness.webclient.CLIServlet.java

private void sendPending(HttpServletResponse response) throws IOException {
    String[] pending = RunQ.listPending();
    if (pending == null) {
        response.sendError(HttpServletResponse.SC_NO_CONTENT, "No pending runs");
    } else {// www.  j  a v  a  2 s .c  o m
        Writer w = response.getWriter();
        for (int i = 0; i < pending.length; i++)
            w.write(pending[i] + '\n');
        w.flush();
        w.close();
    }
}

From source file:org.brekka.paveway.web.servlet.UploadServlet.java

@Override
protected void doDelete(final HttpServletRequest req, final HttpServletResponse resp)
        throws ServletException, IOException {
    UploadingFilesContext filesContext = getFilesContext(req);
    String requestUri = req.getRequestURI();
    String fileName = StringUtils.substringAfterLast(requestUri, "/");
    fileName = URLDecoder.decode(fileName, "UTF-8");
    if (!filesContext.discard(fileName)) {
        resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
        return;//from   w w w  .ja  v  a2 s.c  o  m
    }
    resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
}

From source file:com.sap.dirigible.runtime.registry.RegistryServlet.java

@Override
protected void doGet(final HttpServletRequest request, final HttpServletResponse response)
        throws ServletException, IOException {

    String repositoryPath = null;
    final String requestPath = request.getPathInfo();
    boolean deep = false;
    if (requestPath == null) {
        deep = true;/*from   w ww . ja v a 2 s.co m*/
    }
    final OutputStream out = response.getOutputStream();
    try {
        repositoryPath = extractRepositoryPath(request);
        final IEntity entity = getEntity(repositoryPath, request);
        byte[] data;
        if (entity != null) {
            if (entity instanceof IResource) {
                data = buildResourceData(entity, request, response);
            } else if (entity instanceof ICollection) {
                String collectionPath = request.getRequestURI().toString();
                String acceptHeader = request.getHeader(ACCEPT_HEADER);
                if (acceptHeader != null && acceptHeader.contains(JSON)) {
                    if (!collectionPath.endsWith(IRepository.SEPARATOR)) {
                        collectionPath += IRepository.SEPARATOR;
                    }
                    data = buildCollectionData(deep, entity, collectionPath);
                } else {
                    // welcome file support
                    IResource index = ((ICollection) entity).getResource(INDEX_HTML);
                    if (index.exists() && (collectionPath.endsWith(IRepository.SEPARATOR))) {
                        data = buildResourceData(index, request, response);
                    } else {
                        // listing of collections is forbidden
                        exceptionHandler(response, repositoryPath, HttpServletResponse.SC_FORBIDDEN,
                                LISTING_OF_FOLDERS_IS_FORBIDDEN);
                        return;
                    }
                }
            } else {
                exceptionHandler(response, repositoryPath, HttpServletResponse.SC_FORBIDDEN,
                        LISTING_OF_FOLDERS_IS_FORBIDDEN);
                return;
            }
        } else {
            exceptionHandler(response, repositoryPath, HttpServletResponse.SC_NOT_FOUND,
                    String.format("Resource at [%s] does not exist", requestPath));
            return;
        }

        if (entity instanceof IResource) {
            final IResource resource = (IResource) entity;
            String mimeType = null;
            String extension = ContentTypeHelper.getExtension(resource.getName());
            if ((mimeType = ContentTypeHelper.getContentType(extension)) != null) {
                response.setContentType(mimeType);
            } else {
                response.setContentType(resource.getContentType());
            }
        }
        sendData(out, data);
    } catch (final IllegalArgumentException ex) {
        exceptionHandler(response, repositoryPath, HttpServletResponse.SC_BAD_REQUEST, ex.getMessage());
    } catch (final MissingResourceException ex) {
        exceptionHandler(response, repositoryPath, HttpServletResponse.SC_NO_CONTENT, ex.getMessage());
    } catch (final RuntimeException ex) {
        exceptionHandler(response, repositoryPath, HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                ex.getMessage());
    } finally {
        out.flush();
        out.close();
    }
}

From source file:uk.co.caprica.bootlace.security.SecurityConfiguration.java

/**
 * Create a logout success handler.//from   ww w .  ja  v  a  2s  .c o  m
 * <p>
 * Simply return an appropriate response code instead of using the default handler that wants
 * to force a page redirect to "login?logout".
 *
 * @return logout success handler
 */
private LogoutSuccessHandler logoutSuccessHandler() {
    return new LogoutSuccessHandler() {
        @Override
        public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response,
                Authentication authentication) throws IOException, ServletException {
            response.sendError(HttpServletResponse.SC_NO_CONTENT);
        }
    };
}

From source file:com.fpmislata.banco.presentation.controladores.CuentaBancariaController.java

@RequestMapping(value = "/cuentabancaria/{idCuentaBancaria}", method = RequestMethod.DELETE, produces = "application/json")
public void delete(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse,
        @PathVariable("idCuentaBancaria") int idCuentaBancaria) {
    try {/*from   w  w w.  j  a va 2s  .co m*/
        boolean comprobar;
        comprobar = cuentaBancariaService.delete(idCuentaBancaria);
        if (comprobar == true) {
            httpServletResponse.setStatus(HttpServletResponse.SC_NO_CONTENT);
        } else {
            httpServletResponse.setStatus(HttpServletResponse.SC_BAD_REQUEST);
        }
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}

From source file:org.jasig.portal.rest.ImportExportController.java

/**
 * Delete an uPortal database object.  This method provides a REST interface
 * for uPortal database object deletion.
 * //www  .  j  a v a 2  s .c om
 * The path for this method is /entity/type/identifier.  The identifier generally
 * a string that may be used as a unique identifier, but is dependent on the 
 * entity type.  For example, to delete the "demo" user one might use the 
 * path /entity/user/demo.
 */
@RequestMapping(value = "/entity/{entityType}/{entityId}", method = RequestMethod.DELETE)
public void deleteEntity(@PathVariable("entityType") String entityType,
        @PathVariable("entityId") String entityId, HttpServletRequest request, HttpServletResponse response)
        throws IOException {

    final IPerson person = personManager.getPerson(request);
    final EntityIdentifier ei = person.getEntityIdentifier();
    final IAuthorizationPrincipal ap = AuthorizationService.instance().newPrincipal(ei.getKey(), ei.getType());

    if (!ap.hasPermission(OWNER, DELETE_PERMISSION, entityType)) {
        response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
        return;
    }

    // get the task associated with exporting this entity type 
    portalDataHandlerService.deleteData(entityType, entityId);

    response.setStatus(HttpServletResponse.SC_NO_CONTENT);
}

From source file:org.apereo.portal.rest.ImportExportController.java

/**
 * Delete an uPortal database object.  This method provides a REST interface
 * for uPortal database object deletion.
 * /*from   www  .j  a  va2  s .  c o m*/
 * The path for this method is /entity/type/identifier.  The identifier generally
 * a string that may be used as a unique identifier, but is dependent on the 
 * entity type.  For example, to delete the "demo" user one might use the 
 * path /entity/user/demo.
 */
@RequestMapping(value = "/entity/{entityType}/{entityId}", method = RequestMethod.DELETE)
public void deleteEntity(@PathVariable("entityType") String entityType,
        @PathVariable("entityId") String entityId, HttpServletRequest request, HttpServletResponse response)
        throws IOException {

    final IPerson person = personManager.getPerson(request);
    final EntityIdentifier ei = person.getEntityIdentifier();
    final IAuthorizationPrincipal ap = AuthorizationService.instance().newPrincipal(ei.getKey(), ei.getType());

    if (!ap.hasPermission(IPermission.PORTAL_SYSTEM, IPermission.DELETE_ACTIVITY, entityType)) {
        response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
        return;
    }

    // get the task associated with exporting this entity type 
    portalDataHandlerService.deleteData(entityType, entityId);

    response.setStatus(HttpServletResponse.SC_NO_CONTENT);
}