Package org.wso2.carbon

Examples of org.wso2.carbon.CarbonException


    public void jsSet_credentials(Object object) throws CarbonException {
        // sets authentication scheme priority of apache httpclient
        if (object instanceof NativeObject) {
            this.credentials = (NativeObject) object;
        } else {
            throw new CarbonException("HttpClient Credentials should be an Object");
        }
    }
View Full Code Here


        // sets authentication scheme priority of apache httpclient
        if (object instanceof NativeObject) {
            this.proxyCredentials = (NativeObject) object;
            //httpClient.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, nativeAuthSchemePriority);
        } else {
            throw new CarbonException("HttpClient Proxy Credentials should be an Object");
        }
    }
View Full Code Here

    public void jsSet_host(Object object) throws CarbonException {
        // sets authentication scheme priority of apache httpclient
        if (object instanceof NativeObject) {
            this.host = (NativeObject) object;
        } else {
            throw new CarbonException("HttpClient Host should be an Object");
        }
    }
View Full Code Here

    public String jsGet_response() throws CarbonException {
        try {
            return this.method.getResponseBodyAsString();
        } catch (IOException e) {
            throw new CarbonException("Error getting the response");
        }
    }
View Full Code Here

            long length = file.length();
            // to ensure that file is not larger than Integer.MAX_VALUE.
            if (length > Integer.MAX_VALUE) {
                // File is too large
                throw new CarbonException("File to read is too large. File name: " +
                        file.getName() + ". File length limit: " + Integer.MAX_VALUE);
            }

            // byte array to keep the data
            byte[] bytes = new byte[(int) length];

            int numRead;
            int offset = 0;
            while (offset < bytes.length
                    && (numRead = is.read(bytes, offset, bytes.length - offset)) >= 0) {
                offset += numRead;
            }

            if (offset < bytes.length) {
                throw new CarbonException("Couldn't read the entire file. " +
                        "File name: " + file.getName());
            }

            return bytes;  

        } catch (FileNotFoundException e) {
            throw new CarbonException("Error creating the file input stream", e);

        } catch (IOException e) {
            throw new CarbonException("Error in reading file. File name: " + file.getName());

        } finally {
            try {
                if(is != null){
                    is.close();
View Full Code Here

       
        try {
            componentEle.serializeAndConsume(bos);
        } catch (XMLStreamException e) {
            e.printStackTrace();
            throw new CarbonException(e);
        }
        byte[] bytes = bos.toByteArray();

        try {
            // Transform
            for (String templatSuffix : mainTemplateSuffixes) {
                String xslResourceName = "ui/" + templatSuffix + ".xsl";
                URL xslResource = componentBundle.getResource(xslResourceName);
                if (xslResource == null) {
                    throw new CarbonException(
                            xslResourceName + " is not avaiable in component bundle");
                }
                ByteArrayOutputStream jspBos = new ByteArrayOutputStream();
                transform(new ByteArrayInputStream(bytes), xslResource.openStream(), jspBos);
                processedFileMap
                        .put("web/" + templatSuffix + ".jsp", new String(jspBos.toByteArray()));
            }
        } catch (TransformerException e) {
            e.printStackTrace();
            throw new CarbonException(e);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            throw new CarbonException(e);
        } catch (IOException e) {
            e.printStackTrace();
            throw new CarbonException(e);
        }


    }
View Full Code Here

            while (all.hasMoreElements()) {
                getFile((ZipEntry) all.nextElement(), jarFile, targetLocation, dirsMade);
            }
        } catch (IOException e) {
            log.error("Error while copying component", e);
            throw new CarbonException(e);
        }
    }
View Full Code Here

                                           boolean inNewExpr) throws CarbonException {
        if (args.length == 1) {
            if (args[0] instanceof Collection && !(args[0] instanceof Scriptable)) {
                return new CollectionHostObject((Collection) args[0], cx);
            } else if (args[0] instanceof Scriptable) {
                throw new CarbonException("Collection object cannot be initialized directly, " +
                                          "use registry.newCollection() instead");
            } else {
                throw new CarbonException("Invalid argument type for Collection constructor");
            }
        } else {
            throw new CarbonException("Invalid no. of arguments for Collection constructor");
        }
    }
View Full Code Here

        CollectionHostObject collectionHostObject = (CollectionHostObject) thisObj;
        if (arguments.length == 0) {
            try {
                return new NativeArray(((Collection)collectionHostObject.getResource()).getChildren());
            } catch (RegistryException e) {
                throw new CarbonException("Error occurred while creating a new Resource.", e);
            }
        } else if (arguments.length == 2) {
            if (arguments[0] instanceof Number && arguments[1] instanceof Number) {
                try {
                    return new NativeArray(((Collection)collectionHostObject.getResource()).getChildren(
                            ((Number) arguments[0]).intValue(),
                            ((Number) arguments[1]).intValue()));
                } catch (RegistryException e) {
                    throw new CarbonException("Error occurred while creating a new Resource.", e);
                }
            } else {
                throw new CarbonException("Invalid argument types for getChildren() method");
            }
        } else {
            throw new CarbonException("Invalid no. of arguments for getChildren() method");
        }
    }
View Full Code Here

    public int jsGet_childCount() throws CarbonException {
        try {
            return ((Collection)this.getResource()).getChildCount();
        } catch (RegistryException e) {
            throw new CarbonException("Error occurred while creating a new Resource.", e);
        }
    }
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.