Refactor: split long service files and centralize exception handling#35
Merged
milljoniaer merged 6 commits intomainfrom Mar 20, 2026
Merged
Refactor: split long service files and centralize exception handling#35milljoniaer merged 6 commits intomainfrom
milljoniaer merged 6 commits intomainfrom
Conversation
…boilerplate - Create ResourceNotFoundException for 404 responses - Create GlobalExceptionHandler (@ControllerAdvice) handling ResourceNotFoundException, IllegalArgumentException, IOException, and RuntimeException - Remove try-catch blocks from all ActivityController endpoints (591→434 lines) - Extract reusable parseRequiredDocumentId() and buildFileDownloadResponse() helpers - Remove unused buildCombinedMarkdown() method - Update ActivityService to throw ResourceNotFoundException Co-authored-by: milljoniaer <78978542+milljoniaer@users.noreply.github.com>
- Extract DocxHeaderFooterHelper (300 lines) - header/footer creation, logo, styled runs, field runs - Extract DocxTableHelper (146 lines) - Artikulationsschema table layout, column widths, cell sizing - MarkdownToDocxService reduced from 632→270 lines (57% reduction) - Update tests to use new constructor with injected helpers Co-authored-by: milljoniaer <78978542+milljoniaer@users.noreply.github.com>
- Move PDF metadata extraction, normalization, and defaults logic to ActivityExtractionService (239 lines) - ActivityService reduced from 673→491 lines (27% reduction) - ActivityService retains CRUD, filtering, recommendation criteria - Update ActivityServiceTest to inject extraction service with mocks Co-authored-by: milljoniaer <78978542+milljoniaer@users.noreply.github.com>
- Extract ActivityApi (309 lines) - activity CRUD, PDF/DOCX downloads, recommendations - Extract HistoryApi (105 lines) - search history and favourites - Extract UserApi (77 lines) - user management and profiles - apiService.ts reduced from 521→106 lines (80% reduction) - ApiService class remains as backward-compatible facade - Export ApiRequestMixin for shared request handling Co-authored-by: milljoniaer <78978542+milljoniaer@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor code for better readability and reuse
Refactor: split long service files and centralize exception handling
Mar 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Codebase cleanup — several files grew past 500-600 lines. Split them into focused modules and eliminated repetitive try-catch boilerplate across controllers.
Server
GlobalExceptionHandler(@ControllerAdvice) — centralizes exception→HTTP mapping (ResourceNotFoundException→404,IllegalArgumentException→400,IOException/RuntimeException→500). Removes ~160 lines of try-catch fromActivityController(591→434 lines).Split
MarkdownToDocxService(632→270 lines) — extractedDocxHeaderFooterHelper(header/footer creation, logo, styled runs, field runs) andDocxTableHelper(Artikulationsschema table layout, column widths)Split
ActivityService(673→491 lines) — extractedActivityExtractionServicefor PDF upload, LLM metadata extraction, data normalization, and defaultsClient
apiService.ts(521→106 lines) — extracted domain modulesactivityApiService.ts,historyApiService.ts,userApiService.ts.ApiServiceclass remains as a re-exporting facade so all existing call sites are unaffected.Test impact
All 62 server tests and 114 client tests pass unchanged (test setup updated for new constructors/injections).
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
jfrog-prod-use1-shared-virginia-main.s3.amazonaws.com/usr/lib/jvm/temurin-21-jdk-amd64/bin/java /usr/lib/jvm/temurin-21-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /home/REDACTED/.m2/wrapper/dists/apache-maven-3.9.11/a2d47e15/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/home/REDACTED/.m2/wrapper/dists/apache-maven-3.9.11/a2d47e15/bin/m2.conf -Dmaven.home=/home/REDACTED/.m2/wrapper/dists/apache-maven-3.9.11/a2d47e15 -Dlibrary.jansi.path=/home/REDACTED/.m2/wrapper/dists/apache-maven-3.9.11/a2d47e15/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/LEARN-Hub/LEARN-Hub/server org.codehaus.plexus.classworlds.launcher.Launcher clean compile -q(dns block)/usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java -Dfile.encoding=UTF-8 -Xms256M -Xss8M -Djdk.util.zip.disableZip64ExtraFieldValidation=true -Dsun.misc.unsafe.memory.access=allow --add-opens java.base/sun.reflect.annotation=ALL-UNNAMED -Xmx14576m -classpath /opt/hostedtoolcache/CodeQL/2.24.3/x64/codeql/java/tools/semmle-extractor-java.jar:/opt/hostedtoolcache/CodeQL/2.24.3/x64/codeql/java/tools/lombok-javac-extend.jar com.semmle.extractor.java.JavaExtractor --jdk-version 17 --javac-args @@@/tmp/codeql-scratch-21fe057196e5a270/dbs/java/log/ext/javac.args(dns block)If you need me to access, download, or install something from one of these locations, you can either:
⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.