Package org.fcrepo.server.types.gen

Examples of org.fcrepo.server.types.gen.Datastream


        // check
        assertTrue("authorization \"A\" DENIED, expected PERMITTED",checkPolicyEnforcement("A"));
        assertFalse(checkPolicyEnforcement("B"));

        // purge latest datastream version
        Datastream ds = apim.getDatastream(pid, POLICY_DATASTREAM, null);
        apim.purgeDatastream(pid, POLICY_DATASTREAM, ds.getCreateDate(), ds.getCreateDate(), "purging latest version", false);

        // check reverted back to B in force, A not in force (ie prior version)
        assertTrue("authorization \"B\" DENIED, expected PERMITTED",checkPolicyEnforcement("B"));
        assertFalse(checkPolicyEnforcement("A"));
View Full Code Here


                          DatastreamsPane owner)
            throws Exception {
        super(gramps, owner, versions.get(0).getID());
        m_pid = pid;
        m_versions = versions.toArray(new Datastream[]{});
        Datastream mostRecent = versions.get(0);
        m_mostRecent = mostRecent;
        m_owner = owner;
        m_labelDims = new JLabel("Control Group").getPreferredSize();
        new TextContentEditor(); // causes it to be registered if not already
        new ImageContentViewer(); // causes it to be registered if not already
        new SVGContentViewer(); // causes it to be registered if not already
        new RDFTupleEditor(); // causes it to be registered if not already
        // mainPane(commonPane, versionPane)

        // NORTH: commonPane(state, controlGroup)

        // LEFT: labels
        JLabel idLabel = new JLabel("ID");
        JLabel stateLabel = new JLabel("State");
        JLabel versionableLabel = new JLabel("Versionable");
        JLabel controlGroupLabel = new JLabel("Control Group");
        JLabel[] leftCommonLabels =
                new JLabel[] {idLabel, controlGroupLabel, stateLabel,
                        versionableLabel};

        // RIGHT: values

        String[] comboBoxStrings = {"Active", "Inactive", "Deleted"};
        m_stateComboBox = new JComboBox(comboBoxStrings);
        Administrator.constrainHeight(m_stateComboBox);
        if (mostRecent.getState().equals("A")) {
            m_stateComboBox.setSelectedIndex(0);
            m_stateComboBox.setBackground(Administrator.ACTIVE_COLOR);
        } else if (mostRecent.getState().equals("I")) {
            m_stateComboBox.setSelectedIndex(1);
            m_stateComboBox.setBackground(Administrator.INACTIVE_COLOR);
        } else {
            m_stateComboBox.setSelectedIndex(2);
            m_stateComboBox.setBackground(Administrator.DELETED_COLOR);
        }
        m_stateComboBox.addActionListener(dataChangeListener);
        m_stateComboBox.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent evt) {
                String curState;
                if (m_stateComboBox.getSelectedIndex() == 1) {
                    curState = "I";
                    m_stateComboBox.setBackground(Administrator.INACTIVE_COLOR);
                } else if (m_stateComboBox.getSelectedIndex() == 2) {
                    curState = "D";
                    m_stateComboBox.setBackground(Administrator.DELETED_COLOR);
                } else {
                    curState = "A";
                    m_stateComboBox.setBackground(Administrator.ACTIVE_COLOR);
                }
                m_owner.colorTabForState(m_mostRecent.getID(), curState);
            }
        });

        String[] comboBoxStrings2 =
                {"Updates will create new version",
                        "Updates will replace most recent version"};
        m_versionableComboBox = new JComboBox(comboBoxStrings2);
        Administrator.constrainHeight(m_versionableComboBox);
        m_versionableComboBox
                .setSelectedIndex(mostRecent.isVersionable() ? NEW_VERSION_ON_UPDATE
                        : REPLACE_ON_UPDATE);
        m_versionableComboBox.addActionListener(dataChangeListener);

        JTextArea controlGroupValueLabel =
                new JTextArea(getControlGroupString(mostRecent
                        .getControlGroup().toString()));
        controlGroupValueLabel.setBackground(Administrator.BACKGROUND_COLOR);
        controlGroupValueLabel.setEditable(false);
        JComponent[] leftCommonValues =
                new JComponent[] {new JLabel(mostRecent.getID()),
                        controlGroupValueLabel, m_stateComboBox,
                        m_versionableComboBox};

        JPanel leftCommonPane = new JPanel();
        GridBagLayout leftCommonGridBag = new GridBagLayout();
View Full Code Here

                                 String versionID,
                                 boolean isVersionable,
                                 String controlGroup,
                                 int size,
                                 String[] altIDs) {
        Datastream ds = null;
        for (Datastream candidate : dsArray) {
            if (candidate.getID().equals(id)) {
                ds = candidate;
            }
        }
        if (ds != null) {
            if (testingMETS() && formatURI == null && ds.getFormatURI() != null) {
                assertTrue(ds.getFormatURI().endsWith("MD.OTHER.UNSPECIFIED"));
            } else {
                assertEquals(formatURI, ds.getFormatURI());
            }
            assertEquals(label, ds.getLabel());
            assertEquals(location, ds.getLocation());
            assertEquals(mimeType, ds.getMIMEType());
            assertEquals(state, ds.getState());
            assertEquals(versionID, ds.getVersionID());
            assertEquals(isVersionable, ds.isVersionable());
            assertEquals(controlGroup, ds.getControlGroup().value());
            if (size > -1) {
                assertEquals(size, ds.getSize());
            }
            if (altIDs == null) {
                assertEquals(null, ds.getAltIDs());
            } else {
                assertEquals(altIDs.length, ds.getAltIDs().getItem().size());
                for (int i = 0; i < altIDs.length; i++) {
                    assertEquals("AltID at position " + i + " did not match",
                                 altIDs[i],
                                 ds.getAltIDs().getItem().get(i));
                }
            }
        } else {
            assertEquals("Datastream with id " + id + " not found in dsArray",
                         true,
View Full Code Here

                apim.setDatastreamState("demo:5",
                                        "DC",
                                        "I",
                                        "changed state of datstream DC to Inactive");
        assertNotNull(result);
        Datastream ds = apim.getDatastream("demo:5", "DC", null);
        assertEquals("I", ds.getState());
        //System.out.println("***** Testcase: TestAPIM.testSetDatastreamState new state: "+ds.getState());

        // test setDatastreamState audit
        byte[] objectXML = TypeUtility.convertDataHandlerToBytes(apim.getObjectXML("demo:5"));
        assertTrue(objectXML.length > 0);
        String xmlIn = new String(objectXML, "UTF-8");
        assertXpathExists("foxml:digitalObject[@PID='demo:5']", xmlIn);
        assertXpathExists("//audit:auditTrail/audit:record[last()]/audit:action['setDatastreamState']",
                          xmlIn);

        // reset datastream state
        result =
                apim.setDatastreamState("demo:5",
                                        "DC",
                                        "A",
                                        "reset state of datastream DC to Active");
        assertNotNull(result);
        ds = apim.getDatastream("demo:5", "DC", null);
        assertEquals("A", ds.getState());
    }
View Full Code Here

                apim.setDatastreamVersionable("demo:5",
                                              "DC",
                                              false,
                                              "changed versionable on datastream DC to false");
        assertNotNull(result);
        Datastream ds = apim.getDatastream("demo:5", "DC", null);
        assertEquals(false, ds.isVersionable());

        // test setDatastreamVersionable audit
        byte[] objectXML = TypeUtility.convertDataHandlerToBytes(apim.getObjectXML("demo:5"));
        assertTrue(objectXML.length > 0);
        String xmlIn = new String(objectXML, "UTF-8");
        assertXpathExists("foxml:digitalObject[@PID='demo:5']", xmlIn);
        assertXpathExists("//audit:auditTrail/audit:record[last()]/audit:action['setDatastreamVersionable']",
                          xmlIn);

        // reset datastream to versionable
        result =
                apim.setDatastreamVersionable("demo:5",
                                              "DC",
                                              true,
                                              "reset versionable on datastream DC to true");
        assertNotNull(result);
        ds = apim.getDatastream("demo:5", "DC", null);
        assertEquals(true, ds.isVersionable());

    }
View Full Code Here

        m_currentVersionPane.m_editCustomButton.doClick();
    }

    private static Datastream[] MakeBlankRelsExtDatastream() {
        Datastream[] ds = new Datastream[1];
        ds[0] = new Datastream();
        ds[0].setControlGroup(DatastreamControlGroup.fromValue("X"));
        ds[0].setID("s_dsid");
        ds[0].setVersionID("RELS-EXT.0");
        ds[0].setLabel("RDF Statements about this object");
        ds[0].setVersionable(true);
View Full Code Here

        String actual = verifyGETStatusString(url, SC_OK, true, true);
        assertEquals(expected, actual);

        // managed (M) datastream
        String mimeType = "text/plain";
        Datastream ds = apim.getDatastream(DEMO_REST_PID.toString(),"BAR",null);
        assertNull(ds);
        dsPath = "/objects/" + DEMO_REST_PID + "/datastreams/BAR";
        url = getURI(dsPath + "?controlGroup=M&dsLabel=bar&mimeType=" + mimeType);
        File temp = File.createTempFile("test", null);
        DataOutputStream os = new DataOutputStream(new FileOutputStream(temp));
        os.write(42);
        os.close();
        response = post(url, temp, false);
        EntityUtils.consumeQuietly(response.getEntity());
        assertEquals(SC_UNAUTHORIZED, response.getStatusLine().getStatusCode());
        response = post(url, temp, true);
        expected = readString(response);
        assertEquals(SC_CREATED, response.getStatusLine().getStatusCode());
        locationHeader = response.getFirstHeader(HttpHeaders.LOCATION);
        assertNotNull(locationHeader);
        assertEquals(getURI(dsPath),
                     URI.create(locationHeader.getValue()));
        assertEquals(TEXT_XML, response.getFirstHeader(HttpHeaders.CONTENT_TYPE)
                .getValue());
        url = getURI(dsPath + "?format=xml");
        actual = verifyGETStatusString(url, SC_OK, true, true);
        assertEquals(expected, actual);
        ds = apim.getDatastream(DEMO_REST_PID.toString(), "BAR", null);
        assertNotNull(ds);
        assertEquals(ds.getMIMEType(), mimeType);
    }
View Full Code Here

        StringEntity entity = getStringEntity("", TEXT_XML);
        verifyPUTStatusOnly(url, SC_UNAUTHORIZED, entity, false);
        verifyPUTStatusOnly(url, SC_OK, entity, true);

        Datastream ds1 = apim.getDatastream(DEMO_REST_PID.toString(), "DS1", null);
        assertEquals(label, ds1.getLabel());
    }
View Full Code Here

                        .toString(), state));
        StringEntity entity = getStringEntity("", TEXT_XML);
        verifyPUTStatusOnly(url, SC_UNAUTHORIZED, entity, false);
        verifyPUTStatusOnly(url, SC_OK, entity, true);

        Datastream ds1 = apim.getDatastream(DEMO_REST_PID.toString(), "DS1", null);
        assertEquals(state, ds1.getState());
    }
View Full Code Here

                        .toString(), versionable));
        StringEntity entity = getStringEntity("", TEXT_XML);
        verifyPUTStatusOnly(url, SC_UNAUTHORIZED, entity, false);
        verifyPUTStatusOnly(url, SC_OK, entity, true);

        Datastream ds1 = apim.getDatastream(DEMO_REST_PID.toString(), "DS1", null);
        assertEquals(versionable, ds1.isVersionable());
    }
View Full Code Here

TOP

Related Classes of org.fcrepo.server.types.gen.Datastream

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.