Package org.chaidb.db.exception

Examples of org.chaidb.db.exception.ChaiDBException


        if (orgFile.exists()) {
            orgFile.delete();
        }

        if (!tmpFile.renameTo(orgFile)) {
            throw new ChaiDBException(ErrorCode.BACKUP_FILE_COPY_ERROR, "Can't rename a temp file. The File is " + tmpFilename + ". You should rename it to " + filename + " manually.");
        }
    }
View Full Code Here


    }

    synchronized void register(AbstractDaemonThread thread) throws ChaiDBException {
        if (threads.containsKey(thread.getName())) {
            logger.warn("There is already a daemon thead named " + thread.getName());
            throw new ChaiDBException(ErrorCode.FAILT_TO_START_DAEMONTHREAD);
        } else {
            threads.put(thread.getName(), thread);
        }
    }
View Full Code Here

     */
    public static void load(File configFile) throws ChaiDBException {

        //check whether file exists
        if (!configFile.exists()) {
            throw new ChaiDBException(ErrorCode.PARSE_ERROR, "Config File does not exists!");
        }

        root = new ConfigTool();
        FileInputStream fis;
        try {
            fis = new FileInputStream(configFile);
        } catch (FileNotFoundException e) {
            throw new ChaiDBException(ErrorCode.PARSE_ERROR, "Config File does not exists!");
        }
        load(fis);
    }
View Full Code Here

            InputSource inputSource = new InputSource(is);
            DOMParser parser = new DOMParser();
            parser.parse(inputSource);
            Document document = parser.getDocument();
            if (document == null) {
                throw new ChaiDBException(ErrorCode.PARSE_ERROR, "Config File is not well-formed!");
            }
            Element rootElement = document.getDocumentElement();

            root = paseXML2Element(rootElement);

        } catch (Exception ex) {
            throw new ChaiDBException(ErrorCode.PARSE_ERROR, "Config File is not well-formed!");
        } finally {
            try {
                is.close();
            } catch (IOException e) {
                throw new ChaiDBException(ErrorCode.PARSE_ERROR, "Close config file IO error!");
            }
        }
    }
View Full Code Here

        Hashtable attributes = new Hashtable();
        try {
            attributes.put(attributeName, attributeValue);
        } catch (Exception ex) {
            throw new ChaiDBException(ErrorCode.INVALID_INPUT_PARAM, "null can't be used as input!");
        }
        return findElement(root, elementName, attributes);

    }
View Full Code Here

        Vector parasedPath = parasePath(path);
        String pathType = (String) parasedPath.elementAt(0);

        if (pathType.equals(ConfigTool.PATH_TYPE_WRONG))
            throw new ChaiDBException(ErrorCode.PARSE_ERROR, "Path is wrong!");
        if (pathType.equals(ConfigTool.PATH_TYPE_ROOT)) return root;

        if (pathType.equals(ConfigTool.PATH_TYPE_NORMAL)) {

            ConfigTool parent = root;

            for (int i = 1; i < parasedPath.size(); i++) {

                String elementName = (String) parasedPath.elementAt(i);
                ElementSet elementSet = parent.getChildren();
                if (elementSet == null) break;
                ConfigTool child;
                for (Iterator childrenIter = elementSet.iterator(); childrenIter.hasNext();) {

                    child = (ConfigTool) childrenIter.next();
                    if (child.getName() != null && elementName.equals(child.getName())) {

                        if (i == parasedPath.size() - 1) {
                            if (elementID == null) {
                                return child;
                            }
                            if (child.getAttributes() != null && child.getAttributes().get(ELEMENT_ID) != null && ((String) child.getAttributes().get(ELEMENT_ID)).equalsIgnoreCase(elementID)) {
                                return child;
                            }
                        } else {
                            parent = child;
                            break;
                        }
                    }
                }
            }
        }
        throw new ChaiDBException(ErrorCode.INVALID_INPUT_PARAM, "No such Config was found! Input Param:path=" + path + "elementId=" + elementID);

    }
View Full Code Here

     * vector.the rest may be deduced by analogy .
     */
    private static Vector parasePath(String path) throws ChaiDBException {

        if (path == null) {
            throw new ChaiDBException(ErrorCode.INVALID_INPUT_PARAM, "null can't used as path!");
        }
        Vector parasedPath = new Vector();
        final String SEPARATOR = "/";
        final char SEPARATOR_CHAR = '/';

View Full Code Here

     * @return vectort whose element is string
     */
    public Enumeration getChildElementIDByChildElementName(String elementName) throws ChaiDBException {

        if (elementName == null) {
            throw new ChaiDBException(ErrorCode.INVALID_INPUT_PARAM, "null can't used as input!");
        }
        Hashtable nameAndID = getChildAllElementNamesAndID(null);
        Vector IDs = (Vector) nameAndID.get(elementName);
        if (IDs == null) {
//      throw new ChaiDBException(ErrorCode.INVALID_INPUT_PARAM,
View Full Code Here

        if (attributes.containsKey(attributeName)) {
            attributes.remove(attributeName);
            try {
                attributes.put(attributeName, attributeNewValue);
            } catch (Exception ex) {
                throw new ChaiDBException(ErrorCode.INVALID_INPUT_PARAM, "attribute name or attribute" + " value should not be null");
            }
            return true;
        }

        throw new ChaiDBException(ErrorCode.INVALID_INPUT_PARAM, "the attribute " + attributeName + " has not existed!");


    }
View Full Code Here

                        if (canRemoved) {
                            children.remove(child);
                            return true;
                        } else {
                            throw new ChaiDBException(ErrorCode.INVALID_INPUT_PARAM, "the " + elementName + " can't be removed!");

                        }
                    }

                }
            }
        }

        throw new ChaiDBException(ErrorCode.INVALID_INPUT_PARAM, "the config " + elementName + " has not exist!");

    }
View Full Code Here

TOP

Related Classes of org.chaidb.db.exception.ChaiDBException

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.