Examples of HandleException


Examples of net.handle.hdllib.HandleException

        try
        {
            if (theHandle == null)
            {
                throw new HandleException(HandleException.INTERNAL_ERROR);
            }

            String handle = Util.decodeString(theHandle);

            context = new Context();

            String url = HandleManager.resolveToURL(context, handle);

            if (url == null)
            {
                throw new HandleException(HandleException.HANDLE_DOES_NOT_EXIST);
            }

            HandleValue value = new HandleValue();

            value.setIndex(100);
            value.setType(Util.encodeString("URL"));
            value.setData(Util.encodeString(url));
            value.setTTLType((byte) 0);
            value.setTTL(100);
            value.setTimestamp(100);
            value.setReferences(null);
            value.setAdminCanRead(true);
            value.setAdminCanWrite(false);
            value.setAnyoneCanRead(true);
            value.setAnyoneCanWrite(false);

            List values = new LinkedList();

            values.add(value);

            byte[][] rawValues = new byte[values.size()][];

            for (int i = 0; i < values.size(); i++)
            {
                HandleValue hvalue = (HandleValue) values.get(i);

                rawValues[i] = new byte[Encoder.calcStorageSize(hvalue)];
                Encoder.encodeHandleValue(rawValues[i], 0, hvalue);
            }

            return rawValues;
        }
        catch (HandleException he)
        {
            throw he;
        }
        catch (Exception e)
        {
            if (log.isDebugEnabled())
            {
                log.debug("Exception in getRawHandleValues", e);
            }

            throw new HandleException(HandleException.INTERNAL_ERROR);
        }
        finally
        {
            if (context != null)
            {
View Full Code Here

Examples of net.handle.hdllib.HandleException

            if (log.isDebugEnabled())
            {
                log.debug("Exception in getHandlesForNA", sqle);
            }

            throw new HandleException(HandleException.INTERNAL_ERROR);
        }
        finally
        {
            if (context != null)
            {
View Full Code Here

Examples of net.handle.hdllib.HandleException

        }
       
        // did we found any prefixes?
        if (this.prefixes.isEmpty())
        {
            throw new HandleException(HandleException.INTERNAL_ERROR,
                    "Unable to find configuration or to reach any DSpace instance.");
        }
       
        if (log.isInfoEnabled())
        {
View Full Code Here

Examples of net.handle.hdllib.HandleException

            log.info("Called getRawHandleValues");
        }

        if (theHandle == null)
        {
            throw new HandleException(HandleException.INTERNAL_ERROR);
        }

        String handle = Util.decodeString(theHandle);
        String url = getRemoteDSpaceURL(handle);
        HandleValue value = new HandleValue();
View Full Code Here

Examples of net.handle.hdllib.HandleException

            {
                if (log.isDebugEnabled())
                {
                    log.debug("Cannot find endpoint for prefix " + prefix + ", throw HANDLE_DOES_NOT_EXIST.");
                }
                throw new HandleException(HandleException.HANDLE_DOES_NOT_EXIST);
            }

            String jsonurl = endpoint + "/resolve/" + handle;
            jsonStreamReader = new InputStreamReader(
                    new URL(jsonurl).openStream(), "UTF-8");
            JsonParser parser = new JsonParser();
            JsonElement jsonElement = parser.parse(jsonStreamReader);

            if (jsonElement == null || jsonElement.isJsonNull()
                    || jsonElement.getAsJsonArray().size() == 0
                    || jsonElement.getAsJsonArray().get(0).isJsonNull())
            {
                if (log.isDebugEnabled())
                {
                    log.debug("Throw HandleException: HANDLE_DOES_NOT_EXIST.");
                }
                throw new HandleException(HandleException.HANDLE_DOES_NOT_EXIST);
            }

            url = jsonElement.getAsJsonArray().get(0).getAsString();
        }
        catch (Exception e)
        {
            if (log.isDebugEnabled())
            {
                log.debug("Exception in getRawHandleValues", e);
            }

            // Stack loss as exception does not support cause
            throw new HandleException(HandleException.INTERNAL_ERROR);
        }
        finally
        {
            if (jsonStreamReader != null)
            {
View Full Code Here

Examples of net.handle.hdllib.HandleException

            {
                log.debug("Exception in getHandlesForNA", e);
            }

            // Stack loss as exception does not support cause
            throw new HandleException(HandleException.INTERNAL_ERROR);
        }
        finally
        {
            if (jsonStreamReader != null)
            {
View Full Code Here

Examples of net.handle.hdllib.HandleException

        try
        {
            if (theHandle == null)
            {
                throw new HandleException(HandleException.INTERNAL_ERROR);
            }

            String handle = Util.decodeString(theHandle);

            context = new Context();

            String url = HandleManager.resolveToURL(context, handle);

            if (url == null)
            {
                throw new HandleException(HandleException.HANDLE_DOES_NOT_EXIST);
            }

            HandleValue value = new HandleValue();

            value.setIndex(100);
            value.setType(Util.encodeString("URL"));
            value.setData(Util.encodeString(url));
            value.setTTLType((byte) 0);
            value.setTTL(100);
            value.setTimestamp(100);
            value.setReferences(null);
            value.setAdminCanRead(true);
            value.setAdminCanWrite(false);
            value.setAnyoneCanRead(true);
            value.setAnyoneCanWrite(false);

            List<HandleValue> values = new LinkedList<HandleValue>();

            values.add(value);

            byte[][] rawValues = new byte[values.size()][];

            for (int i = 0; i < values.size(); i++)
            {
                HandleValue hvalue = values.get(i);

                rawValues[i] = new byte[Encoder.calcStorageSize(hvalue)];
                Encoder.encodeHandleValue(rawValues[i], 0, hvalue);
            }

            return rawValues;
        }
        catch (HandleException he)
        {
            throw he;
        }
        catch (Exception e)
        {
            if (log.isDebugEnabled())
            {
                log.debug("Exception in getRawHandleValues", e);
            }

            // Stack loss as exception does not support cause
            throw new HandleException(HandleException.INTERNAL_ERROR);
        }
        finally
        {
            if (context != null)
            {
View Full Code Here

Examples of net.handle.hdllib.HandleException

            {
                log.debug("Exception in getHandlesForNA", sqle);
            }

            // Stack loss as exception does not support cause
            throw new HandleException(HandleException.INTERNAL_ERROR);
        }
        finally
        {
            if (context != null)
            {
View Full Code Here

Examples of org.apache.onami.test.reflection.HandleException

                                  Module.class.getName() ) );
        }

        if ( !Modifier.isPublic( method.getModifiers() ) || !Modifier.isStatic( method.getModifiers() ) )
        {
            throw new HandleException( "Impossible to invoke method: " + method + ", it has to be static and public" );
        }

        final Class<?> type = method.getDeclaringClass();

        try
        {
            if ( Module.class.isAssignableFrom( returnType ) )
            {
                modules.add( (Module) method.invoke( type ) );
            }
            else if ( MoreTypes.getRawType( new TypeLiteral<Iterable<Module>>()
            {
            }.getType() ).isAssignableFrom( returnType ) )
            {
                addModules( (Iterable<Module>) method.invoke( type ) );
            }
            else if ( MoreTypes.getRawType( new TypeLiteral<Module[]>()
            {
            }.getType() ).isAssignableFrom( returnType ) )
            {
                addModules( (Module[]) method.invoke( type ) );
            }
            else
            {
                throw new ClassCastException( format( "  Incompatible return type: %s.\nThe return type must be one of ( %s | Iterable<%s> | %s[] )",
                                                      returnType.getName(),
                                                      Module.class.getName(),
                                                      Module.class.getName(),
                                                      Module.class.getName() ) );
            }

            if ( LOGGER.isLoggable( Level.FINER ) )
            {
                LOGGER.finer( "  Invoked method: " + method.toGenericString() );
            }
        }
        catch ( Exception e )
        {
            throw new HandleException( e );
        }
    }
View Full Code Here

Examples of org.apache.onami.test.reflection.HandleException

            {
                modules.add( module.newInstance() );
            }
            catch ( Exception e )
            {
                throw new HandleException( e );
            }
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.