Example usage for com.liferay.portal.kernel.io.unsync UnsyncByteArrayOutputStream size

List of usage examples for com.liferay.portal.kernel.io.unsync UnsyncByteArrayOutputStream size

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.io.unsync UnsyncByteArrayOutputStream size.

Prototype

public int size() 

Source Link

Usage

From source file:at.bibbox.reactjsservice.service.ClpSerializer.java

License:Open Source License

public static Throwable translateThrowable(Throwable throwable) {
    if (_useReflectionToTranslateThrowable) {
        try {//w  w w.j av  a2  s.co m
            UnsyncByteArrayOutputStream unsyncByteArrayOutputStream = new UnsyncByteArrayOutputStream();
            ObjectOutputStream objectOutputStream = new ObjectOutputStream(unsyncByteArrayOutputStream);

            objectOutputStream.writeObject(throwable);

            objectOutputStream.flush();
            objectOutputStream.close();

            UnsyncByteArrayInputStream unsyncByteArrayInputStream = new UnsyncByteArrayInputStream(
                    unsyncByteArrayOutputStream.unsafeGetByteArray(), 0, unsyncByteArrayOutputStream.size());

            Thread currentThread = Thread.currentThread();

            ClassLoader contextClassLoader = currentThread.getContextClassLoader();

            ObjectInputStream objectInputStream = new ClassLoaderObjectInputStream(unsyncByteArrayInputStream,
                    contextClassLoader);

            throwable = (Throwable) objectInputStream.readObject();

            objectInputStream.close();

            return throwable;
        } catch (SecurityException se) {
            if (_log.isInfoEnabled()) {
                _log.info("Do not use reflection to translate throwable");
            }

            _useReflectionToTranslateThrowable = false;
        } catch (Throwable throwable2) {
            _log.error(throwable2, throwable2);

            return throwable2;
        }
    }

    Class<?> clazz = throwable.getClass();

    String className = clazz.getName();

    if (className.equals(PortalException.class.getName())) {
        return new PortalException();
    }

    if (className.equals(SystemException.class.getName())) {
        return new SystemException();
    }

    if (className.equals("at.bibbox.reactjsservice.NoSuchToolInformationException")) {
        return new at.bibbox.reactjsservice.NoSuchToolInformationException();
    }

    return throwable;
}

From source file:at.graz.hmmc.liferay.portlet.puch.service.ClpSerializer.java

License:Open Source License

public static Throwable translateThrowable(Throwable throwable) {
    if (_useReflectionToTranslateThrowable) {
        try {//from  w w  w  .j a v  a 2 s.  c o m
            UnsyncByteArrayOutputStream unsyncByteArrayOutputStream = new UnsyncByteArrayOutputStream();
            ObjectOutputStream objectOutputStream = new ObjectOutputStream(unsyncByteArrayOutputStream);

            objectOutputStream.writeObject(throwable);

            objectOutputStream.flush();
            objectOutputStream.close();

            UnsyncByteArrayInputStream unsyncByteArrayInputStream = new UnsyncByteArrayInputStream(
                    unsyncByteArrayOutputStream.unsafeGetByteArray(), 0, unsyncByteArrayOutputStream.size());

            Thread currentThread = Thread.currentThread();

            ClassLoader contextClassLoader = currentThread.getContextClassLoader();

            ObjectInputStream objectInputStream = new ClassLoaderObjectInputStream(unsyncByteArrayInputStream,
                    contextClassLoader);

            throwable = (Throwable) objectInputStream.readObject();

            objectInputStream.close();

            return throwable;
        } catch (SecurityException se) {
            if (_log.isInfoEnabled()) {
                _log.info("Do not use reflection to translate throwable");
            }

            _useReflectionToTranslateThrowable = false;
        } catch (Throwable throwable2) {
            _log.error(throwable2, throwable2);

            return throwable2;
        }
    }

    Class<?> clazz = throwable.getClass();

    String className = clazz.getName();

    if (className.equals(PortalException.class.getName())) {
        return new PortalException();
    }

    if (className.equals(SystemException.class.getName())) {
        return new SystemException();
    }

    if (className.equals("at.graz.hmmc.liferay.portlet.puch.NoSuchConfigurationException")) {
        return new at.graz.hmmc.liferay.portlet.puch.NoSuchConfigurationException();
    }

    if (className.equals("at.graz.hmmc.liferay.portlet.puch.NoSuchObjectDataException")) {
        return new at.graz.hmmc.liferay.portlet.puch.NoSuchObjectDataException();
    }

    if (className.equals("at.graz.hmmc.liferay.portlet.puch.NoSuchObjectImageException")) {
        return new at.graz.hmmc.liferay.portlet.puch.NoSuchObjectImageException();
    }

    if (className.equals("at.graz.hmmc.liferay.portlet.puch.NoSuchParameterConfigurationException")) {
        return new at.graz.hmmc.liferay.portlet.puch.NoSuchParameterConfigurationException();
    }

    if (className.equals("at.graz.hmmc.liferay.portlet.puch.NoSuchParameterOptionsConfigurationException")) {
        return new at.graz.hmmc.liferay.portlet.puch.NoSuchParameterOptionsConfigurationException();
    }

    if (className.equals("at.graz.hmmc.liferay.portlet.puch.NoSuchPersonException")) {
        return new at.graz.hmmc.liferay.portlet.puch.NoSuchPersonException();
    }

    if (className.equals("at.graz.hmmc.liferay.portlet.puch.NoSuchPuchMuseumsObjektException")) {
        return new at.graz.hmmc.liferay.portlet.puch.NoSuchPuchMuseumsObjektException();
    }

    if (className.equals("at.graz.hmmc.liferay.portlet.puch.NoSuchTransaktionException")) {
        return new at.graz.hmmc.liferay.portlet.puch.NoSuchTransaktionException();
    }

    if (className.equals("at.graz.hmmc.liferay.portlet.puch.NoSuchTransaktionDataException")) {
        return new at.graz.hmmc.liferay.portlet.puch.NoSuchTransaktionDataException();
    }

    return throwable;
}

From source file:at.graz.meduni.bibbox.liferay.portlet.service.ClpSerializer.java

License:Open Source License

public static Throwable translateThrowable(Throwable throwable) {
    if (_useReflectionToTranslateThrowable) {
        try {//  w  ww  .  j  ava2  s.  co  m
            UnsyncByteArrayOutputStream unsyncByteArrayOutputStream = new UnsyncByteArrayOutputStream();
            ObjectOutputStream objectOutputStream = new ObjectOutputStream(unsyncByteArrayOutputStream);

            objectOutputStream.writeObject(throwable);

            objectOutputStream.flush();
            objectOutputStream.close();

            UnsyncByteArrayInputStream unsyncByteArrayInputStream = new UnsyncByteArrayInputStream(
                    unsyncByteArrayOutputStream.unsafeGetByteArray(), 0, unsyncByteArrayOutputStream.size());

            Thread currentThread = Thread.currentThread();

            ClassLoader contextClassLoader = currentThread.getContextClassLoader();

            ObjectInputStream objectInputStream = new ClassLoaderObjectInputStream(unsyncByteArrayInputStream,
                    contextClassLoader);

            throwable = (Throwable) objectInputStream.readObject();

            objectInputStream.close();

            return throwable;
        } catch (ClassNotFoundException cnfe) {
            if (_log.isInfoEnabled()) {
                _log.info("Do not use reflection to translate throwable");
            }

            _useReflectionToTranslateThrowable = false;
        } catch (SecurityException se) {
            if (_log.isInfoEnabled()) {
                _log.info("Do not use reflection to translate throwable");
            }

            _useReflectionToTranslateThrowable = false;
        } catch (Throwable throwable2) {
            _log.error(throwable2, throwable2);

            return throwable2;
        }
    }

    Class<?> clazz = throwable.getClass();

    String className = clazz.getName();

    if (className
            .equals("at.graz.meduni.bibbox.liferay.portlet.exception.NoSuchApplicationInstanceException")) {
        return new at.graz.meduni.bibbox.liferay.portlet.exception.NoSuchApplicationInstanceException(
                throwable.getMessage(), throwable.getCause());
    }

    if (className.equals(
            "at.graz.meduni.bibbox.liferay.portlet.exception.NoSuchApplicationInstanceContainerException")) {
        return new at.graz.meduni.bibbox.liferay.portlet.exception.NoSuchApplicationInstanceContainerException(
                throwable.getMessage(), throwable.getCause());
    }

    if (className
            .equals("at.graz.meduni.bibbox.liferay.portlet.exception.NoSuchApplicationInstancePortException")) {
        return new at.graz.meduni.bibbox.liferay.portlet.exception.NoSuchApplicationInstancePortException(
                throwable.getMessage(), throwable.getCause());
    }

    if (className.equals(
            "at.graz.meduni.bibbox.liferay.portlet.exception.NoSuchApplicationInstanceStatusException")) {
        return new at.graz.meduni.bibbox.liferay.portlet.exception.NoSuchApplicationInstanceStatusException(
                throwable.getMessage(), throwable.getCause());
    }

    return throwable;
}

