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:com.pymegest.applicationserver.api.FamiliaController.java

@RequestMapping(value = { "/Familia/{idsFamilias}" }, method = RequestMethod.DELETE)
public void delete(HttpServletRequest request, HttpServletResponse response,
        @PathVariable("idsFamilias") String idsFamiliasStr) {

    try {//w  w w . j  a va 2s .c o m
        String[] idsFamiliasArr = idsFamiliasStr.split(",");
        for (int i = 0; i < idsFamiliasArr.length; i++) {
            familiaDAO.delete(Integer.parseInt(idsFamiliasArr[i]));
        }

        response.setStatus(HttpServletResponse.SC_NO_CONTENT);

    } catch (Exception ex) {
        response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
        response.setContentType("text/plain; charset=UTF-8");
        try {

            ex.printStackTrace(response.getWriter());

        } catch (IOException ex1) {
        }
    }

}

From source file:com.pymegest.applicationserver.api.UsuarioController.java

@RequestMapping(value = { "/Usuario/{idsUsuarios}" }, method = RequestMethod.DELETE)
public void delete(HttpServletRequest request, HttpServletResponse response,
        @PathVariable("idsUsuarios") String idsUsuariosStr) {

    try {//w w w.j  a  va 2 s  .  c  o  m
        String[] idsUsuariosArr = idsUsuariosStr.split(",");
        for (int i = 0; i < idsUsuariosArr.length; i++) {
            usuarioDAO.delete(Integer.parseInt(idsUsuariosArr[i]));
        }

        response.setStatus(HttpServletResponse.SC_NO_CONTENT);

    } catch (Exception ex) {
        response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
        response.setContentType("text/plain; charset=UTF-8");
        try {

            ex.printStackTrace(response.getWriter());

        } catch (IOException ex1) {
        }
    }

}

From source file:org.eclipse.leshan.bootstrap.servlet.BootstrapServlet.java

@Override
protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    if (req.getPathInfo() == null) {
        // we need the endpoint in the URL
        resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "endpoint name should be specified in the URL");
        return;//from   www.ja v  a 2 s  . c  om
    }

    String[] path = StringUtils.split(req.getPathInfo(), '/');

    // endPoint
    if (path.length != 1) {
        resp.sendError(HttpServletResponse.SC_BAD_REQUEST,
                "endpoint name should be specified in the URL, nothing more");
        return;
    }

    String endpoint = path[0];

    if (bsStore.deleteConfig(endpoint)) {
        resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
    } else {
        resp.sendError(HttpServletResponse.SC_NOT_FOUND);
    }
}

From source file:org.basinmc.irc.bridge.github.TeamCityHandler.java

/**
 * {@inheritDoc}/*from w  w  w.j a  v a  2  s. co  m*/
 */
@Override
public void handle(@Nonnull String target, @Nonnull Request baseRequest, @Nonnull HttpServletRequest request,
        @Nonnull HttpServletResponse response) throws IOException, ServletException {
    if (!target.startsWith("/build")) {
        return;
    }

    if (this.serverAddress != null && !this.serverAddress.isEmpty()
            && !this.serverAddress.equals(request.getRemoteAddr())) {
        logger.info("Access denied to build webhook from " + request.getRemoteAddr());

        response.sendError(HttpServletResponse.SC_FORBIDDEN);
        baseRequest.setHandled(true);
        return;
    }

    JsonNode data;

    try (InputStream inputStream = request.getInputStream()) {
        data = reader.readTree(inputStream).get("build");
    }

    switch (target) {
    default:
        return;
    case "/build/started":
        this.bridge.sendMessage(String.format(MESSAGE_START, data.get("buildFullName").asText(),
                data.get("agentName").asText(), data.get("buildStatusUrl").asText()));
        break;
    case "/build/success":
        this.bridge.sendMessage(String.format(MESSAGE_SUCCESS, data.get("buildFullName").asText(),
                data.get("buildStatusUrl").asText()));
        break;
    case "/build/failure":
        this.bridge.sendMessage(String.format(MESSAGE_FAILURE, data.get("buildFullName").asText(),
                data.get("buildStatusUrl").asText()));
        break;
    }

    logger.info("Handled build webhook from " + request.getRemoteAddr());
    response.setStatus(HttpServletResponse.SC_NO_CONTENT);
    baseRequest.setHandled(true);
}

