@xiangyang9999/folib-server-sync-a8be7ecd6f05 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +57 -2
  2. package/bin/folib-commit-sync.js +70 -0
  3. package/package.json +22 -4
  4. package/payload/INSTRUCTIONS.docx +0 -0
  5. package/payload/changes.patch +1538 -0
  6. package/payload/manifest.json +367 -0
  7. package/payload/manifest.sha256 +41 -0
  8. package/payload/source-files.zip +0 -0
  9. package/source/SECURITY_DEPENDENCY_UPGRADE.md +97 -0
  10. package/source/folib-client/pom.xml +160 -0
  11. package/source/folib-commons/folib-commons-core/pom.xml +297 -0
  12. package/source/folib-commons/folib-commons-core/src/main/java/com/veadan/folib/util/ArchiveExtractionPaths.java +86 -0
  13. package/source/folib-commons/folib-commons-core/src/main/java/com/veadan/folib/util/CompressUtils.java +148 -0
  14. package/source/folib-commons/folib-commons-core/src/test/java/com/veadan/folib/util/ArchiveExtractionPathsTest.java +77 -0
  15. package/source/folib-commons/folib-commons-core/src/test/java/com/veadan/folib/util/CompressUtilsTest.java +286 -0
  16. package/source/folib-commons/folib-commons-io/pom.xml +184 -0
  17. package/source/folib-data-service/pom.xml +259 -0
  18. package/source/folib-data-service/src/test/java/com/veadan/folib/config/hazelcast/HazelcastClusterCompatibilityTest.java +124 -0
  19. package/source/folib-rest-client/pom.xml +166 -0
  20. package/source/folib-security/folib-authentication-registry/pom.xml +117 -0
  21. package/source/folib-security/folib-security-api/pom.xml +416 -0
  22. package/source/folib-storage/folib-storage-layout-providers/folib-storage-debian-layout-provider/src/main/java/com/veadan/folib/indexer/DebianGroupInterceptor.java +251 -0
  23. package/source/folib-storage/folib-storage-layout-providers/folib-storage-debian-layout-provider/src/main/java/com/veadan/folib/indexer/DebianPackagesMetadataIndexer.java +72 -0
  24. package/source/folib-storage/folib-storage-layout-providers/folib-storage-docker-layout-provider/pom.xml +236 -0
  25. package/source/folib-storage/folib-storage-layout-providers/folib-storage-gitlfs-layout-provider/pom.xml +187 -0
  26. package/source/folib-storage/folib-storage-layout-providers/folib-storage-go-layout-provider/pom.xml +180 -0
  27. package/source/folib-storage/folib-storage-layout-providers/folib-storage-helm-layout-provider/pom.xml +125 -0
  28. package/source/folib-storage/folib-storage-layout-providers/folib-storage-huggingface-layout-provider/pom.xml +193 -0
  29. package/source/folib-storage/folib-storage-layout-providers/folib-storage-maven-layout/folib-maven-metadata-api/pom.xml +101 -0
  30. package/source/folib-storage/folib-storage-layout-providers/folib-storage-maven-layout/folib-storage-maven-layout-provider/pom.xml +179 -0
  31. package/source/folib-storage/folib-storage-layout-providers/folib-storage-npm-layout-provider/pom.xml +162 -0
  32. package/source/folib-storage/folib-storage-layout-providers/folib-storage-nuget-layout-provider/pom.xml +155 -0
  33. package/source/folib-storage/folib-storage-layout-providers/folib-storage-p2-layout-provider/pom.xml +116 -0
  34. package/source/folib-storage/folib-storage-layout-providers/folib-storage-php-layout-provider/pom.xml +170 -0
  35. package/source/folib-storage/folib-storage-layout-providers/folib-storage-pypi-layout-provider/pom.xml +278 -0
  36. package/source/folib-storage/folib-storage-layout-providers/folib-storage-raw-layout-provider/pom.xml +183 -0
  37. package/source/folib-web-core/pom.xml +1089 -0
  38. package/source/folib-web-core/src/main/java/com/veadan/folib/app/FolibSpringBootApplication.java +67 -0
  39. package/source/folib-web-core/src/main/java/com/veadan/folib/config/LegacySpringDataWebConfig.java +41 -0
  40. package/source/folib-web-core/src/main/java/com/veadan/folib/config/WebConfig.java +377 -0
  41. package/source/folib-web-core/src/main/java/com/veadan/folib/model/response/OhpmPublishRes.java +16 -0
  42. package/source/folib-web-core/src/main/java/com/veadan/folib/promotion/DockerParsePacketsUtil.java +202 -0
  43. package/source/folib-web-core/src/test/java/com/veadan/folib/config/LegacySpringDataWebConfigTest.java +75 -0
  44. package/source/folib-web-core/src/test/java/com/veadan/folib/config/WebConfigResourceHandlersTest.java +31 -0
  45. package/source/folib-web-core/src/test/java/com/veadan/folib/promotion/DockerArchiveExtractionTest.java +112 -0
  46. package/source/folib-web-core/src/test/java/com/veadan/folib/utils/DependencyCompatibilityTest.java +62 -0
