Package org.jaggeryjs.scriptengine.exceptions

Examples of org.jaggeryjs.scriptengine.exceptions.ScriptException


        if (args[0] instanceof String) {
            try {
                who.inbound.getWsOutbound().writeTextMessage(CharBuffer.wrap((String) args[0]));
            } catch (IOException e) {
                log.error(e.getMessage(), e);
                throw new ScriptException(e);
            }
        } else {
            StreamHostObject sho = (StreamHostObject) args[0];
            InputStream is = sho.getStream();
            try {
                byte[] buffer = new byte[1024];
                int length;
                while ((length = is.read(buffer)) != -1) {
                    who.inbound.getWsOutbound().writeBinaryMessage(ByteBuffer.wrap(buffer, 0, length));
                }
            } catch (IOException e) {
                log.error(e.getMessage(), e);
                throw new ScriptException(e);
            }
        }
    }
View Full Code Here


        if (arguments.length == 1) {
            if (arguments[0] instanceof String) {
                try {
                    rho.registry.delete((String) arguments[0]);
                } catch (RegistryException e) {
                    throw new ScriptException("Registry error occurred while executing delete() operation", e);
                }
            } else {
                throw new ScriptException("Path argument of method delete() should be a string");
            }
        } else {
            throw new ScriptException("Invalid no. of arguments for delete() method");
        }
    }
View Full Code Here

                    } else {
                        hostObject = cx.newObject(rho, "Resource", new Object[]{resource});
                    }
                    return hostObject;
                } catch (RegistryException e) {
                    throw new ScriptException("Registry error occurred while executing get() operation", e);
                }
            } else {
                throw new ScriptException("Path argument of method get() should be a string");
            }
        } else if (arguments.length == 3) {
            if (arguments[0] instanceof String && arguments[1] instanceof Number && arguments[2] instanceof Number) {
                try {
                    Collection collection = rho.registry.get((String) arguments[0],
                            ((Number) arguments[1]).intValue(), ((Number) arguments[2]).intValue());
                    CollectionHostObject cho = (CollectionHostObject) cx.newObject(
                            rho, "Collection", new Object[]{collection});
                    return cho;
                } catch (RegistryException e) {
                    throw new ScriptException("Registry error occurred while executing get() operation", e);
                }

            } else {
                throw new ScriptException("Invalid argument types for get() method");
            }
        } else {
            throw new ScriptException("Invalid no. of arguments for get() method");
        }
    }
View Full Code Here

            if (arguments[0] instanceof String && arguments[1] instanceof Scriptable) {
                ResourceHostObject reho = (ResourceHostObject) arguments[1];
                try {
                    return rho.registry.put((String) arguments[0], reho.getResource());
                } catch (RegistryException e) {
                    throw new ScriptException("Registry error occurred while executing get() operation", e);
                }
            } else {
                throw new ScriptException("Invalid argument types for put() method");
            }
        } else {
            throw new ScriptException("Invalid no. of arguments for put() method");
        }
    }
View Full Code Here

                    Collection collection = rho.registry.newCollection();
                    CollectionHostObject cho = (CollectionHostObject) cx.newObject(
                            rho, "Collection", new Object[]{collection});
                    return cho;
                } catch (RegistryException e) {
                    throw new ScriptException("Error occurred while creating a new Collection", e);
                }
            } else {
                throw new ScriptException("Registry has not initialized");
            }
        } else {
            throw new ScriptException("newCollection() Method doesn't accept arguments");
        }
    }
View Full Code Here

                    Resource resource = registryHostObject.registry.newResource();
                    ResourceHostObject rho = (ResourceHostObject) cx.newObject(
                            registryHostObject, "Resource", new Object[]{resource});
                    return rho;
                } catch (RegistryException e) {
                    throw new ScriptException("Error occurred while creating a new Resource", e);
                }
            } else {
                throw new ScriptException("Registry has not initialized");
            }
        } else {
            throw new ScriptException("newResource() Method doesn't accept arguments");
        }
    }
View Full Code Here

        if (arguments.length == 1) {
            if (arguments[0] instanceof String) {
                try {
                    return registryHostObject.registry.resourceExists((String) arguments[0]);
                } catch (RegistryException e) {
                    throw new ScriptException("Error occurred while creating a new Resource", e);
                }
            } else {
                throw new ScriptException("Invalid argument types for resourceExists() method");
            }
        } else {
            throw new ScriptException("Invalid no. of arguments");
        }
    }
View Full Code Here

        if (arguments.length == 2) {
            if (arguments[0] instanceof String && arguments[1] instanceof String) {
                try {
                    registryHostObject.registry.createLink((String) arguments[0], (String) arguments[1]);
                } catch (RegistryException e) {
                    throw new ScriptException("Error occurred while creating a Link", e);
                }
            } else {
                throw new ScriptException("Invalid argument types for createLink() method");
            }
        } else {
            throw new ScriptException("Invalid no. of arguments");
        }
    }
View Full Code Here

        }
        RegistryHostObject registryHostObject = (RegistryHostObject) thisObj;
        try {
            registryHostObject.registry.rateResource((String) args[0], ((Number) args[1]).intValue());
        } catch (RegistryException e) {
            throw new ScriptException(e);
        }
    }
View Full Code Here

        RegistryHostObject registryHostObject = (RegistryHostObject) thisObj;
        try {
            registryHostObject.registry.addComment((String) args[0],
                    new org.wso2.carbon.registry.core.Comment((String) args[1]));
        } catch (RegistryException e) {
            throw new ScriptException(e);
        }
    }
View Full Code Here

TOP

Related Classes of org.jaggeryjs.scriptengine.exceptions.ScriptException

Copyright © 2018 www.massapicom. 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.