From source file:com.pymegest.applicationserver.api.ProductoController.java

@RequestMapping(value = { "/Producto/{idsProductos}" }, method = RequestMethod.DELETE)
public void delete(HttpServletRequest request, HttpServletResponse response,
        @PathVariable("idsProductos") String idsProductosStr) {

    try {/*from   w w  w  .  j  a  v  a2 s .co m*/
        String[] idsProductosArr = idsProductosStr.split(",");
        for (int i = 0; i < idsProductosArr.length; i++) {
            productoDAO.delete(Integer.parseInt(idsProductosArr[i]));
        }

        response.setStatus(HttpServletResponse.SC_NO_CONTENT);

    } catch (Exception ex) {
        response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
        response.setContentType("text/plain; charset=UTF-8");
        try {

            ex.printStackTrace(response.getWriter());

        } catch (IOException ex1) {
        }
    }

}

From source file:com.pymegest.applicationserver.api.EmpleadoController.java

@RequestMapping(value = { "/Empleado/{idsEmpleados}" }, method = RequestMethod.DELETE)
public void delete(HttpServletRequest request, HttpServletResponse response,
        @PathVariable("idsEmpleados") String idsEmpleadosStr) {

    try {/*from  www.  j a  v  a2  s .c o m*/

        String[] idsEmpleadosArr = idsEmpleadosStr.split(",");
        for (int i = 0; i < idsEmpleadosArr.length; i++) {
            empleadoDAO.delete(Integer.parseInt(idsEmpleadosArr[i]));
        }

        response.setStatus(HttpServletResponse.SC_NO_CONTENT);

    } catch (Exception ex) {
        response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
        response.setContentType("text/plain; charset=UTF-8");
        try {

            ex.printStackTrace(response.getWriter());

        } catch (IOException ex1) {
        }
    }

}

From source file:org.eclipse.dirigible.runtime.registry.RepositoryServlet.java

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

    String repositoryPath = null;
    final OutputStream out = response.getOutputStream();
    try {//w  w w  .  j a v  a  2  s.  c  o  m
        repositoryPath = extractRepositoryPath(request);
        IEntity entity = getEntity(repositoryPath, request);
        byte[] data;
        if (entity == null) {
            ByteArrayOutputStream buff = new ByteArrayOutputStream();
            IOUtils.copy(request.getInputStream(), buff);
            data = buff.toByteArray();
            String contentType = request.getContentType();
            if (contentType == null) {
                contentType = "text/plain"; //$NON-NLS-1$
            }
            boolean isBinary = ContentTypeHelper.isBinary(contentType);
            getRepository(request).createResource(repositoryPath, data, isBinary, contentType);
        } else {
            if (entity instanceof IResource) {
                response.sendError(HttpServletResponse.SC_BAD_REQUEST,
                        THERE_IS_AN_EXISTING_RESOURCE_AT_THE_SAME_LOCATION_USE_PUT_METHOD_FOR_UPDATE);
            } else if (entity instanceof ICollection) {
                response.sendError(HttpServletResponse.SC_BAD_REQUEST,
                        THERE_IS_AN_EXISTING_COLLECTION_AT_THE_SAME_LOCATION);
            }
        }
    } catch (IllegalArgumentException ex) {
        logger.error(String.format(REQUEST_PROCESSING_FAILED_S, repositoryPath) + ex.getMessage(), ex);
        response.sendError(HttpServletResponse.SC_BAD_REQUEST, ex.getMessage());
    } catch (MissingResourceException ex) {
        logger.error(String.format(REQUEST_PROCESSING_FAILED_S, repositoryPath) + ex.getMessage(), ex);
        response.sendError(HttpServletResponse.SC_NO_CONTENT, ex.getMessage());
    } finally {
        out.flush();
        out.close();
    }

}

From source file:org.openo.drivermgr.service.impl.DriverMgrServiceImpl.java

/**
 * unregister the driver info from the DB.
 * <br/>//w ww .j a  v  a2  s.c  o m
 * 
 * @param request : HttpServletRequest Object
 * @param response : HttpServletResponse Object
 * @since  
 */
public void unregister(HttpServletRequest request, HttpServletResponse response, String instanceId) {

    LOGGER.info("Going to UnRegister Driver");

    if (driverManager.getDriverByInstanceId(instanceId) == null) {
        throw new DriverManagerException(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE,
                ErrorCode.INVALID_PARAMETERS);
    }

    if (driverManager.unregisterDriver(instanceId)) {
        response.setStatus(HttpServletResponse.SC_NO_CONTENT);
    } else {
        throw new DriverManagerException(HttpServletResponse.SC_FORBIDDEN, ErrorCode.FAILURE_INFORMATION);
    }
}

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

@RequestMapping(value = "/marketplace/entry/{fname}.json")
public ModelAndView marketplaceEntryFeed(HttpServletRequest request, HttpServletResponse response,
        @PathVariable String fname) {
    final IPerson user = personManager.getPerson(request);
    final IAuthorizationPrincipal principal = AuthorizationPrincipalHelper.principalFromUser(user);

    final MarketplacePortletDefinition marketplacePortletDefinition = marketplaceService
            .getOrCreateMarketplacePortletDefinitionIfTheFnameExists(fname);
    if (marketplacePortletDefinition != null
            && marketplaceService.mayBrowsePortlet(principal, marketplacePortletDefinition)) {
        MarketplaceEntry entry = new MarketplaceEntry(marketplacePortletDefinition, true, user);
        entry.setCanAdd(marketplaceService.mayAddPortlet(user, marketplacePortletDefinition));

        return new ModelAndView("json", "entry", entry);
    }// ww w. ja  v  a 2  s  .c o  m

    response.setStatus(HttpServletResponse.SC_NO_CONTENT);
    return null;
}

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

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

    String repositoryPath = null;
    final OutputStream out = response.getOutputStream();
    try {/* w ww .  java2s.  co  m*/
        repositoryPath = extractRepositoryPath(request);
        IEntity entity = getEntity(repositoryPath, request);
        byte[] data;
        if (entity == null) {
            ByteArrayOutputStream buff = new ByteArrayOutputStream();
            IOUtils.copy(request.getInputStream(), buff);
            data = buff.toByteArray();
            String contentType = request.getContentType();
            if (contentType == null) {
                contentType = "text/plain"; //$NON-NLS-1$
            }
            boolean isBinary = ContentTypeHelper.isBinary(contentType);
            getRepository(request).createResource(repositoryPath, data, isBinary, contentType);
        } else {
            if (entity instanceof IResource) {
                response.sendError(HttpServletResponse.SC_BAD_REQUEST,
                        THERE_IS_AN_EXISTING_RESOURCE_AT_THE_SAME_LOCATION_USE_PUT_METHOD_FOR_UPDATE);
            } else if (entity instanceof ICollection) {
                response.sendError(HttpServletResponse.SC_BAD_REQUEST,
                        THERE_IS_AN_EXISTING_COLLECTION_AT_THE_SAME_LOCATION);
            }
        }
    } catch (IllegalArgumentException ex) {
        logger.error(String.format(REQUEST_PROCESSING_FAILED_S, repositoryPath) + ex.getMessage());
        response.sendError(HttpServletResponse.SC_BAD_REQUEST, ex.getMessage());
    } catch (MissingResourceException ex) {
        logger.error(String.format(REQUEST_PROCESSING_FAILED_S, repositoryPath) + ex.getMessage());
        response.sendError(HttpServletResponse.SC_NO_CONTENT, ex.getMessage());
    } finally {
        out.flush();
        out.close();
    }

}