Example usage for javax.servlet.http HttpServletResponse SC_RESET_CONTENT

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

Introduction

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

Prototype

int SC_RESET_CONTENT

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

Click Source Link

Document

Status code (205) indicating that the agent SHOULD reset the document view which caused the request to be sent.

Usage

From source file:de.zib.gndms.kit.monitor.GroovyMoniServlet.java

@SuppressWarnings({ "BooleanMethodNameMustStartWithQuestion" })
private synchronized boolean contAftOperatingSrvIfRequested(@NotNull HttpServletRequestWrapper requestWrapper,
        final HttpServletResponse responseParam) throws IOException {
    final String mode = requestWrapper.getParameter("m");

    // refresh == reload config and restart server if config has changed
    if ("refresh".equalsIgnoreCase(mode)) {
        try {//ww  w. j  a v  a2  s  . c o m
            moniServer.refresh();
            throw new ServletRuntimeException(HttpServletResponse.SC_RESET_CONTENT, "Refreshed", false);
        } catch (Exception e) {
            intlError(e);
        }
    }
    // restart server
    if ("restart".equalsIgnoreCase(mode)) {
        try {
            moniServer.restart();
            throw new ServletRuntimeException(HttpServletResponse.SC_RESET_CONTENT, "Restarted", false);
        } catch (Exception e) {
            intlError(e);
        }
    }
    if ("call".equals(mode)) {
        doCallAction(requestWrapper, responseParam);
        return false;
    }
    return true;
}

From source file:de.mendelson.comm.as2.send.MessageHttpUploader.java

