Skip to content

Development: Migrate file URL paths for various entities #10433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 129 commits into from
Mar 15, 2025

Conversation

ole-ve
Copy link
Contributor

@ole-ve ole-ve commented Mar 2, 2025

Do not deploy to test servers because of DB migrations

Checklist

General

Server

  • Important: I implemented the changes with a very good performance and prevented too many (unnecessary) and too complex database calls.
  • I strictly followed the principle of data economy for all database calls.
  • I strictly followed the server coding and design guidelines.
  • I documented the Java code using JavaDoc style.

Motivation and Context

In #10416, we changed the URL paths to be prefixed by the respective module name.

Since we've adapted the asset paths (that are stored in the DB), existing assets can currently not be loaded after upgrading.

Also, we will remove the API base prefix for files (/api/core/files) from the paths stored literally in the database. Instead, the client has to append the prefix.

Description

Liquibase Migration that updates the paths for all entities that rely on this URL path. Additionally, includes all paths that need to be adapted.

Steps for Testing

Note: Needs to be tested locally.

  1. Start Server with a commit before the above PR has been merged (example: 6fc669b)
  2. Create the following entities:
  • Course (Icon)
  • Lecture Attachments - one type is enough
  • Quiz Questions (Background Image and Drag-and-Drog pictures)
  • User avatars
  • Student exam signature & student exam image path
  • file upload submissions
  • create an exercise and place a static link to https://artemis-test.../api/core/files/testfile.png. the file doesn't have to exist
  1. Check out develop, restart the server
  2. See that some requests fail like on the course page (course icon). Only applies to previously existing assets, new ones will be saved correctly (even with develop).
  3. Checkout this branch and start the server
  4. For every created entity, check that opening this entity (includes loading the files in any way from the /api/core/file-endpoint works fine.

Testserver States

You can manage test servers using Helios. Check environment statuses in the environment list. To deploy to a test server, go to the CI/CD page, find your PR or branch, and trigger the deployment.

Review Progress

Code Review

  • Code Review 2

Manual Tests

  • Test 1

Summary by CodeRabbit

  • New Features

    • Introduced a migration tool to update legacy API endpoints in job definitions.
  • Refactor

    • Standardized file and image URL construction across the application to ensure consistent display of course icons, profile pictures, attachments, and file uploads.
  • Bug Fixes

    • Enhanced error handling during file path resolution to improve reliability in file downloads and image rendering.

coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 14, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 14, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/test/playwright/support/requests/CourseManagementAPIRequests.ts (1)

107-109: Fix inconsistent property naming convention.

The newly added property courseIconpath has inconsistent casing compared to the original courseIcon property. To maintain consistent naming conventions throughout the codebase, consider changing it to courseIconPath with a capital 'P'.

const json = await response.json();
-json.courseIconpath = addPublicFilePrefix(json.courseIcon);
+json.courseIconPath = addPublicFilePrefix(json.courseIcon);
return json;
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7652e02 and 39b62cc.

📒 Files selected for processing (1)
  • src/test/playwright/support/requests/CourseManagementAPIRequests.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: Call Build Workflow / Build and Push Docker Image
  • GitHub Check: Call Build Workflow / Build .war artifact
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: client-tests
  • GitHub Check: server-tests
  • GitHub Check: client-tests-selected
  • GitHub Check: Analyse
🔇 Additional comments (1)
src/test/playwright/support/requests/CourseManagementAPIRequests.ts (1)

12-12: Good addition of the addPublicFilePrefix import.

The import of the utility function aligns with the migration goal to update URL paths consistently across the codebase.

coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 14, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/main/webapp/app/course/manage/course-management.service.ts (1)

529-538: Fix typo in method comment and consider checking if courseIcon exists.

The implementation correctly adds the public file prefix to the course icon path, but there are two minor issues:

  1. There's a typo in the comment: "THis" should be "This"
  2. The method doesn't check if courseIcon exists before using it with addPublicFilePrefix
/**
- * THis method adds the public file prefix to the course icon.
+ * This method adds the public file prefix to the course icon.
 * @param courseRes
 */
private processCourseIcon(courseRes: EntityResponseType): EntityResponseType {
    if (courseRes.body) {
-        courseRes.body.courseIconPath = addPublicFilePrefix(courseRes.body.courseIcon);
+        courseRes.body.courseIconPath = courseRes.body.courseIcon ? addPublicFilePrefix(courseRes.body.courseIcon) : undefined;
    }
    return courseRes;
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7d59761 and 5f7f3d4.

📒 Files selected for processing (2)
  • src/main/webapp/app/course/manage/course-management.service.ts (3 hunks)
  • src/main/webapp/app/course/manage/course-update.component.ts (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/webapp/app/course/manage/course-update.component.ts
🧰 Additional context used
📓 Path-based instructions (1)
`src/main/webapp/**/*.ts`: angular_style:https://angular.io/...

src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

  • src/main/webapp/app/course/manage/course-management.service.ts
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: Call Build Workflow / Build .war artifact
  • GitHub Check: Call Build Workflow / Build and Push Docker Image
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: client-tests
  • GitHub Check: client-tests-selected
  • GitHub Check: server-tests
  • GitHub Check: server-style
  • GitHub Check: Analyse
🔇 Additional comments (2)
src/main/webapp/app/course/manage/course-management.service.ts (2)

31-31: LGTM - Appropriate import added for file path prefixing.

The import of addPublicFilePrefix from 'app/app.constants' is correctly added to support the new path processing functionality.


518-518: LGTM - Good integration into the existing processing pipeline.

The new processCourseIcon method is now correctly called as part of the standard course entity response processing, ensuring all course icons will have consistent paths.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client Pull requests that update TypeScript code. (Added Automatically!) core Pull requests that affect the corresponding module database Pull requests that update the database. (Added Automatically!). Require a CRITICAL deployment. exam Pull requests that affect the corresponding module exercise Pull requests that affect the corresponding module fileupload Pull requests that affect the corresponding module iris Pull requests that affect the corresponding module lecture Pull requests that affect the corresponding module quiz Pull requests that affect the corresponding module ready for review server Pull requests that update Java code. (Added Automatically!) tests
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants