Skip to content

Commit 6508eff

Browse files
committed
add an architecture to the repository source
1 parent a60cb92 commit 6508eff

File tree

53 files changed

+4070
-317
lines changed

Some content is hidden

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

53 files changed

+4070
-317
lines changed

haikudepotserver-api1/src/main/java/org/haiku/haikudepotserver/api1/model/repository/GetRepositoryResult.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2018, Andrew Lindesay
2+
* Copyright 2014-2022, Andrew Lindesay
33
* Distributed under the terms of the MIT License.
44
*/
55

@@ -58,6 +58,12 @@ public static class RepositorySource {
5858

5959
public Long lastImportTimestamp;
6060

61+
/**
62+
* @since 2022-03-12
63+
*/
64+
65+
public String architectureCode;
66+
6167
}
6268

6369
}

haikudepotserver-api1/src/main/java/org/haiku/haikudepotserver/api1/model/repository/GetRepositorySourceResult.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2020, Andrew Lindesay
2+
* Copyright 2015-2022, Andrew Lindesay
33
* Distributed under the terms of the MIT License.
44
*/
55

@@ -53,6 +53,12 @@ public class GetRepositorySourceResult {
5353

5454
public List<RepositorySourceMirror> repositorySourceMirrors;
5555

56+
/**
57+
* @since 2022-03-12
58+
*/
59+
60+
public String architectureCode;
61+
5662
public static class RepositorySourceMirror {
5763

5864
public Boolean active;

haikudepotserver-core-test/src/main/java/org/haiku/haikudepotserver/IntegrationTestSupportService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018-2020, Andrew Lindesay
2+
* Copyright 2018-2022, Andrew Lindesay
33
* Distributed under the terms of the MIT License.
44
*/
55

@@ -160,6 +160,7 @@ public StandardTestData createStandardTestData() {
160160
result.repositorySource.setCode("testreposrc_xyz");
161161
result.repositorySource.setRepository(result.repository);
162162
result.repositorySource.setIdentifier("http://www.example.com/test/identifier/url");
163+
result.repositorySource.setArchitecture(x86_64);
163164

164165
RepositorySourceExtraIdentifier repositorySourceExtraIdentifier = context.newObject(RepositorySourceExtraIdentifier.class);
165166
repositorySourceExtraIdentifier.setIdentifier("example:haiku:identifier");

haikudepotserver-core-test/src/test/java/org/haiku/haikudepotserver/api1/RepositoryApiIT.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018-2021, Andrew Lindesay
2+
* Copyright 2018-2022, Andrew Lindesay
33
* Distributed under the terms of the MIT License.
44
*/
55

@@ -132,7 +132,7 @@ public void setupSourceBasedUrlTest() {
132132
}
133133

134134
@Test
135-
public void getRepositoryTest() throws Exception {
135+
public void getRepositoryTest() {
136136
integrationTestSupportService.createStandardTestData();
137137

138138
GetRepositoryRequest request = new GetRepositoryRequest();
@@ -151,10 +151,11 @@ public void getRepositoryTest() throws Exception {
151151
Assertions.assertThat(repositorySource.code).isEqualTo("testreposrc_xyz");
152152
Assertions.assertThat(repositorySource.active).isTrue();
153153
Assertions.assertThat(repositorySource.url).startsWith("file:///");
154+
Assertions.assertThat(repositorySource.architectureCode).isEqualTo("x86_64");
154155
}
155156

156157
@Test
157-
public void testCreateRepository_ok() throws Exception {
158+
public void testCreateRepository_ok() {
158159
setAuthenticatedUserToRoot();
159160

160161
CreateRepositoryRequest request = new CreateRepositoryRequest();
@@ -175,7 +176,7 @@ public void testCreateRepository_ok() throws Exception {
175176
}
176177

177178
@Test
178-
public void testCreateRepository_codeNotUnique() throws Exception {
179+
public void testCreateRepository_codeNotUnique() {
179180
IntegrationTestSupportService.StandardTestData data = integrationTestSupportService.createStandardTestData();
180181
setAuthenticatedUserToRoot();
181182

@@ -198,7 +199,7 @@ public void testCreateRepository_codeNotUnique() throws Exception {
198199
}
199200

200201
@Test
201-
public void testGetRepositorySource() throws Exception {
202+
public void testGetRepositorySource() {
202203
IntegrationTestSupportService.StandardTestData data = integrationTestSupportService.createStandardTestData();
203204

204205
GetRepositorySourceRequest request = new GetRepositorySourceRequest();
@@ -214,6 +215,7 @@ public void testGetRepositorySource() throws Exception {
214215
Assertions.assertThat(result.identifier).isEqualTo("http://www.example.com/test/identifier/url");
215216
Assertions.assertThat(result.repositorySourceMirrors.size()).isEqualTo(2);
216217
Assertions.assertThat(result.extraIdentifiers).containsExactly("example:haiku:identifier");
218+
Assertions.assertThat(result.architectureCode).isEqualTo("x86_64");
217219

218220
GetRepositorySourceResult.RepositorySourceMirror mirror0 = result.repositorySourceMirrors.get(0);
219221
GetRepositorySourceResult.RepositorySourceMirror mirror1 = result.repositorySourceMirrors.get(1);
@@ -226,7 +228,7 @@ public void testGetRepositorySource() throws Exception {
226228
}
227229

228230
@Test
229-
public void testUpdateRepositorySource() throws Exception {
231+
public void testUpdateRepositorySource() {
230232
integrationTestSupportService.createStandardTestData();
231233
setAuthenticatedUserToRoot();
232234

@@ -254,7 +256,7 @@ public void testUpdateRepositorySource() throws Exception {
254256
}
255257

256258
@Test
257-
public void testCreateRepositorySource() throws Exception {
259+
public void testCreateRepositorySource() {
258260
integrationTestSupportService.createStandardTestData();
259261
setAuthenticatedUserToRoot();
260262

@@ -278,7 +280,7 @@ public void testCreateRepositorySource() throws Exception {
278280
}
279281

280282
@Test
281-
public void testCreateRepositorySourceMirror() throws Exception {
283+
public void testCreateRepositorySourceMirror() {
282284
integrationTestSupportService.createStandardTestData();
283285
setAuthenticatedUserToRoot();
284286

@@ -303,7 +305,7 @@ public void testCreateRepositorySourceMirror() throws Exception {
303305
}
304306

305307
@Test
306-
public void testUpdateRepositorySourceMirror() throws Exception {
308+
public void testUpdateRepositorySourceMirror() {
307309
integrationTestSupportService.createStandardTestData();
308310
setAuthenticatedUserToRoot();
309311

@@ -343,7 +345,7 @@ public void testUpdateRepositorySourceMirror() throws Exception {
343345
}
344346

345347
@Test
346-
public void testGetRepositorySourceMirror() throws Exception {
348+
public void testGetRepositorySourceMirror() {
347349
integrationTestSupportService.createStandardTestData();
348350

349351
GetRepositorySourceMirrorRequest request = new GetRepositorySourceMirrorRequest();
@@ -360,7 +362,7 @@ public void testGetRepositorySourceMirror() throws Exception {
360362
}
361363

362364
@Test
363-
public void testRemoveRepositorySourceMirror() throws Exception {
365+
public void testRemoveRepositorySourceMirror() {
364366
integrationTestSupportService.createStandardTestData();
365367

366368
RemoveRepositorySourceMirrorRequest request = new RemoveRepositorySourceMirrorRequest();

haikudepotserver-core-test/src/test/java/org/haiku/haikudepotserver/repository/RepositoryHpkrIngressServiceIT.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018-2019, Andrew Lindesay
2+
* Copyright 2018-2022, Andrew Lindesay
33
* Distributed under the terms of the MIT License.
44
*/
55

@@ -225,6 +225,8 @@ public void testImportThenCheck() throws Exception {
225225
RepositorySource repositorySource = RepositorySource.tryGetByCode(context, "testsrc_xyz").get();
226226
Assertions.assertThat(repositorySource.getIdentifier()).isEqualTo("f0c086e5-e096-429c-b38d-57beabd764e9");
227227
// ^^ as defined in the repo info file.
228+
Assertions.assertThat(repositorySource.getArchitecture().getCode()).isEqualTo("x86_gcc2");
229+
// ^^ as defined in the repo info file.
228230
}
229231

230232
// now pull out some known packages and make sure they are imported correctly.

haikudepotserver-core-test/src/test/java/org/haiku/haikudepotserver/repository/job/RepositoryDumpExportJobRunnerIT.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018, Andrew Lindesay
2+
* Copyright 2018-2022, Andrew Lindesay
33
* Distributed under the terms of the MIT License.
44
*/
55

@@ -59,7 +59,7 @@ public void testRun() throws IOException {
5959

6060
jobService.awaitJobFinishedUninterruptibly(guid, 10000);
6161
Optional<? extends JobSnapshot> snapshotOptional = jobService.tryGetJob(guid);
62-
Assert.assertEquals(snapshotOptional.get().getStatus(), JobSnapshot.Status.FINISHED);
62+
Assertions.assertThat(snapshotOptional.get().getStatus()).isEqualTo(JobSnapshot.Status.FINISHED);
6363

6464
// pull in the ZIP file now and extract the data
6565

@@ -85,6 +85,9 @@ public void testRun() throws IOException {
8585
JsonNode repositorySourceIdentifier = rootNode.at("/items/0/repositorySources/0/identifier");
8686
Assert.assertThat(repositorySourceIdentifier.asText(), CoreMatchers.is("http://www.example.com/test/identifier/url"));
8787

88+
JsonNode architectureCode = rootNode.at("/items/0/repositorySources/0/architectureCode");
89+
Assertions.assertThat(architectureCode.asText()).isEqualTo("x86_64");
90+
8891
JsonNode mirror0CountryCode = rootNode.at("/items/0/repositorySources/0/repositorySourceMirrors/0/countryCode");
8992
Assert.assertThat(mirror0CountryCode.asText(), CoreMatchers.is("ZA"));
9093
JsonNode mirror0BaseUrl = rootNode.at("/items/0/repositorySources/0/repositorySourceMirrors/0/baseUrl");

haikudepotserver-core/src/main/java/org/haiku/haikudepotserver/api1/RepositoryApiImpl.java

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018-2021, Andrew Lindesay
2+
* Copyright 2018-2022, Andrew Lindesay
33
* Distributed under the terms of the MIT License.
44
*/
55

@@ -16,11 +16,41 @@
1616
import org.apache.commons.collections4.SetUtils;
1717
import org.apache.commons.lang3.BooleanUtils;
1818
import org.apache.commons.lang3.StringUtils;
19-
import org.haiku.haikudepotserver.api1.model.repository.*;
19+
import org.haiku.haikudepotserver.api1.model.repository.CreateRepositoryRequest;
20+
import org.haiku.haikudepotserver.api1.model.repository.CreateRepositoryResult;
21+
import org.haiku.haikudepotserver.api1.model.repository.CreateRepositorySourceMirrorRequest;
22+
import org.haiku.haikudepotserver.api1.model.repository.CreateRepositorySourceMirrorResult;
23+
import org.haiku.haikudepotserver.api1.model.repository.CreateRepositorySourceRequest;
24+
import org.haiku.haikudepotserver.api1.model.repository.CreateRepositorySourceResult;
25+
import org.haiku.haikudepotserver.api1.model.repository.GetRepositoriesRequest;
26+
import org.haiku.haikudepotserver.api1.model.repository.GetRepositoriesResult;
27+
import org.haiku.haikudepotserver.api1.model.repository.GetRepositoryRequest;
28+
import org.haiku.haikudepotserver.api1.model.repository.GetRepositoryResult;
29+
import org.haiku.haikudepotserver.api1.model.repository.GetRepositorySourceMirrorRequest;
30+
import org.haiku.haikudepotserver.api1.model.repository.GetRepositorySourceMirrorResult;
31+
import org.haiku.haikudepotserver.api1.model.repository.GetRepositorySourceRequest;
32+
import org.haiku.haikudepotserver.api1.model.repository.GetRepositorySourceResult;
33+
import org.haiku.haikudepotserver.api1.model.repository.RemoveRepositorySourceMirrorRequest;
34+
import org.haiku.haikudepotserver.api1.model.repository.RemoveRepositorySourceMirrorResult;
35+
import org.haiku.haikudepotserver.api1.model.repository.SearchRepositoriesRequest;
36+
import org.haiku.haikudepotserver.api1.model.repository.SearchRepositoriesResult;
37+
import org.haiku.haikudepotserver.api1.model.repository.TriggerImportRepositoryRequest;
38+
import org.haiku.haikudepotserver.api1.model.repository.TriggerImportRepositoryResult;
39+
import org.haiku.haikudepotserver.api1.model.repository.UpdateRepositoryRequest;
40+
import org.haiku.haikudepotserver.api1.model.repository.UpdateRepositoryResult;
41+
import org.haiku.haikudepotserver.api1.model.repository.UpdateRepositorySourceMirrorRequest;
42+
import org.haiku.haikudepotserver.api1.model.repository.UpdateRepositorySourceMirrorResult;
43+
import org.haiku.haikudepotserver.api1.model.repository.UpdateRepositorySourceRequest;
44+
import org.haiku.haikudepotserver.api1.model.repository.UpdateRepositorySourceResult;
2045
import org.haiku.haikudepotserver.api1.support.ObjectNotFoundException;
2146
import org.haiku.haikudepotserver.api1.support.ValidationException;
2247
import org.haiku.haikudepotserver.api1.support.ValidationFailure;
23-
import org.haiku.haikudepotserver.dataobjects.*;
48+
import org.haiku.haikudepotserver.dataobjects.Architecture;
49+
import org.haiku.haikudepotserver.dataobjects.Country;
50+
import org.haiku.haikudepotserver.dataobjects.Repository;
51+
import org.haiku.haikudepotserver.dataobjects.RepositorySource;
52+
import org.haiku.haikudepotserver.dataobjects.RepositorySourceExtraIdentifier;
53+
import org.haiku.haikudepotserver.dataobjects.RepositorySourceMirror;
2454
import org.haiku.haikudepotserver.dataobjects.auto._RepositorySourceMirror;
2555
import org.haiku.haikudepotserver.job.model.JobService;
2656
import org.haiku.haikudepotserver.job.model.JobSnapshot;
@@ -29,7 +59,6 @@
2959
import org.haiku.haikudepotserver.repository.model.RepositorySearchSpecification;
3060
import org.haiku.haikudepotserver.repository.model.RepositoryService;
3161
import org.haiku.haikudepotserver.security.model.Permission;
32-
import org.haiku.haikudepotserver.security.model.UserAuthenticationService;
3362
import org.haiku.haikudepotserver.support.SingleCollector;
3463
import org.slf4j.Logger;
3564
import org.slf4j.LoggerFactory;
@@ -38,7 +67,12 @@
3867
import org.springframework.security.core.context.SecurityContextHolder;
3968
import org.springframework.stereotype.Component;
4069

41-
import java.util.*;
70+
import java.util.Collections;
71+
import java.util.HashSet;
72+
import java.util.List;
73+
import java.util.Optional;
74+
import java.util.Set;
75+
import java.util.UUID;
4276
import java.util.stream.Collectors;
4377

4478
@Component("repositoryApiImplV1")
@@ -49,19 +83,16 @@ public class RepositoryApiImpl extends AbstractApiImpl implements RepositoryApi
4983

5084
private final ServerRuntime serverRuntime;
5185
private final PermissionEvaluator permissionEvaluator;
52-
private final UserAuthenticationService userAuthenticationService;
5386
private final RepositoryService repositoryService;
5487
private final JobService jobService;
5588

5689
public RepositoryApiImpl(
5790
ServerRuntime serverRuntime,
5891
PermissionEvaluator permissionEvaluator,
59-
UserAuthenticationService userAuthenticationService,
6092
RepositoryService repositoryService,
6193
JobService jobService) {
6294
this.serverRuntime = Preconditions.checkNotNull(serverRuntime);
6395
this.permissionEvaluator = Preconditions.checkNotNull(permissionEvaluator);
64-
this.userAuthenticationService = Preconditions.checkNotNull(userAuthenticationService);
6596
this.repositoryService = Preconditions.checkNotNull(repositoryService);
6697
this.jobService = Preconditions.checkNotNull(jobService);
6798
}
@@ -237,6 +268,9 @@ public GetRepositoryResult getRepository(GetRepositoryRequest getRepositoryReque
237268
resultRs.code = rs.getCode();
238269
resultRs.url = rs.tryGetPrimaryMirror().map(_RepositorySourceMirror::getBaseUrl).orElse(null);
239270
resultRs.identifier = rs.getIdentifier();
271+
resultRs.architectureCode = Optional.ofNullable(rs.getArchitecture())
272+
.map(Architecture::getCode)
273+
.orElse(null);
240274

241275
if (null != rs.getLastImportTimestamp()) {
242276
resultRs.lastImportTimestamp = rs.getLastImportTimestamp().getTime();
@@ -394,6 +428,9 @@ public GetRepositorySourceResult getRepositorySource(
394428
result.code = repositorySource.getCode();
395429
result.repositoryCode = repositorySource.getRepository().getCode();
396430
result.identifier = repositorySource.getIdentifier();
431+
result.architectureCode = Optional.ofNullable(repositorySource.getArchitecture())
432+
.map(Architecture::getCode)
433+
.orElse(null);
397434

398435
if (null != repositorySource.getLastImportTimestamp()) {
399436
result.lastImportTimestamp = repositorySource.getLastImportTimestamp().getTime();

haikudepotserver-core/src/main/java/org/haiku/haikudepotserver/dataobjects/auto/_Architecture.java

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package org.haiku.haikudepotserver.dataobjects.auto;
22

3+
import java.io.IOException;
4+
import java.io.ObjectInputStream;
5+
import java.io.ObjectOutputStream;
6+
37
import org.apache.cayenne.exp.Property;
48
import org.haiku.haikudepotserver.dataobjects.support.AbstractDataObject;
59

@@ -17,8 +21,61 @@ public abstract class _Architecture extends AbstractDataObject {
1721

1822
public static final Property<String> CODE = Property.create("code", String.class);
1923

24+
protected String code;
25+
26+
2027
public String getCode() {
21-
return (String)readProperty("code");
28+
beforePropertyRead("code");
29+
return this.code;
30+
}
31+
32+
@Override
33+
public Object readPropertyDirectly(String propName) {
34+
if(propName == null) {
35+
throw new IllegalArgumentException();
36+
}
37+
38+
switch(propName) {
39+
case "code":
40+
return this.code;
41+
default:
42+
return super.readPropertyDirectly(propName);
43+
}
44+
}
45+
46+
@Override
47+
public void writePropertyDirectly(String propName, Object val) {
48+
if(propName == null) {
49+
throw new IllegalArgumentException();
50+
}
51+
52+
switch (propName) {
53+
case "code":
54+
this.code = (String)val;
55+
break;
56+
default:
57+
super.writePropertyDirectly(propName, val);
58+
}
59+
}
60+
61+
private void writeObject(ObjectOutputStream out) throws IOException {
62+
writeSerialized(out);
63+
}
64+
65+
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
66+
readSerialized(in);
67+
}
68+
69+
@Override
70+
protected void writeState(ObjectOutputStream out) throws IOException {
71+
super.writeState(out);
72+
out.writeObject(this.code);
73+
}
74+
75+
@Override
76+
protected void readState(ObjectInputStream in) throws IOException, ClassNotFoundException {
77+
super.readState(in);
78+
this.code = (String)in.readObject();
2279
}
2380

2481
}

0 commit comments

Comments
 (0)