Package org.fcrepo.common

Examples of org.fcrepo.common.PID


            }

            Set<String> parents = mapping.get(relationship);
            if (parents != null) {
                for (String parent : parents) {
                    PID parentPID = PID.getInstance(parent);
                    // we want the parents in demo:123 form, not info:fedora/demo:123
                    parentPIDs.add(parentPID.toString());
                    if (logger.isDebugEnabled()) {
                        logger.debug("added parent " + parentPID.toString());
                    }
                }
            }
        }
        return parentPIDs;
View Full Code Here


            strippedSubject = subject.substring(Constants.FEDORA.uri.length());
        } else {
            strippedSubject = subject;
        }
        String parts[] = strippedSubject.split("/");
        PID pid = new PID(parts[0]);
        String subjectURI;
        if (parts.length == 1) {
            subjectURI = pid.toURI();
        } else if (parts.length == 2) {
            subjectURI = pid.toURI() + "/" + parts[1]; // add datastream
        } else {
            logger.warn("Invalid subject argument for getRelationships: " + subject + ". Should be pid or datastream (URI form optional");
            subjectURI = null;
        }
View Full Code Here


    // Wraps PID constructor, throwing a ServerException instead
    public static PID getPID(String pidString) throws MalformedPidException {
        try {
            return new PID(pidString);
        } catch (MalformedPIDException e) {
            throw new MalformedPidException(e.getMessage());
        }
    }
View Full Code Here

    public synchronized PID generatePID(String namespace) throws IOException {
        int i = getHighestID(namespace);
        i++;

        try {
            m_lastPID = new PID(namespace + ":" + i);
        } catch (MalformedPIDException e) {
            throw new IOException(e.getMessage());
        }

        setHighestID(namespace, i);
View Full Code Here

     * Cause the given PID to never be generated by the PID generator.
     */
    public synchronized void neverGeneratePID(String pid) throws IOException {
        logger.debug("Never generating PID: " + pid);
        try {
            PID p = new PID(pid);
            String ns = p.getNamespaceId();
            int id = Integer.parseInt(p.getObjectId());
            if (id > getHighestID(ns)) {
                setHighestID(ns, id);
            }
        } catch (MalformedPIDException mpe) {
            throw new IOException(mpe.getMessage());
View Full Code Here

                                                "testManagedDatastreams",
                                                false);
    }

    private Feed createAtomObject(String spid, String contentLocation) throws Exception {
        PID pid = PID.getInstance(spid);
        Date date = new Date(1);
        String title = "title";
        String author = "org.fcrepo.test.api.TestManagedDatastreams";

        Feed feed = abdera.newFeed();
        feed.setId(pid.toURI());
        feed.setTitle(title);
        feed.setUpdated(date);
        feed.addAuthor(author);

        if (contentLocation != null && contentLocation.length() > 0) {
View Full Code Here

        dsvEntry.setSummary("summary");
        dsvEntry.setContent(new IRI(contentLocation), "text/plain");
    }

    private Foxml11Document createFoxmlObject(String spid, String contentLocation) throws Exception {
        PID pid = PID.getInstance(spid);
        Date date = new Date(1);

        Foxml11Document doc = new Foxml11Document(pid.toString());
        doc.addObjectProperty(Property.STATE, "A");

        if (contentLocation != null && contentLocation.length() > 0) {
            String ds = "DS";
            String dsv = "DS1.0";
View Full Code Here

            fail(e.getMessage());
        }
    }

    public void testgetLastPID() {
        PID pid;
        try {
            pid = testPIDGenerator.getLastPID();
        } catch (UnsupportedOperationException e) {
            // optional
        } catch (IOException e) {
View Full Code Here

    /**
     * hashCode() should return the same value for lexically equivalent PIDs.
     */
    @Test
    public void testHashCodeSamePID() throws Exception {
        PID pid1 = PID.getInstance("test:somepid");
        PID pid2 = new PID("test:somepid");
        PID pid3 = PID.fromFilename("test_somepid");
        assertEquals(pid1.hashCode(), pid2.hashCode());
        assertEquals(pid2.hashCode(), pid3.hashCode());
    }
View Full Code Here

    /**
     * equals() should return true for lexically equivalent PIDs.
     */
    @Test
    public void testEqualsSamePID() throws Exception {
        PID pid1 = PID.getInstance("test:somepid");
        PID pid2 = new PID("test:somepid");
        PID pid3 = PID.fromFilename("test_somepid");
        assertEquals(pid1, pid2);
        assertEquals(pid2, pid3);
    }
View Full Code Here

TOP

Related Classes of org.fcrepo.common.PID

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.