Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dad
archive-format-converter
Commits
032f17e6
Commit
032f17e6
authored
Sep 21, 2021
by
marceteau
Browse files
ajout gestion ark dans les relations + refactor fermeture bufferReader
parent
d9610d57
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
archive-converter
View file @
032f17e6
#!/usr/bin/env bash
java
-jar
/usr/share/java/archive-converter/
${
project
.name
}
-
${
project
.version
}
.jar
"
$@
"
\ No newline at end of file
java
-Dfr
.cines.vitam.converter.ark
=
/etc/
${
project
.name
}
/pac_list_all_ark.txt
-jar
/usr/share/java/archive-converter/
${
project
.name
}
-
${
project
.version
}
.jar
"
$@
"
\ No newline at end of file
src/main/java/fr/cines/pac/converter/DCToSeda21Converter.java
View file @
032f17e6
...
...
@@ -468,9 +468,10 @@ public class DCToSeda21Converter extends AbstractArchiveConverter {
* @param submissionAgency
* @param currentArchive
* @throws IngestRejectException
* @throws IOException
*/
@SuppressWarnings
(
"null"
)
private
DataObjectPackageType
mapArchiveBlock
(
ArchiveUnitType
currentArchive
,
PacType
sip
)
throws
IngestRejectException
{
private
DataObjectPackageType
mapArchiveBlock
(
ArchiveUnitType
currentArchive
,
PacType
sip
)
throws
IngestRejectException
,
IOException
{
DataObjectPackageType
dataObjectPackage
=
objectFactory
.
createDataObjectPackageType
();
// Contrat d'archive
...
...
@@ -807,16 +808,40 @@ public class DCToSeda21Converter extends AbstractArchiveConverter {
}
/**
* Cette fonction sert à tenter de reformer l'ark depuis un identifiant provenant de PAC
* Cette fonction sert à reformer l'ark depuis un identifiant provenant de PAC (qui est unique)
* Pour ce faire, on utilise la liste complète de tous les ark provenant d'arcsys qui doit être disponible localement dans
* le fichier pac_list_all_ark.txt.
* Il faudra mettre à jour cette liste jusqu'à ce que arcsys ne soit plus utilisé.
*
* @param identifiantSourceRelation
* @return
* @throws IOException
*/
private
String
constructArkFromIdentifier
(
String
identifiantSourceRelation
)
{
// TODO Corriger cette fonction pour être certain que l'ark existe (si c'est seulement possible...)
//Il faudra peut-être aller interroger vitam et/ou arcsys si l'on veut être rigoureux
String
prefix
=
properties
.
getProperty
(
PREFIXE_ARK
);
return
prefix
.
concat
(
identifiantSourceRelation
);
String
arkProperty
=
System
.
getProperty
(
"fr.cines.vitam.converter.ark"
);
try
(
BufferedReader
br
=
new
BufferedReader
(
new
FileReader
(
arkProperty
)))
{
String
ligne
=
null
;
while
((
ligne
=
br
.
readLine
())
!=
null
)
{
String
[]
data
=
ligne
.
split
(
"-"
);
if
(
data
.
length
==
2
)
{
String
identifiant
=
data
[
1
].
trim
();
if
(
identifiant
.
equalsIgnoreCase
(
identifiantSourceRelation
))
{
br
.
close
();
return
ligne
;
}
}
}
br
.
close
();
return
null
;
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
/**
...
...
@@ -1318,7 +1343,11 @@ public class DCToSeda21Converter extends AbstractArchiveConverter {
metadata
.
setAudio
(
audioTechnicalMetadataType
);
}
}
binaryDataObject
.
setMetadata
(
metadata
);
if
(
metadata
.
getAudio
()
!=
null
||
metadata
.
getDocument
()
!=
null
||
metadata
.
getImage
()
!=
null
||
metadata
.
getOtherCoreTechnicalMetadataAbstract
()
!=
null
||
metadata
.
getText
()
!=
null
||
metadata
.
getVideo
()
!=
null
)
{
binaryDataObject
.
setMetadata
(
metadata
);
}
// if (formatVideoList.contains(format.getName())) {
// JAXBElement<String> jaxbElementEncoding = createXMLElement(format.getEncoding(), "encoding");
//
...
...
@@ -1992,32 +2021,40 @@ public class DCToSeda21Converter extends AbstractArchiveConverter {
* @return
* @throws Exception
*/
public
static
String
[]
filePlanData
(
String
filePath
,
String
planClassement
)
throws
Exception
public
static
String
[]
filePlanData
(
String
filePath
,
String
planClassement
)
{
BufferedReader
br
=
new
BufferedReader
(
new
FileReader
(
filePath
));
String
ligne
=
null
;
planClassement
=
planClassement
.
trim
();
//Si planClassement termine ou commence par un / on le retire
if
(
planClassement
.
endsWith
(
"/"
)
&&
planClassement
.
length
()
>
1
)
planClassement
=
planClassement
.
substring
(
0
,
planClassement
.
length
()
-
1
);
if
(
planClassement
.
startsWith
(
"/"
)
&&
planClassement
.
length
()
>
1
)
planClassement
=
planClassement
.
substring
(
1
,
planClassement
.
length
());
while
((
ligne
=
br
.
readLine
())
!=
null
)
{
// Retourner la ligne dans un tableau
String
[]
data
=
ligne
.
split
(
"\t"
);
if
(
data
.
length
==
4
)
{
String
planClassementFile
=
data
[
0
].
trim
();
if
(
planClassement
.
equals
(
planClassementFile
))
{
return
data
;
try
(
BufferedReader
br
=
new
BufferedReader
(
new
FileReader
(
filePath
)))
{
String
ligne
=
null
;
planClassement
=
planClassement
.
trim
();
//Si planClassement termine ou commence par un / on le retire
if
(
planClassement
.
endsWith
(
"/"
)
&&
planClassement
.
length
()
>
1
)
planClassement
=
planClassement
.
substring
(
0
,
planClassement
.
length
()
-
1
);
if
(
planClassement
.
startsWith
(
"/"
)
&&
planClassement
.
length
()
>
1
)
planClassement
=
planClassement
.
substring
(
1
,
planClassement
.
length
());
while
((
ligne
=
br
.
readLine
())
!=
null
)
{
// Retourner la ligne dans un tableau
String
[]
data
=
ligne
.
split
(
"\t"
);
if
(
data
.
length
==
4
)
{
String
planClassementFile
=
data
[
0
].
trim
();
if
(
planClassement
.
equals
(
planClassementFile
))
{
br
.
close
();
return
data
;
}
}
}
}
br
.
close
();
br
.
close
();
}
catch
(
FileNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
//TODO : lever une exception car on n'a pas d'équivalent dans le fichier de référence
return
null
;
}
...
...
@@ -2033,37 +2070,47 @@ public class DCToSeda21Converter extends AbstractArchiveConverter {
* @throws IOException
* @throws Exception
*/
private
static
String
propertiesCorespondance
(
String
filePath
,
String
agency
,
String
planClassement
)
throws
IOException
private
static
String
propertiesCorespondance
(
String
filePath
,
String
agency
,
String
planClassement
)
{
BufferedReader
br
=
new
BufferedReader
(
new
FileReader
(
filePath
+
"/correspondances_properties.csv"
));
String
ligne
=
null
;
agency
=
agency
.
trim
();
if
(
planClassement
==
null
)
{
planClassement
=
"/"
;
}
planClassement
=
planClassement
.
trim
();
String
defaultProperties
=
""
;
while
((
ligne
=
br
.
readLine
())
!=
null
)
{
String
[]
data
=
ligne
.
split
(
"\t"
);
if
(
data
.
length
==
3
)
{
String
agencyFile
=
data
[
0
].
trim
();
String
planClassementFile
=
data
[
1
].
trim
();
if
(
agency
.
equalsIgnoreCase
(
agencyFile
)
&&
planClassement
.
equalsIgnoreCase
(
planClassementFile
))
{
return
data
[
2
];
}
else
if
(
agency
.
equalsIgnoreCase
(
agencyFile
)
&&
"/"
.
equalsIgnoreCase
(
planClassementFile
))
{
defaultProperties
=
data
[
2
];
try
(
BufferedReader
br
=
new
BufferedReader
(
new
FileReader
(
filePath
+
"/correspondances_properties.csv"
)))
{
String
ligne
=
null
;
agency
=
agency
.
trim
();
if
(
planClassement
==
null
)
{
planClassement
=
"/"
;
}
planClassement
=
planClassement
.
trim
();
String
defaultProperties
=
""
;
while
((
ligne
=
br
.
readLine
())
!=
null
)
{
String
[]
data
=
ligne
.
split
(
"\t"
);
if
(
data
.
length
==
3
)
{
String
agencyFile
=
data
[
0
].
trim
();
String
planClassementFile
=
data
[
1
].
trim
();
if
(
agency
.
equalsIgnoreCase
(
agencyFile
)
&&
planClassement
.
equalsIgnoreCase
(
planClassementFile
))
{
br
.
close
();
return
data
[
2
];
}
else
if
(
agency
.
equalsIgnoreCase
(
agencyFile
)
&&
"/"
.
equalsIgnoreCase
(
planClassementFile
))
{
defaultProperties
=
data
[
2
];
}
}
}
}
if
(!
defaultProperties
.
equals
(
""
))
{
return
defaultProperties
;
}
if
(!
defaultProperties
.
equals
(
""
))
{
br
.
close
();
return
defaultProperties
;
}
br
.
close
();
br
.
close
();
}
catch
(
FileNotFoundException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
//TODO : lever une exception car on n'a pas de fichier properties
return
null
;
}
...
...
src/main/resources/ABES.properties
deleted
100644 → 0
View file @
d9610d57
# Metadonnees Generales
ArchivalAgreement
=
CE-000004
ArchivalProfile
=
false
ArchiveUnitProfile
=
false
AppraisalRule_Rule
=
false
OriginatingAgencyIdentifier
=
SA-000023
SubmissionAgencyIdentifier
=
SA-000023
ArchivalAgency_Identifier
=
SA-000001
TransferringAgency_Identifier
=
SA-000023
# Indique la balise cible : choix entre OriginatingSystemId, OriginatingAgencyArchiveUnitIdentifier et TransferringAgencyArchiveUnitIdentifier
IdentifiantDocProducteur
=
TransferringAgencyArchiveUnitIdentifier
# Configuration specifique
# Mapping des balises oui/non
format
=
false
coverage
=
true
planClassement
=
false
# Optionnel : utiliser pour mapper DocumentType
# Si absent reprends la concatnation des balises type de DocDC
DocumentType
=
Electronic Thesis or Dissertation
# Generation des balises
prefixeARK
=
false
cines-dc
=
true
# Non utilise
X-Access-Contract-Id
=
CA-000001
src/main/resources/BSG.properties
deleted
100644 → 0
View file @
d9610d57
# Metadonnees Generales
ArchivalAgreement
=
CE-000005
ArchivalProfile
=
false
ArchiveUnitProfile
=
false
AppraisalRule_Rule
=
false
OriginatingAgencyIdentifier
=
SA-000024
SubmissionAgencyIdentifier
=
SA-000024
ArchivalAgency_Identifier
=
SA-000001
TransferringAgency_Identifier
=
SA-000024
# Indique la balise cible : choix entre OriginatingSystemId, OriginatingAgencyArchiveUnitIdentifier et TransferringAgencyArchiveUnitIdentifier
IdentifiantDocProducteur
=
TransferringAgencyArchiveUnitIdentifier
# Configuration specifique
# Mapping des balises oui/non
format
=
true
coverage
=
true
planClassement
=
true
# Generation des balises
prefixeARK
=
false
cines-dc
=
true
# Non utilise
X-Access-Contract-Id
=
CA-000001
\ No newline at end of file
src/main/resources/CINES.properties
deleted
100644 → 0
View file @
d9610d57
# Metadonnees Generales
ArchivalAgreement
=
CE-000001
ArchivalProfile
=
false
ArchiveUnitProfile
=
false
AppraisalRule_Rule
=
false
OriginatingAgencyIdentifier
=
SA-000001
SubmissionAgencyIdentifier
=
SA-000001
ArchivalAgency_Identifier
=
SA-000001
TransferringAgency_Identifier
=
SA-000001
# Indique la balise cible : choix entre OriginatingSystemId, OriginatingAgencyArchiveUnitIdentifier et TransferringAgencyArchiveUnitIdentifier
IdentifiantDocProducteur
=
OriginatingSystemId
# Configuration specifique
# Mapping des balises oui/non
format
=
false
coverage
=
false
planClassement
=
false
# Optionnel : utiliser pour mapper DocumentType
# Si absent reprends la concatnation des balises type de DocDC
#DocumentType=Mon type
# Generation des balises
prefixeARK
=
false
cines-dc
=
false
# Non utilise
X-Access-Contract-Id
=
CA-000001
src/main/resources/pac_list_all_ark.txt
0 → 100644
View file @
032f17e6
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment