Example usage for java.util.logging Level FINEST

List of usage examples for java.util.logging Level FINEST

Introduction

In this page you can find the example usage for java.util.logging Level FINEST.

Prototype

Level FINEST

To view the source code for java.util.logging Level FINEST.

Click Source Link

Document

FINEST indicates a highly detailed tracing message.

Usage

From source file:com.google.enterprise.connector.salesforce.BaseTraversalManager.java

/**
 * Converts the <document></document> xml into a BaseSimpleDocument object
 * that we can send into a documentList object that ultimately gets returned
 * to the connector-manager/* w  ww.j a  v a  2  s. c o  m*/
 * 
 * @param inxml
 *            the xml form of and individual <document></document> object
 */

private BaseSimpleDocument convertXMLtoBaseDocument(Document doc) {
    try {

        HashMap hm_spi = new HashMap();
        HashMap hm_meta_tags = new HashMap();
        Map props = new HashMap();
        String content_value = "";

        TransformerFactory transfac = TransformerFactory.newInstance();
        Transformer trans = transfac.newTransformer();
        trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
        trans.setOutputProperty(OutputKeys.INDENT, "yes");
        trans.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
        trans.setOutputProperty(OutputKeys.ENCODING, "UTF-8");

        // TODO: figure out why the initial doc passed in to the method
        // doesn't have the stylesheet 'fully' applied
        // this is why we do the conversion back and forth below
        // because for some reason the doc->string->doc has the stylesheet
        // applied.
        String sdoc = Util.XMLDoctoString(doc);
        logger.log(Level.FINEST, "About to convert STORE XML to BaseDocument " + sdoc);
        doc = Util.XMLStringtoDoc(sdoc);

        NodeList nl_document = doc.getElementsByTagName("document");

        Node ndoc = nl_document.item(0);

        NodeList nl_doc_child = ndoc.getChildNodes();

        for (int j = 0; j < nl_doc_child.getLength(); j++) {
            Node cnode = nl_doc_child.item(j);
            String doc_child_node_name = cnode.getNodeName();

            if (doc_child_node_name.equalsIgnoreCase("spiheaders")) {
                NodeList nl_spi = cnode.getChildNodes();
                for (int k = 0; k < nl_spi.getLength(); k++) {
                    Node n_spi = nl_spi.item(k);
                    if (n_spi.getNodeType() == Node.ELEMENT_NODE) {
                        String spi_name = n_spi.getAttributes().getNamedItem("name").getNodeValue();
                        String spi_value = "";
                        if (n_spi.getFirstChild() != null) {
                            spi_value = n_spi.getFirstChild().getNodeValue();
                            logger.log(Level.FINEST, "Adding SPI " + spi_name + " " + spi_value);
                        }
                        hm_spi.put(spi_name, spi_value);
                    }
                }
            }

            if (doc_child_node_name.equalsIgnoreCase("metadata")) {
                NodeList nl_meta = cnode.getChildNodes();
                for (int k = 0; k < nl_meta.getLength(); k++) {
                    Node n_meta = nl_meta.item(k);
                    if (n_meta.getNodeType() == Node.ELEMENT_NODE) {
                        String meta_name = n_meta.getAttributes().getNamedItem("name").getNodeValue();
                        String meta_value = "";
                        if (n_meta.getFirstChild() != null) {
                            meta_value = n_meta.getFirstChild().getNodeValue();
                            logger.log(Level.FINEST, "Adding METATAG " + meta_name + " " + meta_value);
                        }
                        hm_meta_tags.put(meta_name, meta_value);
                    }
                }
            }

            if (doc_child_node_name.equalsIgnoreCase("content")) {
                content_value = cnode.getChildNodes().item(0).getNodeValue();
                String encoding_type = "";
                NamedNodeMap attribs = cnode.getAttributes();
                if (attribs.getLength() > 0) {
                    Node attrib = attribs.getNamedItem("encoding");
                    if (attrib != null)
                        encoding_type = attrib.getNodeValue();

                    if (encoding_type.equalsIgnoreCase("base64")
                            || encoding_type.equalsIgnoreCase("base64binary")) {
                        byte[] b = org.apache.commons.codec.binary.Base64
                                .decodeBase64(content_value.getBytes());
                        ByteArrayInputStream input1 = new ByteArrayInputStream(b);
                        logger.log(Level.FINEST, "Adding base64 encoded CONTENT " + content_value);
                        props.put(SpiConstants.PROPNAME_CONTENT, input1);
                    } else {
                        logger.log(Level.FINEST, "Adding Text/HTML CONTENT " + content_value);
                        props.put(SpiConstants.PROPNAME_CONTENT, content_value);
                    }
                } else {
                    logger.log(Level.FINEST, "Adding default Text/HTML CONTENT " + content_value);
                    props.put(SpiConstants.PROPNAME_CONTENT, content_value);
                }
            }
        }

        // the hashmap holding the spi headers
        Iterator itr_spi = hm_spi.keySet().iterator();

        while (itr_spi.hasNext()) {
            String key = (String) itr_spi.next();
            String value = (String) hm_spi.get(key);

            if (key.equals("DEFAULT_MIMETYPE"))
                props.put(SpiConstants.DEFAULT_MIMETYPE, value);

            if (key.equals("PROPNAME_ACTION"))
                props.put(SpiConstants.PROPNAME_ACTION, value);

            if (key.equals("PROPNAME_CONTENTURL"))
                props.put(SpiConstants.PROPNAME_CONTENTURL, value);

            if (key.equals("PROPNAME_DISPLAYURL"))
                props.put(SpiConstants.PROPNAME_DISPLAYURL, value);

            if (key.equals("PROPNAME_DOCID"))
                props.put(SpiConstants.PROPNAME_DOCID, value);

            if (key.equals("PROPNAME_ISPUBLIC"))
                props.put(SpiConstants.PROPNAME_ISPUBLIC, value);

            if (key.equals("PROPNAME_LASTMODIFIED"))
                props.put(SpiConstants.PROPNAME_LASTMODIFIED, value);

            if (key.equals("PROPNAME_MIMETYPE"))
                props.put(SpiConstants.PROPNAME_MIMETYPE, value);

            // if (key.equals("PROPNAME_SEARCHURL"))
            // props.put(SpiConstants.PROPNAME_SEARCHURL, value);

            // if (key.equals("PROPNAME_SECURITYTOKEN"))
            // props.put(SpiConstants.PROPNAME_SECURITYTOKEN, value);

        }

        // hashmap holding the custom metatags
        Iterator itr_meta = hm_meta_tags.keySet().iterator();

        while (itr_meta.hasNext()) {
            String key = (String) itr_meta.next();
            String value = (String) hm_meta_tags.get(key);
            props.put(key, value);
        }

        BaseSimpleDocument bsd = createSimpleDocument(new Date(), props);
        return bsd;
    } catch (Exception ex) {
        logger.log(Level.SEVERE, "Error " + ex);
    }
    return null;

}

