Skip to content

Commit

Permalink
Merge pull request #112 from moritzvieli/feature/backup
Browse files Browse the repository at this point in the history
Feature/backup
  • Loading branch information
moritzvieli authored Jul 13, 2024
2 parents 0264459 + 3215831 commit d86d5c6
Show file tree
Hide file tree
Showing 74 changed files with 14,268 additions and 13,691 deletions.
6 changes: 5 additions & 1 deletion dist/currentversion2.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<versionInfo>
<version>2.3.5</version>
<version>2.3.7</version>
<date>2024-05-13</date>
<changeNoteList>
<changeNote>
<version>2.3.7</version>
<changes>Option to create and restore backups (settings -> system). Upload size limit for all kind of files has been removed. Fixed light rays in the show designer for newer browser versions.</changes>
</changeNote>
<changeNote>
<version>2.3.6</version>
<changes>Support Raspberry Pi 5, bugfix with WLAN AP disable, minor fixes</changes>
Expand Down
8 changes: 8 additions & 0 deletions dist/install/raspbian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,19 @@ wget https://rocketshow.net/designer/downloads/fixtures.zip
unzip fixtures.zip -d fixtures
rm fixtures.zip

# TODO not required for raspberry pi 5 anymore?
# Overclock the raspberry to sustain streams without underruns
# - Set more memory for the GPU to play larger video files with omx
# - Enable turbo-mode by default (boot_delay avoids sdcard corruption)
# - Overclock the sdcard a little bit to prevent bufferunderruns with ALSA
# - Hide warnings (e.g. temperature icon)
sed -i '1i# ROCKETSHOWSTART\ngpu_mem=256\nforce_turbo=1\nboot_delay=1\ndtparam=sd_overclock=100\navoid_warnings=1\n# ROCKETSHOWEND\n' /boot/config.txt

# TODO not required for raspberry pi 5 anymore?
# Set rocketshows nice priority to 10
sed -i '1irocketshow soft priority 10' /etc/security/limits.conf

# TODO not required for raspberry pi 5 anymore?
# Add realtime permissions to the audio group
sed -i '1i@audio - rtprio 99\n@audio - memlock unlimited' /etc/security/limits.d/audio.conf