/**Returns the created header for the sent data*/
public Properties upload(HttpConnectionParameter connectionParameter, AS2Message message, Partner sender,
        Partner receiver) throws Exception {
    NumberFormat formatter = new DecimalFormat("0.00");
    AS2Info as2Info = message.getAS2Info();
    MessageAccessDB messageAccess = null;
    MDNAccessDB mdnAccess = null;//  w w w  .  ja va 2 s.c  o m
    if (this.runtimeConnection != null && messageAccess == null && !as2Info.isMDN()) {
        messageAccess = new MessageAccessDB(this.configConnection, this.runtimeConnection);
        messageAccess.initializeOrUpdateMessage((AS2MessageInfo) as2Info);
    } else if (this.runtimeConnection != null && as2Info.isMDN()) {
        mdnAccess = new MDNAccessDB(this.configConnection, this.runtimeConnection);
        mdnAccess.initializeOrUpdateMDN((AS2MDNInfo) as2Info);
    }
    if (this.clientserver != null) {
        this.clientserver.broadcastToClients(new RefreshClientMessageOverviewList());
    }
    long startTime = System.currentTimeMillis();
    //sets the global requestHeader
    int returnCode = this.performUpload(connectionParameter, message, sender, receiver);
    long size = message.getRawDataSize();
    long transferTime = System.currentTimeMillis() - startTime;
    float bytePerSec = (float) ((float) size * 1000f / (float) transferTime);
    float kbPerSec = (float) (bytePerSec / 1024f);
    if (returnCode == HttpServletResponse.SC_OK) {
        if (this.logger != null) {
            this.logger.log(Level.INFO,
                    this.rb.getResourceString("returncode.ok",
                            new Object[] { as2Info.getMessageId(), String.valueOf(returnCode),
                                    AS2Tools.getDataSizeDisplay(size), AS2Tools.getTimeDisplay(transferTime),
                                    formatter.format(kbPerSec), }),
                    as2Info);
        }
    } else if (returnCode == HttpServletResponse.SC_ACCEPTED || returnCode == HttpServletResponse.SC_CREATED
            || returnCode == HttpServletResponse.SC_NO_CONTENT
            || returnCode == HttpServletResponse.SC_RESET_CONTENT
            || returnCode == HttpServletResponse.SC_PARTIAL_CONTENT) {
        if (this.logger != null) {
            this.logger.log(Level.INFO,
                    this.rb.getResourceString("returncode.accepted",
                            new Object[] { as2Info.getMessageId(), String.valueOf(returnCode),
                                    AS2Tools.getDataSizeDisplay(size), AS2Tools.getTimeDisplay(transferTime),
                                    formatter.format(kbPerSec), }),
                    as2Info);
        }
    } else {
        //the system was unable to connect the partner
        if (returnCode < 0) {
            throw new NoConnectionException(
                    this.rb.getResourceString("error.noconnection", as2Info.getMessageId()));
        }
        if (this.runtimeConnection != null) {
            if (messageAccess == null) {
                messageAccess = new MessageAccessDB(this.configConnection, this.runtimeConnection);
            }
            messageAccess.setMessageState(as2Info.getMessageId(), AS2Message.STATE_STOPPED);
        }
        throw new Exception(as2Info.getMessageId() + ": HTTP " + returnCode);
    }
    if (this.configConnection != null) {
        //inc the sent data size, this is for new connections (as2 messages, async mdn)
        AS2Server.incRawSentData(size);
        if (message.getAS2Info().isMDN()) {
            AS2MDNInfo mdnInfo = (AS2MDNInfo) message.getAS2Info();
            //ASYNC MDN sent: insert an entry into the statistic table
            QuotaAccessDB.incReceivedMessages(this.configConnection, this.runtimeConnection,
                    mdnInfo.getSenderId(), mdnInfo.getReceiverId(), mdnInfo.getState(),
                    mdnInfo.getRelatedMessageId());
        }
    }
    if (this.configConnection != null) {
        MessageStoreHandler messageStoreHandler = new MessageStoreHandler(this.configConnection,
                this.runtimeConnection);
        messageStoreHandler.storeSentMessage(message, sender, receiver, this.requestHeader);
    }
    //inform the server of the result if a sync MDN has been requested
    if (!message.isMDN()) {
        AS2MessageInfo messageInfo = (AS2MessageInfo) message.getAS2Info();
        if (messageInfo.requestsSyncMDN()) {
            //perform a check if the answer really contains a MDN or is just an empty HTTP 200 with some header data
            //this check looks for the existance of some key header values
            boolean as2FromExists = false;
            boolean as2ToExists = false;
            for (int i = 0; i < this.getResponseHeader().length; i++) {
                String key = this.getResponseHeader()[i].getName();
                if (key.toLowerCase().equals("as2-to")) {
                    as2ToExists = true;
                } else if (key.toLowerCase().equals("as2-from")) {
                    as2FromExists = true;
                }
            }
            if (!as2ToExists) {
                throw new Exception(this.rb.getResourceString("answer.no.sync.mdn",
                        new Object[] { as2Info.getMessageId(), "as2-to" }));
            }
            //send the data to the as2 server. It does not care if the MDN has been sync or async anymore
            GenericClient client = new GenericClient();
            CommandObjectIncomingMessage commandObject = new CommandObjectIncomingMessage();
            //create temporary file to store the data
            File tempFile = AS2Tools.createTempFile("SYNCMDN_received", ".bin");
            FileOutputStream outStream = new FileOutputStream(tempFile);
            ByteArrayInputStream memIn = new ByteArrayInputStream(this.responseData);
            this.copyStreams(memIn, outStream);
            memIn.close();
            outStream.flush();
            outStream.close();
            commandObject.setMessageDataFilename(tempFile.getAbsolutePath());
            for (int i = 0; i < this.getResponseHeader().length; i++) {
                String key = this.getResponseHeader()[i].getName();
                String value = this.getResponseHeader()[i].getValue();
                commandObject.addHeader(key.toLowerCase(), value);
                if (key.toLowerCase().equals("content-type")) {
                    commandObject.setContentType(value);
                }
            }
            //compatibility issue: some AS2 systems do not send a as2-from in the sync case, even if
            //this if _NOT_ RFC conform
            //see RFC 4130, section 6.2: The AS2-To and AS2-From header fields MUST be
            //present in all AS2 messages and AS2 MDNs whether asynchronous or synchronous in nature,
            //except for asynchronous MDNs, which are sent using SMTP.
            if (!as2FromExists) {
                commandObject.addHeader("as2-from",
                        AS2Message.escapeFromToHeader(receiver.getAS2Identification()));
            }
            ErrorObject errorObject = client.send(commandObject);
            if (errorObject.getErrors() > 0) {
                messageAccess.setMessageState(as2Info.getMessageId(), AS2Message.STATE_STOPPED);
            }
            tempFile.delete();
        }
    }
    return (this.requestHeader);
}

From source file:de.mendelson.comm.as2.send.MessageHttpUploader.java

/**Uploads the data, returns the HTTP result code*/
public int performUpload(HttpConnectionParameter connectionParameter, AS2Message message, Partner sender,
        Partner receiver, URL receiptURL) {
    String ediintFeatures = "multiple-attachments, CEM";
    //set the http connection/routing/protocol parameter
    HttpParams httpParams = new BasicHttpParams();
    if (connectionParameter.getConnectionTimeoutMillis() != -1) {
        HttpConnectionParams.setConnectionTimeout(httpParams, connectionParameter.getConnectionTimeoutMillis());
    }//from   w  ww  .j  a  va2  s. co m
    if (connectionParameter.getSoTimeoutMillis() != -1) {
        HttpConnectionParams.setSoTimeout(httpParams, connectionParameter.getSoTimeoutMillis());
    }
    HttpConnectionParams.setStaleCheckingEnabled(httpParams, connectionParameter.isStaleConnectionCheck());
    if (connectionParameter.getHttpProtocolVersion() == null) {
        //default settings: HTTP 1.1
        HttpProtocolParams.setVersion(httpParams, HttpVersion.HTTP_1_1);
    } else if (connectionParameter.getHttpProtocolVersion().equals(HttpConnectionParameter.HTTP_1_0)) {
        HttpProtocolParams.setVersion(httpParams, HttpVersion.HTTP_1_0);
    } else if (connectionParameter.getHttpProtocolVersion().equals(HttpConnectionParameter.HTTP_1_1)) {
        HttpProtocolParams.setVersion(httpParams, HttpVersion.HTTP_1_1);
    }
    HttpProtocolParams.setUseExpectContinue(httpParams, connectionParameter.isUseExpectContinue());
    HttpProtocolParams.setUserAgent(httpParams, connectionParameter.getUserAgent());
    if (connectionParameter.getLocalAddress() != null) {
        ConnRouteParams.setLocalAddress(httpParams, connectionParameter.getLocalAddress());
    }
    int status = -1;
    HttpPost filePost = null;
    DefaultHttpClient httpClient = null;
    try {
        ClientConnectionManager clientConnectionManager = this.createClientConnectionManager(httpParams);
        httpClient = new DefaultHttpClient(clientConnectionManager, httpParams);
        //some ssl implementations have problems with a session/connection reuse
        httpClient.setReuseStrategy(new NoConnectionReuseStrategy());
        //disable SSL hostname verification. Do not confuse this with SSL trust verification!
        SSLSocketFactory sslFactory = (SSLSocketFactory) httpClient.getConnectionManager().getSchemeRegistry()
                .get("https").getSocketFactory();
        sslFactory.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
        //determine the receipt URL if it is not set
        if (receiptURL == null) {
            //async MDN requested?
            if (message.isMDN()) {
                if (this.runtimeConnection == null) {
                    throw new IllegalArgumentException(
                            "MessageHTTPUploader.performUpload(): A MDN receipt URL is not set, unable to determine where to send the MDN");
                }
                MessageAccessDB messageAccess = new MessageAccessDB(this.configConnection,
                        this.runtimeConnection);
                AS2MessageInfo relatedMessageInfo = messageAccess
                        .getLastMessageEntry(((AS2MDNInfo) message.getAS2Info()).getRelatedMessageId());
                receiptURL = new URL(relatedMessageInfo.getAsyncMDNURL());
            } else {
                receiptURL = new URL(receiver.getURL());
            }
        }
        filePost = new HttpPost(receiptURL.toExternalForm());
        filePost.addHeader("as2-version", "1.2");
        filePost.addHeader("ediint-features", ediintFeatures);
        filePost.addHeader("mime-version", "1.0");
        filePost.addHeader("recipient-address", receiptURL.toExternalForm());
        filePost.addHeader("message-id", "<" + message.getAS2Info().getMessageId() + ">");
        filePost.addHeader("as2-from", AS2Message.escapeFromToHeader(sender.getAS2Identification()));
        filePost.addHeader("as2-to", AS2Message.escapeFromToHeader(receiver.getAS2Identification()));
        String originalFilename = null;
        if (message.getPayloads() != null && message.getPayloads().size() > 0) {
            originalFilename = message.getPayloads().get(0).getOriginalFilename();
        }
        if (originalFilename != null) {
            String subject = this.replace(message.getAS2Info().getSubject(), "${filename}", originalFilename);
            filePost.addHeader("subject", subject);
            //update the message infos subject with the actual content
            if (!message.isMDN()) {
                ((AS2MessageInfo) message.getAS2Info()).setSubject(subject);
                //refresh this in the database if it is requested
                if (this.runtimeConnection != null) {
                    MessageAccessDB access = new MessageAccessDB(this.configConnection, this.runtimeConnection);
                    access.updateSubject((AS2MessageInfo) message.getAS2Info());
                }
            }
        } else {
            filePost.addHeader("subject", message.getAS2Info().getSubject());
        }
        filePost.addHeader("from", sender.getEmail());
        filePost.addHeader("connection", "close, TE");
        //the data header must be always in english locale else there would be special
        //french characters (e.g. 13 dc. 2011 16:28:56 CET) which is not allowed after 
        //RFC 4130           
        DateFormat format = new SimpleDateFormat("EE, dd MMM yyyy HH:mm:ss zz", Locale.US);
        filePost.addHeader("date", format.format(new Date()));
        String contentType = null;
        if (message.getAS2Info().getEncryptionType() != AS2Message.ENCRYPTION_NONE) {
            contentType = "application/pkcs7-mime; smime-type=enveloped-data; name=smime.p7m";
        } else {
            contentType = message.getContentType();
        }
        filePost.addHeader("content-type", contentType);
        //MDN header, this is always the way for async MDNs
        if (message.isMDN()) {
            if (this.logger != null) {
                this.logger.log(Level.INFO,
                        this.rb.getResourceString("sending.mdn.async",
                                new Object[] { message.getAS2Info().getMessageId(), receiptURL }),
                        message.getAS2Info());
            }
            filePost.addHeader("server", message.getAS2Info().getUserAgent());
        } else {
            AS2MessageInfo messageInfo = (AS2MessageInfo) message.getAS2Info();
            //outbound AS2/CEM message
            if (messageInfo.requestsSyncMDN()) {
                if (this.logger != null) {
                    if (messageInfo.getMessageType() == AS2Message.MESSAGETYPE_CEM) {
                        this.logger.log(Level.INFO,
                                this.rb.getResourceString("sending.cem.sync",
                                        new Object[] { messageInfo.getMessageId(), receiver.getURL() }),
                                messageInfo);
                    } else if (messageInfo.getMessageType() == AS2Message.MESSAGETYPE_AS2) {
                        this.logger.log(Level.INFO,
                                this.rb.getResourceString("sending.msg.sync",
                                        new Object[] { messageInfo.getMessageId(), receiver.getURL() }),
                                messageInfo);
                    }
                }
            } else {
                //Message with ASYNC MDN request
                if (this.logger != null) {
                    if (messageInfo.getMessageType() == AS2Message.MESSAGETYPE_CEM) {
                        this.logger.log(Level.INFO,
                                this.rb.getResourceString("sending.cem.async", new Object[] {
                                        messageInfo.getMessageId(), receiver.getURL(), sender.getMdnURL() }),
                                messageInfo);
                    } else if (messageInfo.getMessageType() == AS2Message.MESSAGETYPE_AS2) {
                        this.logger.log(Level.INFO,
                                this.rb.getResourceString("sending.msg.async", new Object[] {
                                        messageInfo.getMessageId(), receiver.getURL(), sender.getMdnURL() }),
                                messageInfo);
                    }
                }
                //The following header indicates that this requests an asnc MDN.
                //When the header "receipt-delivery-option" is present,
                //the header "disposition-notification-to" serves as a request
                //for an asynchronous MDN.
                //The header "receipt-delivery-option" must always be accompanied by
                //the header "disposition-notification-to".
                //When the header "receipt-delivery-option" is not present and the header
                //"disposition-notification-to" is present, the header "disposition-notification-to"
                //serves as a request for a synchronous MDN.
                filePost.addHeader("receipt-delivery-option", sender.getMdnURL());
            }
            filePost.addHeader("disposition-notification-to", sender.getMdnURL());
            //request a signed MDN if this is set up in the partner configuration
            if (receiver.isSignedMDN()) {
                filePost.addHeader("disposition-notification-options",
                        messageInfo.getDispositionNotificationOptions().getHeaderValue());
            }
            if (messageInfo.getSignType() != AS2Message.SIGNATURE_NONE) {
                filePost.addHeader("content-disposition", "attachment; filename=\"smime.p7m\"");
            } else if (messageInfo.getSignType() == AS2Message.SIGNATURE_NONE
                    && message.getAS2Info().getSignType() == AS2Message.ENCRYPTION_NONE) {
                filePost.addHeader("content-disposition",
                        "attachment; filename=\"" + message.getPayload(0).getOriginalFilename() + "\"");
            }
        }
        int port = receiptURL.getPort();
        if (port == -1) {
            port = receiptURL.getDefaultPort();
        }
        filePost.addHeader("host", receiptURL.getHost() + ":" + port);
        InputStream rawDataInputStream = message.getRawDataInputStream();
        InputStreamEntity postEntity = new InputStreamEntity(rawDataInputStream, message.getRawDataSize());
        postEntity.setContentType(contentType);
        filePost.setEntity(postEntity);
        if (connectionParameter.getProxy() != null) {
            this.setProxyToConnection(httpClient, message, connectionParameter.getProxy());
        }
        this.setHTTPAuthentication(httpClient, receiver, message.getAS2Info().isMDN());
        this.updateUploadHttpHeader(filePost, receiver);
        HttpHost targetHost = new HttpHost(receiptURL.getHost(), receiptURL.getPort(),
                receiptURL.getProtocol());
        BasicHttpContext localcontext = new BasicHttpContext();
        // Generate BASIC scheme object and stick it to the local
        // execution context. Without this a HTTP authentication will not be sent
        BasicScheme basicAuth = new BasicScheme();
        localcontext.setAttribute("preemptive-auth", basicAuth);
        HttpResponse httpResponse = httpClient.execute(targetHost, filePost, localcontext);
        rawDataInputStream.close();
        this.responseData = this.readEntityData(httpResponse);
        if (httpResponse != null) {
            this.responseStatusLine = httpResponse.getStatusLine();
            status = this.responseStatusLine.getStatusCode();
            this.responseHeader = httpResponse.getAllHeaders();
        }
        for (Header singleHeader : filePost.getAllHeaders()) {
            if (singleHeader.getValue() != null) {
                this.requestHeader.setProperty(singleHeader.getName(), singleHeader.getValue());
            }
        }
        //accept all 2xx answers
        //SC_ACCEPTED Status code (202) indicating that a request was accepted for processing, but was not completed.
        //SC_CREATED  Status code (201) indicating the request succeeded and created a new resource on the server.
        //SC_NO_CONTENT Status code (204) indicating that the request succeeded but that there was no new information to return.
        //SC_NON_AUTHORITATIVE_INFORMATION Status code (203) indicating that the meta information presented by the client did not originate from the server.
        //SC_OK Status code (200) indicating the request succeeded normally.
        //SC_RESET_CONTENT Status code (205) indicating that the agent SHOULD reset the document view which caused the request to be sent.
        //SC_PARTIAL_CONTENT Status code (206) indicating that the server has fulfilled the partial GET request for the resource.
        if (status != HttpServletResponse.SC_OK && status != HttpServletResponse.SC_ACCEPTED
                && status != HttpServletResponse.SC_CREATED && status != HttpServletResponse.SC_NO_CONTENT
                && status != HttpServletResponse.SC_NON_AUTHORITATIVE_INFORMATION
                && status != HttpServletResponse.SC_RESET_CONTENT
                && status != HttpServletResponse.SC_PARTIAL_CONTENT) {
            if (this.logger != null) {
                this.logger
                        .severe(this.rb.getResourceString("error.httpupload",
                                new Object[] { message.getAS2Info().getMessageId(),
                                        URLDecoder.decode(
                                                this.responseStatusLine == null ? ""
                                                        : this.responseStatusLine.getReasonPhrase(),
                                                "UTF-8") }));
            }
        }
    } catch (Exception ex) {
        if (this.logger != null) {
            StringBuilder errorMessage = new StringBuilder(message.getAS2Info().getMessageId());
            errorMessage.append(": MessageHTTPUploader.performUpload: [");
            errorMessage.append(ex.getClass().getSimpleName());
            errorMessage.append("]");
            if (ex.getMessage() != null) {
                errorMessage.append(": ").append(ex.getMessage());
            }
            this.logger.log(Level.SEVERE, errorMessage.toString(), message.getAS2Info());
        }
    } finally {
        if (httpClient != null && httpClient.getConnectionManager() != null) {
            //shutdown the HTTPClient to release the resources
            httpClient.getConnectionManager().shutdown();
        }
    }
    return (status);
}

