Package org.fcrepo.server.errors

Examples of org.fcrepo.server.errors.GeneralException


            SchemaFactory schemaFactory =
                    SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
            m_schema = schemaFactory.newSchema(schemaFile);
        } catch (Exception e) {
            logger.error("Error constructing validator", e);
            throw new GeneralException(e.getMessage());
        }
    }
View Full Code Here


            String msg =
                    "DOValidatorXMLSchema returned error.\n"
                            + "The underlying exception was a "
                            + e.getClass().getName() + ".\n"
                            + "The message was " + "\"" + e.getMessage() + "\"";
            throw new GeneralException(msg);
        }
    }
View Full Code Here

            String msg =
                    "DOValidatorXMLSchema returned error.\n"
                            + "The underlying error was a "
                            + e.getClass().getName() + ".\n"
                            + "The message was " + "\"" + e.getMessage() + "\"";
            throw new GeneralException(msg, e);
        }
    }
View Full Code Here

        }

        try {
            return readRelationships(ds.getContentStream());
        } catch (TrippiException e) {
            throw new GeneralException(e.getMessage(), e);
        }
    }
View Full Code Here

                m_xmlSchemaMap.put(
                    entry.getKey(),
                    new DOValidatorXMLSchema(
                        schemaFactory.newSchema(new File(entry.getValue()))));
            } catch (SAXException e) {
                throw new GeneralException("Cannot read or create schema at " +
                        entry.getValue(),e);
            }
        }
        m_ruleSchemaMap = ruleSchemaMap;
        if (tempDir == null) {
            throw new ObjectValidityException("[DOValidatorImpl] ERROR in constructor: "
                    + "tempDir is null.");
        }
        if (schematronPreprocessorPath == null) {
            throw new ObjectValidityException("[DOValidatorImpl] ERROR in constructor. "
                    + "schematronPreprocessorPath is null.");
        }
        m_tempDir = new File(tempDir);
        if (!m_tempDir.exists() && !m_tempDir.mkdirs()) {
            throw new GeneralException("Cannot read or create tempDir at " +
                tempDir);
        }
        m_absoluteTempPath = m_tempDir.getAbsolutePath();
        DOValidatorImpl.tempDir = tempDir;
        DOValidatorImpl.schematronPreprocessorPath = schematronPreprocessorPath;
View Full Code Here

                        phase);
                break;
            default:
                String msg = "VALIDATE: ERROR - missing or invalid validationType";
                logger.error(msg);
                throw new GeneralException("[DOValidatorImpl] " + msg + ":"
                    + validationType);
        }
        return;
    }
View Full Code Here

                    }
                }
                zip.close();
                objectAsFile = manifest;
            } catch(IOException e) {
                throw new GeneralException(e.getMessage(), e);
            }
        }
       
        try {

            FileInputStream objectAsStream = new FileInputStream(objectAsFile);
            if (validationType == VALIDATE_ALL) {
                validateByRules(objectAsStream,
                        m_ruleSchemaMap.get(format),
                        schematronPreprocessorPath,
                        phase);
                validateXMLSchema(new FileInputStream(objectAsFile),
                    m_xmlSchemaMap.get(format));
            } else if (validationType == VALIDATE_XML_SCHEMA) {
                validateXMLSchema(objectAsStream, m_xmlSchemaMap.get(format));
            } else if (validationType == VALIDATE_SCHEMATRON) {
                validateByRules(objectAsStream,
                        m_ruleSchemaMap.get(format),
                        schematronPreprocessorPath,
                        phase);
            } else {
                String msg = "VALIDATE: ERROR - missing or invalid validationType";
                logger.error(msg);
                throw new GeneralException("[DOValidatorImpl] " + msg + ":"
                        + validationType);
            }
        } catch (IOException ioe) {
            logger.error("VALIDATE: ERROR - failed validations.", ioe);
            throw new ObjectValidityException("[DOValidatorImpl]: validate(File input...). "
View Full Code Here

            dsId = "RELS-EXT";
        } else {
            if (subject.startsWith(pidURI + "/")) {
                dsId = "RELS-INT";
            } else {
                throw new GeneralException("Cannot determine which relationship datastream to update for subject " + subject + ".  Relationship subjects must be the URI of the object or the URI of a datastream within the object.");
            }
        }
        return dsId;

    }
View Full Code Here

            try {
                TripleIterator triples =
                        new FilteredTripleIterator(map, toAdd, true);
                triples.toStream(out, RDFFormat.RDF_XML, false);
            } catch (TrippiException e) {
                throw new GeneralException(e.getMessage(), e);
            }

            dsxml = new XMLDatastreamProcessor(dsId);
            Datastream newds = dsxml.getDatastream();
            newds.DatastreamAltIDs = new String[0];
            // formats for internal datastreams
            if (dsId.equals("RELS-EXT")) {
                newds.DSFormatURI = RELS_EXT1_0.uri;
            } else {
                if (dsId.equals("RELS-INT"))
                    newds.DSFormatURI = RELS_INT1_0.uri;
            }
            newds.DSMIME = "application/rdf+xml";
            //newds.DSControlGrp = "X"; set by XMLDatastreamProcessor instead
            newds.DSInfoType = null;
            newds.DSState = "A";
            newds.DSVersionable = false;
            newds.DSVersionID = dsId + ".0";
            newds.DSLabel = "Relationships";
            newds.DSCreateDT = Server.getCurrentDate(m_context);
            newds.DSLocation = null;
            newds.DSLocationType = null;
            newds.DSChecksumType = Datastream.getDefaultChecksumType();
            dsxml.setXMLContent(out.toByteArray());
            newds.DSSize = dsxml.getXMLContent().length;

            ValidationUtility.validateReservedDatastream(PID.getInstance(m_obj.getPid()),
                                                         newds.DatastreamID,
                                                         newds);
            addDatastream(newds, false);
        } else { // (relsDatastream != null)
            dsxml = new XMLDatastreamProcessor(relsDatastream);
            FilteredTripleIterator newIter = null;
            try {
                ByteArrayOutputStream out = new ByteArrayOutputStream();
                TripleIterator iter =
                        TripleIteratorFactory.defaultInstance().fromStream(relsDatastream.getContentStream(),
                                                  RDFFormat.RDF_XML);
                newIter = new FilteredTripleIterator(iter, toAdd, true);
                newIter.toStream(out, RDFFormat.RDF_XML, false);

                if (newIter.wasChangeMade()) {
                    XMLDatastreamProcessor newdsxml = dsxml.newVersion();
                    Datastream newds = newdsxml.getDatastream();

                    // TODO: only for XML Metadata datastream
                    newdsxml.setDSMDClass(dsxml.getDSMDClass());

                    newds.DatastreamID = relsDatastream.DatastreamID;
                    newds.DatastreamAltIDs = relsDatastream.DatastreamAltIDs;
                    newds.DSFormatURI = relsDatastream.DSFormatURI;
                    newds.DSMIME = relsDatastream.DSMIME;
                    // newds.DSControlGrp = "X"; set by XMLDatastreamProcessor
                    newds.DSInfoType = relsDatastream.DSInfoType;
                    newds.DSState = relsDatastream.DSState;
                    newds.DSVersionable = relsDatastream.DSVersionable;
                    newds.DSVersionID = newDatastreamID(dsId);
                    newds.DSLabel = relsDatastream.DSLabel;
                    newds.DSCreateDT = Server.getCurrentDate(m_context);
                    newds.DSLocation = null;
                    newds.DSLocationType = null;
                    newds.DSChecksumType = relsDatastream.DSChecksumType;
                    newdsxml.setXMLContent(out.toByteArray());
                    newds.DSSize = newdsxml.getXMLContent().length;

                    ValidationUtility.validateReservedDatastream(PID.getInstance(m_obj.getPid()),
                                                                 newds.DatastreamID,
                                                                 newds);
                    addDatastream(newds, newds.DSVersionable);
                } else {
                    // relationship already exists
                    return false;
                }
            } catch (TrippiException e) {
                throw new GeneralException(e.getMessage(), e);
            } finally {
                try {
                    if (newIter != null) {
                        newIter.close();
                    }
                } catch (TrippiException e) {
                    throw new GeneralException(e.getMessage(), e);
                }
            }
        }
        return true;
    }
View Full Code Here

                } else {
                    // relationship does not exist
                    return false;
                }
            } catch (TrippiException e) {
                throw new GeneralException(e.getMessage(), e);
            } finally {
                try {
                    if (newIter != null) {
                        newIter.close(); // also closes the contained iter
                    }
                } catch (TrippiException e) {
                    throw new GeneralException(e.getMessage(), e);
                }
            }
        }
        return true;
    }
View Full Code Here

TOP

Related Classes of org.fcrepo.server.errors.GeneralException

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.