Expand Down Expand Up @@ -168,6 +171,11 @@ pcm.!default {
EOF

chown -R rocketshow:rocketshow /home/rocketshow
chown -R rocketshow:rocketshow /opt/rocketshow_factory.tar.gz
chown -R rocketshow:rocketshow /opt/rocketshow_reset.sh

chmod 755 /opt/rocketshow_factory.tar.gz
chmod 755 /opt/rocketshow_reset.sh

# Apply a patch to make seeking videos work on the Raspberry Pi 4
# https://github.com/moritzvieli/rocketshow/issues/7
Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.ascargon</groupId>
<artifactId>rocketshow</artifactId>
<version>2.3.6</version>
<version>2.3.7</version>
<packaging>jar</packaging>

<name>Rocket Show</name>
Expand Down Expand Up @@ -55,8 +55,8 @@
</goals>
<phase>generate-sources</phase>
<configuration>
<nodeVersion>v10.13.0</nodeVersion>
<npmVersion>6.4.1</npmVersion>
<nodeVersion>v18.19.1</nodeVersion>
<npmVersion>10.2.4</npmVersion>
</configuration>
</execution>
<execution>
Expand All @@ -66,7 +66,7 @@
</goals>
<!-- Optional configuration which provides for running any npm command -->
<configuration>
<arguments>install</arguments>
<arguments>install --force</arguments>
</configuration>
<phase>generate-sources</phase>
</execution>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/ascargon/rocketshow/Instrument.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import jakarta.xml.bind.annotation.XmlRootElement;

/**
* Defines an instrument played in the band.
* Defines an instrument played in a band.
*
* @author Moritz A. Vieli
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,23 @@
@CrossOrigin
public class CompositionController {

private final ControllerService controllerService;
private final CompositionService compositionService;
private final PlayerService playerService;
private final SetService setService;

public CompositionController(CompositionService compositionService, PlayerService playerService, SetService setService) {
public CompositionController(ControllerService controllerService, CompositionService compositionService, PlayerService playerService, SetService setService) {
this.controllerService = controllerService;
this.compositionService = compositionService;
this.playerService = playerService;
this.setService = setService;
}

@ExceptionHandler(Exception.class)
public ResponseEntity<ErrorResponse> handleException(Exception exception) {
return controllerService.handleException(exception);
}

@GetMapping("list")
public List<Composition> getAll() {
return compositionService.getAllCompositions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,55 @@

import com.ascargon.rocketshow.composition.CompositionFile;
import com.ascargon.rocketshow.composition.CompositionFileService;
import org.apache.commons.fileupload.FileItemIterator;
import org.apache.commons.fileupload.FileItemStream;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.io.FilenameUtils;
import org.springframework.core.io.InputStreamResource;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.List;

@RestController()
@RequestMapping("${spring.data.rest.base-path}/file")
@CrossOrigin
public class CompositionFileController {

private final ControllerService controllerService;
private final CompositionFileService compositionFileService;

public CompositionFileController(CompositionFileService compositionFileService) {
public CompositionFileController(ControllerService controllerService, CompositionFileService compositionFileService) {
this.controllerService = controllerService;
this.compositionFileService = compositionFileService;
}

@ExceptionHandler(Exception.class)
public ResponseEntity<ErrorResponse> handleException(Exception exception) {
return controllerService.handleException(exception);
}

@GetMapping("list")
public List<CompositionFile> getAll() {
return compositionFileService.getAllFiles();
}

@PostMapping("upload")
public CompositionFile upload(HttpServletRequest request) throws Exception {
ServletFileUpload upload = new ServletFileUpload();
FileItemIterator itemIterator = upload.getItemIterator(request);

while (itemIterator.hasNext()) {
FileItemStream item = itemIterator.next();
String fileName = item.getName();

if (fileName != null) {
fileName = FilenameUtils.getName(fileName);
}

InputStream stream = item.openStream();

if (!item.isFormField()) {
return compositionFileService.saveFile(stream, fileName);
}
public CompositionFile upload(
@RequestParam("file") MultipartFile file,
@RequestParam("dzchunkindex") Long dzchunkindex,
@RequestParam("dztotalchunkcount") Long dztotalchunkcount
) throws Exception {
String fileName = file.getOriginalFilename();
CompositionFile compositionFile = null;
if (dzchunkindex == 0) {
compositionFileService.saveFileInit(fileName);
}

return null;
compositionFileService.saveFileAddChunk(file.getInputStream(), fileName);
if (dzchunkindex.equals(dztotalchunkcount - 1)) {
compositionFile = compositionFileService.saveFileFinish(fileName);
}
return compositionFile;
}

@PostMapping("delete")
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/ascargon/rocketshow/api/ControllerService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.ascargon.rocketshow.api;

import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

@Service
public interface ControllerService {

ResponseEntity<ErrorResponse> handleException(Exception exception);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.ascargon.rocketshow.api;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

@Service
public class DefaultControllerService implements ControllerService {

private final static Logger logger = LoggerFactory.getLogger(DefaultControllerService.class);

@Override
public ResponseEntity<ErrorResponse> handleException(Exception exception) {
HttpStatus httpStatus = HttpStatus.INTERNAL_SERVER_ERROR;
ErrorResponse errorResponse = new ErrorResponse();
errorResponse.setMessage(exception.getMessage());
errorResponse.setCode("unknown");

// specific mapping
// if (exception instanceof NotFoundException) {
// httpStatus = HttpStatus.NOT_FOUND;
// errorResponse.setCode("not-found");
// } else {
logger.error("An exception has been thrown in the controller", exception);
// }

return new ResponseEntity<>(errorResponse, httpStatus);
}

}
12 changes: 10 additions & 2 deletions src/main/java/com/ascargon/rocketshow/api/DesignerController.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.ascargon.rocketshow.lighting.designer.FixtureService;
import com.ascargon.rocketshow.lighting.designer.Project;
import com.ascargon.rocketshow.lighting.designer.SearchFixtureTemplate;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.io.File;
Expand All @@ -18,16 +19,23 @@
@CrossOrigin
public class DesignerController {

private final ControllerService controllerService;
private final FixtureService fixtureService;
private final DesignerService designerService;
private final SettingsService settingsService;

public DesignerController(FixtureService fixtureService, DesignerService designerService, SettingsService settingsService) {
public DesignerController(ControllerService controllerService, FixtureService fixtureService, DesignerService designerService, SettingsService settingsService) {
this.controllerService = controllerService;
this.fixtureService = fixtureService;
this.designerService = designerService;
this.settingsService = settingsService;
}

@ExceptionHandler(Exception.class)
public ResponseEntity<ErrorResponse> handleException(Exception exception) {
return controllerService.handleException(exception);
}

@GetMapping("fixtures")
public List<SearchFixtureTemplate> searchFixtures(@RequestParam(value = "uuid", required = false) String uuid, @RequestParam(value = "manufacturerShortName", required = false) String manufacturerShortName, @RequestParam(value = "name", required = false) String name, @RequestParam(value = "mainCategory", required = false) String mainCategory) throws IOException {
return fixtureService.searchFixtures(uuid, manufacturerShortName, name, mainCategory);
Expand All @@ -49,7 +57,7 @@ public synchronized void preview(@RequestBody Project project, @RequestParam("po
designerService.setPreviewPreset(project.isPreviewPreset());
designerService.setSelectedPresetUuid(project.getSelectedPresetUuid());
designerService.setSelectedSceneUuids(project.getSelectedSceneUuids());
if (compositionName != null && compositionName.length() > 0) {
if (compositionName != null && !compositionName.isEmpty()) {
designerService.setPreviewComposition(compositionName);
}
designerService.startPreview(positionMillis);
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/com/ascargon/rocketshow/api/ErrorResponse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.ascargon.rocketshow.api;

public class ErrorResponse {
private String message;
private String code;

public String getMessage() {
return message;
}

public void setMessage(String message) {
this.message = message;
}

public String getCode() {
return code;
}

public void setCode(String code) {
this.code = code;
}
}
49 changes: 23 additions & 26 deletions src/main/java/com/ascargon/rocketshow/api/LeadSheetController.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,55 @@

import com.ascargon.rocketshow.composition.LeadSheet;
import com.ascargon.rocketshow.composition.LeadSheetService;
import org.apache.commons.fileupload.FileItemIterator;
import org.apache.commons.fileupload.FileItemStream;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.io.FilenameUtils;
import org.springframework.core.io.InputStreamResource;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.List;

@RestController()
@RequestMapping("${spring.data.rest.base-path}/lead-sheet")
@CrossOrigin
public class LeadSheetController {

private final ControllerService controllerService;
private final LeadSheetService leadSheetService;

public LeadSheetController(LeadSheetService leadSheetService) {
public LeadSheetController(ControllerService controllerService, LeadSheetService leadSheetService) {
this.controllerService = controllerService;
this.leadSheetService = leadSheetService;
}

@ExceptionHandler(Exception.class)
public ResponseEntity<ErrorResponse> handleException(Exception exception) {
return controllerService.handleException(exception);
}

@GetMapping("list")
public List<LeadSheet> getAll() {
return leadSheetService.getAllLeadSheets();
}

@PostMapping("upload")
public LeadSheet upload(HttpServletRequest request) throws Exception {
ServletFileUpload upload = new ServletFileUpload();
FileItemIterator itemIterator = upload.getItemIterator(request);

while (itemIterator.hasNext()) {
FileItemStream item = itemIterator.next();
String fileName = item.getName();

if (fileName != null) {
fileName = FilenameUtils.getName(fileName);
}

InputStream stream = item.openStream();

if (!item.isFormField()) {
return leadSheetService.saveLeadSheet(stream, fileName);
}
public LeadSheet upload(
@RequestParam("file") MultipartFile file,
@RequestParam("dzchunkindex") Long dzchunkindex,
@RequestParam("dztotalchunkcount") Long dztotalchunkcount
) throws Exception {
String fileName = file.getOriginalFilename();
LeadSheet leadSheet = null;
if (dzchunkindex == 0) {
leadSheetService.saveLeadSheetInit(fileName);
}

return null;
leadSheetService.saveLeadSheetAddChunk(file.getInputStream(), fileName);
if (dzchunkindex.equals(dztotalchunkcount - 1)) {
leadSheet = leadSheetService.saveLeadSheetFinish(fileName);
}
return leadSheet;
}

@PostMapping("delete")
Expand Down
Loading

0 comments on commit d86d5c6

Please sign in to comment.