Commit f20d2897 authored by granier's avatar granier
Browse files

Suppression de Name (inutile).

parent 74a25272
......@@ -31,7 +31,7 @@
<dependency>
<groupId>fr.cines.archive</groupId>
<artifactId>archive-api</artifactId>
<version>2.0.0</version>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>fr.cines.pac</groupId>
......
......@@ -55,7 +55,6 @@ import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.xml.XMLConstants;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
......@@ -69,7 +68,14 @@ import javax.xml.namespace.QName;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerFactoryConfigurationError;
import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.stream.StreamResult;
import org.apache.commons.codec.digest.DigestUtils;
import org.purl.dc.elements._1.SimpleLiteral;
......@@ -120,6 +126,7 @@ import fr.gouv.culture.archivesdefrance.seda.v2.LevelType;
import fr.gouv.culture.archivesdefrance.seda.v2.LogBookOgType;
import fr.gouv.culture.archivesdefrance.seda.v2.LogBookType;
import fr.gouv.culture.archivesdefrance.seda.v2.ManagementMetadataType;
import fr.gouv.culture.archivesdefrance.seda.v2.ManagementType;
import fr.gouv.culture.archivesdefrance.seda.v2.MessageDigestBinaryObjectType;
import fr.gouv.culture.archivesdefrance.seda.v2.ObjectFactory;
import fr.gouv.culture.archivesdefrance.seda.v2.OrganizationType;
......@@ -268,19 +275,18 @@ public class DCToSeda21Converter extends AbstractArchiveConverter {
JAXBContext jc_sip = JAXBContext.newInstance(PacType.class);
Unmarshaller unmarshaller = jc_sip.createUnmarshaller();
//Create an XMLReader to use with our filter
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser parser = spf.newSAXParser();
// XMLReader reader = XMLReaderFactory.createXMLReader();
XMLReader reader = parser.getXMLReader();
//Create the filter (to add namespace) and set the xmlReader as its parent.
NamespaceFilter inFilter = new NamespaceFilter(null, false);
inFilter.setParent(reader);
//Prepare the input, in this case a java.io.File (output)
InputSource is = new InputSource(inputStreamOriginal);
//Create a SAXSource specifying the filter
SAXSource source = new SAXSource(inFilter, is);
sip = (PacType) unmarshaller.unmarshal(source);
......@@ -309,11 +315,10 @@ public class DCToSeda21Converter extends AbstractArchiveConverter {
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", new DublincCoreNamespacePrefixMapper());
OutputStream os = new FileOutputStream(convertedManifest);
marshaller.marshal(manifest, os);
os.close();
}
// Création de InformationPackage
catch (IOException e) {
e.printStackTrace();
} catch (JAXBException e) {
......@@ -322,7 +327,9 @@ public class DCToSeda21Converter extends AbstractArchiveConverter {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
}
} catch (TransformerFactoryConfigurationError e) {
e.printStackTrace();
}
// On peuple avec les dataObjects, seul le chemin original est gardé
for (BinaryDataObjectTypeWithType oldBinary : binaryDataObjectWithTypeList) {
......@@ -330,7 +337,6 @@ public class DCToSeda21Converter extends AbstractArchiveConverter {
informationPackage.getDataObjectList().add(dataObject);
}
return manifest;
}
......@@ -491,6 +497,12 @@ public class DCToSeda21Converter extends AbstractArchiveConverter {
DescriptiveMetadataType descriptiveMetadata = objectFactory.createDescriptiveMetadataType();
ManagementType management = objectFactory.createManagementType();
management.setUpdateOperation(null);
rootArchiveUnit.setManagement(management);
/**
* Balise <Content> de l'unité d'archive racine
*/
......
......@@ -25,11 +25,11 @@ public class ExtraContentAppenderFilter extends XMLFilterImpl {
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
super.endElement(uri, localName, qName);
if ("Content".equals(localName)) {
super.startElement("", "ArchivingDate", "ArchivingDate", new AttributesImpl());
char[] chars = String.valueOf("toDay").toCharArray();
if ("Management".equals(localName)) {
super.startElement("", "updateOperation", "updateOperation", new AttributesImpl());
char[] chars = String.valueOf("toto").toCharArray();
super.characters(chars, 0, chars.length);
super.endElement("", "ArchivingDate", "ArchivingDate");
super.endElement("", "updateOperation", "updateOperation");
}
}
......
/**
*
*/
package fr.cines.pac.converter;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlValue;
/**
* Classe pour ajouter l'élément XML <name> dans le bordereau SEDA 2.1<br/>
*
* Ciblé dans :
*
* <li> DataObjectPackage/DescriptiveMetadata/ArchiveUnit/Content/OriginatingAgency/OrganizationDescriptiveMetadata/Name
* <li> ArchivalAgency/OrganizationDescriptiveMetadata/Name
* <li> TransferringAgency/OrganizationDescriptiveMetadata/Name
* <li>DataObjectPackage/DescriptiveMetadata/ArchiveUnit/Content/SubmissionAgency/OrganizationDescriptiveMetadata/Name
*
* @author Alexandre Granier <granier@cines.fr> <granier.alexandre@free.fr>
*
*/
@XmlRootElement
public class Name {
@XmlValue
private String value;
public Name(String value) {
this.value = value;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
......@@ -8,18 +8,18 @@ import javax.xml.transform.sax.SAXTransformerFactory;
import javax.xml.transform.sax.TransformerHandler;
import javax.xml.transform.stream.StreamResult;
import org.junit.Ignore;
import org.junit.Test;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.AttributesImpl;
import org.xml.sax.helpers.XMLFilterImpl;
import org.xml.sax.helpers.XMLReaderFactory;
public class XmlFilterTest {
@Test
@Ignore
public void test() throws TransformerConfigurationException, SAXException, IOException {
SAXTransformerFactory factory = (SAXTransformerFactory) TransformerFactory.newInstance();
TransformerHandler serializer = factory.newTransformerHandler();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment