Skip to content

Commit

Permalink
Merge pull request bigbluebutton#14786 from paultrudel/recording-api-…
Browse files Browse the repository at this point in the history
…changes
  • Loading branch information
gustavotrott authored Jun 30, 2022
2 parents 502523a + 4b33ae2 commit 807f028
Show file tree
Hide file tree
Showing 35 changed files with 3,679 additions and 698 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ contact_links:
about: Issue tracker for the Greenlight frontend
- name: Commercial Support
url: https://bigbluebutton.org/commercial-support
abount: List of companies offering commercial BigBlueButton support
about: List of companies offering commercial BigBlueButton support
5 changes: 5 additions & 0 deletions bbb-common-web/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
POSTGRES_VERSION=14.1
POSTGRES_USER=bbb
POSTGRES_PASSWORD=bbb123
HOST_PORT=5432
CONTAINER_PORT=5432
12 changes: 12 additions & 0 deletions bbb-common-web/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,15 @@ libraryDependencies += "javax.validation" % "validation-api" % "2.0.1.Final"
libraryDependencies += "org.springframework.boot" % "spring-boot-starter-validation" % "2.5.1"
libraryDependencies += "org.glassfish" % "javax.el" % "3.0.1-b12"
libraryDependencies += "org.apache.httpcomponents" % "httpclient" % "4.5.13"

libraryDependencies ++= Seq(
"javax.validation" % "validation-api" % "2.0.1.Final",
"org.springframework.boot" % "spring-boot-starter-validation" % "2.6.1",
"org.springframework.data" % "spring-data-commons" % "2.6.1",
"org.glassfish" % "javax.el" % "3.0.1-b12",
"org.apache.httpcomponents" % "httpclient" % "4.5.13",
"org.postgresql" % "postgresql" % "42.2.16",
"org.hibernate" % "hibernate-core" % "5.6.1.Final",
"org.flywaydb" % "flyway-core" % "7.8.2",
"com.zaxxer" % "HikariCP" % "4.0.3"
)
2 changes: 2 additions & 0 deletions bbb-common-web/docker-clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
docker rm -f $(docker ps -aq)
14 changes: 14 additions & 0 deletions bbb-common-web/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: '2'

services:
postgres:
image: postgres:${POSTGRES_VERSION}
container_name: postgres
environment:
- "TZ=UTC"
- "POSTGRES_USER=${POSTGRES_USER}"
- "POSTGRES_PASSWORD=${POSTGRES_PASSWORD}"
ports:
- "${HOST_PORT}:${CONTAINER_PORT}"
volumes:
- "./src/main/java/db/migration:/docker-entrypoint-initdb.d"
31 changes: 31 additions & 0 deletions bbb-common-web/hibernate-cfg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
. .env
mkdir -p ./src/main/resources
echo '<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- JDBC Database connection settings -->
<property name="connection.driver_class">org.postgresql.Driver</property>
<property name="connection.url">jdbc:postgresql://localhost:'"$HOST_PORT"'/bbb</property>
<property name="connection.username">'"$POSTGRES_USER"'</property>
<property name="connection.password">'"$POSTGRES_PASSWORD"'</property>
<!-- JDBC connection pool settings -->
<property name="hibernate.connection.provider_class">com.zaxxer.hikari.hibernate.HikariConnectionProvider</property>
<property name="hibernate.hikari.minimumIdle">5</property>
<property name="hibernate.hikari.maximumPoolSize">10</property>
<property name="hibernate.hikari.idleTimeout">30000</property>
<!-- Select our SQL dialect -->
<property name="dialect">org.hibernate.dialect.PostgreSQL10Dialect</property>
<!-- Echo the SQL to stdout -->
<property name="show_sql">true</property>
<!-- Set the current session context -->
<property name="current_session_context_class">thread</property>
<property name="hibernate.show_sql">false</property>
<!-- format the sql nice -->
<property name="hibernate.format_sql">false</property>
<!-- show the hql as comment -->
<property name="use_sql_comments">false</property>
</session-factory>
</hibernate-configuration>' > ./src/main/resources/hibernate.cfg.xml
12 changes: 12 additions & 0 deletions bbb-common-web/psql.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
. .env
echo "================== Help for psql ========================="
echo "\\dt : Describe the current database"
echo "\\d [table] : Describe a table"
echo "\\c : Connect to a database"
echo "\\h : help with SQL commands"
echo "\\? : help with psql commands"
echo "\\q : quit"
echo "Reset the database using the truncate_tables('$POSTGRES_USER') function"
echo "=================================================================="
docker exec -it postgres psql -U $POSTGRES_USER -d bbb
75 changes: 75 additions & 0 deletions bbb-common-web/src/main/java/db/migration/V1__Initial_create.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
CREATE DATABASE bbb;
\c bbb;

