Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CSW2DCAT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Open-Data
CSW2DCAT
Commits
92dce796
Commit
92dce796
authored
1 year ago
by
Thorge Petersen
Browse files
Options
Downloads
Patches
Plain Diff
Improved handling of unknown licenses
parent
780690ab
No related branches found
No related tags found
1 merge request
!21
Resolve "Robusteres Hinzufügen der Lizenzinformationen"
Pipeline
#614
failed
1 year ago
Stage: build
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/de/landsh/opendata/csw2dcat/MDMetadata2Dataset.java
+24
-17
24 additions, 17 deletions
.../java/de/landsh/opendata/csw2dcat/MDMetadata2Dataset.java
with
24 additions
and
17 deletions
src/main/java/de/landsh/opendata/csw2dcat/MDMetadata2Dataset.java
+
24
−
17
View file @
92dce796
...
@@ -546,29 +546,36 @@ public class MDMetadata2Dataset {
...
@@ -546,29 +546,36 @@ public class MDMetadata2Dataset {
if
(
licenseInformation
!=
null
)
{
if
(
licenseInformation
!=
null
)
{
resource
.
addLiteral
(
DCATAPde
.
licenseAttributionByText
,
licenseInformation
.
getString
(
"quelle"
));
resource
.
addLiteral
(
DCATAPde
.
licenseAttributionByText
,
licenseInformation
.
getString
(
"quelle"
));
if
(
licenseInformation
.
has
(
"url"
))
{
if
(
licenseInformation
.
has
(
"url"
))
{
// Some publishers specify the licence as the URL and not the id.
String
licenseURL
=
licenseInformation
.
getString
(
"url"
);
String
licenseURL
=
licenseInformation
.
getString
(
"url"
);
if
(
licenseURL
.
startsWith
(
"http://dcat-ap.de/def/licenses/"
))
{
if
(
licenseURL
.
startsWith
(
"http://dcat-ap.de/def/licenses/"
))
{
resource
.
addProperty
(
DCTerms
.
license
,
model
.
createResource
(
license
Information
.
getString
(
"url"
)
));
resource
.
addProperty
(
DCTerms
.
license
,
model
.
createResource
(
license
URL
));
}
else
{
}
else
{
final
JSONObject
license
=
url2license
.
get
(
licenseURL
);
final
JSONObject
license
=
url2license
.
get
(
licenseURL
);
if
(
license
!=
null
&&
license
.
has
(
"uri"
))
{
if
(
license
!=
null
&&
license
.
has
(
"uri"
))
{
resource
.
addProperty
(
DCTerms
.
license
,
model
.
createResource
(
license
.
getString
(
"uri"
)));
resource
.
addProperty
(
DCTerms
.
license
,
model
.
createResource
(
license
.
getString
(
"uri"
)));
}
else
{
}
else
{
log
.
info
(
"Unknown license: {}"
,
licenseURL
);
log
.
info
(
"Unknown license: {}"
,
licenseURL
);
handleUnknownLicense
(
resource
,
licenseInformation
.
getString
(
"id"
));
}
}
}
}
}
else
{
}
else
{
String
licenseId
=
licenseInformation
.
getString
(
"id"
);
handleUnknownLicense
(
resource
,
licenseInformation
.
getString
(
"id"
));
}
}
}
private
void
handleUnknownLicense
(
Resource
resource
,
String
licenseId
)
{
try
{
try
{
licenseId
=
URLEncoder
.
encode
(
licenseId
,
"UTF-8"
);
licenseId
=
URLEncoder
.
encode
(
licenseId
,
"UTF-8"
);
resource
.
addProperty
(
DCTerms
.
license
,
model
.
createResource
(
"http://dcat-ap.de/def/licenses/"
+
licenseId
));
log
.
info
(
"Falling back to: {}"
,
licenseId
);
}
catch
(
UnsupportedEncodingException
e
)
{
}
catch
(
UnsupportedEncodingException
e
)
{
log
.
info
(
"Unable to encode licenseId: {}"
,
e
);
log
.
info
(
"Unable to encode licenseId: {}"
,
e
);
}
}
resource
.
addProperty
(
DCTerms
.
license
,
model
.
createResource
(
"http://dcat-ap.de/def/licenses/"
+
licenseId
));
}
}
}
}
private
Resource
guessFormat
(
String
url
)
{
private
Resource
guessFormat
(
String
url
)
{
...
...
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