Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
irma2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gerhard Gonter
irma2
Commits
a15cff50
Commit
a15cff50
authored
Sep 6, 2018
by
Gerhard Gonter
Browse files
Options
Downloads
Patches
Plain Diff
added test mode and OJS namespace
parent
fc2d5444
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
dcd.pl
+91
-75
91 additions, 75 deletions
dcd.pl
lib/DataCite/API.pm
+2
-2
2 additions, 2 deletions
lib/DataCite/API.pm
with
93 additions
and
77 deletions
dcd.pl
+
91
−
75
View file @
a15cff50
...
...
@@ -41,6 +41,7 @@ my $config_file= '/etc/irma/DataCite.json';
# identifiers table
my
$na_path
=
'
na/na-dcd-10-25365
';
my
$identifiers_file
=
join
('
/
',
$na_path
,
'
identifiers.tsv
');
my
$ifx
=
'
10.25365/phaidra
';
my
$na_id
=
1
;
my
$context_id
=
1
;
...
...
@@ -63,6 +64,11 @@ while (defined ($arg= shift (@ARGV)))
if
(
$opt
eq
'
help
')
{
usage
();
}
elsif
(
$opt
eq
'
ticket
')
{
$ticket
=
$val
||
shift
(
@ARGV
);
}
elsif
(
$opt
eq
'
doit
')
{
$register_live
=
1
;
}
elsif
(
$opt
eq
'
test
')
{
$na_path
=
'
na/na-dcd-10-5072
';
$identifiers_file
=
join
('
/
',
$na_path
,
'
identifiers.tsv
');
}
else
{
usage
();
}
}
elsif
(
$arg
=~
/^-(.+)/
)
...
...
@@ -130,6 +136,7 @@ sub register_url
print
__LINE__
,
"
repo_url=[
$repo_url
]
\n
";
if
(
$repo_url
=~
m#^https?://(phaidra(-(sandbox|temp))?\.univie\.ac\.at)/(detail_object|view/)?(o:\d+)$#
# || $repo_url =~ m# ... uscholar ... #)
||
$repo_url
=~
m#https://(ojs3test\.(univie)\.(ac)\.at)/(index\.php)/wks/article/view/(\d+)$#
)
{
my
(
$repo
,
$s1
,
$s2
,
$s3
,
$pid
)
=
(
$
1
,
$
2
,
$
3
,
$
4
,
$
5
);
...
...
@@ -154,28 +161,31 @@ sub register_url
}
my
(
$pfx
,
$ns
,
$nr
)
=
split_doi_string
(
$prod_doi_string
);
# print __LINE__, " prod_doi_string=[$prod_doi_string] pfx=[$pfx] ns=[$ns] nr=[$nr]\n";
my
$
fo
_xml
=
join
('
/
',
$na_path
,
'
metadata
',
$ns
,
join
(
'
.
'
,
$ns
,
$nr
,
'
xml
')
)
;
my
$
dc
_xml
=
join
('
/
',
$na_path
,
'
metadata
',
$ns
,
join
(
$repo_cnf
->
{
id_separator
}
,
$ns
,
$nr
)
.
'
.
xml
');
print
__LINE__
,
"
prod_doi_string=[
$prod_doi_string
] pfx=[
$pfx
] ns=[
$ns
] nr=[
$nr
]
fo
_xml=[
$
fo
_xml
]
\n
";
print
__LINE__
,
"
prod_doi_string=[
$prod_doi_string
] pfx=[
$pfx
] ns=[
$ns
] nr=[
$nr
]
dc
_xml=[
$
dc
_xml
]
\n
";
my
$prod_xml_new
;
# DataCite Metadata in XML format
if
(
-
f
$
fo
_xml
)
if
(
-
f
$
dc
_xml
)
{
my
@st
=
stat
(
_
);
my
$size
=
$st
[
7
];
print
"
ATTN: XML file [
$
fo
_xml
] already exists, reading it!
\n
";
unless
(
open
(
FO
_XML
,
'
<:utf8
',
$
fo
_xml
))
print
"
ATTN: XML file [
$
dc
_xml
] already exists, reading it!
\n
";
unless
(
open
(
DC
_XML
,
'
<:utf8
',
$
dc
_xml
))
{
print
"
ATTN: can not read XML from [
$
fo
_xml
]
\n
";
print
"
ATTN: can not read XML from [
$
dc
_xml
]
\n
";
return
;
}
sysread
(
FO
_XML
,
$prod_xml_new
,
$size
);
close
(
FO
_XML
);
sysread
(
DC
_XML
,
$prod_xml_new
,
$size
);
close
(
DC
_XML
);
}
else
{
# no XML found, so fetch metadata, convert it to XML and test it on the mds.test.datacite.org
if
(
$repo_cnf
->
{
repo_type
}
eq
'
phaidra
')
{
my
$repo_obj
=
new
Phaidra::
DataCite
(
config
=>
$repo_cnf
);
# print __LINE__, " repo_obj: ", main::Dumper ($repo_obj);
...
...
@@ -230,13 +240,13 @@ print __LINE__, " prod_doi_string=[$prod_doi_string] pfx=[$pfx] ns=[$ns] nr=[$nr
$prod_xml_new
=
$repo_obj
->
json_2_xml
(
$md
);
unless
(
open
(
FO
_XML
,
'
>:utf8
',
$
fo
_xml
))
unless
(
open
(
DC
_XML
,
'
>:utf8
',
$
dc
_xml
))
{
print
"
ATTN: can not write XML to [
$
fo
_xml
]
\n
";
print
"
ATTN: can not write XML to [
$
dc
_xml
]
\n
";
return
;
}
syswrite
(
FO
_XML
,
$prod_xml_new
);
close
(
FO
_XML
);
syswrite
(
DC
_XML
,
$prod_xml_new
);
close
(
DC
_XML
);
print
"
metatada fetched:
",
get_ts
(),
"
\n
";
if
(
$dc_res
->
{
status
}
ne
'
OK
')
...
...
@@ -251,6 +261,12 @@ print __LINE__, " prod_doi_string=[$prod_doi_string] pfx=[$pfx] ns=[$ns] nr=[$nr
return
undef
;
}
}
else
{
print
"
ERROR: can't fetch metadata for this type of repository! [
",
$repo_cnf
->
{
repo_type
},
"
]
\n
";
return
undef
;
}
}
print
__LINE__
,
"
prod_xml_new=[
$prod_xml_new
]
\n
";
...
...
@@ -309,7 +325,7 @@ sub split_doi_string
my
$doi
=
shift
;
# e.g. 10.25365/phaidra.1
my
(
$pfx
,
$sfx
)
=
split
('
/
',
$doi
,
2
);
my
(
$ns
,
$nr
)
=
split
(
/\./
,
$sfx
,
2
);
my
(
$ns
,
$nr
)
=
split
(
/
[
\.
\-]
/
,
$sfx
,
2
);
(
$pfx
,
$ns
,
$nr
);
}
...
...
This diff is collapsed.
Click to expand it.
lib/DataCite/API.pm
+
2
−
2
View file @
a15cff50
...
...
@@ -61,7 +61,7 @@ url=$repo_url
EOX
my
(
$code2
,
$res2
)
=
$self
->
datacite_request
('
POST
',
'
doi
',
$doi_reg
,
'
application/xml;charset=UTF-8
');
print
__LINE__
,
"
code2=[
$code2
] res2=[
$res2
]
\n
";
print
__LINE__
,
"
doi_reg=[
$doi_reg
]
code2=[
$code2
] res2=[
$res2
]
\n
";
unless
(
$code2
=~
m#^20[01]#
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment