// use external file and mdRef if possible, wrap and binData if not.
private void addRightsStream(InputStream is , String resourceName,
String mimeType, String mdType, AmdSec amdSec)
throws IOException, MetsException
{
RightsMD rightsMD = new RightsMD();
rightsMD.setID(gensym("rights"));
if (extraFiles == null)
{
MdWrap rightsMDWrap = new MdWrap();
rightsMDWrap.setMIMETYPE(mimeType);
rightsMDWrap.setMDTYPE(Mdtype.OTHER);
rightsMDWrap.setOTHERMDTYPE(mdType);
BinData bin = new BinData();
bin.getContent().add(new Base64(is));
rightsMDWrap.getContent().add(bin);
rightsMD.getContent().add(rightsMDWrap);
}
else
{
extraFiles.put(resourceName, is);
MdRef rightsMDRef = new MdRef();
rightsMDRef.setMIMETYPE(mimeType);
rightsMDRef.setMDTYPE(Mdtype.OTHER);
rightsMDRef.setOTHERMDTYPE(mdType);
rightsMDRef.setLOCTYPE(Loctype.URL);
rightsMDRef.setXlinkHref(resourceName);
rightsMD.getContent().add(rightsMDRef);
}
amdSec.getContent().add(rightsMD);
}