From source file:org.osaf.cosmo.mc.MorseCodeServlet.java

/**
 * Handles update requests./*from  w w  w  .  j  a va  2 s.com*/
 */
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    if (log.isDebugEnabled())
        log.debug("handling POST for " + req.getPathInfo());

    CollectionPath cp = CollectionPath.parse(req.getPathInfo());
    if (cp != null) {
        String tokenStr = req.getHeader(HEADER_SYNC_TOKEN);
        if (StringUtils.isBlank(tokenStr)) {
            String msg = "Missing sync token";
            handleGeneralException(new BadRequestException(msg), resp);
            return;
        }

        if (!checkWritePreconditions(req, resp))
            return;

        EimmlStreamReader reader = null;
        try {
            SyncToken token = SyncToken.deserialize(tokenStr);

            reader = new EimmlStreamReader(req.getReader());
            if (!reader.getCollectionUuid().equals(cp.getUid())) {
                String msg = "EIMML collection uid " + reader.getCollectionUuid()
                        + " does not match target collection uid " + cp.getUid();
                handleGeneralException(new BadRequestException(msg), resp);
                return;
            }

            EimmlStreamReaderIterator i = new EimmlStreamReaderIterator(reader);
            PubRecords records = new PubRecords(i, reader.getCollectionName(), reader.getCollectionHue());

            PubCollection pubCollection = controller.updateCollection(cp.getUid(), token, records);

            resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
            resp.addHeader(HEADER_SYNC_TOKEN, pubCollection.getToken().serialize());
            return;
        } catch (CosmoSecurityException e) {
            if (e instanceof ItemSecurityException) {
                InsufficientPrivilegesException ipe = new InsufficientPrivilegesException(
                        (ItemSecurityException) e);
                handleGeneralException(ipe, resp);
            } else {
                resp.sendError(HttpServletResponse.SC_FORBIDDEN, e.getMessage());
            }
            return;
        } catch (EimmlStreamException e) {
            Throwable cause = e.getCause();
            String msg = "Unable to read EIM stream: " + e.getMessage();
            msg += cause != null ? ": " + cause.getMessage() : "";
            handleGeneralException(new BadRequestException(msg, e), resp);
            return;
        } catch (CollectionLockedException e) {
            resp.sendError(SC_LOCKED, "Collection is locked for update");
            return;
        } catch (StaleCollectionException e) {
            resp.sendError(HttpServletResponse.SC_RESET_CONTENT,
                    "Collection contains more recently updated items");
            return;
        } catch (MorseCodeException e) {
            Throwable root = e.getCause();
            if (root != null && root instanceof EimmlStreamException) {
                String msg = "Unable to read EIM stream: " + root.getMessage();
                handleGeneralException(new BadRequestException(msg, e), resp);
                return;
            }
            if (root != null && root instanceof EimSchemaException) {
                String msg = "Unable to process EIM records: " + root.getMessage();
                handleGeneralException(new BadRequestException(msg, e), resp);
                return;
            }

            handleGeneralException(e, resp);
            return;
        } catch (RuntimeException e) {
            handleGeneralException(new MorseCodeException(e), resp);
            return;
        } finally {
            if (reader != null)
                reader.close();
        }
    }
    resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
}

From source file:org.osjava.atom4j.servlet.AtomServlet.java

/**
 * Update the Entry (save changes).//from   w w w.  j a v  a 2  s. c o m
 * 
 * PathInfo: /USER/entry/id
 * 
 * @param request
 */
protected void updateEntry(String[] pathInfo, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {
    EntryReader reader = new EntryReader(request.getInputStream());
    List entries = (List) reader.getEntries();
    if (entries == null || entries.size() < 1) {
        error(request, response, "No Entry Found For Update.", "Unable to locate entry submitted for update.");
        return;
    }

    if (pathInfo.length > 2) {
        // find the Entry to be edited
        Entry entry = (Entry) entries.get(0);

        if (entry != null) {
            try {
                updateEntry(entry, pathInfo);

                response.setStatus(HttpServletResponse.SC_RESET_CONTENT);
            } catch (Exception e) {
                throw new ServletException(e);
            }
        }
    } else {
        error(request, response, "Invalid request.", "Insufficient Information to Process Request.");
    }
}