From source file:com.ibm.datapower.amt.clientAPI.Blob.java

/**
 * Get the contents of the blob as a byte array.
 * <p>/*from ww  w . java 2s .  c om*/
 * If the Blob was initially constructed via a byte array, it will just
 * return a reference to that same byte array.
 * <p>
 * If the Blob was initially constructed via a File, it will open the file,
 * allocate a byte array large enough to hold the contents, read the file
 * into that byte array, and return a reference to the byte array. Doing
 * that may be quite expensive if the file is large. This method does not
 * cause this object to have a reference to the byte array, so as soon as
 * the caller is done with the return value it may be eligible for garbage
 * collection.
 * <p>
 * This method needs to be public so it can be invoked by the dataAPI.
 * 
 * @return a byte array representation of the binary data
 * @throws IOException
 *             there was a problem reading the file while converting it to a
 *             byte array.
 */
public byte[] getByteArray() throws IOException {
    final String METHOD_NAME = "getByteArray"; //$NON-NLS-1$
    byte[] result = null;
    if (this.bytes != null) {
        result = this.bytes;
    } else if ((this.file != null) || (this.url != null)) {
        // need to load it
        if (this.file != null) {
            logger.logp(Level.FINER, CLASS_NAME, METHOD_NAME,
                    "Creating byte array in Blob from file: " + this.file.getAbsolutePath()); //$NON-NLS-1$
        } else {
            logger.logp(Level.FINER, CLASS_NAME, METHOD_NAME,
                    "Creating byte array in Blob from url" + this.url.toString()); //$NON-NLS-1$
        }

        InputStream inputStream = this.getInputStream();

        // read in 4k chunks until we determine the size
        int totalBytes = 0;
        int bytesRead = 0;
        byte[] buffer = new byte[4096];
        while ((bytesRead = inputStream.read(buffer, 0, 4096)) > 0) {
            totalBytes += bytesRead;
        }
        inputStream.close();

        inputStream = this.getInputStream();

        // Read the blob into a byte array now that we know the size
        result = new byte[totalBytes];
        int increment = 4096;
        if (totalBytes < increment) {
            increment = totalBytes;
        }
        int bufferIndex = 0;
        while ((bytesRead = inputStream.read(result, bufferIndex, increment)) > 0) {
            bufferIndex += bytesRead;
            if ((totalBytes - bufferIndex) < 4096) {
                increment = totalBytes - bufferIndex;
            }
        }

        inputStream.close();
    } else {
        // this should not happen
        logger.logp(Level.INFO, CLASS_NAME, METHOD_NAME,
                Messages.getString("wamt.clientAPI.Blob.internalErr", this.toString())); //$NON-NLS-1$
    }

    if (result != null)
        logger.logp(Level.FINEST, CLASS_NAME, METHOD_NAME, "Returning byte array, length: " + result.length); //$NON-NLS-1$
    String message = "First 20 bytes of Blob: "; //$NON-NLS-1$
    StringBuffer buf = new StringBuffer(message);
    for (int i = 0; i < 20 && i < result.length; i++) {
        int a = result[i];
        buf.append(Integer.toHexString(a & 0xff) + " "); //$NON-NLS-1$             
    }
    message = buf.toString();
    logger.logp(Level.FINEST, CLASS_NAME, METHOD_NAME, message);

    return (result);
}

