Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-server
Commits
683a81d4
Verified
Commit
683a81d4
authored
5 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
EHN: add timezone info to Info Resource
parent
0a9b0a5c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/caosdb/datetime/UTCTimeZoneShift.java
+13
-0
13 additions, 0 deletions
src/main/java/caosdb/datetime/UTCTimeZoneShift.java
src/main/java/caosdb/server/resource/InfoResource.java
+11
-0
11 additions, 0 deletions
src/main/java/caosdb/server/resource/InfoResource.java
with
24 additions
and
0 deletions
src/main/java/caosdb/datetime/UTCTimeZoneShift.java
+
13
−
0
View file @
683a81d4
...
@@ -111,4 +111,17 @@ public class UTCTimeZoneShift extends TimeZone {
...
@@ -111,4 +111,17 @@ public class UTCTimeZoneShift extends TimeZone {
public
String
getID
()
{
public
String
getID
()
{
return
str
;
return
str
;
}
}
/**
* Generate an ISO 8601 time zone offset string (e.g. +0200) from the given raw offset in
* milliseconds.
*
* @param rawOffset - offset in ms.
* @return ISO 8601 time zone offset.
*/
public
static
String
getISO8601Offset
(
int
rawOffset
)
{
int
h
=
Integer
.
divideUnsigned
(
rawOffset
,
1000
*
60
*
60
);
int
m
=
Integer
.
remainderUnsigned
(
rawOffset
,
1000
*
60
*
60
);
return
generateString
(
Integer
.
signum
(
h
),
h
,
m
);
}
}
}
This diff is collapsed.
Click to expand it.
src/main/java/caosdb/server/resource/InfoResource.java
+
11
−
0
View file @
683a81d4
...
@@ -22,10 +22,12 @@
...
@@ -22,10 +22,12 @@
*/
*/
package
caosdb.server.resource
;
package
caosdb.server.resource
;
import
caosdb.datetime.UTCTimeZoneShift
;
import
caosdb.server.database.backend.implementation.MySQL.ConnectionException
;
import
caosdb.server.database.backend.implementation.MySQL.ConnectionException
;
import
caosdb.server.database.misc.TransactionBenchmark
;
import
caosdb.server.database.misc.TransactionBenchmark
;
import
caosdb.server.utils.FlagInfo
;
import
caosdb.server.utils.FlagInfo
;
import
caosdb.server.utils.Info
;
import
caosdb.server.utils.Info
;
import
java.util.TimeZone
;
import
org.jdom2.Document
;
import
org.jdom2.Document
;
import
org.jdom2.Element
;
import
org.jdom2.Element
;
import
org.jdom2.JDOMException
;
import
org.jdom2.JDOMException
;
...
@@ -43,6 +45,7 @@ public class InfoResource extends AbstractCaosDBServerResource {
...
@@ -43,6 +45,7 @@ public class InfoResource extends AbstractCaosDBServerResource {
protected
Representation
httpGetInChildClass
()
throws
Exception
{
protected
Representation
httpGetInChildClass
()
throws
Exception
{
final
Document
doc
=
new
Document
();
final
Document
doc
=
new
Document
();
final
Element
root
=
generateRootElement
();
final
Element
root
=
generateRootElement
();
root
.
addContent
(
getTimeZone
());
root
.
addContent
(
Info
.
toElement
());
root
.
addContent
(
Info
.
toElement
());
root
.
addContent
(
FlagInfo
.
toElement
());
root
.
addContent
(
FlagInfo
.
toElement
());
root
.
addContent
(
TransactionBenchmark
.
getRootInstance
().
toElememt
());
root
.
addContent
(
TransactionBenchmark
.
getRootInstance
().
toElememt
());
...
@@ -50,6 +53,14 @@ public class InfoResource extends AbstractCaosDBServerResource {
...
@@ -50,6 +53,14 @@ public class InfoResource extends AbstractCaosDBServerResource {
return
ok
(
doc
);
return
ok
(
doc
);
}
}
public
Element
getTimeZone
()
{
TimeZone
d
=
TimeZone
.
getDefault
();
return
new
Element
(
"TimeZone"
)
.
setAttribute
(
"offset"
,
UTCTimeZoneShift
.
getISO8601Offset
(
d
.
getRawOffset
()))
.
setAttribute
(
"id"
,
d
.
getID
())
.
addContent
(
d
.
getDisplayName
());
}
/** There is no POST request specified for the /Info resource. */
/** There is no POST request specified for the /Info resource. */
@Override
@Override
protected
Representation
httpPostInChildClass
(
final
Representation
entity
)
protected
Representation
httpPostInChildClass
(
final
Representation
entity
)
...
...
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