Skip to content

Commit

Permalink
Merge pull request #81 from BakuAnimation/develop
Browse files Browse the repository at this point in the history
Mise en prod 12/05
  • Loading branch information
JBGamond authored May 12, 2020
2 parents f162dfe + e0fc000 commit 3a4ab63
Show file tree
Hide file tree
Showing 107 changed files with 25,323 additions and 1,845 deletions.
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM gradle:6.2.2-jdk11 AS back-compiler
WORKDIR /app
COPY back/build.gradle back/gradle.properties ./
COPY .git/ ./.git/
RUN gradle build --no-daemon
COPY back/ .
RUN gradle assemble --no-daemon
Expand All @@ -23,6 +24,9 @@ FROM openjdk:11 AS app
EXPOSE 80 443
WORKDIR /app
COPY ssl ssl
RUN set -x \
&& apt-get update \
&& apt-get install -y ffmpeg
COPY --from=back-compiler /app/build/libs/app-all.jar .
COPY --from=front-compiler /app/dist ./dist
CMD ["java", "-jar", "app-all.jar"]
Expand Down
12 changes: 12 additions & 0 deletions back/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id "net.ltgt.apt-eclipse" version "0.21"
id "com.github.johnrengelman.shadow" version "5.2.0"
id "com.gorylenko.gradle-git-properties" version "2.2.2"
id "application"
}