From source file:com.sun.grizzly.http.jk.server.JkMain.java

public void setBeanProperty(Object target, String name, String val) {
    if (val != null) {
        val = IntrospectionUtils.replaceProperties(val, (Hashtable) props, null);
    }/*from w  ww . ja v a2s  .  c  o m*/
    if (LoggerUtils.getLogger().isLoggable(Level.FINEST)) {
        LoggerUtils.getLogger().log(Level.FINEST, "setProperty " + target + " " + name + "=" + val);
    }

    IntrospectionUtils.setProperty(target, name, val);
}

From source file:edu.usu.sdl.openstorefront.web.rest.service.Application.java

private List<String> loadLevels() {
    List<String> logLevels = Arrays.asList(Level.OFF.getName(), Level.SEVERE.getName(), Level.WARNING.getName(),
            Level.CONFIG.getName(), Level.INFO.getName(), Level.FINE.getName(), Level.FINER.getName(),
            Level.FINEST.getName(), Level.ALL.getName());
    return logLevels;
}

From source file:org.apache.bval.jsr.JsrMetaBeanFactory.java

private void processGroupSequence(Class<?> beanClass, MetaBean metabean, String key) {
    GroupSequence annotation = beanClass.getAnnotation(GroupSequence.class);
    List<Group> groupSeq = metabean.getFeature(key);
    if (groupSeq == null) {
        groupSeq = metabean.initFeature(key,
                new ArrayList<Group>(annotation == null ? 1 : annotation.value().length));
    }/*w w  w .  jav  a  2  s .c  o m*/
    Class<?>[] groupClasses = factory.getDefaultSequence(beanClass);
    if (groupClasses == null || groupClasses.length == 0) {
        if (annotation == null) {
            groupSeq.add(Group.DEFAULT);
            return;
        } else {
            groupClasses = annotation.value();
        }
    }
    boolean containsDefault = false;
    for (final Class<?> groupClass : groupClasses) {
        if (groupClass.getName().equals(beanClass.getName())) {
            groupSeq.add(Group.DEFAULT);
            containsDefault = true;
        } else if (groupClass.getName().equals(Default.class.getName())) {
            throw new GroupDefinitionException("'Default.class' must not appear in @GroupSequence! Use '"
                    + beanClass.getSimpleName() + ".class' instead.");
        } else {
            groupSeq.add(new Group(groupClass));
        }
    }
    if (!containsDefault) {
        throw new GroupDefinitionException(
                "Redefined default group sequence must contain " + beanClass.getName());
    }
    log.log(Level.FINEST,
            String.format("Default group sequence for bean %s is: %s", beanClass.getName(), groupSeq));
}