From source file:at.graz.meduni.liferay.api.service.ClpSerializer.java

License:Open Source License

public static Throwable translateThrowable(Throwable throwable) {
    if (_useReflectionToTranslateThrowable) {
        try {//from   w  ww .j  a  v a2 s . c  o  m
            UnsyncByteArrayOutputStream unsyncByteArrayOutputStream = new UnsyncByteArrayOutputStream();
            ObjectOutputStream objectOutputStream = new ObjectOutputStream(unsyncByteArrayOutputStream);

            objectOutputStream.writeObject(throwable);

            objectOutputStream.flush();
            objectOutputStream.close();

            UnsyncByteArrayInputStream unsyncByteArrayInputStream = new UnsyncByteArrayInputStream(
                    unsyncByteArrayOutputStream.unsafeGetByteArray(), 0, unsyncByteArrayOutputStream.size());

            Thread currentThread = Thread.currentThread();

            ClassLoader contextClassLoader = currentThread.getContextClassLoader();

            ObjectInputStream objectInputStream = new ClassLoaderObjectInputStream(unsyncByteArrayInputStream,
                    contextClassLoader);

            throwable = (Throwable) objectInputStream.readObject();

            objectInputStream.close();

            return throwable;
        } catch (SecurityException se) {
            if (_log.isInfoEnabled()) {
                _log.info("Do not use reflection to translate throwable");
            }

            _useReflectionToTranslateThrowable = false;
        } catch (Throwable throwable2) {
            _log.error(throwable2, throwable2);

            return throwable2;
        }
    }

    Class<?> clazz = throwable.getClass();

    String className = clazz.getName();

    if (className.equals(PortalException.class.getName())) {
        return new PortalException();
    }

    if (className.equals(SystemException.class.getName())) {
        return new SystemException();
    }

    if (className.equals("at.graz.meduni.liferay.api.NoSuchrdconnectException")) {
        return new at.graz.meduni.liferay.api.NoSuchrdconnectException();
    }

    return throwable;
}

From source file:at.graz.meduni.liferay.portlet.bbmriat.service.service.ClpSerializer.java

License:Open Source License

public static Throwable translateThrowable(Throwable throwable) {
    if (_useReflectionToTranslateThrowable) {
        try {/*from  ww w. j  av  a  2s .  co  m*/
            UnsyncByteArrayOutputStream unsyncByteArrayOutputStream = new UnsyncByteArrayOutputStream();
            ObjectOutputStream objectOutputStream = new ObjectOutputStream(unsyncByteArrayOutputStream);

            objectOutputStream.writeObject(throwable);

            objectOutputStream.flush();
            objectOutputStream.close();

            UnsyncByteArrayInputStream unsyncByteArrayInputStream = new UnsyncByteArrayInputStream(
                    unsyncByteArrayOutputStream.unsafeGetByteArray(), 0, unsyncByteArrayOutputStream.size());

            Thread currentThread = Thread.currentThread();

            ClassLoader contextClassLoader = currentThread.getContextClassLoader();

            ObjectInputStream objectInputStream = new ClassLoaderObjectInputStream(unsyncByteArrayInputStream,
                    contextClassLoader);

            throwable = (Throwable) objectInputStream.readObject();

            objectInputStream.close();

            return throwable;
        } catch (SecurityException se) {
            if (_log.isInfoEnabled()) {
                _log.info("Do not use reflection to translate throwable");
            }

            _useReflectionToTranslateThrowable = false;
        } catch (Throwable throwable2) {
            _log.error(throwable2, throwable2);

            return throwable2;
        }
    }

    Class<?> clazz = throwable.getClass();

    String className = clazz.getName();

    if (className.equals(PortalException.class.getName())) {
        return new PortalException();
    }

    if (className.equals(SystemException.class.getName())) {
        return new SystemException();
    }

    if (className.equals("at.graz.meduni.liferay.portlet.bbmriat.service.NoSuchOrganizationlinkException")) {
        return new at.graz.meduni.liferay.portlet.bbmriat.service.NoSuchOrganizationlinkException();
    }

    return throwable;
}

From source file:at.graz.meduni.liferay.portlet.bibbox.kdssmp.service.service.ClpSerializer.java

License:Open Source License

public static Throwable translateThrowable(Throwable throwable) {
    if (_useReflectionToTranslateThrowable) {
        try {/*from  www  .  j a  v  a2  s .  c  o m*/
            UnsyncByteArrayOutputStream unsyncByteArrayOutputStream = new UnsyncByteArrayOutputStream();
            ObjectOutputStream objectOutputStream = new ObjectOutputStream(unsyncByteArrayOutputStream);

            objectOutputStream.writeObject(throwable);

            objectOutputStream.flush();
            objectOutputStream.close();

            UnsyncByteArrayInputStream unsyncByteArrayInputStream = new UnsyncByteArrayInputStream(
                    unsyncByteArrayOutputStream.unsafeGetByteArray(), 0, unsyncByteArrayOutputStream.size());

            Thread currentThread = Thread.currentThread();

            ClassLoader contextClassLoader = currentThread.getContextClassLoader();

            ObjectInputStream objectInputStream = new ClassLoaderObjectInputStream(unsyncByteArrayInputStream,
                    contextClassLoader);

            throwable = (Throwable) objectInputStream.readObject();

            objectInputStream.close();

            return throwable;
        } catch (SecurityException se) {
            if (_log.isInfoEnabled()) {
                _log.info("Do not use reflection to translate throwable");
            }

            _useReflectionToTranslateThrowable = false;
        } catch (Throwable throwable2) {
            _log.error(throwable2, throwable2);

            return throwable2;
        }
    }

    Class<?> clazz = throwable.getClass();

    String className = clazz.getName();

    if (className.equals(PortalException.class.getName())) {
        return new PortalException();
    }

    if (className.equals(SystemException.class.getName())) {
        return new SystemException();
    }

    if (className.equals("at.graz.meduni.liferay.portlet.bibbox.kdssmp.service.NoSuchEventException")) {
        return new at.graz.meduni.liferay.portlet.bibbox.kdssmp.service.NoSuchEventException();
    }

    if (className.equals("at.graz.meduni.liferay.portlet.bibbox.kdssmp.service.NoSuchEventDataException")) {
        return new at.graz.meduni.liferay.portlet.bibbox.kdssmp.service.NoSuchEventDataException();
    }

    if (className.equals(
            "at.graz.meduni.liferay.portlet.bibbox.kdssmp.service.NoSuchKdssmpConfigurationException")) {
        return new at.graz.meduni.liferay.portlet.bibbox.kdssmp.service.NoSuchKdssmpConfigurationException();
    }

    if (className.equals(
            "at.graz.meduni.liferay.portlet.bibbox.kdssmp.service.NoSuchKdssmpParameterConfigurationException")) {
        return new at.graz.meduni.liferay.portlet.bibbox.kdssmp.service.NoSuchKdssmpParameterConfigurationException();
    }

    if (className.equals(
            "at.graz.meduni.liferay.portlet.bibbox.kdssmp.service.NoSuchKdssmpParameterOptionsException")) {
        return new at.graz.meduni.liferay.portlet.bibbox.kdssmp.service.NoSuchKdssmpParameterOptionsException();
    }

    if (className.equals("at.graz.meduni.liferay.portlet.bibbox.kdssmp.service.NoSuchKdssmpPatientException")) {
        return new at.graz.meduni.liferay.portlet.bibbox.kdssmp.service.NoSuchKdssmpPatientException();
    }

    if (className.equals("at.graz.meduni.liferay.portlet.bibbox.kdssmp.service.NoSuchKdssmpRulesException")) {
        return new at.graz.meduni.liferay.portlet.bibbox.kdssmp.service.NoSuchKdssmpRulesException();
    }

    if (className.equals(
            "at.graz.meduni.liferay.portlet.bibbox.kdssmp.service.NoSuchpatientnamegeneratorException")) {
        return new at.graz.meduni.liferay.portlet.bibbox.kdssmp.service.NoSuchpatientnamegeneratorException();
    }

    return throwable;
}

From source file:at.graz.meduni.liferay.portlet.bibbox.rdconnect.service.service.ClpSerializer.java

License:Open Source License

public static Throwable translateThrowable(Throwable throwable) {
    if (_useReflectionToTranslateThrowable) {
        try {//from  ww  w  .  ja v  a  2s.  c o m
            UnsyncByteArrayOutputStream unsyncByteArrayOutputStream = new UnsyncByteArrayOutputStream();
            ObjectOutputStream objectOutputStream = new ObjectOutputStream(unsyncByteArrayOutputStream);

            objectOutputStream.writeObject(throwable);

            objectOutputStream.flush();
            objectOutputStream.close();

            UnsyncByteArrayInputStream unsyncByteArrayInputStream = new UnsyncByteArrayInputStream(
                    unsyncByteArrayOutputStream.unsafeGetByteArray(), 0, unsyncByteArrayOutputStream.size());

            Thread currentThread = Thread.currentThread();

            ClassLoader contextClassLoader = currentThread.getContextClassLoader();

            ObjectInputStream objectInputStream = new ClassLoaderObjectInputStream(unsyncByteArrayInputStream,
                    contextClassLoader);

            throwable = (Throwable) objectInputStream.readObject();

            objectInputStream.close();

            return throwable;
        } catch (SecurityException se) {
            if (_log.isInfoEnabled()) {
                _log.info("Do not use reflection to translate throwable");
            }

            _useReflectionToTranslateThrowable = false;
        } catch (Throwable throwable2) {
            _log.error(throwable2, throwable2);

            return throwable2;
        }
    }

    Class<?> clazz = throwable.getClass();

    String className = clazz.getName();

    if (className.equals(PortalException.class.getName())) {
        return new PortalException();
    }

    if (className.equals(SystemException.class.getName())) {
        return new SystemException();
    }

    if (className
            .equals("at.graz.meduni.liferay.portlet.bibbox.rdconnect.service.NoSuchRDConnectEventException")) {
        return new at.graz.meduni.liferay.portlet.bibbox.rdconnect.service.NoSuchRDConnectEventException();
    }

    if (className.equals(
            "at.graz.meduni.liferay.portlet.bibbox.rdconnect.service.NoSuchRDConnectEventNotificationException")) {
        return new at.graz.meduni.liferay.portlet.bibbox.rdconnect.service.NoSuchRDConnectEventNotificationException();
    }

    return throwable;
}

From source file:at.graz.meduni.liferay.portlet.bibbox.service.ClpSerializer.java

License:Open Source License

public static Throwable translateThrowable(Throwable throwable) {
    if (_useReflectionToTranslateThrowable) {
        try {// w  w w.  j ava  2 s  .  co m
            UnsyncByteArrayOutputStream unsyncByteArrayOutputStream = new UnsyncByteArrayOutputStream();
            ObjectOutputStream objectOutputStream = new ObjectOutputStream(unsyncByteArrayOutputStream);

            objectOutputStream.writeObject(throwable);

            objectOutputStream.flush();
            objectOutputStream.close();

            UnsyncByteArrayInputStream unsyncByteArrayInputStream = new UnsyncByteArrayInputStream(
                    unsyncByteArrayOutputStream.unsafeGetByteArray(), 0, unsyncByteArrayOutputStream.size());

            Thread currentThread = Thread.currentThread();

            ClassLoader contextClassLoader = currentThread.getContextClassLoader();

            ObjectInputStream objectInputStream = new ClassLoaderObjectInputStream(unsyncByteArrayInputStream,
                    contextClassLoader);

            throwable = (Throwable) objectInputStream.readObject();

            objectInputStream.close();

            return throwable;
        } catch (SecurityException se) {
            if (_log.isInfoEnabled()) {
                _log.info("Do not use reflection to translate throwable");
            }

            _useReflectionToTranslateThrowable = false;
        } catch (Throwable throwable2) {
            _log.error(throwable2, throwable2);

            return throwable2;
        }
    }

    Class<?> clazz = throwable.getClass();

    String className = clazz.getName();

    if (className.equals(PortalException.class.getName())) {
        return new PortalException();
    }

    if (className.equals(SystemException.class.getName())) {
        return new SystemException();
    }

    if (className.equals("at.graz.meduni.liferay.portlet.bibbox.NoSuchDDLConfigurationException")) {
        return new at.graz.meduni.liferay.portlet.bibbox.NoSuchDDLConfigurationException();
    }

    if (className.equals("at.graz.meduni.liferay.portlet.bibbox.NoSuchGeneException")) {
        return new at.graz.meduni.liferay.portlet.bibbox.NoSuchGeneException();
    }

    if (className.equals("at.graz.meduni.liferay.portlet.bibbox.NoSuchGeneLocusException")) {
        return new at.graz.meduni.liferay.portlet.bibbox.NoSuchGeneLocusException();
    }

    if (className.equals("at.graz.meduni.liferay.portlet.bibbox.NoSuchGeneReferenceException")) {
        return new at.graz.meduni.liferay.portlet.bibbox.NoSuchGeneReferenceException();
    }

    if (className.equals("at.graz.meduni.liferay.portlet.bibbox.NoSuchGeneSynonymException")) {
        return new at.graz.meduni.liferay.portlet.bibbox.NoSuchGeneSynonymException();
    }

    if (className.equals("at.graz.meduni.liferay.portlet.bibbox.NoSuchIconConfigurationException")) {
        return new at.graz.meduni.liferay.portlet.bibbox.NoSuchIconConfigurationException();
    }

    if (className.equals("at.graz.meduni.liferay.portlet.bibbox.NoSuchIconsException")) {
        return new at.graz.meduni.liferay.portlet.bibbox.NoSuchIconsException();
    }

    if (className.equals("at.graz.meduni.liferay.portlet.bibbox.NoSuchOrganizationSearchIndexException")) {
        return new at.graz.meduni.liferay.portlet.bibbox.NoSuchOrganizationSearchIndexException();
    }

    if (className.equals("at.graz.meduni.liferay.portlet.bibbox.NoSuchOrphanetDisorderException")) {
        return new at.graz.meduni.liferay.portlet.bibbox.NoSuchOrphanetDisorderException();
    }

    if (className.equals("at.graz.meduni.liferay.portlet.bibbox.NoSuchOrphanetReferenceException")) {
        return new at.graz.meduni.liferay.portlet.bibbox.NoSuchOrphanetReferenceException();
    }

    if (className.equals("at.graz.meduni.liferay.portlet.bibbox.NoSuchOrphanetSynonymException")) {
        return new at.graz.meduni.liferay.portlet.bibbox.NoSuchOrphanetSynonymException();
    }

    if (className.equals("at.graz.meduni.liferay.portlet.bibbox.NoSuchSymbolConfigurationException")) {
        return new at.graz.meduni.liferay.portlet.bibbox.NoSuchSymbolConfigurationException();
    }

    if (className.equals("at.graz.meduni.liferay.portlet.bibbox.NoSuchSymbolTypeConfigurationException")) {
        return new at.graz.meduni.liferay.portlet.bibbox.NoSuchSymbolTypeConfigurationException();
    }

    return throwable;
}

From source file:at.graz.meduni.liferay.portlet.bibbox.service.service.ClpSerializer.java

License:Open Source License

