Skip to content

Commit

Permalink
Merge pull request #2 from mark-cooper/fix_file_version_with_filename
Browse files Browse the repository at this point in the history
Fix file version with filename
  • Loading branch information
mark-cooper committed Sep 12, 2016
2 parents 1eee615 + 0dce786 commit 4b922bb
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/org/nyu/edu/dlts/dbCopyFrame.java
Expand Up @@ -551,7 +551,7 @@ private void initComponents() {
CellConstraints cc = new CellConstraints();

//======== this ========
setTitle("Archon Data Migrator v1.0.0 (11-09-2015)");
setTitle("Archon Data Migrator v1.0.1 (09-08-2016)");
Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());

Expand Down
5 changes: 4 additions & 1 deletion src/org/nyu/edu/dlts/utils/ASpaceMapper.java
@@ -1,6 +1,7 @@
package org.nyu.edu.dlts.utils;

import org.apache.commons.lang.WordUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
Expand Down Expand Up @@ -833,7 +834,9 @@ public void addFileVersion(JSONArray fileVersionsJA, JSONObject record, String t
fileVersionJS.put("xlink_actuate_attribute", "none");
fileVersionJS.put("xlink_show_attribute", "none");
fileVersionJS.put("file_format_name", record.get("FileTypeID"));
fileVersionJS.put("file_size_bytes", record.get("Bytes"));
fileVersionJS.put("file_size_bytes", NumberUtils.toInt((String) record.get("Bytes"), 0));

fileVersionsJA.put(fileVersionJS);
} else {
//System.out.println("No file version found for " + type + ": " + record.get("Title"));
}
Expand Down
33 changes: 31 additions & 2 deletions src/org/nyu/edu/dlts/utils/ArchonClient.java
Expand Up @@ -861,8 +861,10 @@ public void setPrintConsole(PrintConsole printConsole) {
*/
public static void main(String[] args) throws JSONException {
//String host = "http://archives-dev.library.illinois.edu/archondev/tracer";
String host = "http://localhost/~nathan/archon";
ArchonClient archonClient = new ArchonClient(host, "sa", "admin");
String host = System.getenv("ARCHON_CLIENT_HOST");
String user = System.getenv("ARCHON_CLIENT_USER");
String pass = System.getenv("ARCHON_CLIENT_PASS");
ArchonClient archonClient = new ArchonClient(host, user, pass);
archonClient.getSession();

// the json object containing list of records
Expand Down Expand Up @@ -907,6 +909,33 @@ public static void main(String[] args) throws JSONException {
records = archonClient.getDigitalObjectRecords();
System.out.println("Total Digital Objects: " + records.length());

Iterator<String> keys = records.keys();
while(keys.hasNext()) {
String key = keys.next();
JSONObject recordJS = records.getJSONObject(key);
// System.out.println(recordJS); // SHOW THE GENERATED JSON
ASpaceMapper mapper = new ASpaceMapper();
try {
JSONObject dobj = mapper.convertDigitalObject(recordJS);
// System.out.println(dobj); // SHOW THE DOBJ JSON PAYLOAD
} catch (Exception e) {
e.printStackTrace();
}
if (recordJS.has("components")) {
JSONArray components = recordJS.getJSONArray("components");
for (int i=0 ; i < components.length(); i++) {
JSONObject component = components.getJSONObject(i);
// System.out.println(component); // SHOW THE COMPONENT
try {
JSONObject dobjc = mapper.convertToDigitalObjectComponent(component);
// System.out.println(dobjc); // SHOW THE DOBJC PAYLOAD
} catch (Exception e) {
e.printStackTrace();
}
}
}
}

/*records = archonClient.getCollectionRecords();
System.out.println("Total Collection Records: " + records.length());
Expand Down

0 comments on commit 4b922bb

Please sign in to comment.