Beispiel #1
0
  public static void main(String[] args) {
    System.setProperty("java.awt.headless", "true");

    try {
      if (args.length < 6 || args.length > 7) {
        DatastreamConduit.showUsage("You must provide six or seven arguments.");
      } else {
        String hostName = args[0];
        int portNum = Integer.parseInt(args[1]);
        String username = args[2];
        String password = args[3];
        String pid = args[4];
        String protocol = args[5];

        String context = Constants.FEDORA_DEFAULT_APP_CONTEXT;
        if (args.length == 7 && !args[6].equals("")) {
          context = args[6];
        }
        // ******************************************
        // NEW: use new client utility class
        String baseURL = protocol + "://" + hostName + ":" + portNum + "/" + context;
        FedoraClient fc = new FedoraClient(baseURL, username, password);
        FedoraAPIMMTOM sourceRepoAPIM = fc.getAPIMMTOM();
        // *******************************************
        DatastreamConduit c = new DatastreamConduit(sourceRepoAPIM);

        List<Datastream> datastreams = c.getDatastreams(pid, null, null);
        for (Datastream ds : datastreams) {
          System.out.println("   Datastream : " + ds.getID());
          System.out.println("Control Group : " + ds.getControlGroup().toString());
          System.out.println("  Versionable : " + ds.isVersionable());
          System.out.println("    Mime Type : " + ds.getMIMEType());
          System.out.println("   Format URI : " + ds.getFormatURI());
          ArrayOfString altIDs = ds.getAltIDs();
          if (altIDs != null && altIDs.getItem() != null) {
            for (String element : altIDs.getItem()) {
              System.out.println(" Alternate ID : " + element);
            }
          }
          System.out.println("        State : " + ds.getState());
          // print version id, create date, and label for each version
          List<Datastream> versions = c.getDatastreamHistory(pid, ds.getID());
          for (Datastream ver : versions) {
            System.out.println("      VERSION : " + ver.getVersionID());
            System.out.println("        Created : " + ver.getCreateDate());
            System.out.println("          Label : " + ver.getLabel());
            System.out.println("       Location : " + ver.getLocation());
          }
          System.out.println("");
        }
      }
    } catch (Exception e) {
      DatastreamConduit.showUsage(
          e.getClass().getName()
              + " - "
              + (e.getMessage() == null ? "(no detail provided)" : e.getMessage()));
    }
  }
  @Before
  public void setUp() throws Exception {
    apim = s_client.getAPIMMTOM();
    Map<String, String> nsMap = new HashMap<String, String>();
    nsMap.put("oai_dc", "http://www.openarchives.org/OAI/2.0/oai_dc/");
    nsMap.put("dc", "http://purl.org/dc/elements/1.1/");
    nsMap.put("foxml", "info:fedora/fedora-system:def/foxml#");
    NamespaceContext ctx = new SimpleNamespaceContext(nsMap);
    XMLUnit.setXpathNamespaceContext(ctx);

    apim.ingest(
        TypeUtility.convertBytesToDataHandler(DEMO_888_FOXML),
        FOXML1_1.uri,
        "ingesting new foxml object");
    apim.ingest(
        TypeUtility.convertBytesToDataHandler(DEMO_777_FOXML),
        FOXML1_1.uri,
        "ingesting new foxml object");

    // managed content versions of above (reserved datastreams translated from X to M)
    ManagedContentTranslator.createManagedClone(apim, "demo:888", "demo:888m");
    ManagedContentTranslator.createManagedClone(apim, "demo:777", "demo:777m");
  }
Beispiel #3
0
 public PolicyUtils(FedoraClient fedoraClient) throws ServiceException, IOException {
   apim = fedoraClient.getAPIMMTOM();
 }