Package org.exist

Examples of org.exist.EXistException


                    throw new PermissionDeniedException("User '" + broker.getSubject().getName() + "' does not have permission to write to the document '" + doc.getDocumentURI() + "'!");
                                }
        doc.getMetadata().setIndexListener(listener);
        parent = (NodeImpl) node.getParentNode();
                if (parent == null || parent.getNodeType() != Node.ELEMENT_NODE) {
          throw new EXistException(
              "you cannot remove the document element. Use update "
                  + "instead");
        } else
          {parent.removeChild(transaction, node);}
        doc.getMetadata().clearIndexListener();
View Full Code Here


    declareVariables(context);
    if(compiled == null)
      try {
        compiled = xquery.compile(context, source);
      } catch (final IOException e) {
        throw new EXistException("An exception occurred while compiling the query: " + e.getMessage());
      }
   
    Sequence seq = null;
    try {
      seq = xquery.execute(compiled, null);
View Full Code Here

      EXistException, XPathException, TriggerException {
    final NodeList children = content;
        if (children.getLength() == 0)
            {return 0;}
        if (children.getLength() > 1)
          {throw new EXistException("xupdate:replace requires exactly one content node");}
        LOG.debug("processing replace ...");
        int modifications = children.getLength();
        try {
            final StoredNode ql[] = selectAndLock(transaction);
            final IndexListener listener = new IndexListener(ql);
            final NotificationService notifier = broker.getBrokerPool().getNotificationService();
            Node temp;
            TextImpl text;
            AttrImpl attribute;
            ElementImpl parent;
            for (int i = 0; i < ql.length; i++) {
                final StoredNode node = ql[i];
                if (node == null) {
                    LOG.warn("select " + selectStmt + " returned empty node set");
                    continue;
                }
                final DocumentImpl doc = (DocumentImpl)node.getOwnerDocument();
                doc.getMetadata().setIndexListener(listener);
                if (!doc.getPermissions().validate(broker.getSubject(), Permission.WRITE)) {
                        throw new PermissionDeniedException("User '" + broker.getSubject().getName() + "' does not have permission to write to the document '" + doc.getDocumentURI() + "'!");
                }
                parent = (ElementImpl) node.getParentStoredNode();
                if (parent == null)
                    {throw new EXistException("The root element of a document can not be replaced with 'xu:replace'. " +
                        "Please consider removing the document or use 'xu:update' to just replace the children of the root.");}
                switch (node.getNodeType()) {
                    case Node.ELEMENT_NODE:
                        if (modifications == 0) {modifications = 1;}
                        temp = children.item(0);
                        parent.replaceChild(transaction, temp, node);
                        break;
                    case Node.TEXT_NODE:
                        temp = children.item(0);
                        text = new TextImpl(temp.getNodeValue());
                        modifications = 1;
                        text.setOwnerDocument(doc);
                        parent.updateChild(transaction, node, text);
                        break;
                    case Node.ATTRIBUTE_NODE:
                        final AttrImpl attr = (AttrImpl) node;
                        temp = children.item(0);
                        attribute = new AttrImpl(attr.getQName(), temp.getNodeValue(), broker.getBrokerPool().getSymbols());
                        attribute.setOwnerDocument(doc);
                        parent.updateChild(transaction, node, attribute);
                        break;
                    default:
                        throw new EXistException("unsupported node-type");
                }
                doc.getMetadata().clearIndexListener();
                doc.getMetadata().setLastModified(System.currentTimeMillis());
                modifiedDocuments.add(doc);
                broker.storeXMLResource(transaction, doc);
View Full Code Here

                        newAttr.setNodeName(new QName(newName, "", null));
                        parent.updateChild(transaction, node, newAttr);
                        modificationCount++;
                        break;
                    default:
                        throw new EXistException("unsupported node-type");
                }

                doc.getMetadata().clearIndexListener();
                doc.getMetadata().setLastModified(System.currentTimeMillis());
                modifiedDocuments.add(doc);
View Full Code Here

            try {
                store.createNewFile();
                br = new BufferedReader(new FileReader(store));
            } catch (IOException e1) {
                // Failed to create an empty file, probably no write permission..
                throw new EXistException("Unable to create counter store file.");
            }
        }

        try {
            if (store.exists() && store.canRead()) {
                String line = "";

                while ((line = br.readLine()) != null) {
                    //Use ; as a DELIMITER, counter names must be tested and rejected when they contain this character!
                    String[] tokens = line.split(DELIMITER);
                    counters.put(tokens[0], Long.parseLong(tokens[1]));
                }

                br.close();
            }

        } catch (IOException e) {
            throw new EXistException("IOException occurred when reading counter store file.");

        } catch (NumberFormatException e) {
            throw new EXistException("Corrupt counter store file: " + store.getAbsolutePath());

        } catch (ArrayIndexOutOfBoundsException e) {
            throw new EXistException("Corrupt counter store file: " + store.getAbsolutePath());
        }
    }
View Full Code Here

            counters.put(counterName, initValue);

            try {
                serializeTable();
            } catch (FileNotFoundException e) {
                throw new EXistException("Unable to save to counter store file.");
            }

            return counters.get(counterName);
        }
    }
View Full Code Here

            counters.remove(counterName);

            try {
                serializeTable();
            } catch (FileNotFoundException e) {
                throw new EXistException("Unable to remove counter from counter store file.");
            }

            return true;
        } else {
            return false;
View Full Code Here

        counters.put(counterName, c);

        try {
            serializeTable();
        } catch (FileNotFoundException e) {
            throw new EXistException("Unable to save to counter store file.");
        }

        return c;
    }
View Full Code Here

        String counterName = args[0].getStringValue();

        if (getSignature().equals(createCounter)) {
            try {
                if (counterName.contains(Counters.DELIMITER)) {
                    throw new EXistException("Invalid name for counter, character '"
                            + Counters.DELIMITER + "' is not allowed.");

                } else {
                    return new IntegerValue(counters.createCounter(counterName), Type.LONG);
                }

            } catch (EXistException e) {
                logger.error(e.getMessage());
                return Sequence.EMPTY_SEQUENCE;
            }

        } else if (getSignature().equals(createCounterAndInit)) {
            try {
                Long initValue = Long.parseLong(args[1].getStringValue());
                if (counterName.contains(Counters.DELIMITER)) {
                    throw new EXistException("Invalid name for counter, character '"
                            + Counters.DELIMITER + "' is not allowed.");
                   
                } else {
                    return new IntegerValue( counters.createCounter(counterName, initValue), Type.LONG);
                }
View Full Code Here

        else if (e instanceof PermissionDeniedException)
            {throw (PermissionDeniedException) e;}
       
        else {
            //System.out.println(e.getClass().getName());
            throw new EXistException(e);
        }
    }
View Full Code Here

TOP

Related Classes of org.exist.EXistException

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.