Package org.jaggeryjs.scriptengine.exceptions

Examples of org.jaggeryjs.scriptengine.exceptions.ScriptException


            HostObjectUtil.invalidArgsError(hostObjectName, functionName, "2", "string", args[1], false);
        }
        try {
            return registryHostObject.registry.getRating((String) args[0], (String) args[1]);
        } catch (RegistryException e) {
            throw new ScriptException(e);
        }
    }
View Full Code Here


            HostObjectUtil.invalidArgsError(hostObjectName, functionName, "1", "string", args[0], false);
        }
        try {
            return registryHostObject.registry.getAverageRating((String) args[0]);
        } catch (RegistryException e) {
            throw new ScriptException(e);
        }
    }
View Full Code Here

                commentObj.put("created", commentObj, comment.getCreatedTime().getTime());
                commentsArray.add(commentObj);
            }
            return cx.newArray(thisObj, commentsArray.toArray());
        } catch (RegistryException e) {
            throw new ScriptException(e);
        }
    }
View Full Code Here

                result.put("tags", result, cx.newArray(thisObj, tags.toArray()));
                results.add(result);
            }
            return cx.newArray(thisObj, results.toArray());
        } catch (RegistryException e) {
            throw new ScriptException(e);
        } catch (CarbonException e) {
            throw new ScriptException(e);
        }
    }
View Full Code Here

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

        try {
            int tId = RegistryHostObjectContext.getRealmService().getTenantManager().getTenantId(tDomain);
            registry = registryService.getGovernanceUserRegistry(username, password, tId);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            throw new ScriptException(e);
        }
        if (registry == null) {
            String msg = "User governance registry cannot be retrieved";
            throw new ScriptException(msg);
        }
        return registry;
    }
View Full Code Here

        try {
            int tId = RegistryHostObjectContext.getRealmService().getTenantManager().getTenantId(tDomain);
            registry = registryService.getGovernanceUserRegistry(username, tId);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            throw new ScriptException(e);
        }
        if (registry == null) {
            String msg = "User governance registry cannot be retrieved";
            throw new ScriptException(msg);
        }
        return registry;
    }
View Full Code Here

                if (providerConfig.getApi_key() == null
                        || providerConfig.getApi_secret() == null
                        || providerConfig.getAccess_token_url() == null
                        || providerConfig.getAuthorization_url() == null
                        || providerConfig.getOAuth_version() == null) {
                    throw new ScriptException("API configuration not specified");
                }

                oauthho.apiKey = providerConfig.getApi_key();
                oauthho.apiSecret = providerConfig.getApi_secret();

                if (providerConfig.getOAuth_version() == 1.0) {
                 
                    if (providerConfig.getRequest_token_url() == null) {
                        throw new ScriptException("API configuration not specified");
                    }
                   
                  oauthho.oAuthVersion = OAuthVersion.OAUTH1;
                    GenericOAuth10aApi oauth10aApi = new GenericOAuth10aApi();
                    oauth10aApi.setAccessTokenEndpoint(providerConfig.getAccess_token_url());
                    oauth10aApi.setAuthorizationUrl(providerConfig.getAuthorization_url());
                    oauth10aApi.setRequestTokenEndpoint(providerConfig.getRequest_token_url());
                    oauthho.oauthService = new ServiceBuilder()
                            .provider(oauth10aApi)
                            .apiKey(oauthho.apiKey)
                            .apiSecret(oauthho.apiSecret)
                            .build();

                } else if (providerConfig.getOAuth_version() == 2.0) {
                 
                    if (providerConfig.getCallback_url() == null) {
                        throw new ScriptException("API configuration not specified");
                    }
                   
                  oauthho.oAuthVersion = OAuthVersion.OAUTH2;
                    GenericOAuth20Api oauth20Api = new GenericOAuth20Api();
                    oauth20Api.setAccessTokenEP(providerConfig.getAccess_token_url());
                    oauth20Api.setAuthorizeUrl(providerConfig.getAuthorization_url());
                    oauthho.oauthService = new ServiceBuilder()
                            .provider(oauth20Api)
                            .apiKey(oauthho.apiKey)
                            .apiSecret(oauthho.apiSecret)
                            .build();
                }

            }
            return oauthho;
        } else {
            throw new ScriptException("API configuration not specified");
        }
    }
View Full Code Here

        if (args.length >= 3) {
            if (!(args[0] == Context.getUndefinedValue()) && args[0] instanceof NativeJavaObject) {
                oauthho.accessToken = (Token) Context.jsToJava(args[0], Token.class);
            } else {
                throw new ScriptException("Invalid Access Token");
            }

            if (!(args[1] == Context.getUndefinedValue()) && args[1] instanceof String) {
                String inputVerb = (String) args[1];
                if ("GET".equals(inputVerb.toUpperCase())) {
                    verb = Verb.GET;
                } else if ("PUT".equals(inputVerb.toUpperCase())) {
                    verb = Verb.PUT;
                } else if ("POST".equals(inputVerb.toUpperCase())) {
                    verb = Verb.POST;
                } else if ("DELETE".equals(inputVerb.toUpperCase())) {
                    verb = Verb.DELETE;
                }
            } else {
                throw new ScriptException("Invalid Verb");
            }

            if (!(args[2] == Context.getUndefinedValue()) && args[2] instanceof String) {
                oauthho.protectedResource = (String) args[2];
            } else {
                throw new ScriptException("Invalid URL");
            }

            oauthho.oauthRequest = new OAuthRequest(verb, oauthho.protectedResource);

            if ((args.length == 4) && !(args[3] == Context.getUndefinedValue()) && args[3] instanceof Scriptable) {
                Scriptable queryJsonString = (Scriptable) args[3];
                String[] ids = Arrays.copyOf(queryJsonString.getIds(), queryJsonString.getIds().length, String[].class);
                for (String id : ids) {
                    String value = ((Scriptable) args[3]).get(id, cx.initStandardObjects()).toString();
                    oauthho.oauthRequest.addQuerystringParameter(id, value);
                }
            }
            oauthho.oauthService.signRequest(oauthho.accessToken, oauthho.oauthRequest);
            oauthho.response = oauthho.oauthRequest.send();
            return oauthho.response;


        } else {
            throw new ScriptException("Required properties not provided, Request cannot be built");
        }

    }
View Full Code Here

        OAuthHostObject oauthho = (OAuthHostObject) thisObj;
        if ((args.length == 1) && !(args[0] == Context.getUndefinedValue()) && args[0] instanceof String) {
            oauthho.verifier = new Verifier((String) args[0]);
            return oauthho.oauthService.getAccessToken(oauthho.requestToken, oauthho.verifier);
        } else {
            throw new ScriptException("Illegal argument for the verifier : Add the code given from Provider");
        }
    }
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.