From source file:eu.europa.ejusticeportal.dss.applet.DssApplet.java

/**
 * Called from when a callback is received from asynch call to
 * the server./*  w  w  w  .  j a  v  a 2 s.  c  o m*/
 *
 * @param method  callback name
 * @param data    xml data
 * @param errCode xml error code
 */
public void handleServerCallBack(final String method, final String data, final String errCode,
        final String hash, final String algo) {
    calledBack = true;

    CallbackHandler callbackHandler;

    if (errCode == null && !canTrustServerHash(data, hash, algo)) {
        UIControllerHome.getInstance().getUiController().eval(UIFunction.closeForTamperedCommunication);
        callbackHandler = new CallbackHandler(null, "dss_applet_message_technical_failure");
    } else {
        ServerCallId serverCall = ServerCallId.valueOf(method);
        if (data != null && data.length() < LOGLIMIT) {
            LOG.log(Level.FINEST, "handleServerCallBack:\nmethod={0}\narg1={1}\narg2={2}",
                    new Object[] { serverCall.name(), data, errCode });
        } else if (data != null) {
            LOG.log(Level.FINEST, "handleServerCallBack:\nmethod={0}\narg1={1}\narg2={2}",
                    new Object[] { serverCall.name(), "data too long", errCode });
        } else {
            LOG.log(Level.FINEST, "handleServerCallBack:\nmethod={0}\narg1={1}\narg2={2}",
                    new Object[] { serverCall.name(), "data is null", errCode });
        }
        if (errCode != null) {
            LOG.log(Level.INFO, "Server calls back after \"{0}\" with error code \"{1}\"",
                    new Object[] { serverCall.getLabel(), errCode });
        } else {
            LOG.log(Level.INFO, "Server calls back after \"{0}\"",
                    new Object[] { serverCall.getLabel(), errCode });
        }
        callbackHandler = new CallbackHandler(data, errCode);
    }
    callbackHandler.handle(ServerCallId.valueOf(method));
}

From source file:com.sun.grizzly.http.jk.server.JkMain.java

public void setPropertyString(String handlerN, String name, String val) {
    if (LoggerUtils.getLogger().isLoggable(Level.FINEST)) {
        LoggerUtils.getLogger().log(Level.FINEST, "setProperty " + handlerN + " " + name + "=" + val);
    }//from w w w .j a  v a  2  s .  co m
    Object target = getWorkerEnv().getHandler(handlerN);

    setBeanProperty(target, name, val);
    if (started) {
        saveProperties();
    }

}

From source file:org.apache.bval.jsr.xml.ValidationParser.java

private static void applyMappingStreams(ValidationConfigType xmlConfig, ConfigurationImpl target) {
    for (String rawMappingFileName : xmlConfig.getConstraintMapping()) {
        String mappingFileName = rawMappingFileName;
        if (mappingFileName.startsWith("/")) {
            // Classloader needs a path without a starting /
            mappingFileName = mappingFileName.substring(1);
        }//from   ww w  . ja  va2 s.co  m
        log.log(Level.FINEST, String.format("Trying to open input stream for %s", mappingFileName));
        InputStream in;
        try {
            in = getInputStream(mappingFileName);
            if (in == null) {
                throw new ValidationException(
                        "Unable to open input stream for mapping file " + mappingFileName);
            }
        } catch (IOException e) {
            throw new ValidationException("Unable to open input stream for mapping file " + mappingFileName, e);
        }
        target.addMapping(in);
    }
}

