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
31d051bd
Commit
31d051bd
authored
5 years ago
by
Alexander Schlemmer
Browse files
Options
Downloads
Patches
Plain Diff
DOC: documentation and an additional check for readability of the drop off box folder added
parent
2568957c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/caosdb/server/resource/InfoResource.java
+14
-0
14 additions, 0 deletions
src/main/java/caosdb/server/resource/InfoResource.java
src/main/java/caosdb/server/utils/Info.java
+37
-7
37 additions, 7 deletions
src/main/java/caosdb/server/utils/Info.java
with
51 additions
and
7 deletions
src/main/java/caosdb/server/resource/InfoResource.java
+
14
−
0
View file @
31d051bd
...
@@ -32,8 +32,15 @@ import org.jdom2.JDOMException;
...
@@ -32,8 +32,15 @@ import org.jdom2.JDOMException;
import
org.restlet.representation.Representation
;
import
org.restlet.representation.Representation
;
import
org.restlet.resource.Options
;
import
org.restlet.resource.Options
;
/**
* This class represents the information retrieved by the /Info GET request to CaosDB.
*/
public
class
InfoResource
extends
AbstractCaosDBServerResource
{
public
class
InfoResource
extends
AbstractCaosDBServerResource
{
/**
* The response to the HTTP GET request is generated here.
* @return The response code for OK and the resulting info XML document.
*/
@Override
@Override
protected
Representation
httpGetInChildClass
()
throws
Exception
{
protected
Representation
httpGetInChildClass
()
throws
Exception
{
final
Document
doc
=
new
Document
();
final
Document
doc
=
new
Document
();
...
@@ -45,12 +52,19 @@ public class InfoResource extends AbstractCaosDBServerResource {
...
@@ -45,12 +52,19 @@ public class InfoResource extends AbstractCaosDBServerResource {
return
ok
(
doc
);
return
ok
(
doc
);
}
}
/**
* There is no POST request specified for the /Info resource.
*/
@Override
@Override
protected
Representation
httpPostInChildClass
(
final
Representation
entity
)
protected
Representation
httpPostInChildClass
(
final
Representation
entity
)
throws
ConnectionException
,
JDOMException
{
throws
ConnectionException
,
JDOMException
{
return
null
;
return
null
;
}
}
/**
* TODO: Can this stub be removed?
*/
@Deprecated
@Options
@Options
public
static
Representation
describeResource
()
{
public
static
Representation
describeResource
()
{
return
null
;
return
null
;
...
...
This diff is collapsed.
Click to expand it.
src/main/java/caosdb/server/utils/Info.java
+
37
−
7
View file @
31d051bd
...
@@ -95,6 +95,17 @@ public class Info extends AbstractObservable implements Observer, TransactionInt
...
@@ -95,6 +95,17 @@ public class Info extends AbstractObservable implements Observer, TransactionInt
return
recordTypesCount
;
return
recordTypesCount
;
}
}
/**
* Utility function that takes an array of file objects and returns a linked list containing
* XML representations of all files within each contained directory.
* All files in the array that are directories are recursively traversed.
* This function is used for files within the drop off box only.
*
* @param files An array of file objects.
* @return A linked list containing XML elements. The path attribute of these elements is set
* to the absolute path of the filenames where the path to the drop off box is removed
* at the beginning.
*/
private
static
LinkedList
<
Element
>
getFlatList
(
final
File
[]
files
)
{
private
static
LinkedList
<
Element
>
getFlatList
(
final
File
[]
files
)
{
try
{
try
{
final
LinkedList
<
Element
>
ret
=
new
LinkedList
<
Element
>();
final
LinkedList
<
Element
>
ret
=
new
LinkedList
<
Element
>();
...
@@ -158,6 +169,20 @@ public class Info extends AbstractObservable implements Observer, TransactionInt
...
@@ -158,6 +169,20 @@ public class Info extends AbstractObservable implements Observer, TransactionInt
return
toElement
(
false
);
return
toElement
(
false
);
}
}
/**
* Generates an XML element showing the information for the /Info resource in CaosDB.
*
* @return An XML element containing:
* - The number of records
* - The number of properties
* - The number of record types
* - The number of files
* - The total file size
* - The number of temp files
* - The path of the DropOffBox
* - A tree of files in the DropOffBox
* TODO: The error format for missing or not readable drop off box has to be specified.
*/
public
static
Element
toElement
(
final
boolean
tree
)
throws
Exception
,
SQLException
{
public
static
Element
toElement
(
final
boolean
tree
)
throws
Exception
,
SQLException
{
dropOffBox
=
new
File
(
FileSystem
.
getDropOffBox
());
dropOffBox
=
new
File
(
FileSystem
.
getDropOffBox
());
final
Element
info
=
new
Element
(
"Stats"
);
final
Element
info
=
new
Element
(
"Stats"
);
...
@@ -173,14 +198,19 @@ public class Info extends AbstractObservable implements Observer, TransactionInt
...
@@ -173,14 +198,19 @@ public class Info extends AbstractObservable implements Observer, TransactionInt
}
}
final
Element
e
=
new
Element
(
"dropOffBox"
);
final
Element
e
=
new
Element
(
"dropOffBox"
);
if
(
dropOffBox
.
isDirectory
())
{
if
(
dropOffBox
.
isDirectory
())
{
if
(
tree
)
{
if
(
dropOffBox
.
isReadable
())
{
e
.
setAttribute
(
"path"
,
dropOffBox
.
getAbsolutePath
());
if
(
tree
)
{
e
.
addContent
(
getTree
(
dropOffBox
.
listFiles
()));
e
.
setAttribute
(
"path"
,
dropOffBox
.
getAbsolutePath
());
}
else
{
e
.
addContent
(
getTree
(
dropOffBox
.
listFiles
()));
e
.
setAttribute
(
"path"
,
dropOffBox
.
getAbsolutePath
());
}
else
{
e
.
addContent
(
getFlatList
(
dropOffBox
.
listFiles
()));
e
.
setAttribute
(
"path"
,
dropOffBox
.
getAbsolutePath
());
}
e
.
addContent
(
getFlatList
(
dropOffBox
.
listFiles
()));
}
}
else
{
// TODO: return a message that the DropOffBox is not readable.
}
}
else
{
}
else
{
// TODO: This function should at least return a message that the DropOffBox is diabled or not present.
}
}
info
.
addContent
(
counts
);
info
.
addContent
(
counts
);
info
.
addContent
(
e
);
info
.
addContent
(
e
);
...
...
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