Package org.wso2.carbon

Examples of org.wso2.carbon.CarbonException


            Object object = cx.getThreadLocal(MashupConstants.AXIS2_SERVICE);
            AxisService axisService;
            if (object instanceof AxisService) {
                axisService = (AxisService) object;
            } else {
                throw new CarbonException("Error obtaining the AxisService.");
            }
            String mashupAuthor = (String) axisService.getParameter(
                    MashupConstants.MASHUP_AUTHOR).getValue();
            int tenantId = SuperTenantCarbonContext.getCurrentContext(axisConfig).getTenantId();
            registryHostObject.registry = RegistryHostObjectContext.getUserRegistry(mashupAuthor, tenantId);
            return registryHostObject;
        } else {
            throw new CarbonException("Registry() constructor doesn't accept arguments.");
        }
    }
View Full Code Here


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

                        hostObject = cx.newObject(
                            registryHostObject, "Resource", new Object[]{resource});
                    }
                    return hostObject;
                } catch (RegistryException e) {
                    throw new CarbonException("Registry error occurred while executing get() " +
                                              "operation.", e);
                }
            } else {
                throw new CarbonException("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 = registryHostObject.registry.get(
                            getAbsoluteRegistryPath((String) arguments[0]), ((Number) arguments[1]).intValue(),
                            ((Number) arguments[2]).intValue());
                    CollectionHostObject collectionHostobject = (CollectionHostObject) cx.newObject(
                            registryHostObject, "Collection", new Object[]{collection});
                    return collectionHostobject;
                } catch (RegistryException e) {
                    throw new CarbonException("Registry error occurred while executing get() " +
                                              "operation.", e);
                }

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

                ResourceHostObject resourceHostobject = (ResourceHostObject) arguments[1];
                try {
                    return registryHostObject.registry.put(getAbsoluteRegistryPath((String) arguments[0]),
                                                           resourceHostobject.getResource());
                } catch (RegistryException e) {
                    throw new CarbonException("Registry error occurred while executing get() " +
                                              "operation.", e);
                }
            } else {
                throw new CarbonException("Invalid argument types for put() method.");
            }
        } else {
            throw new CarbonException("Invalid no. of arguments for put() method");
        }
    }
View Full Code Here

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

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

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

                .getThreadLocal(MashupConstants.AXIS2_CONFIGURATION_CONTEXT);
        if (configurationContextObject != null
            && configurationContextObject instanceof ConfigurationContext) {
            return (ConfigurationContext) configurationContextObject;
        } else {
            throw new CarbonException(
                    "Error obtaining the Service Meta Data : Axis2 ConfigurationContext");
        }
    }
View Full Code Here

        RegistryHostObjectContext.registryService = registryService;
    }

    public static Registry getUserRegistry(String mashupAuthor, int tenantId) throws CarbonException {
        if (registryService == null) {
            throw new CarbonException("Registry is null");
        }
        try {
            if(registryService.getUserRealm(tenantId).getUserStoreManager().isExistingUser(mashupAuthor)) {
                return registryService.getGovernanceUserRegistry(mashupAuthor, tenantId);
            } else {
                throw new CarbonException("Unable to access Registry, mashup author is not an active user");
            }
        } catch (UserStoreException e) {
            log.error(e.getMessage(), e);
            throw new CarbonException(e);
        }catch (RegistryException e) {
            log.error(e.getMessage(), e);
            throw new CarbonException(e);
        }
    }
View Full Code Here

        Object object = cx.getThreadLocal(MashupConstants.AXIS2_SERVICE);
        AxisService axisService;
        if (object instanceof AxisService) {
            axisService = (AxisService) object;
        } else {
            throw new CarbonException("Error obtaining the AxisService.");
        }

        Object resourceFileObject = axisService
                .getParameterValue(MashupConstants.RESOURCES_FOLDER);
        File resourceFolder;
        if (resourceFileObject != null && resourceFileObject instanceof File) {
            resourceFolder = (File) resourceFileObject;
        } else {
            throw new CarbonException("Resources folder not found.");
        }

        if (args.length == 1 & !(args[0] == Context.getUndefinedValue())) {
            if (args[0] instanceof String) {
                String filePath = FilenameUtils.normalizeNoEndSeparator((String) args[0]);
                if (filePath == null) {
                    throw new CarbonException(
                            "FileHostObject : Illegal file path, Cannot navigate away from resources directory");
                }
                result.file = new File(resourceFolder, filePath);
                if (result.file.isDirectory()) {
                    throw new CarbonException(
                            "Given path is not a File. This object does not support directories.");
                }
            } else if (args[0] instanceof XML) {
                //TODO: Initial code bits to handle MTOM using the file object. Yet to be completed.
                XML xml = (XML) args[0];
                OMNode node = xml.getAxiomFromXML();
                if (node instanceof OMText) {
                    OMText textNode = (OMText) node;
                    if (textNode.isBinary()) {
                        result.dataHandler = (DataHandler) textNode.getDataHandler();
                    } else {
                        // TODO support directly writing XML to the file
                        throw new CarbonException(
                                "XML content given for the File does not contain base64Binary.");
                    }

                } else {
                    // TODO support directly writing XML to the file
                    throw new CarbonException(
                            "XML content given for the File does not contain base64Binary.");
                }
            } else {
                throw new CarbonException("Invalid parameters.");
            }
        }
        return result;
    }
View Full Code Here

TOP

Related Classes of org.wso2.carbon.CarbonException

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.