Gitlab Community Edition Instance

Commit 7d6e8cda authored by mhellka's avatar mhellka
Browse files

Refactoring

parent 7e67c7d2
......@@ -291,7 +291,7 @@ endpoints:
Request form data is interpreted as a list of commands and applied in order. The order is significant. For example, a file can be uploaded, then copied, then annotated with metadata, all in the same request. Make sure your HTTP client preserves the order of form fields when
generating the request body.
Commands that contain a `{filename}` placeholder operate on files within the archive. The filename must start with a slash (`/`) in order to be recognized. If the filename also ends with a slash, it usually affects all files with that prefix. Be careful.
Commands that contain a `{filename}` placeholder operate on files within the archive. The filename must start with a slash (`/`) in order to be recognized. If the filename also ends with a slash, it usually affects all files with that prefix. Be careful.
File uploads only work with `multipart/form-data` and are not recommended for large files.
Prefer <<putFile>> for anything larger than a couple of MB. Uploading a large number of small files may be faster using this api, though. Your mileage may vary.
......@@ -302,7 +302,7 @@ endpoints:
"{filename}":
type: file upload
help: |
Upload a file (`multipart/form-data` only).
Upload a new file (`multipart/form-data` only).
If the filename ends with a slash, then the original (client-side) name of the file is appended.
If the filetype is either `application/x-autodetect` or missing, cdstar ill tyr to guess the correct content-type from the file name extension an default to `application/octet-stream` if that fails.
......@@ -312,18 +312,19 @@ endpoints:
$ curl --form /filename.txt=@source.txt;type=text/plain
$ curl --form /folder/=@source.txt;name=filename.txt
"copy:{filename}":
help: Create a file by copying the content of an existing file from the same archive.
help: Create a new file by copying the content of an existing file from the same archive.
example: "$ curl --data copy:/target.txt=/source.txt"
"clone:{filename}":
help: Create a file by copying the content and metadata of an existing file from the same archive.
help: Create a new file by copying the content and metadata of an existing file from the same archive.
"move:{filename}":
help: Create a file by renaming an existing file from the same archive.
help: Rename an existing file.
"fetch:{filename}":
type: url
type: uri
help: |
Create a file by fetching an external resource. If `{filename}` ends in a slash (`/`) then the last path segment of the fetch URL is appended to the file name.
Create a new file by fetching an external resource. If `{filename}` ends in a slash (`/`) then the last path segment of the fetch URL is appended to the file name.
This feature must be enabled in the vault configuration and is disabled by default.
Supported URI schemes depend on installed plugins and not all URIs may be allowed.
For example, fetching from `http://` URLs may be limited to trusted domains, or diabled completely.
example: "$ curl --data fetch:/bigfile.dat=http://example.com/bigfile.dat"
"delete:{filename}":
help: Delete a file. The value is ignored. If `{filename}` ends with a slash (`/`), then all files under that directory are removed.
......
......@@ -93,37 +93,37 @@ public class JsonFormat {
switch (fieldName) {
case ("id"):
doc.id = readText(p);
break;
break;
case ("v"):
doc.v = (int) readLong(p);
if (doc.v != JsonIndex.CURRENT_FORMAT_V)
throw new FormatVersionError("Migration required: " + p.getLongValue());
break;
if (doc.v != JsonIndex.CURRENT_FORMAT_V)
throw new FormatVersionError("Migration required: " + p.getLongValue());
break;
case ("rev"):
doc.rev = readText(p);
break;
break;
case ("parent"):
doc.parent = readText(p);
break;
break;
case ("type"):
doc.type = readText(p);
break;
break;
case ("ctime"):
doc.ctime = readLong(p);
break;
break;
case ("mtime"):
doc.mtime = readLong(p);
break;
break;
case ("dtime"):
doc.dtime = readLong(p);
break;
break;
case ("resources"):
assertNextToken(p, JsonToken.START_ARRAY);
doc.resources = new ArrayList<>();
while (p.nextToken() == JsonToken.START_OBJECT)
doc.resources.add(readResourceEntry(p));
assertCurrentToken(p, JsonToken.END_ARRAY);
break;
doc.resources = new ArrayList<>();
while (p.nextToken() == JsonToken.START_OBJECT)
doc.resources.add(readResourceEntry(p));
assertCurrentToken(p, JsonToken.END_ARRAY);
break;
default:
if (fieldName.startsWith("x-")) {
if (doc.attr == null)
......@@ -200,34 +200,34 @@ public class JsonFormat {
switch (fieldName) {
case ("id"):
jr.id = readText(p);
break;
break;
case ("src"):
jr.src = readText(p);
break;
break;
case ("name"):
jr.name = readText(p);
break;
break;
case ("type"):
jr.type = readText(p);
break;
break;
case ("size"):
jr.size = readLong(p);
break;
break;
case ("ctime"):
jr.ctime = readLong(p);
break;
break;
case ("mtime"):
jr.mtime = readLong(p);
break;
break;
case ("md5"):
jr.md5 = readBytes(p);
break;
break;
case ("sha1"):
jr.sha1 = readBytes(p);
break;
break;
case ("sha256"):
jr.sha256 = readBytes(p);
break;
break;
default:
if (fieldName.startsWith("x-")) {
if (jr.attr == null)
......@@ -354,8 +354,8 @@ public class JsonFormat {
private void migrate(JsonNode node) throws IOException {
if (!node.isObject())
throw new FormatError("Not a json object at all.");
final ObjectNode tree = (ObjectNode) node;
final ObjectNode tree = (ObjectNode) node;
final int v = tree.path("v").asInt(0);
switch (v) {
......@@ -373,8 +373,8 @@ public class JsonFormat {
}
tree.put("v", JsonIndex.CURRENT_FORMAT_V); // Bump to current version
// after migration is
// complete
// after migration is
// complete
}
......@@ -438,7 +438,7 @@ public class JsonFormat {
if (src.startsWith("external:")) {
res.put("src", "x-" + src.substring("external:".length()));
} else if (src.endsWith(".bin")
&& src.equals(Utils.bytesToHex(Utils.base64decode(res.get("sha256").asText())) + ".bin")) {
&& src.equals(Utils.bytesToHex(Utils.base64decode(res.get("sha256").asText())) + ".bin")) {
res.remove("src");
} else {
throw new FormatError("Unrecognized value for 'resource.src' in version 3 format: " + Utils.repr(src));
......
......@@ -331,7 +331,7 @@ class ArchiveImpl implements CDStarArchive {
filesCache = new ArrayList<>();
for (final Resource r : sto.getResourcesByPrefix(FileImpl.RESOURCE_PREFIX)) {
String name = r.getName();
name = name.substring(FileImpl.RESOURCE_PREFIX.length(), name.length());
name = name.substring(FileImpl.RESOURCE_PREFIX.length());
filesCache.add(new FileImpl(this, r, name, null));
}
}
......
......@@ -25,7 +25,6 @@ import de.gwdg.cdstar.runtime.listener.RuntimeListener;
import de.gwdg.cdstar.runtime.services.health.HealthService;
import de.gwdg.cdstar.runtime.services.health.HealthStatus;
@SuppressWarnings("restriction")
public class DefaultMetricsAndHealthChecks implements RuntimeListener {
private RuntimeContext runtime;
......@@ -82,11 +81,11 @@ public class DefaultMetricsAndHealthChecks implements RuntimeListener {
for (final MemoryPoolMXBean pool : pools) {
final String saveName = pool.getName()
.toLowerCase()
.replaceAll("[^a-z0-9]+", " ")
.trim()
.replace(" ", "-")
.replace("-space", "");
.toLowerCase()
.replaceAll("[^a-z0-9]+", " ")
.trim()
.replace(" ", "-")
.replace("-space", "");
final String prefix = "jvm.pool." + saveName;
metrics.gauge(prefix + ".max", () -> () -> pool.getUsage().getMax());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment