Skip to content

Commit ee81790

Browse files
committed
Import: asset-manager project
1 parent 94eea16 commit ee81790

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2999
-0
lines changed

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/mvnw text eol=lf
2+
*.cmd text eol=crlf
3+
*.sh text eol=lf

asset-manager/.gitignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
HELP.md
2+
target/
3+
!.mvn/wrapper/maven-wrapper.jar
4+
!**/src/main/**/target/
5+
!**/src/test/**/target/
6+
7+
### STS ###
8+
.apt_generated
9+
.classpath
10+
.factorypath
11+
.project
12+
.settings
13+
.springBeans
14+
.sts4-cache
15+
16+
### IntelliJ IDEA ###
17+
.idea
18+
*.iws
19+
*.iml
20+
*.ipr
21+
22+
### NetBeans ###
23+
/nbproject/private/
24+
/nbbuild/
25+
/dist/
26+
/nbdist/
27+
/.nb-gradle/
28+
build/
29+
!**/src/main/**/build/
30+
!**/src/test/**/build/
31+
32+
### VS Code ###
33+
.vscode/
34+
35+
/logs/
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
wrapperVersion=3.3.2
18+
distributionType=only-script
19+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip

asset-manager/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Menghua Xiao
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

asset-manager/PROMPTS.md

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
# Prompts for Copilot Edits Agent
2+
3+
Most of the project source code was generated by the Copilot Edits Agent mode, with a except in the `scripts` directory
4+
where AI didn't perform well in generating CMD batch script under Windows environment.
5+
6+
During the process, we found that the Agent mode was capable to fulfill small scope tasks (maybe the scope of a typical
7+
pull request), but not that well-performed on more complex scope. In that case, we may need more manual care, reverts,
8+
fine-tune the prompts, etc., which results in longer time consumed. So, during the project authoring, we manually split
9+
the goal into smaller pieces, and run each piece with a concrete prompt in the Agent mode.
10+
11+
Here is the list of some prompts used during the project creation, for your reference.
12+
13+
---
14+
15+
```markdown
16+
I have a blank Java project created from Spring Initializer, with the spring-web and thymeleaf dependency.
17+
18+
I want to build a web based AWS S3 client, that allows me to upload pictures to S3 buckets, list all the pictures, view a given picture, and delete pictures from S3 buckets.
19+
20+
Please generate the frontend UI using Thymeleaf templates and the backend web server that actually talks to S3 buckets when it receives the request from the frontend.
21+
```
22+
---
23+
24+
```
25+
I don't have an AWS S3 account. I want to try all the application logic locally except for the actual communication with AWS S3.
26+
27+
Extract the APIs of `S3Service` to a interface, generate another service implementation of this interface based on local files. Use profiles `dev` to register this service instead of the actual S3 one, so that I can test the app with profile `dev`.
28+
```
29+
---
30+
31+
```markdown
32+
The View button current opens a new window for the image, which will directly download the image rather than view the image in the browser.
33+
34+
Generate a View page, to allow the user to view the big picture in the web view.
35+
```
36+
---
37+
38+
```
39+
The current upload use the traditional upload UI. Please add the drag and drop support to allow the customer to upload a file by droping the file to a control in the page.
40+
```
41+
---
42+
43+
```
44+
I need to add another app to the project, which connects to the same storage as the current project. It will do some background processing for the files uploaded.
45+
46+
1. Convert the current project to a submodule `web` under the folder `web`
47+
2. Add a top level parent pom.xml that includes the `web` folder as a submodule
48+
3. Create another module `worker`, with dummy code that simply get the file lists and log to console
49+
```
50+
---
51+
52+
```
53+
The top level project should only be an index to submodule, without any code logic. Move the current project src to the web submodule.
54+
```
55+
---
56+
57+
```
58+
I see the following warning when I compile the top level parent project, please help to fix them.
59+
60+
[WARNING] Some problems were encountered while building the effective model for com.microsoft.migration:assets-manager-web:jar:0.0.1-SNAPSHOT
61+
[WARNING] 'build.plugins.plugin.version' for org.springframework.boot:spring-boot-maven-plugin is missing. @ line 54, column 21
62+
[WARNING]
63+
[WARNING] Some problems were encountered while building the effective model for com.microsoft.migration:assets-manager-worker:jar:0.0.1-SNAPSHOT
64+
[WARNING] 'build.plugins.plugin.version' for org.springframework.boot:spring-boot-maven-plugin is missing. @ line 39, column 21
65+
[WARNING]
66+
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
67+
[WARNING]
68+
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
69+
```
70+
71+
This didn't work well. It will add the version to the plugin explicitly. Refined to the following:
72+
73+
```
74+
I see the following warning when I compile the top level parent project, please help to fix them. Will it resolve the problem if you update the top level pom.xml to use spring boot as parent, rather than import it in dependencyManagement?
75+
76+
[WARNING] Some problems were encountered while building the effective model for com.microsoft.migration:assets-manager-web:jar:0.0.1-SNAPSHOT [WARNING] 'build.plugins.plugin.version' for org.springframework.boot:spring-boot-maven-plugin is missing. @ line 54, column 21 [WARNING] [WARNING] Some problems were encountered while building the effective model for com.microsoft.migration:assets-manager-worker:jar:0.0.1-SNAPSHOT [WARNING] 'build.plugins.plugin.version' for org.springframework.boot:spring-boot-maven-plugin is missing. @ line 39, column 21 [WARNING] [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build. [WARNING] [WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
77+
```
78+
---
79+
80+
```
81+
I need to use a queue in RabbitMQ to connect the web module and the worker module. When an image is uploaded from the web project, a message containing the image properties is sent to the queue. The worker listen to the queue, and when it receives the message properties from the queue, it creates a thumbnail image with width and height no more than 150px, the aspect ratio need to be the same as the original image. The thumbnail is then stored in the same location, local dir or a separate bucket, with a `_thumbnail` suffix in the file name.
82+
```
83+
84+
Copilot Agent incorrectly adds the dependency version configuration for AMQP in the parent pom's dependencyManagement section, which leads to compilation error. I manually removed it.
85+
86+
---
87+
88+
```
89+
Just like the web project that supports falling back to local storage when running in `dev` profile, the `FileProcessingService` should also be aware of local storage. Extract the key methods in `FileProcessingService` to a interface, and add another service implementation that processes the files from the local file storage, when the dev profile is activated. Create abstract parent class if necessary to ensure reusing common logics for different service implementation. Ensure the message in the message queue has enough information to identify if the file is from prod S3 or dev local storage.
90+
```
91+
---
92+
```
93+
Is `FileProcessingService` still needed, given in previous step it was refactored to two different implementation: s3 for prod and local file for dev?
94+
```
95+
---
96+
97+
```
98+
Add Spring Boot data JPA support to the web module. Sync the uploaded image's detailed metadata (without the image content) to the PostgreSQL database. And update or delete the metadata according to the client operation on the given image.
99+
```
100+
---
101+
102+
```
103+
Add a cmd script for windows and a bash script for Linux in the scripts directory of the parent project root. The two scripts need to have identical flow:
104+
105+
1. Spawn a PostgreSQL server with Docker
106+
2. Spawn a RabbitMQ server with Docker
107+
3. Start the web module in `dev` profile, and ensure the configuration for the above PostgreSQL and RabbitMQ is passed to the app through environment variables
108+
4. Start the worker module in `dev` profile, also properly inject the PostgreSQL and RabbitMQ configurations.
109+
110+
The logging output of the two apps needs to be redirected into two separate log files.
111+
```
112+
---
113+
114+
```
115+
update the scripts so that they can run without error like "cannot find project" regardless of what the current directory is
116+
```
117+
---
118+
119+
```
120+
I see the following error when run start.cmd:
121+
122+
'mvnw' is not recognized as an internal or external command, operable program or batch file.
123+
124+
The wrapper script locates in project root, and needs to use absolute path to invoke.
125+
126+
Same fix required for start.sh
127+
```
128+
---
129+
130+
```
131+
The following error raied when I run stop.cmd
132+
133+
'wmic' is not recognized as an internal or external command, operable program or batch file.
134+
```
135+
---
136+
137+
```
138+
ERROR: The search filter cannot be recognized.
139+
```
140+
---
141+
142+
```
143+
Update the web and the worker Spring Boot app to use `ApplicationPidFileWriter` so that they will write down the process PID to a file. Update the start.cmd script to pass in the desired pid file path to the pid file writer in the app, and update the stop.cmd script so that it will read the PID from that file and kill the process.
144+
145+
the `start /B cmd /c` command needs to be updated because currently there seems to be some problem with the double quote escaping in the long command.
146+
```
147+
---
148+
149+
```
150+
I don't have ImageMagik installed, so I cannot use it to generate thumbnail. Please replace it with some pure Java implementation so that I don't have a dependency to external ImageMagik.
151+
```
152+
---
153+
154+
```
155+
Currently, the RabbitListener will remove the message from the queue regardless whether the message processing is successful or not. Please update the logic so that only when the client successfully processes the message (i.e., the thumbnail is generated correctly) then the message is removed from the queue. Otherwise, the message is available for retry.
156+
157+
To avoid indefinite retry, when the previous processing failed, the message should only be rerouted after some delay, say 1 minute.
158+
```

0 commit comments

Comments
 (0)