Example usage for java.io OptionalDataException getMessage

List of usage examples for java.io OptionalDataException getMessage

Introduction

In this page you can find the example usage for java.io OptionalDataException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.sun.faces.renderkit.ResponseStateManagerImpl.java

public Object getTreeStructureToRestore(FacesContext context, String treeId) {
    StateManager stateManager = Util.getStateManager(context);

    Object structure = null;/*from   w w  w. j a  v  a2s . com*/
    Object state = null;
    ByteArrayInputStream bis = null;
    GZIPInputStream gis = null;
    ObjectInputStream ois = null;
    boolean compress = isCompressStateSet(context);

    Map requestParamMap = context.getExternalContext().getRequestParameterMap();

    String viewString = (String) requestParamMap.get(RIConstants.FACES_VIEW);
    if (viewString == null) {
        return null;
    }
    if (stateManager.isSavingStateInClient(context)) {
        byte[] bytes = Base64.decode(viewString.getBytes());
        try {
            bis = new ByteArrayInputStream(bytes);
            if (isCompressStateSet(context)) {
                if (log.isDebugEnabled()) {
                    log.debug("Deflating state before restoring..");
                }
                gis = new GZIPInputStream(bis);
                ois = new ApplicationObjectInputStream(gis);
            } else {
                ois = new ApplicationObjectInputStream(bis);
            }
            structure = ois.readObject();
            state = ois.readObject();
            Map requestMap = context.getExternalContext().getRequestMap();
            // store the state object temporarily in request scope until it is
            // processed by getComponentStateToRestore which resets it.
            requestMap.put(FACES_VIEW_STATE, state);
            bis.close();
            if (compress) {
                gis.close();
            }
            ois.close();
        } catch (java.io.OptionalDataException ode) {
            log.error(ode.getMessage(), ode);
            throw new FacesException(ode);
        } catch (java.lang.ClassNotFoundException cnfe) {
            log.error(cnfe.getMessage(), cnfe);
            throw new FacesException(cnfe);
        } catch (java.io.IOException iox) {
            log.error(iox.getMessage(), iox);
            throw new FacesException(iox);
        }
    } else {
        structure = viewString;
    }
    return structure;
}