Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tycho #221

Merged
merged 23 commits into from
Mar 1, 2023
Merged

Tycho #221

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ S3 ninja

S3 ninja emulates the Amazon S3 API for development and test purposes.

![Screenshot](http://s3ninja.net/assets/images/screenie_min.jpg)
![Screenshot](src/site/assets/images/screenie_min.png)

See http://s3ninja.net for more details.

Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
<packaging>jar</packaging>
<name>s3-ninja</name>
<description>S3 ninja emulates the S3 API for development and testing purposes.</description>
<url>http://s3ninja.net</url>
<url>https://s3ninja.net</url>

<properties>
<sirius.kernel>dev-34.8.0</sirius.kernel>
<sirius.web>dev-63.0.1</sirius.web>
<sirius.kernel>dev-35.0.1</sirius.kernel>
<sirius.web>dev-64.0.1</sirius.web>
</properties>

<repositories>
Expand Down
56 changes: 28 additions & 28 deletions src/main/java/ninja/APILog.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
import java.util.List;

/**
* Contains a log of the latest API calls
* Contains a log of the latest API calls.
* <p>
* The entries are stored in memory and will be lost during server restarts. Also, the site is limited to 250 entries.
* The entries are stored in memory and will be lost during server restarts. Also, the size is limited to 250 entries.
* The newest entry will be the first in the list.
*/
@Register(classes = APILog.class)
Expand All @@ -35,21 +35,21 @@ public enum Result {OK, REJECTED, ERROR}
* Represents a log entry.
*/
public static class Entry {
private final String tod = NLS.toUserString(LocalDateTime.now());
private final LocalDateTime time = LocalDateTime.now();
private final String function;
private final String description;
private final String result;
private final Result result;
private final String duration;

/**
* Creates a new log entry.
*
* @param function name or method of the function which was invoked
* @param description description of the call
* @param result outcome of the call
* @param duration duration of the call
* @param function the name of the method or function which was invoked
* @param description the description of the call
* @param result the outcome of the call
* @param duration the duration of the call
*/
protected Entry(String function, String description, String result, String duration) {
protected Entry(String function, String description, Result result, String duration) {
this.function = function;
this.description = description;
this.result = result;
Expand All @@ -66,7 +66,7 @@ public String getFunction() {
}

/**
* Returns a description of the call
* Returns a description of the call.
*
* @return a short text describing the call
*/
Expand All @@ -75,16 +75,16 @@ public String getDescription() {
}

/**
* Returns the outcome (one of Result.name()) of the call
* Returns the outcome of the call.
*
* @return a string describing if the call succeeded or why it failed.
* @return a string describing if the call succeeded or why it failed
*/
public String getResult() {
public Result getResult() {
return result;
}

/**
* Returns the duration of the call
* Returns the duration of the call.
*
* @return a textual representation of the duration of the call
*/
Expand All @@ -93,28 +93,28 @@ public String getDuration() {
}

/**
* Returns a timestamp of the call
* Returns a timestamp of the call.
*
* @return a string representation of the timestamp when the call was invoked.
* @return the timestamp when the call was invoked
*/
public String getTod() {
return tod;
public LocalDateTime getTime() {
return time;
}

/**
* Helper method which returns a bootstrap css class based on the result of the call
* Helper method which returns a css class based on the result of the call.
*
* @return a css class used to represent the result of the call.
* @return a css class used to represent the result of the call
*/
public String getCSS() {
if ("ERROR".equals(result)) {
return "error";
public String getStyleClass() {
if (Result.ERROR == result) {
return "sci-left-border-red";
}
if ("REJECTED".equals(result)) {
return "warning";
if (Result.REJECTED == result) {
return "sci-left-border-yellow";
}

return "";
return "sci-left-border-gray";
}
}

Expand All @@ -125,7 +125,7 @@ public String getCSS() {
*
* @param start index of the item where to start
* @param count max number of items returned
* @return a non null list of log entries
* @return a non-null list of log entries
*/
public List<Entry> getEntries(int start, int count) {
List<Entry> result = Lists.newArrayList();
Expand Down Expand Up @@ -156,7 +156,7 @@ public List<Entry> getEntries(int start, int count) {
*/
public void log(String function, String description, Result result, Watch watch) {
synchronized (entries) {
entries.add(0, new Entry("OBJECT " + function, description, result.name(), watch.duration()));
entries.add(0, new Entry("OBJECT " + function, description, result, watch.duration()));
if (entries.size() > 250) {
entries.remove(entries.size() - 1);
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/ninja/Storage.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ public List<Bucket> getBuckets() {
}
}

result.sort((bucket1, bucket2) -> bucket1.getName().compareToIgnoreCase(bucket2.getName()));

return result;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ product {
vcs = "${build.vcs.number}"
tagLine = "S3 ninja emulates the S3 API for development and testing purposes."
claim = "It is however not intended as production system as it neither provides scalability nor replication or proper security."
wondergemRoot = "/ui"
tychoRoot = "/ui"
}

http {
Expand Down
Binary file removed src/main/resources/assets/images/menu_logo.png
Binary file not shown.
1 change: 0 additions & 1 deletion src/main/resources/assets/images/menu_logo.svg

This file was deleted.

90 changes: 0 additions & 90 deletions src/main/resources/assets/stylesheets/custom.scss

This file was deleted.

5 changes: 5 additions & 0 deletions src/main/resources/assets/tycho/images/menu_logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/main/resources/assets/tycho/styles/custom.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$primary-color: #9d2011;
$accent-color: $primary-color;
$linkColor: $primary-color;
14 changes: 14 additions & 0 deletions src/main/resources/extensions/tycho-page-menu/menu.html.pasta
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<i:arg type="String" name="point"/>
<i:pragma name="priority" value="10"/>

<i:switch test="@point">
<i:block name="left">
<t:menuItem label="Home" url="/ui" />
<t:menuItem label="Access Logs" url="/ui?log" />
<t:menuItem label="License" url="/ui?license" />
<t:menuItem label="Supported API" url="/ui?api"/>
</i:block>
<i:block name="right">
<t:menuItem label="F**k me on GitHub" url="https://github.com/scireum/s3ninja" />
</i:block>
</i:switch>
14 changes: 0 additions & 14 deletions src/main/resources/extensions/wondergem-page-menu/menu.html.pasta

This file was deleted.

78 changes: 48 additions & 30 deletions src/main/resources/templates/api.html.pasta
Original file line number Diff line number Diff line change
@@ -1,41 +1,59 @@
<w:page title="Supported API">
<i:block name="breadcrumbBar"/>
<t:page title="Supported API">
<i:block name="breadcrumbs">
<li>
<a href="/ui?api">Supported API</a>
</li>
</i:block>

<i:invoke template="/templates/header.html.pasta" title="Supported API"/>
<i:block name="page-header">
<i:invoke template="/templates/header.html.pasta"
title="Supported API"/>
</i:block>

<div class="row">
<div class="col-md-12">
<div class="well">
<p>
Basically all object methods are supported. However, no ACLs are checked. If the bucket is public,
everyone can access its contents.
Otherwise, a valid hash has to be provided as Authorization header. The hash will be checked as
expected by amazon, but no multiline-headers are supported yet. (Multi-value headers are supported).
</p>
<legend>Supported Methods</legend>
<ul>
<li>GET /bucket</li>
<li>GET /bucket/object</li>
<li>PUT /bucket</li>
<li>PUT /bucket/object</li>
<li>DELETE /bucket/object</li>
<li>DELETE /bucket</li>
<li>HEAD /bucket</li>
<li>HEAD /bucket/object</li>
</ul>
<legend>Supported Multipart Methods</legend>
<ul>
<li>POST /bucket/object?uploads</li>
<li>GET /bucket/object?uploadId=X</li>
<li>PUT /bucket/object?uploadId=X&partNumber=Y</li>
<li>POST /bucket/object?uploadId=X</li>
<li>DELETE /bucket/object?uploadId=X</li>
</ul>
<div class="card shadow-sm mb-4">
<div class="card-body">
<legend>Access Control</legend>
<p class="mb-0">
ACLs are not checked. If the bucket is public, everyone can access its contents.
Otherwise, a valid hash has to be provided as <code>Authorization</code> header. It will be
checked as expected by <em>Amazon,</em> but no multiline-headers are supported yet.
(Multi-value headers are supported.)
</p>
</div>
</div>
<div class="card shadow-sm mb-4">
<div class="card-body">
<legend>Supported Object Methods</legend>
<ul class="mb-0">
<li>GET /bucket</li>
<li>GET /bucket/object</li>
<li>PUT /bucket</li>
<li>PUT /bucket/object</li>
<li>DELETE /bucket/object</li>
<li>DELETE /bucket</li>
<li>HEAD /bucket</li>
<li>HEAD /bucket/object</li>
</ul>
</div>
</div>
<div class="card shadow-sm mb-4">
<div class="card-body">
<legend>Supported Multipart Methods</legend>
<ul class="mb-0">
<li>POST /bucket/object?uploads</li>
<li>GET /bucket/object?uploadId=X</li>
<li>PUT /bucket/object?uploadId=X&partNumber=Y</li>
<li>POST /bucket/object?uploadId=X</li>
<li>DELETE /bucket/object?uploadId=X</li>
</ul>
</div>
</div>
</div>
</div>

<i:block name="footer">
<i:invoke template="/templates/footer.html.pasta"/>
</i:block>
</w:page>
</t:page>
Loading