Expand Down Expand Up @@ -29,13 +30,16 @@ dependencies {
implementation "javax.annotation:javax.annotation-api"
implementation "io.micronaut:micronaut-http-server-netty"
implementation "io.micronaut:micronaut-http-client"
implementation "io.micronaut:micronaut-management"

//tag::graal[]
compileOnly "org.graalvm.nativeimage:svm"
annotationProcessor "io.micronaut:micronaut-graal" // <1>
//end::graal[]

compile group: 'com.google.guava', name: 'guava', version: '29.0-jre'
compile group: 'commons-io', name: 'commons-io', version: '2.6'
compile group: 'org.kohsuke', name: 'github-api', version: '1.111'
implementation "org.slf4j:slf4j-api:1.7.5"
implementation "com.google.code.gson:gson:2.8.6"
implementation "com.google.cloud:google-cloud-translate:1.53.0"
Expand All @@ -49,6 +53,7 @@ dependencies {
testAnnotationProcessor "io.micronaut:micronaut-inject-java"

testCompile "org.assertj:assertj-core:3.15.0"
testCompile group: 'org.mockito', name: 'mockito-core', version: '3.3.3'

testImplementation platform("io.micronaut:micronaut-bom:$micronautVersion")
testImplementation "org.junit.jupiter:junit-jupiter-api"
Expand All @@ -58,6 +63,13 @@ dependencies {
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine"
}

gitProperties {
// using any tags (not limited to annotated tags) for "git.commit.id.describe" property
// see http://ajoberstar.org/grgit/grgit-describe.html for more info about the describe method and available parameters
// 'it' is an instance of org.ajoberstar.grgit.Grgit
customProperty 'git.commit.describe', { it.describe(tags:true) }
}

test.classpath += configurations.developmentOnly

mainClassName = "com.bakuanimation.Application"
Expand Down
2 changes: 1 addition & 1 deletion back/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
micronautVersion=1.3.1
micronautVersion=1.3.4
11 changes: 11 additions & 0 deletions back/src/main/java/com/bakuanimation/api/HistoryService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.bakuanimation.api;

import com.bakuanimation.model.Movie;
import com.bakuanimation.model.Project;
import io.reactivex.Single;

public interface HistoryService {
Single<Boolean> addStack(Project project, byte[] stack);

Single<Movie> interpretHistory(String projectId);
}
16 changes: 16 additions & 0 deletions back/src/main/java/com/bakuanimation/api/ImageService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.bakuanimation.api;

import com.bakuanimation.model.Movie;

import javax.annotation.Nullable;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public interface ImageService {
void writeSmallerImages(String projectId, InputStream inputStream, String filename);

long estimatedExportSize(Movie movie, @Nullable String shotId);

void export(Movie movie, OutputStream outputStream, @Nullable String shotId) throws IOException;
}
7 changes: 7 additions & 0 deletions back/src/main/java/com/bakuanimation/api/IssueService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.bakuanimation.api;

import io.reactivex.Single;

public interface IssueService {
Single<Boolean> submitIssue(String title, String body);
}
18 changes: 18 additions & 0 deletions back/src/main/java/com/bakuanimation/api/MovieService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.bakuanimation.api;

import com.bakuanimation.model.MovieStatus;
import com.bakuanimation.model.VideoState;
import io.reactivex.Single;

import java.nio.file.Path;

public interface MovieService {
// Check last modified time of movie and stack file
// if not the same -> will generate a movie & lock in memory the generation
// The goal is for this method to be called many time on the same project id, and the movie will only be generated once
Single<VideoState> generateMovie(String projectId);

Single<Path> generatePlan(String projectId, String shotId);

Single<MovieStatus> status(String projectId);
}
17 changes: 17 additions & 0 deletions back/src/main/java/com/bakuanimation/api/PermissionService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.bakuanimation.api;

import com.bakuanimation.model.BakuEvent;
import com.bakuanimation.model.Movie;
import com.bakuanimation.model.Project;

public interface PermissionService {
boolean deleteMovie(String projectId);

String getNewProjectId();

Project getProject(String projectId);

void hasRight(Project project, Movie movie, BakuEvent event);

String sign(String projectId) throws Exception;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.bakuanimation.model;

public final class AuthorizationException extends RuntimeException{
public AuthorizationException() {
}

public AuthorizationException(String message) {
super(message);
}

public AuthorizationException(String message, Throwable cause) {
super(message, cause);
}

public AuthorizationException(Throwable cause) {
super(cause);
}

public AuthorizationException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}
50 changes: 50 additions & 0 deletions back/src/main/java/com/bakuanimation/model/BakuAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.bakuanimation.model;

public enum BakuAction {
MOVIE_UPDATE_TITLE,
MOVIE_UPDATE_SYNOPSIS,
MOVIE_UPDATE_POSTER,
MOVIE_INSERT_IMAGE,
SHOT_ADD,
CHANGE_FPS,
MOVIE_REMOVE_IMAGE,
SHOT_REMOVE,
MOVIE_LOCK,
SHOT_LOCK,
SHOT_UPDATE_SYNOPSIS,
SHOT_UPDATE_STORYBOARD,
MOVIE_REVERSE_IMAGES;

public static BakuAction action(int value) {
switch (value) {
case 0:
return MOVIE_UPDATE_TITLE;
case 1:
return MOVIE_UPDATE_SYNOPSIS;
case 2:
return MOVIE_UPDATE_POSTER;
case 3:
return MOVIE_INSERT_IMAGE;
case 4:
return SHOT_ADD;
case 5:
return CHANGE_FPS;
case 6:
return MOVIE_REMOVE_IMAGE;
case 7:
return SHOT_REMOVE;
case 8:
return MOVIE_LOCK;
case 9:
return SHOT_LOCK;
case 10:
return SHOT_UPDATE_SYNOPSIS;
case 11:
return SHOT_UPDATE_STORYBOARD;
case 12:
return MOVIE_REVERSE_IMAGES;
default:
throw new IllegalArgumentException();
}
}
}
67 changes: 67 additions & 0 deletions back/src/main/java/com/bakuanimation/model/BakuEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.bakuanimation.model;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;

import java.util.Objects;

public final class BakuEvent {
private final int action;
private final JsonNode value;
private final String user;
private final String timestamp;

@JsonCreator
public BakuEvent(@JsonProperty("action") int action,
@JsonProperty("value") JsonNode value,
@JsonProperty("user") String user,
@JsonProperty("timestamp") String timestamp) {
this.action = action;
this.value = value;
this.user = user;
this.timestamp = timestamp;
}

public int getAction() {
return action;
}

public JsonNode getValue() {
return value;
}

public String getUser() {
return user;
}

public String getTimestamp() {
return timestamp;
}

@Override
public String toString() {
return "BakuEvent{" +
"action=" + action +
", value=" + value +
", user='" + user + '\'' +
", timestamp='" + timestamp + '\'' +
'}';
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
BakuEvent bakuEvent = (BakuEvent) o;
return action == bakuEvent.action &&
Objects.equals(value, bakuEvent.value) &&
Objects.equals(user, bakuEvent.user) &&
Objects.equals(timestamp, bakuEvent.timestamp);
}

@Override
public int hashCode() {
return Objects.hash(action, value, user, timestamp);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.bakuanimation.model;

public final class ForbiddenOperationException extends RuntimeException {
public ForbiddenOperationException() {
}

public ForbiddenOperationException(String message) {
super(message);
}

public ForbiddenOperationException(String message, Throwable cause) {
super(message, cause);
}

public ForbiddenOperationException(Throwable cause) {
super(cause);
}

public ForbiddenOperationException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}
24 changes: 24 additions & 0 deletions back/src/main/java/com/bakuanimation/model/GithubIssue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.bakuanimation.model;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

public final class GithubIssue {
private final String title;
private final String body;

@JsonCreator
public GithubIssue(@JsonProperty("title") String title,
@JsonProperty("body") String body) {
this.title = title;
this.body = body;
}

public String getTitle() {
return title;
}

public String getBody() {
return body;
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
package com.bakuanimation.server;
package com.bakuanimation.model;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ListMultimap;

import java.nio.file.Path;
import java.util.List;
import java.util.Set;

public final class Movie {
private final String projectId;
private final String name;
private final String synopsis;
private final int fps;
private final boolean locked;
private final ImmutableSet<String> lockedShots;
private final ImmutableList<String> shots;
private final ImmutableListMultimap<String, Path> images;

public Movie(String projectId, String name, String synopsis, int fps, List<String> shots, ListMultimap<String, Path> images) {
public Movie(String projectId, String name, String synopsis, int fps, boolean locked,
Set<String> lockedShots, List<String> shots, ListMultimap<String, Path> images) {
this.locked = locked;
this.lockedShots = ImmutableSet.copyOf(lockedShots);
this.shots = ImmutableList.copyOf(shots);
this.images = ImmutableListMultimap.copyOf(images);
this.projectId = projectId;
Expand All @@ -29,7 +36,7 @@ public String getProjectId() {
}

public String getName() {
return name;
return name.isBlank() ? projectId : name;
}

public String getSynopsis() {
Expand All @@ -40,6 +47,14 @@ public int getFps() {
return fps;
}

public boolean isLocked() {
return locked;
}

public ImmutableSet<String> getLockedShots() {
return lockedShots;
}

public ImmutableList<String> getShots() {
return shots;
}
Expand Down
Loading

0 comments on commit 3a4ab63

Please sign in to comment.