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

Skip to content
Snippets Groups Projects
Commit 3e4e44d2 authored by Michael Breu's avatar Michael Breu :speech_balloon:
Browse files

Open Plugin in new Window

parent cb5ae1c6
2 merge requests!17Initial Merge to Prepare Release 1.0.0,!9Resolve "Sharing Plugin Infrastruktur optimieren"
......@@ -171,10 +171,11 @@ public class ShoppingBasketService {
*
*/
public static class ExtendedShoppingBasket {
public ExtendedShoppingBasket(ShoppingBasketInfoDTO shoppingBasket, Optional<GitLabAccessInfo> gitLabAccessInfo) {
public ExtendedShoppingBasket(ShoppingBasketInfoDTO shoppingBasket, Optional<GitLabAccessInfo> gitLabAccessInfo, long tokenValidUntil) {
super();
this.shoppingBasket = shoppingBasket;
this.gitLabAccessInfo = gitLabAccessInfo;
this.tokenValidUntil = tokenValidUntil;
}
public ExtendedShoppingBasket() {
}
......@@ -182,6 +183,12 @@ public class ShoppingBasketService {
private ShoppingBasketInfoDTO shoppingBasket;
private Optional<GitLabAccessInfo> gitLabAccessInfo;
/**
* token valid until (msecs since 1.1.1970)
*/
private long tokenValidUntil;
/**
* @return the shoppingBasket
*/
......@@ -206,6 +213,12 @@ public class ShoppingBasketService {
public void setGitLabAccessInfo(Optional<GitLabAccessInfo> gitLabAccessInfo) {
this.gitLabAccessInfo = gitLabAccessInfo;
}
/**
* @return the tokenValidUntil
*/
public long getTokenValidUntil() {
return tokenValidUntil;
}
}
......@@ -236,7 +249,7 @@ public class ShoppingBasketService {
if(gitLabAccessInfo.isPresent() && gitLabAccessInfo.get().getUser().isPresent()) {
userInfo = new UserInfo(gitLabAccessInfo.get().getUser().get().getUsername());
}
final ShoppingBasket shoppingBasket = new ShoppingBasket(userInfo, result.toArray(new ExerciseInfo[] {}));
final ShoppingBasket shoppingBasket = new ShoppingBasket(userInfo, result.toArray(new ExerciseInfo[] {}), basketInfo.tokenValidUntil);
log.info("Basket {} is delivered", basketToken );
return shoppingBasket;
}
......@@ -325,7 +338,8 @@ public class ShoppingBasketService {
public ShoppingBasketRedirectInfoDTO getRedirectInfo(ShoppingBasketInfoDTO basket, String baseURL) {
UUID random = UUID.randomUUID();
basketCache.put(random.toString(), new ExtendedShoppingBasket(basket, gitLabRepository.getGitLabAccessInfo()));
long tokenValidUntil = System.currentTimeMillis() + BASKET_EXPIRY_INTERVAL.toMillis();
basketCache.put(random.toString(), new ExtendedShoppingBasket(basket, gitLabRepository.getGitLabAccessInfo(), tokenValidUntil));
ShoppingBasketRedirectInfoDTO result = new ShoppingBasketRedirectInfoDTO();
......
......@@ -72,8 +72,8 @@ export class ExerciseDetailsComponent implements OnInit, OnDestroy {
this.pluginService.getRedirectLink(basketInfo).subscribe(
(redirectInfo: ShoppingBasketRedirectInfoDTO) => {
// alert('redirecting to ' + redirectInfo.redirectURL);
location.href = redirectInfo.redirectURL;
// window.open(redirectInfo.redirectURL/* , action.plugin */);
// location.href = redirectInfo.redirectURL;
window.open(redirectInfo.redirectURL, action.action);
},
() => alert('Search failed'))
}
......
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