@@ -0,0 +1,416 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
+ xmlns="http://maven.apache.org/POM/4.0.0"
4
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5
+
6
+ <modelVersion>4.0.0</modelVersion>
7
+
8
+ <parent>
9
+ <groupId>com.veadan.folib</groupId>
10
+ <artifactId>folib-parent</artifactId>
11
+ <version>3.0-SNAPSHOT</version>
12
+ <relativePath/>
13
+ </parent>
14
+
15
+ <artifactId>folib-security-api</artifactId>
16
+
17
+ <name>Folib: Security API</name>
18
+ <inceptionYear>2019</inceptionYear>
19
+
20
+ <scm>
21
+ <url>http://git.folib.com/folib/folib-server</url>
22
+ <connection>scm:git:git://git.folib.com/folib/folib-server.git</connection>
23
+ <developerConnection>scm:git:git://git.folib.com/folib/folib-server.git</developerConnection>
24
+ </scm>
25
+
26
+ <build>
27
+ <plugins>
28
+ <plugin>
29
+ <groupId>org.apache.maven.plugins</groupId>
30
+ <artifactId>maven-compiler-plugin</artifactId>
31
+ </plugin>
32
+ <plugin>
33
+ <groupId>org.apache.maven.plugins</groupId>
34
+ <artifactId>maven-source-plugin</artifactId>
35
+ </plugin>
36
+
37
+ <plugin>
38
+ <groupId>org.apache.maven.plugins</groupId>
39
+ <artifactId>maven-dependency-plugin</artifactId>
40
+ </plugin>
41
+ </plugins>
42
+ </build>
43
+
44
+ <dependencies>
45
+ <dependency>
46
+ <groupId>${project.groupId}</groupId>
47
+ <artifactId>folib-commons-core</artifactId>
48
+ <version>${project.version}</version>
49
+ </dependency>
50
+ <dependency>
51
+ <groupId>${project.groupId}</groupId>
52
+ <artifactId>folib-configuration</artifactId>
53
+ <version>${project.version}</version>
54
+ </dependency>
55
+ <dependency>
56
+ <groupId>${project.groupId}</groupId>
57
+ <artifactId>folib-data-service</artifactId>
58
+ <version>${project.version}</version>
59
+ </dependency>
60
+ <dependency>
61
+ <groupId>${project.groupId}</groupId>
62
+ <artifactId>folib-commons-resources</artifactId>
63
+ <version>${project.version}</version>
64
+ </dependency>
65
+ <!-- <dependency>-->
66
+ <!-- <groupId>${project.groupId}</groupId>-->
67
+ <!-- <artifactId>folib-testing-core</artifactId>-->
68
+ <!-- <version>${project.version}</version>-->
69
+ <!-- <scope>test</scope>-->
70
+ <!-- </dependency>-->
71
+
72
+ <dependency>
73
+ <groupId>org.glassfish.jersey.core</groupId>
74
+ <artifactId>jersey-common</artifactId>
75
+ <version>2.46</version>
76
+ </dependency>
77
+ <dependency>
78
+ <groupId>org.glassfish.jersey.containers</groupId>
79
+ <artifactId>jersey-container-servlet-core</artifactId>
80
+ <version>2.46</version>
81
+ </dependency>
82
+
83
+ <dependency>
84
+ <groupId>org.glassfish.jersey.core</groupId>
85
+ <artifactId>jersey-client</artifactId>
86
+ <version>2.46</version>
87
+ </dependency>
88
+
89
+ <dependency>
90
+ <groupId>org.springframework</groupId>
91
+ <artifactId>spring-context</artifactId>
92
+ </dependency>
93
+
94
+ <dependency>
95
+ <groupId>org.springframework</groupId>
96
+ <artifactId>spring-context-support</artifactId>
97
+ </dependency>
98
+
99
+ <dependency>
100
+ <groupId>org.junit.jupiter</groupId>
101
+ <artifactId>junit-jupiter</artifactId>
102
+ </dependency>
103
+ </dependencies>
104
+
105
+ <profiles>
106
+ <!-- These two profiles need to be on top: -->
107
+ <profile>
108
+ <id>reserve-ports</id>
109
+ <activation>
110
+ <activeByDefault>false</activeByDefault>
111
+ </activation>
112
+
113
+ <build>
114
+ <plugins>
115
+ <plugin>
116
+ <groupId>org.codehaus.mojo</groupId>
117
+ <artifactId>build-helper-maven-plugin</artifactId>
118
+ <executions>
119
+ <execution>
120
+ <id>reserve-network-port</id>
121
+ <goals>
122
+ <goal>reserve-network-port</goal>
123
+ </goals>
124
+ <phase>process-resources</phase>
125
+ <configuration>
126
+ <portNames>
127
+ <portName>port.littleproxy.listen</portName>
128
+ <portName>port.littleproxy.shutdown</portName>
129
+ <portName>port.unboundid</portName>
130
+ </portNames>
131
+ </configuration>
132
+ </execution>
133
+ </executions>
134
+ </plugin>
135
+ </plugins>
136
+ </build>
137
+ </profile>
138
+ <profile>
139
+ <id>set-default-ports</id>
140
+ <activation>
141
+ <property>
142
+ <name>skipTests</name>
143
+ <value>!true</value>
144
+ </property>
145
+
146
+ <activeByDefault>true</activeByDefault>
147
+ </activation>
148
+
149
+ <properties>
150
+ <!-- Default ports for local development: -->
151
+ <port.littleproxy.listen>8180</port.littleproxy.listen>
152
+ <port.littleproxy.shutdown>8181</port.littleproxy.shutdown>
153
+ <port.unboundid>40636</port.unboundid>
154
+ </properties>
155
+ </profile>
156
+ <!-- These two profiles need to be on top. -->
157
+
158
+ <profile>
159
+ <id>unit-tests</id>
160
+ <activation>
161
+ <property>
162
+ <name>skipTests</name>
163
+ <value>!true</value>
164
+ </property>
165
+ <activeByDefault>false</activeByDefault>
166
+ </activation>
167
+
168
+ <build>
169
+ <plugins>
170
+ <!-- <plugin>-->
171
+ <!-- <groupId>org.carlspring.maven</groupId>-->
172
+ <!-- <artifactId>unboundid-maven-plugin</artifactId>-->
173
+
174
+ <!-- <configuration>-->
175
+ <!-- <baseDn>dc=carlspring,dc=com</baseDn>-->
176
+ <!-- <portSSL>${port.unboundid}</portSSL>-->
177
+ <!-- <useSSL>true</useSSL>-->
178
+ <!-- <keyStorePassword>password</keyStorePassword>-->
179
+ <!-- <keyStorePath>${folib.home}/etc/ssl/keystore.jks</keyStorePath>-->
180
+ <!-- <trustStorePath>${folib.home}/etc/ssl/truststore.jks</trustStorePath>-->
181
+ <!-- </configuration>-->
182
+
183
+ <!-- <executions>-->
184
+ <!-- <execution>-->
185
+ <!-- <id>unboundid-start</id>-->
186
+
187
+ <!-- <phase>test-compile</phase>-->
188
+ <!-- <goals>-->
189
+ <!-- <goal>start</goal>-->
190
+ <!-- </goals>-->
191
+
192
+ <!-- <configuration>-->
193
+ <!-- <ldifFiles>-->
194
+ <!-- <ldifFile>${basedir}/src/test/resources/ldap/unboundid.ldif</ldifFile>-->
195
+ <!-- </ldifFiles>-->
196
+ <!-- </configuration>-->
197
+ <!-- </execution>-->
198
+ <!-- </executions>-->
199
+ <!-- </plugin>-->
200
+
201
+ <plugin>
202
+ <groupId>org.carlspring.maven</groupId>
203
+ <artifactId>little-proxy-maven-plugin</artifactId>
204
+
205
+ <configuration>
206
+ <hash>5FD4F8E2A</hash>
207
+ </configuration>
208
+
209
+ <executions>
210
+ <execution>
211
+ <id>start</id>
212
+ <phase>test-compile</phase>
213
+ <goals>
214
+ <goal>start</goal>
215
+ </goals>
216
+
217
+ <configuration>
218
+ <port>${port.littleproxy.listen}</port>
219
+ <shutdownPort>${port.littleproxy.shutdown}</shutdownPort>
220
+
221
+ <userCredentials>
222
+ <testuser>password</testuser>
223
+ </userCredentials>
224
+ </configuration>
225
+ </execution>
226
+ </executions>
227
+ </plugin>
228
+
229
+ <plugin>
230
+ <groupId>org.apache.maven.plugins</groupId>
231
+ <artifactId>maven-surefire-plugin</artifactId>
232
+
233
+ <configuration>
234
+ <systemPropertyVariables>
235
+ <folib.home>${project.build.directory}/folib</folib.home>
236
+ <folib.vault>${project.build.directory}/folib-vault</folib.vault>
237
+
238
+ <port.littleproxy>${port.littleproxy.listen}</port.littleproxy>
239
+ <port.unboundid>${port.unboundid}</port.unboundid>
240
+
241
+ <!-- override jre/lib/net.properties -->
242
+ <jdk.http.auth.tunneling.disabledSchemes>none</jdk.http.auth.tunneling.disabledSchemes>
243
+ </systemPropertyVariables>
244
+
245
+ <useUnlimitedThreads>false</useUnlimitedThreads>
246
+ </configuration>
247
+ </plugin>
248
+ </plugins>
249
+ </build>
250
+ </profile>
251
+ <profile>
252
+ <id>fail-safe-integration-tests-configuration</id>
253
+ <activation>
254
+ <property>
255
+ <name>integration.tests</name>
256
+ </property>
257
+ </activation>
258
+
259
+ <build>
260
+ <plugins>
261
+ <plugin>
262
+ <groupId>org.apache.maven.plugins</groupId>
263
+ <artifactId>maven-failsafe-plugin</artifactId>
264
+
265
+ <configuration>
266
+ <systemPropertyVariables>
267
+ <folib.home>${project.build.directory}/folib</folib.home>
268
+
269
+ <port.littleproxy>${port.littleproxy.listen}</port.littleproxy>
270
+ <port.unboundid>${port.unboundid}</port.unboundid>
271
+
272
+ <!-- override jre/lib/net.properties -->
273
+ <jdk.http.auth.tunneling.disabledSchemes>none</jdk.http.auth.tunneling.disabledSchemes>
274
+ </systemPropertyVariables>
275
+
276
+ <useUnlimitedThreads>false</useUnlimitedThreads>
277
+ </configuration>
278
+ </plugin>
279
+ </plugins>
280
+ </build>
281
+ </profile>
282
+
283
+ <profile>
284
+ <id>stop-services-for-unit-tests</id>
285
+ <activation>
286
+ <property>
287
+ <name>!integration.tests</name>
288
+ </property>
289
+ </activation>
290
+
291
+ <build>
292
+ <plugins>
293
+ <plugin>
294
+ <groupId>org.carlspring.maven</groupId>
295
+ <artifactId>unboundid-maven-plugin</artifactId>
296
+
297
+ <configuration>
298
+ <baseDn>dc=carlspring,dc=com</baseDn>
299
+ <portSSL>${port.unboundid}</portSSL>
300
+ <useSSL>true</useSSL>
301
+ <keyStorePassword>password</keyStorePassword>
302
+ <keyStorePath>${folib.home}/etc/ssl/keystore.jks</keyStorePath>
303
+ <trustStorePath>${folib.home}/etc/ssl/truststore.jks</trustStorePath>
304
+ </configuration>
305
+
306
+ <executions>
307
+ <execution>
308
+ <id>unboundid-stop</id>
309
+
310
+ <phase>test</phase>
311
+ <goals>
312
+ <goal>stop</goal>
313
+ </goals>
314
+
315
+ <configuration>
316
+ <failIfNotRunning>false</failIfNotRunning>
317
+ </configuration>
318
+ </execution>
319
+ </executions>
320
+ </plugin>
321
+
322
+ <plugin>
323
+ <groupId>org.carlspring.maven</groupId>
324
+ <artifactId>little-proxy-maven-plugin</artifactId>
325
+
326
+ <configuration>
327
+ <hash>5FD4F8E2A</hash>
328
+ </configuration>
329
+
330
+ <executions>
331
+ <execution>
332
+ <id>stop</id>
333
+ <phase>package</phase>
334
+ <goals>
335
+ <goal>stop</goal>
336
+ </goals>
337
+
338
+ <configuration>
339
+ <failIfNotRunning>false</failIfNotRunning>
340
+ <shutdownPort>${port.littleproxy.shutdown}</shutdownPort>
341
+ </configuration>
342
+ </execution>
343
+ </executions>
344
+ </plugin>
345
+ </plugins>
346
+ </build>
347
+ </profile>
348
+ <profile>
349
+ <id>stop-services-for-integration-tests</id>
350
+ <activation>
351
+ <property>
352
+ <name>integration.tests</name>
353
+ </property>
354
+ </activation>
355
+
356
+ <build>
357
+ <plugins>
358
+ <plugin>
359
+ <groupId>org.carlspring.maven</groupId>
360
+ <artifactId>unboundid-maven-plugin</artifactId>
361
+
362
+ <configuration>
363
+ <baseDn>dc=carlspring,dc=com</baseDn>
364
+ <portSSL>${port.unboundid}</portSSL>
365
+ <useSSL>true</useSSL>
366
+ <keyStorePassword>password</keyStorePassword>
367
+ <keyStorePath>${folib.home}/etc/ssl/keystore.jks</keyStorePath>
368
+ <trustStorePath>${folib.home}/etc/ssl/truststore.jks</trustStorePath>
369
+ </configuration>
370
+
371
+ <executions>
372
+ <execution>
373
+ <id>unboundid-stop</id>
374
+
375
+ <phase>verify</phase>
376
+ <goals>
377
+ <goal>stop</goal>
378
+ </goals>
379
+
380
+ <configuration>
381
+ <failIfNotRunning>false</failIfNotRunning>
382
+ </configuration>
383
+ </execution>
384
+ </executions>
385
+ </plugin>
386
+
387
+ <plugin>
388
+ <groupId>org.carlspring.maven</groupId>
389
+ <artifactId>little-proxy-maven-plugin</artifactId>
390
+
391
+ <configuration>
392
+ <hash>5FD4F8E2A</hash>
393
+ </configuration>
394
+
395
+ <executions>
396
+ <execution>
397
+ <id>stop</id>
398
+
399
+ <phase>verify</phase>
400
+ <goals>
401
+ <goal>stop</goal>
402
+ </goals>
403
+
404
+ <configuration>
405
+ <failIfNotRunning>false</failIfNotRunning>
406
+ <shutdownPort>${port.littleproxy.shutdown}</shutdownPort>
407
+ </configuration>
408
+ </execution>
409
+ </executions>
410
+ </plugin>
411
+ </plugins>
412
+ </build>
413
+ </profile>
414
+ </profiles>
415
+
416
+ </project>
@@ -0,0 +1,251 @@
1
+ package com.veadan.folib.indexer;
2
+
3
+ import com.google.common.base.Joiner;
4
+ import com.veadan.folib.constant.DebianConstant;
5
+ import com.veadan.folib.domain.DebianGroupMetadataWorkItem;
6
+ import com.veadan.folib.domain.DebianReleaseContext;
7
+ import com.veadan.folib.interceptor.GroupInterceptor;
8
+ import com.veadan.folib.providers.io.RepositoryPath;
9
+ import com.veadan.folib.providers.io.RepositoryPathResolver;
10
+ import com.veadan.folib.providers.io.RootRepositoryPath;
11
+ import com.veadan.folib.storage.repository.Repository;
12
+ import com.veadan.folib.util.DebianUtils;
13
+ import com.veadan.folib.utils.PathUtils;
14
+ import lombok.extern.slf4j.Slf4j;
15
+ import org.springframework.beans.factory.annotation.Autowired;
16
+ import org.springframework.stereotype.Component;
17
+ import org.springframework.util.StopWatch;
18
+
19
+ import java.nio.file.InvalidPathException;
20
+ import java.util.HashSet;
21
+ import java.util.List;
22
+ import java.util.Map;
23
+ import java.util.Set;
24
+
25
+ /**
26
+ * @author huayanjun
27
+ * @since 2025-02-23 10:46
28
+ */
29
+ @Slf4j
30
+ @Component
31
+ public class DebianGroupInterceptor implements GroupInterceptor {
32
+
33
+ private final DebianGroupHelper debianGroupHelper;
34
+
35
+ private final RepositoryPathResolver repositoryPathResolver;
36
+
37
+
38
+ @Autowired
39
+ public DebianGroupInterceptor(DebianGroupHelper debianGroupHelper,RepositoryPathResolver repositoryPathResolver) {
40
+ this.debianGroupHelper = debianGroupHelper;
41
+ this.repositoryPathResolver = repositoryPathResolver;
42
+ }
43
+
44
+ @Override
45
+ public boolean shouldInterceptor(RepositoryPath path) {
46
+ return this.shouldTakeAction(path);
47
+ }
48
+
49
+ @Override
50
+ public void calculateIndex(RepositoryPath path) {
51
+
52
+ if(!isReleaseFile(path)){
53
+ return;
54
+ }
55
+
56
+ Repository repository = path.getRepository();
57
+ String distribution = DebianUtils.getDistributionName(path);
58
+ String component = getComponentFromPackagesOrReleaseRequest(path);
59
+ DebianGroupMetadataWorkItem debianGroupMetadataWorkItem = new DebianGroupMetadataWorkItem(repository, distribution, component);
60
+ createOrUpdateVirtualIndexes(debianGroupMetadataWorkItem);
61
+ }
62
+
63
+
64
+ private String getComponentFromPackagesOrReleaseRequest(RepositoryPath packagesFileRepoPath) {
65
+ return packagesFileRepoPath.getName().contains("Packages") ? DebianUtils.getComponentFromPackagesRepoPath(packagesFileRepoPath) : "";
66
+ }
67
+
68
+ // private RepoResource retrieveResourceFromVirtualCache(VirtualRepo repo, InternalRequestContext context) {
69
+ // try {
70
+ // RepoResource cachedResource = repo.getInfoFromVirtualCache(context);
71
+ // if (this.cachedResourceExists(cachedResource)) {
72
+ // return cachedResource;
73
+ // }
74
+ // } catch (Exception var5) {
75
+ // String resourcePath = context.getResourcePath();
76
+ // Logger var10000 = log;
77
+ // String var10003 = repo.getKey();
78
+ // var10000.trace("Attempt to locate resource {} in cache failed, executing calculation of virtual debian metadata on path {}", resourcePath, var10003 + "/" + resourcePath);
79
+ // }
80
+ //
81
+ // return null;
82
+ // }
83
+
84
+ // @Nonnull
85
+ // public RepoResource onBeforeReturn(Repository virtualRepo, InternalRequestContext context, RepoResource resource) {
86
+ // if (RepoType.Debian.equals(((VirtualRepoConfig)virtualRepo.getRepoConfig()).getPackageType())) {
87
+ // String path = resource.getRepoPath().getPath();
88
+ // if (isReleaseRequestWithNoPrivateKey(path)) {
89
+ // return new UnfoundRepoResource(resource.getRepoPath(), resource.getRepoPath().getName() + " Not exist");
90
+ // }
91
+ // }
92
+ // return resource;
93
+ // }
94
+
95
+ boolean isReleaseRequestWithNoPrivateKey(String path,Repository repository) {
96
+ return (isInReleaseFile(path) || isReleaseGpgFile(path)) && !hasPrivateKey(repository);
97
+ }
98
+
99
+ private boolean shouldTakeAction(RepositoryPath path) {
100
+ // 1.判断是否为debian仓库 2.判断是否请求的元数据
101
+ String layout = path.getRepository().getLayout();
102
+ String type = path.getRepository().getType();
103
+
104
+ return DebianConstant.LAYOUT_NAME.equals(layout) &&"group".equals(type) &&isMetadataRequest(path);
105
+ }
106
+
107
+ private boolean isByHash(String path) {
108
+ return path.contains("by-hash");
109
+ }
110
+
111
+ private boolean isDebFile(String path) {
112
+ return path.matches(".*([.][d]?deb$)");
113
+ }
114
+
115
+ boolean isMetadataRequest(RepositoryPath repositoryPath) {
116
+
117
+ RootRepositoryPath rootDirectory = repositoryPath.getFileSystem().getRootDirectory();
118
+ RepositoryPath relativePath = rootDirectory.relativize(repositoryPath);
119
+ String path=relativePath.getPath();
120
+ if (path == null) {
121
+ return false;
122
+ } else if (path.contains("dists/by-hash")) {
123
+ return false;
124
+ } else {
125
+ String lastPathElement = PathUtils.getLastPathElement(path);
126
+ return lastPathElement.contains("Packages") || isReleaseFileInProperLevel(path) || isReleaseGpgFile(path) || isInReleaseFile(path);
127
+ }
128
+ }
129
+
130
+ private boolean isReleaseFileInProperLevel(String path) {
131
+ String[] pathElements = PathUtils.getPathElements(path);
132
+ return pathElements.length == 3 && pathElements[2].equalsIgnoreCase("Release");
133
+ }
134
+
135
+ private boolean isReleaseGpgFile(String path) {
136
+ String lastPathElement = PathUtils.getLastPathElement(path);
137
+ return lastPathElement.equalsIgnoreCase("Release.gpg");
138
+ }
139
+
140
+ private boolean isInReleaseFile(String path) {
141
+ String lastPathElement = PathUtils.getLastPathElement(path);
142
+ return lastPathElement.equalsIgnoreCase("InRelease");
143
+ }
144
+
145
+ private boolean isReleaseFile(RepositoryPath path) {
146
+ String lastPathElement = PathUtils.getLastPathElement(path.toString());
147
+ return lastPathElement.equalsIgnoreCase("Release");
148
+ }
149
+
150
+ // private boolean cachedResourceExists(RepoResource resource) {
151
+ // return resource != null && (resource.isFound() || resource.isExpired());
152
+ // }
153
+
154
+ // 判断仓库是否支持公私钥 目前不支持后期实现
155
+ private boolean hasPrivateKey(Repository repository) {
156
+ return false;
157
+ }
158
+
159
+
160
+ private void createOrUpdateVirtualIndexes(DebianGroupMetadataWorkItem workItem) {
161
+ String distribution = workItem.getDistribution();
162
+ Repository groupRepo = workItem.getRepository();
163
+ if (groupRepo == null) {
164
+ log.info("Unable to find repository");
165
+ } else {
166
+ DebianGroupIndexesCollector debianVirtualIndexesCollector = this.getGroupIndexesCollector(workItem);
167
+ // debianVirtualIndexesCollector.collectPackagesFilesToRecalculate(workItem);
168
+ this.indexVirtualRepo(debianVirtualIndexesCollector);
169
+ log.info("Finished writing automatic Debian index for {}/{}", groupRepo.getId(), distribution);
170
+ this.debianGroupHelper.validateParentVirtualRepository(workItem, groupRepo);
171
+ }
172
+ }
173
+
174
+ // public void unexpireMetadataFiles(Repository groupRepo, String distribution, String component) {
175
+ // log.debug("Unexpiring Packages/Release files under distribution {}", distribution);
176
+ // this.debianVirtualHelper.unexpirePackagesFiles(groupRepo, distribution, component);
177
+ // this.debianVirtualHelper.unexpireReleaseFile(groupRepo, distribution);
178
+ // log.debug("Finished unexpiring Packages/Release files under distribution {}", distribution);
179
+ // }
180
+
181
+ private DebianGroupIndexesCollector getGroupIndexesCollector(DebianGroupMetadataWorkItem workItem) {
182
+ String distribution = workItem.getDistribution();
183
+ String component = workItem.getComponent();
184
+ Repository groupRepo = workItem.getRepository();
185
+ log.info("Starting to writing automatic Debian index for {}/{}", groupRepo.getId(), distribution);
186
+ DebianGroupIndexesCollector debianVirtualIndexesCollector = new DebianGroupIndexesCollector(groupRepo, distribution, component);
187
+ // DpkgUtils.updateSigningPassword((DpkgWorkContext)debianVirtualIndexesCollector.getRepo().getWorkContext(), workItem.getPassphrase());
188
+ return debianVirtualIndexesCollector;
189
+ }
190
+
191
+ private void indexVirtualRepo(DebianGroupIndexesCollector debianVirtualIndexesCollector) {
192
+ String distribution = debianVirtualIndexesCollector.getDistribution();
193
+ DebianRepoGroupMetadataIndexFinalizer finalizer = new DebianRepoGroupMetadataIndexFinalizer(debianVirtualIndexesCollector.getGroupRepo(), distribution, null);
194
+ try {
195
+ StopWatch stopWatch = new StopWatch();
196
+ stopWatch.start();
197
+ this.indexPackages(debianVirtualIndexesCollector);
198
+ this.indexRelease(debianVirtualIndexesCollector);
199
+ finalizer.setCompFoldersToDelete(debianVirtualIndexesCollector.getCompFoldersToDelete());
200
+ finalizer.finalizeIndex();
201
+ stopWatch.stop();
202
+ log.info("Finished index for all required packages of distribution {}, took {} s", distribution, stopWatch.getTotalTimeSeconds());
203
+ } finally {
204
+ finalizer.removeTemp();
205
+ }
206
+
207
+ }
208
+
209
+
210
+ private void indexPackages(DebianGroupIndexesCollector debianGroupIndexesCollector) {
211
+ Map<String, Map<String, List<CharSequence>>> componentsToArchsToPackagesFileContent = debianGroupIndexesCollector.collectPackagesFilesFromAggregatedRepos();
212
+ Map<String, Map<String, String>> compToArchToMergedPackageFile = this.debianGroupHelper.mergePackagesFilesByArch(componentsToArchsToPackagesFileContent);
213
+ this.debianGroupHelper.persistMergedPackageFiles(debianGroupIndexesCollector, compToArchToMergedPackageFile);
214
+ }
215
+
216
+
217
+ private void indexRelease(DebianGroupIndexesCollector debianGroupIndexesCollector) {
218
+ Repository groupRepo = debianGroupIndexesCollector.getGroupRepo();
219
+ String distribution = debianGroupIndexesCollector.getDistribution();
220
+ debianGroupIndexesCollector.copyMissingPackagesFromVirtualCacheToVirtualCacheTempFolder();
221
+ DebianReleaseMetadataIndexer releaseIndexer = new DebianReleaseMetadataIndexer(groupRepo, null,this.repositoryPathResolver);
222
+ Set<String> componentsInTempPath = new HashSet<>();
223
+ Set<String> archsInTempPath = new HashSet<>();
224
+ this.debianGroupHelper.extractExistingArchsAndCompsInTempPath(groupRepo, debianGroupIndexesCollector, componentsInTempPath, archsInTempPath);
225
+ releaseIndexer.indexRelease(distribution);
226
+ }
227
+
228
+ private boolean isNeedToRecalculateRepo(DebianGroupIndexesCollector debianGroupIndexesCollector) {
229
+ return true;
230
+ // log.debug("Validating if Release file needed recalculate");
231
+ // Repository groupRepo = debianGroupIndexesCollector.getGroupRepo();
232
+ // String distribution = debianGroupIndexesCollector.getDistribution();
233
+ // RepositoryPath releaseFileRepoPath = repositoryPathResolver.resolve(groupRepo, Joiner.on("/").join("dists", distribution,"Release"));
234
+ // RepoResource releaseFileResource = virtualRepo.getInfoFromVirtualCache(DebianUtils.getDownloadRequestContext(releaseFileRepoPath));
235
+ // if (!releaseFileResource.isFound()) {
236
+ // log.debug("Release file not found in {}, forcing recalculate Release/Packages files", releaseFileRepoPath);
237
+ // return true;
238
+ // } else {
239
+ // Properties props = this.debianVirtualHelper.getPropertiesAndValidateNotEmpty(releaseFileResource.getRepoPath());
240
+ // if (props.isEmpty()) {
241
+ // log.debug("Couldn't find properties on Release file:{}, forcing recalculate Release/Packages files", releaseFileResource.getRepoPath());
242
+ // return true;
243
+ // } else {
244
+ // log.debug("checking SHA1 mismatch on Release file in path:{}, with props:{}, ", releaseFileRepoPath, props);
245
+ // return this.debianVirtualHelper.isReleaseFileSha1Mismatch(virtualRepo, distribution, props) || debianVirtualIndexesCollector.isNeedToRecalculatePackagesFile();
246
+ // }
247
+ // }
248
+ }
249
+
250
+
251
+ }