This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content
Snippets Groups Projects
Commit 15b69a44 authored by Michael Breu's avatar Michael Breu 💬
Browse files

Intermediate commit

parent 6209ebda
1 merge request!17Initial Merge to Prepare Release 1.0.0
package at.ac.uibk.gitsearch.service;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import org.codeability.sharing.plugins.api.SharingPluginConfig;
import org.glassfish.jersey.client.ClientConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
/**
* management services for plugins.
* @author Michael Breu
*
*/
@Service
public class PluginManagementService {
private static String[] registeredPlugins = new String[] {
"http://localhost:8081/api/sharing/config"
};
private static SharingPluginConfig[] registeredPluginConfigs;
private final Logger log = LoggerFactory.getLogger(PluginManagementService.class);
@PostConstruct
public void registerPlugins() {
List<SharingPluginConfig> results = new ArrayList<>();
for(String registeredPlugin: registeredPlugins) {
ClientConfig restClientConfig = new ClientConfig();
Client client = ClientBuilder.newClient(restClientConfig);
WebTarget target = client.target(registeredPlugin);
try {
SharingPluginConfig config = target.
request().
accept(MediaType.APPLICATION_JSON).
get(SharingPluginConfig.class);
results.add(config);
} catch (Exception e) {
log.error("Cannot load plugin at {}", registeredPlugin, e);
}
registeredPluginConfigs = (SharingPluginConfig[]) results.toArray();
}
}
}
package at.ac.uibk.gitsearch.service;
import org.codeability.sharing.plugins.api.ShoppingBasket;
import org.codeability.sharing.plugins.api.ShoppingBasket.ExerciseInfo;
import org.codeability.sharing.plugins.api.ShoppingBasket.UserInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
......@@ -11,113 +14,6 @@ import org.springframework.stereotype.Service;
@Service
public class ShoppingBasketService {
public static class ShoppingBasket {
private UserInfo userInfo;
private ExerciseInfo[] exerciseInfo;
public ShoppingBasket(UserInfo userInfo, ExerciseInfo[] exerciseInfo) {
super();
this.userInfo = userInfo;
this.exerciseInfo = exerciseInfo;
}
/**
* @return the userInfo
*/
public UserInfo getUserInfo() {
return userInfo;
}
/**
* @param userInfo the userInfo to set
*/
public void setUserInfo(UserInfo userInfo) {
this.userInfo = userInfo;
}
/**
* @return the exerciseInfo
*/
public ExerciseInfo[] getExerciseInfo() {
return exerciseInfo;
}
/**
* @param exerciseInfo the exerciseInfo to set
*/
public void setExerciseInfo(ExerciseInfo[] exerciseInfo) {
this.exerciseInfo = exerciseInfo;
}
}
public static class UserInfo {
String email;
public UserInfo(String email) {
super();
this.email = email;
}
/**
* @return the email
*/
public String getEmail() {
return email;
}
/**
* @param email the email to set
*/
public void setEmail(String email) {
this.email = email;
}
}
public static class ExerciseInfo {
private String gitLabURI;
private int gitLabProjectId;
private String title;
public ExerciseInfo(String title, int gitLabProjectId, String gitLabURI) {
super();
this.title = title;
this.setGitLabProjectId(gitLabProjectId);
this.gitLabURI = gitLabURI;
}
/**
* @return the title
*/
public String getTitle() {
return title;
}
/**
* @param title the title to set
*/
public void setTitle(String title) {
this.title = title;
}
/**
* @return the gitLabURI
*/
public String getGitLabURI() {
return gitLabURI;
}
/**
* @param gitLabURI the gitLabURI to set
*/
public void setGitLabURI(String gitLabURI) {
this.gitLabURI = gitLabURI;
}
public int getGitLabProjectId() {
return gitLabProjectId;
}
public void setGitLabProjectId(int gitLabProjectId) {
this.gitLabProjectId = gitLabProjectId;
}
}
private final Logger log = LoggerFactory.getLogger(ShoppingBasketService.class);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment