58 |
58 |
import org.dataone.service.exceptions.UnsupportedType;
|
59 |
59 |
import org.dataone.service.exceptions.NotFound;
|
60 |
60 |
import org.dataone.service.types.*;
|
|
61 |
import org.dataone.service.types.util.ServiceTypeUtil;
|
61 |
62 |
import org.jibx.runtime.BindingDirectory;
|
62 |
63 |
import org.jibx.runtime.IBindingFactory;
|
63 |
64 |
import org.jibx.runtime.IMarshallingContext;
|
... | ... | |
634 |
635 |
File tmpSMFile = new File(tmpDir +
|
635 |
636 |
".sysmeta." + new Date().getTime() + ".tmp");
|
636 |
637 |
System.out.println("temp dir: " + tmpDir.getAbsolutePath());
|
637 |
|
MultipartRequestResolver mrr = new MultipartRequestResolver(tmpDir.getAbsolutePath());
|
|
638 |
MultipartRequestResolver mrr = new MultipartRequestResolver(
|
|
639 |
tmpDir.getAbsolutePath(), 1000000000, 0);
|
638 |
640 |
MultipartRequest mr = mrr.resolveMultipart(request);
|
639 |
641 |
Map<String, File> files = mr.getMultipartFiles();
|
640 |
642 |
Iterator keys = files.keySet().iterator();
|
... | ... | |
710 |
712 |
System.out.println("verifying checksum");
|
711 |
713 |
String docChecksumStr = CrudService.checksum(
|
712 |
714 |
new FileInputStream(outputTmpFile),
|
713 |
|
sm.getChecksum().getAlgorithm().name());
|
|
715 |
sm.getChecksum().getAlgorithm().toString());
|
714 |
716 |
System.out.println("original checksum: " + sm.getChecksum().getValue());
|
715 |
717 |
System.out.println(" created checksum: " + docChecksumStr);
|
716 |
718 |
|
|
719 |
|
717 |
720 |
//insert the document in local db
|
718 |
721 |
System.out.println("creating new doc");
|
719 |
722 |
CrudService.getInstance().create(token,
|
720 |
723 |
sm.getIdentifier(), new FileInputStream(outputTmpFile), sm);
|
721 |
724 |
//call cn.setReplicationStatus(guid, COMPLETE)
|
722 |
725 |
|
723 |
|
/*Questions:
|
724 |
|
* Call is now supposed to look like replicate(token, SystemMetadata, SourceNode)
|
725 |
|
* how is SystemMetadata encoded? Multipart?
|
726 |
|
*
|
727 |
|
* Is the token passed used to access MN_A? How does MN_A
|
728 |
|
* know it's valid?
|
729 |
|
*
|
730 |
|
* What exactly is happening when setReplicationStatus is called
|
731 |
|
* to the CN? Which systemMetadata is being updated? MN_A or MN_B or both?
|
732 |
|
*
|
733 |
|
*
|
734 |
|
*
|
735 |
|
*/
|
736 |
|
|
737 |
726 |
}
|
738 |
727 |
}
|
739 |
728 |
|
... | ... | |
1374 |
1363 |
private void serializeServiceType(Class type, Object object, OutputStream out)
|
1375 |
1364 |
throws JiBXException
|
1376 |
1365 |
{
|
1377 |
|
IBindingFactory bfact = BindingDirectory.getFactory(type);
|
1378 |
|
IMarshallingContext mctx = bfact.createMarshallingContext();
|
1379 |
|
mctx.marshalDocument(object, "UTF-8", null, out);
|
|
1366 |
ServiceTypeUtil.serializeServiceType(type, object, out);
|
1380 |
1367 |
}
|
1381 |
1368 |
|
1382 |
1369 |
/**
|
... | ... | |
1388 |
1375 |
private Object deserializeServiceType(Class type, InputStream is)
|
1389 |
1376 |
throws JiBXException
|
1390 |
1377 |
{
|
1391 |
|
IBindingFactory bfact = BindingDirectory.getFactory(type);
|
1392 |
|
IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
|
1393 |
|
Object o = (Object) uctx.unmarshalDocument(is, null);
|
1394 |
|
return o;
|
|
1378 |
return ServiceTypeUtil.deserializeServiceType(type, is);
|
1395 |
1379 |
}
|
1396 |
1380 |
|
1397 |
1381 |
/**
|
refactor checksum and some other stuff