Initialize MediaManager-Core project with essential setup:

- Added `.gitignore` for common IDE and build artifacts.
- Configured `pom.xml` with dependencies: PostgreSQL, Hibernate, HikariCP, Log4j 2, Jackson, JUnit 5.
- Created `Media` entity with JPA annotations.
- Added `application.properties` for database and IPC configuration.
- Configured Log4j 2 with console and rolling file appenders.
- Provided `README.md` with setup instructions.
- Included `MediaManagerApplication` class as a starting point.
This commit is contained in:
Gustavo Henrique Santos Souza de Miranda
2025-11-13 02:24:11 -03:00
commit f66cfa6ea4
12 changed files with 588 additions and 0 deletions
@@ -0,0 +1,55 @@
package com.mediamanager;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class MediaManagerApplication {
private static final Logger logger = LogManager.getLogger(MediaManagerApplication.class);
private static Properties config;
public static void main(String[] args) {
logger.info("Starting MediaManager Core Application...");
try {
// Load configuration
loadConfiguration();
// TODO: Initialize database connection
// TODO: Initialize IPC server with named pipes
// TODO: Start application services
logger.info("MediaManager Core started successfully");
logger.info("IPC Pipe: {}", config.getProperty("ipc.pipe.path") + "/" + config.getProperty("ipc.pipe.name"));
// Keep application running
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
logger.info("Shutting down MediaManager Core...");
// TODO: Cleanup resources
}));
} catch (Exception e) {
logger.error("Failed to start MediaManager Core", e);
System.exit(1);
}
}
private static void loadConfiguration() throws IOException {
config = new Properties();
try (InputStream input = MediaManagerApplication.class.getClassLoader()
.getResourceAsStream("application.properties")) {
if (input == null) {
throw new IOException("Unable to find application.properties");
}
config.load(input);
logger.info("Configuration loaded successfully");
}
}
public static Properties getConfig() {
return config;
}
}
@@ -0,0 +1,128 @@
package com.mediamanager.model;
import jakarta.persistence.*;
import java.time.LocalDateTime;
@Entity
@Table(name = "media")
public class Media {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
private String title;
@Column(nullable = false, unique = true)
private String filePath;
@Enumerated(EnumType.STRING)
@Column(nullable = false)
private MediaType type;
@Column
private Long fileSize;
@Column
private String mimeType;
@Column(name = "created_at", nullable = false, updatable = false)
private LocalDateTime createdAt;
@Column(name = "updated_at")
private LocalDateTime updatedAt;
@PrePersist
protected void onCreate() {
createdAt = LocalDateTime.now();
updatedAt = LocalDateTime.now();
}
@PreUpdate
protected void onUpdate() {
updatedAt = LocalDateTime.now();
}
// Constructors
public Media() {}
public Media(String title, String filePath, MediaType type) {
this.title = title;
this.filePath = filePath;
this.type = type;
}
// Getters and Setters
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
public MediaType getType() {
return type;
}
public void setType(MediaType type) {
this.type = type;
}
public Long getFileSize() {
return fileSize;
}
public void setFileSize(Long fileSize) {
this.fileSize = fileSize;
}
public String getMimeType() {
return mimeType;
}
public void setMimeType(String mimeType) {
this.mimeType = mimeType;
}
public LocalDateTime getCreatedAt() {
return createdAt;
}
public void setCreatedAt(LocalDateTime createdAt) {
this.createdAt = createdAt;
}
public LocalDateTime getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(LocalDateTime updatedAt) {
this.updatedAt = updatedAt;
}
public enum MediaType {
VIDEO,
AUDIO,
IMAGE,
DOCUMENT,
OTHER
}
}
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="https://jakarta.ee/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence
https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd"
version="3.0">
<persistence-unit name="MediaManagerPU" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<!-- Add entity classes here as they are created -->
<!-- <class>com.mediamanager.model.Media</class> -->
<properties>
<!-- Database connection properties will be set programmatically -->
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.show_sql" value="false"/>
<property name="hibernate.format_sql" value="true"/>
<!-- Connection pool settings -->
<property name="hibernate.hikari.maximumPoolSize" value="10"/>
<property name="hibernate.hikari.minimumIdle" value="2"/>
<property name="hibernate.hikari.connectionTimeout" value="30000"/>
</properties>
</persistence-unit>
</persistence>
+23
View File
@@ -0,0 +1,23 @@
# Database Configuration
db.url=jdbc:postgresql://localhost:5432/mediamanager
db.username=mediamanager
db.password=changeme
db.driver=org.postgresql.Driver
# HikariCP Connection Pool Settings
db.pool.maximum-pool-size=10
db.pool.minimum-idle=2
db.pool.connection-timeout=30000
db.pool.idle-timeout=600000
db.pool.max-lifetime=1800000
# Hibernate Settings
hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
hibernate.hbm2ddl.auto=update
hibernate.show_sql=false
hibernate.format_sql=true
# IPC Configuration
ipc.pipe.name=mediamanager-pipe
ipc.pipe.path=/tmp/mediamanager
ipc.buffer.size=8192
+35
View File
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
<RollingFile name="FileAppender" fileName="logs/mediamanager.log"
filePattern="logs/mediamanager-%d{yyyy-MM-dd}-%i.log">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} [%t] %-5level %logger{36} - %msg%n"/>
<Policies>
<TimeBasedTriggeringPolicy interval="1"/>
<SizeBasedTriggeringPolicy size="10MB"/>
</Policies>
<DefaultRolloverStrategy max="10"/>
</RollingFile>
</Appenders>
<Loggers>
<Logger name="com.mediamanager" level="debug" additivity="false">
<AppenderRef ref="Console"/>
<AppenderRef ref="FileAppender"/>
</Logger>
<Logger name="org.hibernate" level="info" additivity="false">
<AppenderRef ref="Console"/>
<AppenderRef ref="FileAppender"/>
</Logger>
<Root level="info">
<AppenderRef ref="Console"/>
<AppenderRef ref="FileAppender"/>
</Root>
</Loggers>
</Configuration>