refinements to endpoints for NBUI

This commit is contained in:
Jonathan Shook 2020-09-23 13:44:05 -05:00
parent 69dbd0a6ed
commit 03e29bfdf6
3 changed files with 26 additions and 3 deletions

View File

@ -414,11 +414,12 @@ public class ScenarioController {
return activityMap;
}
public Collection<ProgressAndStateMeter> getProgressMeters() {
public List<ProgressAndStateMeter> getProgressMeters() {
List<ProgressAndStateMeter> indicators = new ArrayList<>();
for (ActivityExecutor ae : activityExecutors.values()) {
indicators.add(new ProgressAndStateMeter(ae.getProgressMeter(), ae.getActivity()));
}
indicators.sort((o1, o2) -> Long.compare(o1.getStartedAtMillis(), o2.getStartedAtMillis()));
return indicators;
}
}

View File

@ -11,6 +11,7 @@ import javax.inject.Singleton;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Configuration;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
@ -28,9 +29,16 @@ public class ServiceStatusEndpoint implements WebServiceObject {
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response isEnabled() {
public Response isEnabled(@QueryParam("enabled") String overideEnabled) {
boolean enabled = false;
try {
StatusEncoding status = new StatusEncoding(true, Map.of());
if (overideEnabled != null) {
enabled = Boolean.parseBoolean(overideEnabled);
}
StatusEncoding status = new StatusEncoding(true, Map.of(
"status", "ORIGIN/services/status"
));
return Response.ok(status).build();
} catch (Exception e) {
return Response.serverError().entity(e.getMessage()).build();

View File

@ -15,6 +15,7 @@ import java.util.concurrent.TimeUnit;
public class WorkspaceItemView {
private final Path _path;
private String type;
private String perms;
private String owner;
@ -44,12 +45,14 @@ public class WorkspaceItemView {
setSize(attrs.size());
setMtimeMillis(attrs.lastModifiedTime().to(TimeUnit.MILLISECONDS));
setName(wspath.relativize(path).toString());
this._path = path;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private void setOwner(FileOwnerAttributeView fileAttributeView) {
try {
this.setOwner(fileAttributeView.getOwner().getName());
@ -155,4 +158,15 @@ public class WorkspaceItemView {
private String name;
public boolean contains(String content) {
if (!Files.isRegularFile(_path)) {
return false;
}
try {
String s = Files.readString(this._path);
return s.matches("(?s)" + content);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}