CREATE TABLE IF NOT EXISTS recordings (
id BIGSERIAL PRIMARY KEY,
record_id VARCHAR(64),
meeting_id VARCHAR(256),
name VARCHAR(256),
published BOOLEAN,
participants INT,
state VARCHAR(256),
start_time timestamp,
end_time timestamp,
deleted_at timestamp,
publish_updated BOOLEAN DEFAULT FALSE,
protected BOOLEAN
);
CREATE UNIQUE INDEX index_recording_on_recording_id ON recordings (record_id);
CREATE INDEX index_recordings_on_meeting_id ON recordings(meeting_id);

CREATE TABLE IF NOT EXISTS metadata (
id BIGSERIAL PRIMARY KEY,
recording_id BIGINT,
key VARCHAR(256),
value VARCHAR(256),
CONSTRAINT fk_metadata_recording FOREIGN KEY(recording_id) REFERENCES recordings(id)
);
CREATE UNIQUE INDEX index_metadata_on_recording_id_and_key ON metadata(recording_id, key);

CREATE TABLE IF NOT EXISTS playback_formats (
id BIGSERIAL PRIMARY KEY,
recording_id BIGINT,
format VARCHAR(64),
url VARCHAR(256),
length INT,
processing_time INT,
CONSTRAINT fk_playback_formats_recording FOREIGN KEY (recording_id) REFERENCES recordings(id)
);
CREATE UNIQUE INDEX index_playback_formats_on_recording_id_and_format ON playback_formats(recording_id, format);


CREATE TABLE IF NOT EXISTS thumbnails (
id BIGSERIAL PRIMARY KEY,
playback_format_id BIGINT,
height INT,
width INT,
alt VARCHAR(256),
url VARCHAR(256),
sequence INT,
CONSTRAINT fk_thumbnails_playback_formats FOREIGN KEY (playback_format_id) REFERENCES playback_formats(id)
);
CREATE INDEX index_thumbnails_on_playback_format_id ON thumbnails(playback_format_id);


CREATE TABLE IF NOT EXISTS callback_data (
id BIGSERIAL PRIMARY KEY,
recording_id BIGINT,
meeting_id VARCHAR(256),
callback_attributes TEXT,
created_at timestamp NOT NULL,
updated_at timestamp NOT NULL,
CONSTRAINT fk_callback_data_recordings FOREIGN KEY (recording_id) REFERENCES recordings(id)
);

CREATE OR REPLACE FUNCTION truncate_tables(username IN VARCHAR) RETURNS void AS $$
DECLARE
statements CURSOR FOR
SELECT tablename FROM pg_tables
WHERE tableowner = username AND schemaname = 'public';
BEGIN
FOR stmt IN statements LOOP
EXECUTE 'TRUNCATE TABLE ' || quote_ident(stmt.tablename) || ' CASCADE;';
END LOOP;
END;
$$ LANGUAGE plpgsql;
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@
import java.io.InputStreamReader;
import java.io.InputStream;

import org.springframework.data.domain.*;

public class MeetingService implements MessageListener {
private static Logger log = LoggerFactory.getLogger(MeetingService.class);

Expand Down Expand Up @@ -574,8 +576,26 @@ public boolean isRecordingExist(String recordId) {
return recordingService.isRecordingExist(recordId);
}

public String getRecordings2x(List<String> idList, List<String> states, Map<String, String> metadataFilters) {
return recordingService.getRecordings2x(idList, states, metadataFilters);
public String getRecordings2x(List<String> idList, List<String> states, Map<String, String> metadataFilters, String page, String size) {
int p;
int s;

try {
p = Integer.parseInt(page);
} catch(NumberFormatException e) {
p = 0;
}

try {
s = Integer.parseInt(size);
} catch(NumberFormatException e) {
s = 25;
}

log.info("{} {}", p, s);

Pageable pageable = PageRequest.of(p, s);
return recordingService.getRecordings2x(idList, states, metadataFilters, pageable);
}

public boolean existsAnyRecording(List<String> idList) {
Expand Down
Loading

0 comments on commit 807f028

Please sign in to comment.