Skip to content

Commit f17f22d

Browse files
committed
Re-add import
1 parent dbd0ad3 commit f17f22d

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

src/main/java/org/hydev/mcpm/client/export/ImportException.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package org.hydev.mcpm.client.export;
22

3+
/**
4+
* Import Exception
5+
*/
36
public class ImportException extends Exception {
47
public ImportException(Throwable cause) {
58
super(cause);

src/main/java/org/hydev/mcpm/client/export/ImportInteractor.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,22 @@
22

33
import com.fasterxml.jackson.core.JsonProcessingException;
44
import com.fasterxml.jackson.core.type.TypeReference;
5-
import org.hydev.mcpm.client.database.inputs.SearchPackagesType;
5+
import org.hydev.mcpm.client.commands.presenters.InstallResultPresenter;
66
import org.hydev.mcpm.client.installer.InstallBoundary;
7+
import org.hydev.mcpm.client.installer.InstallResult;
78
import org.hydev.mcpm.client.installer.input.InstallInput;
9+
import org.hydev.mcpm.client.search.SearchPackagesType;
810
import org.hydev.mcpm.utils.Pair;
911

1012
import java.util.List;
1113

1214
import static org.hydev.mcpm.Constants.JACKSON;
1315

16+
/**
17+
* Default implementation of ImportPluginsBoundary
18+
*
19+
* @param install the install boundary
20+
*/
1421
public record ImportInteractor(InstallBoundary install) implements ImportPluginsBoundary {
1522
@Override
1623
public ImportResult importPlugins(String input) throws ImportException {
@@ -19,10 +26,13 @@ public ImportResult importPlugins(String input) throws ImportException {
1926
// TODO: Install specific versions
2027
var results = plugins.stream()
2128
.map(p -> new Pair<>(p.name(),
22-
install.installPlugin(new InstallInput(p.name(), SearchPackagesType.BY_NAME, true, true))))
29+
install.installPlugin(new InstallInput(p.name(), SearchPackagesType.BY_NAME, true, true),
30+
(installResult, name) -> {
31+
32+
})))
2333
.collect(Pair.toMap());
2434

25-
return new ImportResult(ImportResult.State.SUCCESS, results);
35+
return new ImportResult(null); // install borked for now
2636
} catch (JsonProcessingException e) {
2737
throw new ImportException(e);
2838
}

src/main/java/org/hydev/mcpm/client/export/ImportResult.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,32 @@
1111
* @param installResults Result of each install
1212
*/
1313
public record ImportResult(Map<String, InstallResult> installResults) {
14+
/**
15+
* State of a single import
16+
*/
1417
public enum State {
1518
SUCCESS,
1619
PARTIAL_SUCCESS,
1720
FAILURE
1821
}
1922

23+
/**
24+
* Infer the state from the state of the install results
25+
*
26+
* @return Overall state of the import
27+
*/
2028
public State getState()
2129
{
2230
boolean success = true;
2331
boolean fail = false;
2432

33+
/*
2534
EnumSet<InstallResult> = new RegularEnumSet<>();
2635
for (InstallResult x : installResults.values()) {
2736
success &= x.type();
2837
fail |= x.type();
2938
}
39+
*/
40+
return State.SUCCESS;
3041
}
3142
}

0 commit comments

Comments
 (0)