Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
718b262
proto: added the server proto-files
LeanderK Apr 29, 2016
12b15e0
pom: added needed dependencies
LeanderK Apr 29, 2016
d164512
yml: added config yml
LeanderK Apr 29, 2016
ecbfdb3
server: first communications commit
LeanderK Apr 29, 2016
1c54fb1
config: first config commit
LeanderK Apr 29, 2016
50cca20
addon: started working on replace logic
LeanderK Apr 29, 2016
4cbf7ef
main: first draft of server integration
LeanderK Apr 29, 2016
a88086a
filemanager: added newLib location
LeanderK Apr 29, 2016
267d795
addon: finished synchro logic
LeanderK Apr 29, 2016
40f0f02
config: pushed addons out of the main config file
LeanderK Apr 30, 2016
b7a845d
config: reflected changes in the config file
LeanderK Apr 30, 2016
83d4196
pom: added yamlbeans, disabled dependencies because of a strange bug
LeanderK Apr 30, 2016
403fd9c
main: further progress, completed config loading
LeanderK Apr 30, 2016
f159718
server: further progress, started working on addon synchro
LeanderK Apr 30, 2016
7f3a6ba
main: added TODO
LeanderK Apr 30, 2016
4a05e95
server: fixed bug
LeanderK Apr 30, 2016
0b509c4
communication: finished getAddonAndDependencies
LeanderK Apr 30, 2016
72c51b4
filesystem: now creates the newLib folder
LeanderK Apr 30, 2016
a227a5b
addonManager: now deletes files after copy/deletion of the files refe…
LeanderK Apr 30, 2016
3069734
serverrequests: generalize downloadIzouVersion & bug fixes
LeanderK Apr 30, 2016
15ec471
communicationManager: nearly finished synchronizeApps method, some sm…
LeanderK Apr 30, 2016
08b0152
communicationManager: finished synchro App method
LeanderK Apr 30, 2016
bb0693a
addonManager: added TODO
LeanderK Apr 30, 2016
d047071
main: finished initCommunication
LeanderK Apr 30, 2016
bdbd43a
proto: updated proto
LeanderK May 1, 2016
a5e3dfb
proto: updated proto
LeanderK May 1, 2016
0a124df
server: first draft of server request to izou
LeanderK May 1, 2016
b08f4b9
proto: updated proto
LeanderK May 1, 2016
02f41c8
proto: updated proto
LeanderK May 1, 2016
6d258b3
server: nearly finished server-module
LeanderK May 1, 2016
ec17098
main: updated main
LeanderK May 1, 2016
a31548d
pom: deleted unnecessary dependencies
LeanderK May 1, 2016
da5dbef
config: added platform todo
LeanderK May 1, 2016
bfe372f
server: further progress
LeanderK May 15, 2016
238a7c5
proto: added ErrorResponse Proto
LeanderK May 15, 2016
649fd01
server: switched to SSLSocket
LeanderK May 17, 2016
216fbbb
proto: added IzouAppList
LeanderK May 19, 2016
500a439
addon: added handleRequest-method
LeanderK May 19, 2016
4806383
addonInformation: added installed/installedWithDependencies/toInstall…
LeanderK May 19, 2016
5023805
server: much progress in RequestHandler & CommunicationManager. Rewro…
LeanderK May 19, 2016
2043a7f
main: updated main to new api (does not compile yet)
LeanderK May 19, 2016
e335674
server: further progress on CommunicationManager, now inits the Addon…
LeanderK May 19, 2016
c65dd48
main: updated main
LeanderK May 19, 2016
0e95218
proto: updated proto
LeanderK May 21, 2016
005c836
server: added Request/response interfaces
LeanderK May 21, 2016
3b07072
server: updated server-package to new protocol
LeanderK May 21, 2016
aa73303
server: fixed some imports
LeanderK May 21, 2016
7a96f36
server: fixed certificate problem (letsencryp certificates are not ye…
LeanderK May 22, 2016
ce2d355
context: added izou-server link
LeanderK May 22, 2016
6b7f5fe
AddOnManager: set IzouServerLink
LeanderK May 22, 2016
76d6e6b
config: added IzouUrl, IzouSocketUrl, and ssl configuration option
LeanderK May 22, 2016
2b72c0d
pom: changed http client library because of certification problems
LeanderK May 22, 2016
ebd338f
server: some changes:
LeanderK May 22, 2016
efd740d
server: fixed bugs
LeanderK May 23, 2016
3664fcd
server: reworked larger parts, now improved and more clear
LeanderK May 24, 2016
798a2ee
identification: added needed methods for the AddOnInformationManager
LeanderK May 24, 2016
0ed41d2
proto: updated proto to new version & compiled changes
LeanderK May 26, 2016
8259a8c
server: update Request interface to be more efficient, fixed bugs
LeanderK May 26, 2016
66f9b5f
indentification: implemented needed methods
LeanderK May 26, 2016
dec65a1
identification: added missing TODO
LeanderK May 26, 2016
8f710a6
proto: added SocketConnectionResponse
LeanderK May 26, 2016
b394037
proto: updated to new proto
LeanderK May 26, 2016
0a9a5dd
config: added InternalConfig
LeanderK May 27, 2016
9310752
identification: update AddOnInformationManager to deal with new Inter…
LeanderK May 27, 2016
adca8c1
main: prepared disabled-state
LeanderK May 27, 2016
38e1bde
server: further progress
LeanderK May 27, 2016
34d3f90
addon: smaller changes
LeanderK May 27, 2016
b3a1de3
context: now exposes more information about the server and the connec…
LeanderK May 27, 2016
61d95eb
pom: new version
LeanderK May 27, 2016
c6c802a
server: added DelegatingInputstream that has no close-method and used…
LeanderK May 27, 2016
02845c0
server: updated for new token-handling
LeanderK May 27, 2016
41d75e2
addon: moved information about installed/scheduleded apps into the ad…
LeanderK May 29, 2016
af6ff00
addon: moved synchronization from server to addon package, migrated c…
LeanderK May 29, 2016
40773c4
addon: addonmanager now exposes Synchonization & Filesystem information
LeanderK May 29, 2016
324ceec
identification: cleanup after migration (and fixed some code-quality …
LeanderK May 29, 2016
54f5c39
main: added IzouSynchronization & UpdatesManager to better encapsulte…
LeanderK May 29, 2016
98192fe
proto: updated proto
LeanderK May 29, 2016
a69ab59
server: deleted migrated code & updated to new api
LeanderK May 29, 2016
ae80778
izou-config: delete unnecessary TODO
LeanderK May 29, 2016
c186edd
main: updated main to new api & initialized UpdatesManager
LeanderK May 29, 2016
7fb132c
main: updateManager is better than updatesManager
LeanderK May 29, 2016
7e796e0
server: deleted unused variable and updated main accordingly
LeanderK May 29, 2016
32e8fcc
server: deleted unnecessary documentation (copied) and made the class…
LeanderK May 29, 2016
110179f
all: fixed bugs
LeanderK May 30, 2016
d2641b0
synchro: synchro now does not dependend on ordering anymore to get th…
LeanderK May 30, 2016
172bb0b
pom: updated version
LeanderK May 31, 2016
89da1d1
all: fixed bugs
LeanderK Jun 8, 2016
4bebd96
server: implemented status
LeanderK Jun 8, 2016
1ceaf0f
server: implemented selected addons patch function
LeanderK Jun 8, 2016
75b1e8f
server: documented the server package
LeanderK Jun 10, 2016
6eb6e07
identification: documented and improved AddOnInformationManager
LeanderK Jun 10, 2016
158296e
server: added /log route
LeanderK Jun 10, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions internal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#the installed apps. You can modify them here or through the website
addOns:
- name:
version:
id:

state: "RUNNING"
5 changes: 5 additions & 0 deletions izou.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#the token used to identify the izou instance, please visit the website to get the token
token: eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJJWk9VIiwic2lkIjoiMSIsInJlZnJlc2hJem91Ijp0cnVlfQ.0K2RDPucqoihA0_jY41m4VbfKPHWFH-nFfvEXwklQ2A
url: localhost:4567
urlSocket: localhost
ssl: false
26 changes: 24 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.intellimate.izou</groupId>
<artifactId>izou</artifactId>
<version>1.15.1</version>
<version>1.16.5</version>
<packaging>jar</packaging>
<name>Izou</name>
<description>Izou is a framework used for an addon-based personal assistant</description>
Expand Down Expand Up @@ -79,7 +79,7 @@
<dependency>
<groupId>org.intellimate.izou</groupId>
<artifactId>pf4j</artifactId>
<version>1.18.4</version>
<version>1.18.6</version>
<!-- we are releasing a jar with dependencies, version changes require a new Izou Version -->
</dependency>
<dependency>
Expand Down Expand Up @@ -112,6 +112,26 @@
<artifactId>aspectjrt</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.19.1</version>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.0.0-beta-3</version>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java-util</artifactId>
<version>3.0.0-beta-3</version>
</dependency>
<dependency>
<groupId>com.esotericsoftware.yamlbeans</groupId>
<artifactId>yamlbeans</artifactId>
<version>1.09</version>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -147,6 +167,8 @@
<archive>
<manifest>
<mainClass>org.intellimate.izou.main.Main</mainClass>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
</archive>
<descriptorRefs>
Expand Down
123 changes: 123 additions & 0 deletions src/main/java/org/intellimate/izou/addon/AddOnFileManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
package org.intellimate.izou.addon;

import org.intellimate.izou.config.AddOn;
import org.intellimate.izou.config.Version;
import org.intellimate.izou.identification.AddOnInformation;
import org.intellimate.izou.main.Main;
import org.intellimate.izou.util.IzouModule;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
* provides Information about the installed, scheduled etc. AddOns
* @author LeanderK
* @version 1.0
*/
class AddOnFileManager extends IzouModule {
final static String REGEX_DELETE_APP = "\\w+-[\\.\\d]+-delete\\.zip";
final static String REGEX_DELETE_AND_INSTALL_APP = "\\w+-[\\.\\d]+(-.+)?\\.zip";
final static String REGEX_INSTALL_APP = "\\w+-[\\.\\d]+\\.zip";

AddOnFileManager(Main main) {
super(main);
}

/**
* returns the List of the installed zip-files
* @return a list of the ZipFiles
*/
List<String> getInstalledAppsRawNames() throws IOException {
try (Stream<Path> stream = Files.list(getMain().getFileSystemManager().getLibLocation().toPath())){
return stream.map(Path::toFile)
.map(File::getName)
.filter(name -> name.matches(REGEX_INSTALL_APP))
.collect(Collectors.toList());
}
}

/**
* returns all the installed Addons (inclusive the dependencies)
* @return a list of installed Addons
* @throws IOException if an Exception occurred while trying to access the File-System
*/
List<AddOnInformation> getInstalledWithDependencies() throws IOException {
return getInstalledAppsRawNames().stream()
.map(fileName -> AddOnFileManager.fileNameToAppExisting(fileName, getMain()))
.filter(Optional::isPresent)
.map(Optional::get)
.collect(Collectors.toList());
}

/**
* returns the apps scheduled to install
* @return a list of addons
* @throws IOException if an Exception occurred while trying to access the File-System
*/
List<AddOn> getScheduledToInstall() throws IOException {
try (Stream<Path> stream = Files.list(getMain().getFileSystemManager().getNewLibLocation().toPath())) {
return stream.map(Path::toFile)
.map(File::getName)
.filter(fileName -> fileName.matches(REGEX_INSTALL_APP))
.map(AddOnFileManager::pathToApp)
.filter(Optional::isPresent)
.map(Optional::get)
.collect(Collectors.toList());
}
}

/**
* returns teh Downloaded apps
* @return a list of addons
* @throws IOException if an Exception occurred while trying to access the File-System
*/
List<AddOn> getScheduledToDelete() throws IOException {
try (Stream<Path> stream = Files.list(getMain().getFileSystemManager().getNewLibLocation().toPath())) {
return stream.map(Path::toFile)
.map(File::getName)
.filter(fileName -> fileName.matches(REGEX_DELETE_APP))
.map(AddOnFileManager::pathToApp)
.filter(Optional::isPresent)
.map(Optional::get)
.collect(Collectors.toList());
}
}

/**
* maps a Path to an {@link AddOnInformation} (if it is already existing)
* @param fileName the name of the File
* @return an AddOn or null
*/
static Optional<AddOnInformation> fileNameToAppExisting(String fileName, Main main) {
String[] split = fileName.split("-");
String name = split[0];
if (name.isEmpty()) {
return Optional.empty();
} else {
return main.getAddOnInformationManager().getAddOnInformation(name);
}
}

/**
* maps a Path to an App
* @param fileName the name of the File
* @return an AddOn or null
*/
static Optional<AddOn> pathToApp(String fileName) {
String[] split = fileName.split("-");
String name = split[0];
Version version;
try {
version = new Version(split[1]);
} catch (IllegalArgumentException e) {
return null;
}
return Optional.of(new AddOn(name, version.toString(), -1));
}
}
87 changes: 82 additions & 5 deletions src/main/java/org/intellimate/izou/addon/AddOnManager.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package org.intellimate.izou.addon;

import com.sun.jersey.api.client.ClientHandlerException;
import org.apache.logging.log4j.Level;
import org.intellimate.izou.config.AddOn;
import org.intellimate.izou.identification.AddOnInformation;
import org.intellimate.izou.identification.AddOnInformationManager;
import org.intellimate.izou.main.Main;
import org.intellimate.izou.security.SecurityFunctions;
Expand All @@ -24,18 +27,21 @@
import java.security.cert.CertificateException;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
* Manages all the AddOns.
*/
//TODO isolate pf4j calls & catch errors accordingly
//TODO update methods
public class AddOnManager extends IzouModule implements AddonThreadPoolUser {
private IdentifiableSet<AddOnModel> addOns = new IdentifiableSet<>();
private HashMap<AddOnModel, PluginWrapper> pluginWrappers = new HashMap<>();
private Set<AspectOrAffected> aspectOrAffectedSet = new HashSet<>();
private List<Runnable> initializedCallback = new ArrayList<>();
private AddOnInformationManager addOnInformationManager;
private SynchronizationManager synchronizationManager;
private final AddOnFileManager addOnFileManager;

/**
* Creates a new instance of the AddOnManager
Expand All @@ -44,13 +50,15 @@ public class AddOnManager extends IzouModule implements AddonThreadPoolUser {
*/
public AddOnManager(Main main) {
super(main);
addOnInformationManager = main.getAddOnInformationManager();
synchronizationManager = new SynchronizationManager(main);
addOnFileManager = new AddOnFileManager(main);
}

/**
* Retrieves and registers all AddOns.
*/
public void retrieveAndRegisterAddOns() {
public void retrieveAndRegisterAddOns() throws IOException {
synchronizationManager.copyOrDeleteDownloadedApps();
addOns.addAll(loadAddOns());
registerAllAddOns(addOns);
initialized();
Expand Down Expand Up @@ -82,8 +90,8 @@ public void addAndRegisterAddOns(List<AddOnModel> addOns) {
* @param addOns
*/
public void registerAllAddOns(IdentifiableSet<AddOnModel> addOns) {
initAddOns(addOns);
createAddOnInfos(addOns);
initAddOns(addOns);
List<CompletableFuture<Void>> futures = addOns.stream()
.map(addOn -> submit((Runnable) addOn::register))
.collect(Collectors.toList());
Expand All @@ -98,7 +106,7 @@ public void registerAllAddOns(IdentifiableSet<AddOnModel> addOns) {
* Checks that addOns have all required properties and creating the addOn information list if they do
*/
private void createAddOnInfos(IdentifiableSet<AddOnModel> addOns) {
addOns.stream().forEach(addOn -> addOnInformationManager.registerAddOn(addOn));
addOns.stream().forEach(addOn -> getMain().getAddOnInformationManager().registerAddOn(addOn));
}

/**
Expand Down Expand Up @@ -144,6 +152,22 @@ private List<AddOnModel> loadAddOns() {
try {
debug("retrieving addons from the plugins");
List<AddOnModel> addOns = pluginManager.getExtensions(AddOnModel.class);
Collection<AddOnModel> removedDuplicates = addOns.stream()
.filter(addOn -> addOn.getClass().getClassLoader() instanceof IzouPluginClassLoader)
.collect(Collectors.toMap(
addOn -> ((IzouPluginClassLoader) addOn.getClass().getClassLoader()).getPluginDescriptor().getPluginId(),
Function.identity(),
((addOn, addOnModel2) -> {
debug(String.format(
"multiple Extensions with the same PluginId %s discovered! %s and %s.",
((IzouPluginClassLoader) addOn.getClass().getClassLoader()).getPluginDescriptor().getPluginId(),
addOn.toString(),
addOnModel2.toString()));
return addOn;
})
))
.values();
addOns = new ArrayList<>(removedDuplicates);
debug("retrieved: " + addOns.toString());
KeyManager keyManager = new KeyManager();
addOns.stream()
Expand Down Expand Up @@ -337,4 +361,57 @@ private KeyStore createKeyStore(String fileName, String password) {
return keyStore;
}
}

/**
* synchronizes the apps with the server
* @return true if something changed
* @throws IOException if in the early stages of the synchronization something went wrong with the File-IO
* @throws ClientHandlerException if in the early stages of the synchronization something went wrong with the Network-IO
*/
public boolean synchronizeApps() throws IOException, ClientHandlerException{
return synchronizationManager.synchronizeApps();
}

/**
* returns whether the AddOnManager is currently synchronizing
* @return true if synchronizing
*/
public boolean isSynchronizing() {
return synchronizationManager.isBusy();
}

/**
* returns the List of the installed zip-files
* @return a list of the ZipFiles
*/
public List<String> getInstalledAppsRawNames() throws IOException {
return addOnFileManager.getInstalledAppsRawNames();
}

/**
* returns all the installed Addons (inclusive the dependencies)
* @return a list of installed Addons
* @throws IOException if an Exception occurred while trying to access the File-System
*/
public List<AddOnInformation> getInstalledWithDependencies() throws IOException {
return addOnFileManager.getInstalledWithDependencies();
}

/**
* returns the apps scheduled to install
* @return a list of addons
* @throws IOException if an Exception occurred while trying to access the File-System
*/
public List<AddOn> getScheduledToInstall() throws IOException {
return addOnFileManager.getScheduledToInstall();
}

/**
* returns teh Downloaded apps
* @return a list of addons
* @throws IOException if an Exception occurred while trying to access the File-System
*/
public List<AddOn> getScheduledToDelete() throws IOException {
return addOnFileManager.getScheduledToDelete();
}
}
11 changes: 11 additions & 0 deletions src/main/java/org/intellimate/izou/addon/AddOnModel.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package org.intellimate.izou.addon;

import org.intellimate.izou.identification.Identifiable;
import org.intellimate.izou.server.Request;
import org.intellimate.izou.server.Response;
import org.intellimate.izou.system.Context;
import org.intellimate.server.proto.HttpRequest;
import org.intellimate.server.proto.HttpResponse;
import ro.fortsoft.pf4j.AddonAccessible;
import ro.fortsoft.pf4j.ExtensionPoint;
import ro.fortsoft.pf4j.PluginWrapper;
Expand Down Expand Up @@ -39,4 +43,11 @@ public interface AddOnModel extends ExtensionPoint, Identifiable {
* @param plugin the plugin
*/
void setPlugin(PluginWrapper plugin);

/**
* this method handles the HTTP-Requests
* @param request the request to process
* @return the response
*/
Response handleRequest(Request request);
}
Loading