public static Throwable translateThrowable(Throwable throwable) {
    if (_useReflectionToTranslateThrowable) {
        try {/*w w  w  .ja  va 2 s.  co m*/
            UnsyncByteArrayOutputStream unsyncByteArrayOutputStream = new UnsyncByteArrayOutputStream();
            ObjectOutputStream objectOutputStream = new ObjectOutputStream(unsyncByteArrayOutputStream);

            objectOutputStream.writeObject(throwable);

            objectOutputStream.flush();
            objectOutputStream.close();

            UnsyncByteArrayInputStream unsyncByteArrayInputStream = new UnsyncByteArrayInputStream(
                    unsyncByteArrayOutputStream.unsafeGetByteArray(), 0, unsyncByteArrayOutputStream.size());

            Thread currentThread = Thread.currentThread();

            ClassLoader contextClassLoader = currentThread.getContextClassLoader();

            ObjectInputStream objectInputStream = new ClassLoaderObjectInputStream(unsyncByteArrayInputStream,
                    contextClassLoader);

            throwable = (Throwable) objectInputStream.readObject();

            objectInputStream.close();

            return throwable;
        } catch (SecurityException se) {
            if (_log.isInfoEnabled()) {
                _log.info("Do not use reflection to translate throwable");
            }

            _useReflectionToTranslateThrowable = false;
        } catch (Throwable throwable2) {
            _log.error(throwable2, throwable2);

            return throwable2;
        }
    }

    Class<?> clazz = throwable.getClass();

    String className = clazz.getName();

    if (className.equals(PortalException.class.getName())) {
        return new PortalException();
    }

    if (className.equals(SystemException.class.getName())) {
        return new SystemException();
    }

    if (className.equals("at.graz.meduni.liferay.portlet.bibbox.service.NoSuchidcardException")) {
        return new at.graz.meduni.liferay.portlet.bibbox.service.NoSuchidcardException();
    }

    return throwable;
}

From source file:at.graz.meduni.liferay.portlet.saat.service.ClpSerializer.java

License:Open Source License

public static Throwable translateThrowable(Throwable throwable) {
    if (_useReflectionToTranslateThrowable) {
        try {/*from w w w  . j ava2s .  c o m*/
            UnsyncByteArrayOutputStream unsyncByteArrayOutputStream = new UnsyncByteArrayOutputStream();
            ObjectOutputStream objectOutputStream = new ObjectOutputStream(unsyncByteArrayOutputStream);

            objectOutputStream.writeObject(throwable);

            objectOutputStream.flush();
            objectOutputStream.close();

            UnsyncByteArrayInputStream unsyncByteArrayInputStream = new UnsyncByteArrayInputStream(
                    unsyncByteArrayOutputStream.unsafeGetByteArray(), 0, unsyncByteArrayOutputStream.size());

            Thread currentThread = Thread.currentThread();

            ClassLoader contextClassLoader = currentThread.getContextClassLoader();

            ObjectInputStream objectInputStream = new ClassLoaderObjectInputStream(unsyncByteArrayInputStream,
                    contextClassLoader);

            throwable = (Throwable) objectInputStream.readObject();

            objectInputStream.close();

            return throwable;
        } catch (SecurityException se) {
            if (_log.isInfoEnabled()) {
                _log.info("Do not use reflection to translate throwable");
            }

            _useReflectionToTranslateThrowable = false;
        } catch (Throwable throwable2) {
            _log.error(throwable2, throwable2);

            return throwable2;
        }
    }

    Class<?> clazz = throwable.getClass();

    String className = clazz.getName();

    if (className.equals(PortalException.class.getName())) {
        return new PortalException();
    }

    if (className.equals(SystemException.class.getName())) {
        return new SystemException();
    }

    if (className.equals("at.graz.meduni.liferay.portlet.saat.NoSuchDictionaryException")) {
        return new at.graz.meduni.liferay.portlet.saat.NoSuchDictionaryException();
    }

    if (className.equals("at.graz.meduni.liferay.portlet.saat.NoSuchDictionaryDictionaryLinkException")) {
        return new at.graz.meduni.liferay.portlet.saat.NoSuchDictionaryDictionaryLinkException();
    }

    if (className.equals("at.graz.meduni.liferay.portlet.saat.NoSuchICD10Exception")) {
        return new at.graz.meduni.liferay.portlet.saat.NoSuchICD10Exception();
    }

    if (className.equals("at.graz.meduni.liferay.portlet.saat.NoSuchICDO3Exception")) {
        return new at.graz.meduni.liferay.portlet.saat.NoSuchICDO3Exception();
    }

    if (className.equals("at.graz.meduni.liferay.portlet.saat.NoSuchSCGException")) {
        return new at.graz.meduni.liferay.portlet.saat.NoSuchSCGException();
    }

    return throwable;
}