From source file:com.ibm.team.build.internal.hjplugin.util.Helper.java

/**
 * This method first checks whether the given <param>jobParameter</param> exists and is not null
 * If yes, then its value is returned. Otherwise, it checks whether <param>value</param> is actually
 * a job property. If yes and <param>resolveValue</param> is true, it is resolved and returned. 
 * Otherwise, the <param>value</param> is returned
 * @param build//from  w ww  . j  av a2 s .c  o m
 * @param jobParameter the job parameter to look for the value first. may be <code>null</code>
 * @param value
 * @param listener
 * @return the value of the parameter 
 * @throws IOException
 * @throws InterruptedException
 */
public static String parseConfigurationValue(Run<?, ?> build, String jobParameter, String value,
        TaskListener listener) throws IOException, InterruptedException {
    // If a Job parameter exists and not null, then return it
    if (jobParameter != null) {
        String jobParameterValue = getStringBuildParameter(build, jobParameter, listener);
        if (jobParameterValue != null) {
            return jobParameterValue;
        }
    }

    // First trim the value
    value = Util.fixEmptyAndTrim(value);
    if (value == null) {
        return null;
    }

    // If jobParameterValue is null, check whether value itself is a job parameter
    // if it is and paramValue is not null, then return paramValue
    // otherwise just return the value provided in the job configuration as is.
    String paramValue = value;
    if (Helper.isAParameter(value)) {
        paramValue = Helper.resolveBuildParameter(build, value, listener);
        if (paramValue != null) {
            if (LOGGER.isLoggable(Level.FINEST)) {
                LOGGER.finest("Found value for job parameter '" + value + "' : " + paramValue);
            }
        } else {
            paramValue = value;
        }
    }
    // Our value is not a parameter, return it trimmed (see above where we have trimmed 'value')
    return paramValue;
}

From source file:com.npower.dm.server.session.ManagementSessionHandler.java

/**
 * Processes the given message. See the class description for more
 * information.//from w  w  w.  j  ava  2s.  c  o  m
 *
 * @param message the message to be processed
 *
 * @return the response message
 *
 * @throws ProtocolException in case of a protocol error
 * @throws InvalidCredentialsException in case of invalid credentials
 * @throws ServerFailureException in case of an internal server error
 */
public SyncML processMessage(SyncML message, HttpServletRequest httpRequest)
        throws ProtocolException, InvalidCredentialsException, ServerFailureException {
    String deviceId = null;
    SyncML response = null;

    //
    // Reset the cmdIdGenerator has specified in the spec
    //
    resetIdGenerator();

    //
    // Each time a message is received for a particular session adjust the message ID
    //
    msgIdGenerator.next();

    //
    //  We maintain the message Id from client
    //
    sessionState.lastMsgIdFromClient = message.getSyncHdr().getMsgID();

    //
    // Initialize the device ID from the client request.
    //
    deviceId = message.getSyncHdr().getSource().getLocURI();

    if (log.isLoggable(Level.FINEST)) {
        log.finest("device id: " + deviceId);
        log.finest("current state: " + getStateName(currentState));
    }
    //
    // Set maximum message size
    //
    Meta meta = message.getSyncHdr().getMeta();
    if (meta != null) {
        Long maxMsgSize = meta.getMaxMsgSize();
        if (maxMsgSize != null) {
            sessionState.setMaxMsgSize(maxMsgSize.longValue());
        }

        Long maxObjSize = meta.getMaxObjSize();
        if (maxObjSize != null) {
            sessionState.setMaxObjSize(maxObjSize.longValue());
        }
    }

    try {
        switch (currentState) {
        case STATE_ERROR: // in case of error you can start a new initialization
        case STATE_END:
        case STATE_START:
        case STATE_CLIENT_UNAUTHORIZED:
            sessionState.reset();

            sessionState.nextTimestamp = new SyncTimestamp(System.currentTimeMillis());

            //
            // Read device information. Use this information with care
            // until the client has been authenticated.
            //
            sessionState.device = new Sync4jDevice(deviceId);
            engine.readDevice(sessionState.device);

            sessionState.syncMLVerProto = message.getSyncHdr().getVerProto();
            this.engine.setSyncMLVerProto(sessionState.syncMLVerProto.getVersion());

            if (currentState != STATE_CLIENT_UNAUTHORIZED) {
                moveTo(STATE_INITIALIZATION_PROCESSING);
            }
        case STATE_INITIALIZATION_PROCESSING:
            //
            // Skip authentication if already authenticated
            //
            if (!isAuthenticated()) {

                //
                // Check if the client has sent the credentials with a
                // authentication type supported by the server
                //
                Cred cred = message.getSyncHdr().getCred();
                if (!checkAuthType(cred)) {
                    //
                    // the client uses an authentication type different
                    // from the server authentication type
                    //
                    sessionState.loggedCredential = null;
                } else {
                    login(cred, deviceId);

                    if (isAuthenticated()) {
                        try {
                            engine.readPrincipal(sessionState.loggedPrincipal);
                        } catch (NotFoundException e) {
                            if (log.isLoggable(Level.INFO)) {
                                log.info("Authenticated principal not found: " + sessionState.loggedPrincipal);
                            }
                            sessionState.authenticationState = AUTH_INVALID_CREDENTIALS;
                            sessionState.loggedCredential = null;
                        }
                    }
                }
            }

            boolean clientAuthenticated = isAuthenticated();
            boolean chalNotRequired = false;

            if (!clientAuthenticated && (currentState == STATE_CLIENT_UNAUTHORIZED)) {
                //
                // If the client isn't authenticated for the second time,
                // no chal must be sent from the server
                //
                chalNotRequired = true;
            }

            response = processInitMessage(message, chalNotRequired);

            if (!clientAuthenticated) {
                if (currentState == STATE_CLIENT_UNAUTHORIZED) {
                    response.setLastMessage(true);
                    moveTo(STATE_ERROR);
                } else {
                    moveTo(STATE_CLIENT_UNAUTHORIZED);
                }
                break;
            }

            if (message.getSyncBody().isFinalMsg()) {
                moveTo(STATE_INITIALIZATION_PROCESSED);
            } else {
                break;
            }

        case STATE_INITIALIZATION_PROCESSED:
            //
            // If the client did not authenticate the server, we have to
            // set the credentials once more if the authentication type
            // is MD5 or stop the processing otherwise
            //
            checkServerAuthentication(message);

            if ((sessionState.started == false)
                    || ((sessionState.serverAuthenticationState != AUTH_AUTHENTICATED)
                            && (sessionState.serverAuthenticationState != AUTH_ACCEPTED))) {
                init.setFlag(Flags.FLAG_FINAL_MESSAGE);

                // if addAbsCmd != null means that
                // the server have already sent to the client the command,
                // in previous message
                // but the client not have authenticate the server. So,
                // re-add the addAbsCmd to the cache. Before re-add the commands,
                // we checks if there is one command splitted. If  happens,
                // we merge data command with data splitted (splittedData in
                // sessionState)
                //
                if (addAbsCmd != null) {
                    if (sessionState.getSplittedCommand() != null) {
                        if (addAbsCmd.contains(sessionState.getSplittedCommand())) {
                            mergeData();
                            sessionState.setSplittedCommand(null);
                            sessionState.setNextDataToSend(null);
                        }
                    }
                    sessionState.addCmdOut(0, addAbsCmd);
                }

                // re-set the ManagementInitialization with the clientCommand
                AbstractCommand[] allClientCommands = (AbstractCommand[]) (message.getSyncBody()).getCommands()
                        .toArray(new AbstractCommand[0]);

                init.addClientCommand(allClientCommands);

                response = startManagementSession(message, httpRequest);

                if (init.isSessionAbortRequired()) {
                    // session abort

                    if (log.isLoggable(Level.INFO)) {
                        log.info("Session aborted by client");
                    }

                    response.setLastMessage(true);
                    sessionState.nextTimestamp.end = System.currentTimeMillis();
                    sessionState.dmstate.state = DeviceDMState.STATE_ABORTED;
                    endSession();
                    moveTo(STATE_SESSION_ABORTED);
                    break;
                }

                sessionState.started = true;

                if (ProtocolUtil.noMoreResponse(response)) {
                    moveTo(STATE_MANAGEMENT_COMPLETION);
                    sessionState.nextTimestamp.end = System.currentTimeMillis();
                    endSession();
                    moveTo(STATE_END);
                }
                break;
            } else {
                moveTo(STATE_MANAGEMENT_PROCESSING);
            }

        case STATE_MANAGEMENT_PROCESSING:

            response = processManagementMessage(message);

            if (actions.isSessionAbortRequired()) {
                // session abort

                if (log.isLoggable(Level.INFO)) {
                    log.info("Session aborted by client");
                }

                response.setLastMessage(true);
                sessionState.nextTimestamp.end = System.currentTimeMillis();
                sessionState.dmstate.state = DeviceDMState.STATE_ABORTED;
                endSession();
                moveTo(STATE_SESSION_ABORTED);

                break;
            }

            if (ProtocolUtil.noMoreResponse(response)) {
                moveTo(STATE_MANAGEMENT_PROCESSED);
                moveTo(STATE_MANAGEMENT_COMPLETION);
            } else {
                break;
            }

        case STATE_MANAGEMENT_COMPLETION:
            sessionState.nextTimestamp.end = System.currentTimeMillis();

            response.setLastMessage(true);

            endSession();

            moveTo(STATE_END);
            break;

        default:
            endSession();
            throw new ProtocolException(
                    "Illegal state: " + getStateName(currentState) + '(' + currentState + ')');
        }
    } catch (ProtocolException e) {
        if (sessionState.dmstate != null) {
            sessionState.dmstate.state = DeviceDMState.STATE_ERROR;
        }
        endSession();
        log.throwing(getClass().getName(), "processMessage", e);
        moveTo(STATE_ERROR);
        throw e;
    } catch (NotFoundException e) {
        if (sessionState.dmstate != null) {
            sessionState.dmstate.state = DeviceDMState.STATE_ERROR;
        }
        endSession();
        log.throwing(getClass().getName(), "processMessage", e);
        moveTo(STATE_ERROR);
        throw new InvalidCredentialsException("Invalid credential error", e);
    } catch (PersistentStoreException e) {
        if (sessionState.dmstate != null) {
            sessionState.dmstate.state = DeviceDMState.STATE_ERROR;
        }
        endSession();
        log.throwing(getClass().getName(), "processMessage", e);
        moveTo(STATE_ERROR);
        throw new ServerFailureException("Persistent store error", e);
    } catch (ManagementException e) {
        if (sessionState.dmstate != null) {
            sessionState.dmstate.state = DeviceDMState.STATE_ERROR;
        }
        endSession();
        log.throwing(getClass().getName(), "processMessage", e);
        moveTo(STATE_ERROR);
        throw new ServerFailureException("Management error", e);
    } catch (Throwable t) {
        if (sessionState.dmstate != null) {
            sessionState.dmstate.state = DeviceDMState.STATE_ERROR;
        }
        endSession();
        log.throwing(getClass().getName(), "processMessage", t);
        moveTo(STATE_ERROR);
    }

    List<AbstractCommand> commands = response.getSyncBody().getCommands();
    ProtocolUtil.updateCmdId(commands);

    //
    // In order to handle the Status sent by the client as result of the
    // commands, we have to store the ManagementCommandDescriptors for the
    // sent management commands
    //
    storeManagementCommandDescriptorForManagementCommands(msgIdGenerator.current(), commands);

    return response;
}