Skip to content

Commit

Permalink
#53 backend for filesystem manipulation
Browse files Browse the repository at this point in the history
  • Loading branch information
Thorsten Marx committed Nov 6, 2023
1 parent 5f6748e commit 0b11afa
Show file tree
Hide file tree
Showing 19 changed files with 340 additions and 340 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,5 @@
* @author t.marx
*/
public abstract class JettyHttpHandlerExtensionPoint extends AbstractExtensionPoint {

abstract public String getContextPath();

abstract public Mapping getMapping();

}
1 change: 1 addition & 0 deletions cms-server/hosts/demo/test/ui-module/directory-create.http
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
POST http://localhost:1010/module/ui-module/file-system/create?path=.technical&filename=test&type=folder
1 change: 1 addition & 0 deletions cms-server/hosts/demo/test/ui-module/directory-delete.http
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DELETE http://localhost:1010/module/ui-module/file-system/delete?path=.technical/test
8 changes: 8 additions & 0 deletions cms-server/hosts/demo/test/ui-module/file-create.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
POST http://localhost:1010/module/ui-module/file-system/create?path=.technical/test&filename=example.md&type=file

---
title: Das ist der Titel
---
# Neue Datei

Das ist der Inhalt
1 change: 1 addition & 0 deletions cms-server/hosts/demo/test/ui-module/list-files.http
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GET http://localhost:1010/module/ui-module/file-system/list?path=.technical
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@
@Extension(JettyHttpHandlerExtensionPoint.class)
public class ExampleJettyHttpHandlerExtension extends JettyHttpHandlerExtensionPoint {

@Override
public String getContextPath() {
return "example";
}

@Override
public Mapping getMapping() {
Mapping mapping = new Mapping();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.thmarx.cms.modules.ui.http;
package com.github.thmarx.cms.modules.ui.extensionpoints;

/*-
* #%L
Expand All @@ -21,6 +21,9 @@
*/
import com.github.thmarx.cms.api.extensions.JettyHttpHandlerExtensionPoint;
import com.github.thmarx.cms.api.extensions.Mapping;
import com.github.thmarx.cms.modules.ui.http.FileSystemCreateHandler;
import com.github.thmarx.cms.modules.ui.http.FileSystemDeleteHandler;
import com.github.thmarx.cms.modules.ui.http.FileSystemListHandler;
import com.github.thmarx.modules.api.annotation.Extension;
import java.io.IOException;
import java.net.URI;
Expand All @@ -44,11 +47,6 @@
@Slf4j
public class UIJettyHttpHandlerExtension extends JettyHttpHandlerExtensionPoint {

@Override
public String getContextPath() {
return "ui";
}

public static FileSystem createFileSystem () {
try {
URL resource = UIJettyHttpHandlerExtension.class.getResource("/files");
Expand All @@ -72,7 +70,13 @@ public Mapping getMapping() {
resourceHandler.setDirAllowed(false);
resourceHandler.setBaseResource(ResourceFactory.of(resourceHandler)
.newResource(createFileSystem().getPath("/files")));


mapping.add(PathSpec.from("/assets/*"), resourceHandler);
mapping.add(PathSpec.from("/file-system/list"), new FileSystemListHandler(UILifecycleExtension.fileSystemService));
mapping.add(PathSpec.from("/file-system/create"), new FileSystemCreateHandler(UILifecycleExtension.fileSystemService));
mapping.add(PathSpec.from("/file-system/delete"), new FileSystemDeleteHandler(UILifecycleExtension.fileSystemService));


} catch (Exception ex) {
log.error(null, ex);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.thmarx.cms.modules.ui;
package com.github.thmarx.cms.modules.ui.extensionpoints;

/*-
* #%L
Expand All @@ -21,6 +21,7 @@
*/

import com.github.thmarx.cms.api.CMSModuleContext;
import com.github.thmarx.cms.modules.ui.services.FileSystemService;
import com.github.thmarx.cms.modules.ui.services.FileUserService;
import com.github.thmarx.cms.modules.ui.services.UserService;
import com.github.thmarx.modules.api.ModuleLifeCycleExtension;
Expand All @@ -34,6 +35,7 @@
public class UILifecycleExtension extends ModuleLifeCycleExtension<CMSModuleContext> {

public static UserService userService;
public static FileSystemService fileSystemService;

@Override
public void init() {
Expand All @@ -42,6 +44,7 @@ public void init() {
@Override
public void activate() {
userService = new FileUserService(configuration.getDataDir().getAbsolutePath());
fileSystemService = new FileSystemService(getContext().getFileSystem());
}

@Override
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 0b11afa

Please sign in to comment.