Dataset Viewer
Auto-converted to Parquet Duplicate
commit_id
stringlengths
40
40
project
stringclasses
90 values
commit_message
stringlengths
5
2.21k
type
stringclasses
3 values
url
stringclasses
89 values
git_diff
stringlengths
283
4.32M
adbc3b32e7e7546c573e5144c4379f1a3924ca9f
arrayexpress$annotare2
A bit of refactoring of sign-up/sign-in functionality
p
https://github.com/arrayexpress/annotare2
diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/AppServletModule.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/AppServletModule.java index b0ffe1783..de380fd53 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/AppServletModule.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/AppServletModule.java @@ -149,8 +149,7 @@ protected void configureServlets() { bind(SubsTracking.class).in(SINGLETON); bind(SubsTrackingWatchdog.class).asEagerSingleton(); - bind(AuthService.class).to(AuthServiceImpl.class).in(SINGLETON); - bind(SignUpService.class).to(SignUpServiceImpl.class).in(SINGLETON); + bind(AccountService.class).to(AccountServiceImpl.class).in(SINGLETON); bind(AllRpcServicePaths.class).toInstance(allRpc); bind(AnnotareProperties.class).asEagerSingleton(); diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/ExportServlet.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/ExportServlet.java index 15101cb3b..f8db8a0e2 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/ExportServlet.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/ExportServlet.java @@ -25,7 +25,7 @@ import uk.ac.ebi.fg.annotare2.db.om.ExperimentSubmission; import uk.ac.ebi.fg.annotare2.db.om.User; import uk.ac.ebi.fg.annotare2.db.om.enums.Permission; -import uk.ac.ebi.fg.annotare2.web.server.login.AuthService; +import uk.ac.ebi.fg.annotare2.web.server.login.AccountService; import uk.ac.ebi.fg.annotare2.web.server.rpc.MageTabFormat; import uk.ac.ebi.fg.annotare2.web.server.services.AccessControlException; import uk.ac.ebi.fg.annotare2.web.server.services.SubmissionManager; @@ -52,7 +52,7 @@ public class ExportServlet extends HttpServlet { private static final Logger log = LoggerFactory.getLogger(ExportServlet.class); @Inject - private AuthService authService; + private AccountService accountService; @Inject private SubmissionManager submissionManager; @@ -91,7 +91,7 @@ private void exportMageTab(ExperimentSubmission submission, ZipOutputStream zip) private ExperimentSubmission getSubmission(HttpServletRequest request) throws ServletException { try { - User currentUser = authService.getCurrentUser(request.getSession()); + User currentUser = accountService.getCurrentUser(request.getSession()); return submissionManager.getExperimentSubmission(currentUser, getSubmissionId(request), Permission.VIEW); } catch (RecordNotFoundException e) { throw servletException(e); diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/AuthService.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/AccountService.java similarity index 83% rename from app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/AuthService.java rename to app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/AccountService.java index 96d5c1e98..82b954fd6 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/AuthService.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/AccountService.java @@ -26,11 +26,13 @@ /** * @author Olga Melnichuk */ -public interface AuthService { +public interface AccountService { + + ValidationErrors signUp(HttpServletRequest request) throws AccountServiceException; boolean isLoggedIn(HttpServletRequest request); - ValidationErrors login(HttpServletRequest request) throws LoginException; + ValidationErrors login(HttpServletRequest request) throws AccountServiceException; void logout(HttpSession session); diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/LoginException.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/AccountServiceException.java similarity index 87% rename from app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/LoginException.java rename to app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/AccountServiceException.java index 5bc2e21fd..8eb0db5e6 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/LoginException.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/AccountServiceException.java @@ -19,9 +19,9 @@ /** * @author Olga Melnichuk */ -public class LoginException extends Exception { +public class AccountServiceException extends Exception { - public LoginException(String expAcc) { + public AccountServiceException(String expAcc) { super(expAcc); } } diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/AuthServiceImpl.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/AccountServiceImpl.java similarity index 52% rename from app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/AuthServiceImpl.java rename to app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/AccountServiceImpl.java index 1bdd3e46a..1faf49318 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/AuthServiceImpl.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/AccountServiceImpl.java @@ -16,6 +16,7 @@ package uk.ac.ebi.fg.annotare2.web.server.login; +import com.google.common.collect.ImmutableMap; import com.google.inject.Inject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -25,8 +26,10 @@ import uk.ac.ebi.fg.annotare2.web.server.login.utils.RequestParam; import uk.ac.ebi.fg.annotare2.web.server.login.utils.SessionAttribute; import uk.ac.ebi.fg.annotare2.web.server.login.utils.ValidationErrors; +import uk.ac.ebi.fg.annotare2.web.server.services.EmailSender; import uk.ac.ebi.fg.annotare2.web.server.transaction.Transactional; +import javax.mail.MessagingException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; @@ -35,17 +38,19 @@ /** * @author Olga Melnichuk */ -public class AuthServiceImpl implements AuthService { +public class AccountServiceImpl implements AccountService { - private static final Logger log = LoggerFactory.getLogger(AuthServiceImpl.class); + private static final Logger log = LoggerFactory.getLogger(AccountServiceImpl.class); private static final SessionAttribute USER_EMAIL_ATTRIBUTE = new SessionAttribute("email"); private AccountManager accountManager; + private EmailSender emailer; @Inject - public AuthServiceImpl(AccountManager accountManager) { + public AccountServiceImpl(AccountManager accountManager, EmailSender emailer) { this.accountManager = accountManager; + this.emailer = emailer; } public boolean isLoggedIn(HttpServletRequest request) { @@ -53,13 +58,40 @@ public boolean isLoggedIn(HttpServletRequest request) { } @Transactional - public ValidationErrors login(HttpServletRequest request) throws LoginException { + public ValidationErrors signUp(HttpServletRequest request) throws AccountServiceException { + SignUpParams params = new SignUpParams(request); + ValidationErrors errors = params.validate(); + if (errors.isEmpty()) { + if (null != accountManager.getByEmail(params.getEmail())) { + errors.append("email", "User with this email already exists"); + } else { + User u = accountManager.createUser(params.getName(), params.getEmail(), params.getPassword()); + try { + emailer.sendFromTemplate( + EmailSender.NEW_USER_TEMPLATE, + ImmutableMap.of( + "to.name", u.getName(), + "to.email", u.getEmail(), + "verification.token", u.getVerificationToken() + ) + ); + } catch (MessagingException x) { + // + } + } + } + return errors; + } + + + @Transactional + public ValidationErrors login(HttpServletRequest request) throws AccountServiceException { LoginParams params = new LoginParams(request); ValidationErrors errors = params.validate(); if (errors.isEmpty()) { if (!accountManager.isValid(params.getEmail(), params.getPassword())) { log.debug("User '{}' entered invalid params", params.getEmail()); - throw new LoginException("Sorry, the email or password you entered is not valid."); + throw new AccountServiceException("Sorry, the email or password you entered is not valid."); } log.debug("User '{}' logged in", params.getEmail()); USER_EMAIL_ATTRIBUTE.set(request.getSession(), params.getEmail()); @@ -110,4 +142,48 @@ public String getPassword() { return password.getValue(); } } + + static class SignUpParams { + public static final String NAME_PARAM = "name"; + public static final String EMAIL_PARAM = "email"; + public static final String PASSWORD_PARAM = "password"; + public static final String CONFIRM_PASSWORD_PARAM = "confirm-password"; + + private final RequestParam name; + private final RequestParam email; + private final RequestParam password; + private final RequestParam confirmPassword; + + private SignUpParams(HttpServletRequest request) { + name = RequestParam.from(request, NAME_PARAM); + email = RequestParam.from(request, EMAIL_PARAM); + password = RequestParam.from(request, PASSWORD_PARAM); + confirmPassword = RequestParam.from(request, CONFIRM_PASSWORD_PARAM); + } + + public ValidationErrors validate() { + ValidationErrors errors = new ValidationErrors(); + for (RequestParam p : asList(name, email, password)) { + if (p.isEmpty()) { + errors.append(p.getName(), "Please specify a value, " + p.getName() + " is required"); + } + } + if (!password.getValue().equals(confirmPassword.getValue())) { + errors.append(confirmPassword.getName(), "Passwords do not match"); + } + return errors; + } + + public String getName() { + return name.getValue(); + } + + public String getEmail() { + return email.getValue(); + } + + public String getPassword() { + return password.getValue(); + } + } } diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/ChangePasswordServlet.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/ChangePasswordServlet.java index 0fb95fac0..084ec5aa6 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/ChangePasswordServlet.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/ChangePasswordServlet.java @@ -17,7 +17,50 @@ * */ +import com.google.inject.Inject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import uk.ac.ebi.fg.annotare2.web.server.login.utils.ValidationErrors; + +import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +import static uk.ac.ebi.fg.annotare2.web.server.login.ServletNavigation.LOGIN; +import static uk.ac.ebi.fg.annotare2.web.server.login.ServletNavigation.SIGNUP; public class ChangePasswordServlet extends HttpServlet { + private static final Logger log = LoggerFactory.getLogger(SignUpServlet.class); + + @Inject + private AccountService accountService; + + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + log.debug("Sign-up data submitted; checking.."); + ValidationErrors errors = new ValidationErrors(); + try { + errors.append(accountService.signUp(request)); + if (errors.isEmpty()) { + log.debug("Sign-up successful; redirect to login page"); + LOGIN.redirect(request, response); + return; + } + log.debug("Sign-up form had invalid entries"); + } catch (Exception e) { + log.debug("Sign-up failed"); + errors.append(e.getMessage()); + } + + request.setAttribute("errors", errors); + SIGNUP.forward(getServletConfig().getServletContext(), request, response); + + } + + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + SIGNUP.forward(getServletConfig().getServletContext(), request, response); + } } diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/LoginServlet.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/LoginServlet.java index c52b27296..3c5dbf356 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/LoginServlet.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/LoginServlet.java @@ -28,6 +28,7 @@ import java.io.IOException; import static uk.ac.ebi.fg.annotare2.web.server.login.ServletNavigation.*; +import static uk.ac.ebi.fg.annotare2.web.server.login.SessionInformation.*; /** * @author Olga Melnichuk @@ -36,22 +37,26 @@ public class LoginServlet extends HttpServlet { private static final Logger log = LoggerFactory.getLogger(LoginServlet.class); + + @Inject - private AuthService authService; + private AccountService accountService; @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { log.debug("Login details submitted; validating.."); ValidationErrors errors = new ValidationErrors(); try { - errors.append(authService.login(request)); + errors.append(accountService.login(request)); + EMAIL_SESSION_ATTRIBUTE.set(request.getSession(), request.getParameter("email")); + if (errors.isEmpty()) { log.debug("Login details are valid; Authorization succeeded"); HOME.restoreAndRedirect(request, response); return; } log.debug("Login details are invalid"); - } catch (LoginException e) { + } catch (AccountServiceException e) { log.debug("Authorization failed"); errors.append(e.getMessage()); } diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/LogoutServlet.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/LogoutServlet.java index 8e790a28f..087a55e35 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/LogoutServlet.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/LogoutServlet.java @@ -32,11 +32,11 @@ public class LogoutServlet extends HttpServlet { @Inject - private AuthService authService; + private AccountService accountService; @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - authService.logout(request.getSession()); + accountService.logout(request.getSession()); LOGIN.redirect(request, response); } diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/SecurityFilter.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/SecurityFilter.java index 9df980706..6ab36c0f7 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/SecurityFilter.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/SecurityFilter.java @@ -37,7 +37,7 @@ public class SecurityFilter implements Filter { private static final Logger log = LoggerFactory.getLogger(SecurityFilter.class); @Inject - private AuthService authService; + private AccountService accountService; @Inject private AllRpcServicePaths rpcServicePaths; @@ -53,7 +53,7 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo if (servletRequest instanceof HttpServletRequest) { HttpServletRequest request = (HttpServletRequest) servletRequest; - if (!authService.isLoggedIn(request)) { + if (!accountService.isLoggedIn(request)) { forceLogin(request, (HttpServletResponse) servletResponse); return; } diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/ServletNavigation.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/ServletNavigation.java index 075a185cb..41d35d90e 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/ServletNavigation.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/ServletNavigation.java @@ -78,6 +78,12 @@ public void redirect(HttpServletRequest request, HttpServletResponse response) t sendRedirect(contextBasedUrl(redirectTo, request), response); } + public void redirect(HttpServletRequest request, HttpServletResponse response, String queryString) throws IOException { + String redirectUrl = redirectTo + ( isNullOrEmpty(queryString) ? "" : "?" + queryString ); + log.debug("Redirecting to {}", redirectUrl); + sendRedirect(contextBasedUrl(redirectUrl, request), response); + } + public void forward(ServletContext context, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { log.debug("Forwarding to {}", forwardTo); context.getRequestDispatcher(preserveCodeSrvParam(forwardTo, request)).forward(request, response); diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/SignUpService.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/SessionInformation.java similarity index 69% rename from app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/SignUpService.java rename to app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/SessionInformation.java index 3b97abb46..1e69d7e72 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/SignUpService.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/SessionInformation.java @@ -17,10 +17,9 @@ * */ -import uk.ac.ebi.fg.annotare2.web.server.login.utils.ValidationErrors; +import uk.ac.ebi.fg.annotare2.web.server.login.utils.SessionAttribute; -import javax.servlet.http.HttpServletRequest; - -public interface SignUpService { - public ValidationErrors signUp(HttpServletRequest request) throws Exception; +public class SessionInformation { + public static final SessionAttribute EMAIL_SESSION_ATTRIBUTE = new SessionAttribute("email"); + public static final SessionAttribute INFO_SESSION_ATTRIBUTE = new SessionAttribute("info"); } diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/SignUpServiceImpl.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/SignUpServiceImpl.java deleted file mode 100644 index db478ed65..000000000 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/SignUpServiceImpl.java +++ /dev/null @@ -1,107 +0,0 @@ -package uk.ac.ebi.fg.annotare2.web.server.login; - -/* - * Copyright 2009-2013 European Molecular Biology Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -import com.google.common.collect.ImmutableMap; -import com.google.inject.Inject; -import uk.ac.ebi.fg.annotare2.db.om.User; -import uk.ac.ebi.fg.annotare2.web.server.login.utils.RequestParam; -import uk.ac.ebi.fg.annotare2.web.server.login.utils.ValidationErrors; -import uk.ac.ebi.fg.annotare2.web.server.services.AccountManager; -import uk.ac.ebi.fg.annotare2.web.server.services.EmailSender; -import uk.ac.ebi.fg.annotare2.web.server.transaction.Transactional; - -import javax.servlet.http.HttpServletRequest; - -import static java.util.Arrays.asList; - -public class SignUpServiceImpl implements SignUpService { - - @Inject - private AccountManager manager; - - @Inject - private EmailSender emailer; - - @Transactional - public ValidationErrors signUp(HttpServletRequest request) throws Exception { - SignUpParams params = new SignUpParams(request); - ValidationErrors errors = params.validate(); - if (errors.isEmpty()) { - if (null != manager.getByEmail(params.getEmail())) { - errors.append("email", "User with this email already exists"); - } else { - User u = manager.createUser(params.getName(), params.getEmail(), params.getPassword()); - emailer.sendFromTemplate( - EmailSender.NEW_USER_TEMPLATE, - ImmutableMap.of( - "to.name", u.getName(), - "to.email", u.getEmail(), - "verification.token", u.getVerificationToken() - ) - ); - } - } - return errors; - - } - - static class SignUpParams { - public static final String NAME_PARAM = "name"; - public static final String EMAIL_PARAM = "email"; - public static final String PASSWORD_PARAM = "password"; - public static final String CONFIRM_PASSWORD_PARAM = "confirm-password"; - - private final RequestParam name; - private final RequestParam email; - private final RequestParam password; - private final RequestParam confirmPassword; - - private SignUpParams(HttpServletRequest request) { - name = RequestParam.from(request, NAME_PARAM); - email = RequestParam.from(request, EMAIL_PARAM); - password = RequestParam.from(request, PASSWORD_PARAM); - confirmPassword = RequestParam.from(request, CONFIRM_PASSWORD_PARAM); - } - - public ValidationErrors validate() { - ValidationErrors errors = new ValidationErrors(); - for (RequestParam p : asList(name, email, password)) { - if (p.isEmpty()) { - errors.append(p.getName(), "Field \"" + p.getName() + "\" is required"); - } - } - if (!password.getValue().equals(confirmPassword.getValue())) { - errors.append(confirmPassword.getName(), "Passwords do not match"); - } - return errors; - } - - public String getName() { - return name.getValue(); - } - - public String getEmail() { - return email.getValue(); - } - - public String getPassword() { - return password.getValue(); - } - } -} diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/SignUpServlet.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/SignUpServlet.java index bd2cbf9f1..5174f0f3e 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/SignUpServlet.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/SignUpServlet.java @@ -29,26 +29,30 @@ import java.io.IOException; import static uk.ac.ebi.fg.annotare2.web.server.login.ServletNavigation.*; +import static uk.ac.ebi.fg.annotare2.web.server.login.SessionInformation.*; public class SignUpServlet extends HttpServlet { - private static final Logger log = LoggerFactory.getLogger(LoginServlet.class); + private static final Logger log = LoggerFactory.getLogger(SignUpServlet.class); @Inject - private SignUpService signUpService; + private AccountService accountService; @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { log.debug("Sign-up data submitted; checking.."); ValidationErrors errors = new ValidationErrors(); try { - errors.append(signUpService.signUp(request)); + errors.append(accountService.signUp(request)); if (errors.isEmpty()) { log.debug("Sign-up successful; redirect to login page"); + EMAIL_SESSION_ATTRIBUTE.set(request.getSession(), request.getParameter("email")); + INFO_SESSION_ATTRIBUTE.set(request.getSession(), "You have been successfully registered; please sign in now"); LOGIN.redirect(request, response); return; + } else { + log.debug("Sign-up form had invalid entries"); } - log.debug("Sign-up form had invalid entries"); - } catch (Exception e) { + } catch (AccountServiceException e) { log.debug("Sign-up failed"); errors.append(e.getMessage()); } diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/utils/ValidationErrors.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/utils/ValidationErrors.java index 6ded2824d..76b9d3ae2 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/utils/ValidationErrors.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/utils/ValidationErrors.java @@ -53,7 +53,7 @@ public String getErrors() { public String getErrors(String name) { Collection<String> err = errors.get(name); - return err == null ? "" : on(",").join(err); + return err == null ? "" : on(", ").join(err); } } diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/AdfServiceImpl.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/AdfServiceImpl.java index cdfaaf92e..a5ed87ce2 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/AdfServiceImpl.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/AdfServiceImpl.java @@ -35,7 +35,7 @@ import uk.ac.ebi.fg.annotare2.web.gwt.common.client.DataImportException; import uk.ac.ebi.fg.annotare2.web.gwt.common.client.NoPermissionException; import uk.ac.ebi.fg.annotare2.web.gwt.common.client.ResourceNotFoundException; -import uk.ac.ebi.fg.annotare2.web.server.login.AuthService; +import uk.ac.ebi.fg.annotare2.web.server.login.AccountService; import uk.ac.ebi.fg.annotare2.web.server.services.AccessControlException; import uk.ac.ebi.fg.annotare2.web.server.services.SubmissionManager; import uk.ac.ebi.fg.annotare2.web.server.services.UploadedFiles; @@ -51,8 +51,8 @@ public class AdfServiceImpl extends SubmissionBasedRemoteService implements AdfS private static final Logger log = LoggerFactory.getLogger(AdfServiceImpl.class); @Inject - public AdfServiceImpl(AuthService authService, SubmissionManager submissionManager) { - super(authService, submissionManager); + public AdfServiceImpl(AccountService accountService, SubmissionManager submissionManager) { + super(accountService, submissionManager); } @Transactional diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/AuthBasedRemoteService.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/AuthBasedRemoteService.java index 79b4f2c0d..f42fd51ce 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/AuthBasedRemoteService.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/AuthBasedRemoteService.java @@ -18,7 +18,7 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet; import uk.ac.ebi.fg.annotare2.db.om.User; -import uk.ac.ebi.fg.annotare2.web.server.login.AuthService; +import uk.ac.ebi.fg.annotare2.web.server.login.AccountService; import javax.servlet.http.HttpSession; @@ -27,14 +27,14 @@ */ abstract class AuthBasedRemoteService extends RemoteServiceServlet { - private final AuthService authService; + private final AccountService accountService; - public AuthBasedRemoteService(AuthService authService) { - this.authService = authService; + public AuthBasedRemoteService(AccountService accountService) { + this.accountService = accountService; } protected User getCurrentUser() { - return authService.getCurrentUser(getSession()); + return accountService.getCurrentUser(getSession()); } protected HttpSession getSession() { diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/CurrentUserAccountServiceImpl.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/CurrentUserAccountServiceImpl.java index d8a7b2525..a18d786c4 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/CurrentUserAccountServiceImpl.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/CurrentUserAccountServiceImpl.java @@ -19,7 +19,7 @@ import com.google.inject.Inject; import uk.ac.ebi.fg.annotare2.web.gwt.common.client.CurrentUserAccountService; import uk.ac.ebi.fg.annotare2.web.gwt.common.shared.dto.UserDto; -import uk.ac.ebi.fg.annotare2.web.server.login.AuthService; +import uk.ac.ebi.fg.annotare2.web.server.login.AccountService; import uk.ac.ebi.fg.annotare2.web.server.transaction.Transactional; import static uk.ac.ebi.fg.annotare2.web.server.rpc.transform.UIObjectConverter.uiUser; @@ -30,8 +30,8 @@ public class CurrentUserAccountServiceImpl extends AuthBasedRemoteService implements CurrentUserAccountService { @Inject - public CurrentUserAccountServiceImpl(AuthService authService) { - super(authService); + public CurrentUserAccountServiceImpl(AccountService accountService) { + super(accountService); } @Transactional diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/SubmissionBasedRemoteService.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/SubmissionBasedRemoteService.java index da6e8677a..a9ce8b65c 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/SubmissionBasedRemoteService.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/SubmissionBasedRemoteService.java @@ -26,7 +26,7 @@ import uk.ac.ebi.fg.annotare2.db.om.enums.Permission; import uk.ac.ebi.fg.annotare2.web.gwt.common.client.NoPermissionException; import uk.ac.ebi.fg.annotare2.web.gwt.common.client.ResourceNotFoundException; -import uk.ac.ebi.fg.annotare2.web.server.login.AuthService; +import uk.ac.ebi.fg.annotare2.web.server.login.AccountService; import uk.ac.ebi.fg.annotare2.web.server.services.AccessControlException; import uk.ac.ebi.fg.annotare2.web.server.services.SubmissionManager; @@ -39,9 +39,9 @@ public abstract class SubmissionBasedRemoteService extends AuthBasedRemoteServic private final SubmissionManager submissionManager; - protected SubmissionBasedRemoteService(AuthService authService, + protected SubmissionBasedRemoteService(AccountService accountService, SubmissionManager submissionManager) { - super(authService); + super(accountService); this.submissionManager = submissionManager; } diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/SubmissionListServiceImpl.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/SubmissionListServiceImpl.java index b4cc0835e..1e5583edf 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/SubmissionListServiceImpl.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/SubmissionListServiceImpl.java @@ -20,7 +20,7 @@ import uk.ac.ebi.fg.annotare2.db.om.Submission; import uk.ac.ebi.fg.annotare2.web.gwt.common.client.SubmissionListService; import uk.ac.ebi.fg.annotare2.web.gwt.common.shared.SubmissionRow; -import uk.ac.ebi.fg.annotare2.web.server.login.AuthService; +import uk.ac.ebi.fg.annotare2.web.server.login.AccountService; import uk.ac.ebi.fg.annotare2.web.server.rpc.transform.UIObjectConverter; import uk.ac.ebi.fg.annotare2.web.server.services.SubmissionManager; import uk.ac.ebi.fg.annotare2.web.server.transaction.Transactional; @@ -38,8 +38,8 @@ public class SubmissionListServiceImpl extends AuthBasedRemoteService implements private final SubmissionManager submissionManager; @Inject - public SubmissionListServiceImpl(AuthService authService, SubmissionManager submissionManager) { - super(authService); + public SubmissionListServiceImpl(AccountService accountService, SubmissionManager submissionManager) { + super(accountService); this.submissionManager = submissionManager; } diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/SubmissionServiceImpl.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/SubmissionServiceImpl.java index 288acf37f..c7e54d0f8 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/SubmissionServiceImpl.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/SubmissionServiceImpl.java @@ -46,7 +46,7 @@ import uk.ac.ebi.fg.annotare2.web.gwt.common.shared.update.ArrayDesignUpdateCommand; import uk.ac.ebi.fg.annotare2.web.gwt.common.shared.update.ArrayDesignUpdateResult; import uk.ac.ebi.fg.annotare2.web.gwt.common.shared.update.ExperimentUpdateCommand; -import uk.ac.ebi.fg.annotare2.web.server.login.AuthService; +import uk.ac.ebi.fg.annotare2.web.server.login.AccountService; import uk.ac.ebi.fg.annotare2.web.server.properties.AnnotareProperties; import uk.ac.ebi.fg.annotare2.web.server.services.AccessControlException; import uk.ac.ebi.fg.annotare2.web.server.services.DataFileManager; @@ -81,12 +81,12 @@ public class SubmissionServiceImpl extends SubmissionBasedRemoteService implemen private final UserDao userDao; @Inject - public SubmissionServiceImpl(AuthService authService, + public SubmissionServiceImpl(AccountService accountService, SubmissionManager submissionManager, DataFileManager dataFileManager, AnnotareProperties properties, UserDao userDao) { - super(authService, submissionManager); + super(accountService, submissionManager); this.dataFileManager = dataFileManager; this.properties = properties; this.userDao = userDao; diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/SubmissionValidationServiceImpl.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/SubmissionValidationServiceImpl.java index e06b59a52..c28d5901c 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/SubmissionValidationServiceImpl.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/SubmissionValidationServiceImpl.java @@ -30,7 +30,7 @@ import uk.ac.ebi.fg.annotare2.web.gwt.common.client.ResourceNotFoundException; import uk.ac.ebi.fg.annotare2.web.gwt.common.client.SubmissionValidationService; import uk.ac.ebi.fg.annotare2.web.gwt.common.shared.ValidationResult; -import uk.ac.ebi.fg.annotare2.web.server.login.AuthService; +import uk.ac.ebi.fg.annotare2.web.server.login.AccountService; import uk.ac.ebi.fg.annotare2.web.server.services.AccessControlException; import uk.ac.ebi.fg.annotare2.web.server.services.SubmissionManager; import uk.ac.ebi.fg.annotare2.web.server.services.SubmissionValidator; @@ -52,10 +52,10 @@ public class SubmissionValidationServiceImpl extends SubmissionBasedRemoteServic private final SubmissionValidator validator; @Inject - public SubmissionValidationServiceImpl(AuthService authService, + public SubmissionValidationServiceImpl(AccountService accountService, SubmissionManager submissionManager, SubmissionValidator validator) { - super(authService, submissionManager); + super(accountService, submissionManager); this.validator = validator; } diff --git a/app/web/src/main/webapp/login.css b/app/web/src/main/webapp/login.css index 32f3373af..386e086ac 100644 --- a/app/web/src/main/webapp/login.css +++ b/app/web/src/main/webapp/login.css @@ -38,6 +38,12 @@ text-align: left; } +.info { + font-size: small; + color: darkgreen; + text-align: left; +} + .form { border-collapse: collapse; color: #000; diff --git a/app/web/src/main/webapp/login.jsp b/app/web/src/main/webapp/login.jsp index 9d344e7a3..c1e1537ac 100644 --- a/app/web/src/main/webapp/login.jsp +++ b/app/web/src/main/webapp/login.jsp @@ -25,8 +25,11 @@ pageContext.setAttribute("passwordErrors", errors.getErrors("password")); } - String[] values = request.getParameterValues("email"); - pageContext.setAttribute("email", values == null ? "" : values[0]); + String email = request.getParameter("email"); + if (null == email) { + email = (String)session.getAttribute("email"); + } + pageContext.setAttribute("email", email == null ? "" : email); %> <!DOCTYPE html> <html> @@ -48,13 +51,27 @@ <td></td> <td><h1>Annotare 2.0</h1></td> </tr> + <tr class="info"> + <td></td> + <td><c:out value="${sessionScope.info}" /><c:remove var="info" scope="session" /></td> + + </tr> <tr class="error"> <td></td> <td>${dummyErrors}</td> </tr> <tr class="row right"> <td>Email address</td> - <td><input type="text" name="email" value="${email}" style="width:98%"/></td> + <td> + <c:choose> + <c:when test="${email != ''}"> + <input type="text" name="email" value="${email}" style="width:98%"/> + </c:when> + <c:otherwise> + <input type="text" name="email" style="width:98%" autofocus="autofocus"/> + </c:otherwise> + </c:choose> + </td> </tr> <tr class="error"> <td></td> @@ -62,7 +79,16 @@ </tr> <tr class="row right"> <td>Password</td> - <td><input type="password" name="password" style="width:98%"/></td> + <td> + <c:choose> + <c:when test="${email != ''}"> + <input type="password" name="password" style="width:98%" autofocus="autofocus"/> + </c:when> + <c:otherwise> + <input type="password" name="password" style="width:98%"/> + </c:otherwise> + </c:choose> + </td> </tr> <tr class="error"> <td></td> diff --git a/app/web/src/main/webapp/sign-up.jsp b/app/web/src/main/webapp/sign-up.jsp index b372c818d..a19f606a2 100644 --- a/app/web/src/main/webapp/sign-up.jsp +++ b/app/web/src/main/webapp/sign-up.jsp @@ -34,7 +34,6 @@ values = request.getParameterValues("email"); pageContext.setAttribute("email", values == null ? "" : values[0]); - %> <!DOCTYPE html> <html> diff --git a/app/web/src/test/java/uk/ac/ebi/fg/annotare2/web/server/login/AuthenticationServiceImplTest.java b/app/web/src/test/java/uk/ac/ebi/fg/annotare2/web/server/login/AuthenticationServiceImplTest.java index 68f8858e3..b4fa7e101 100644 --- a/app/web/src/test/java/uk/ac/ebi/fg/annotare2/web/server/login/AuthenticationServiceImplTest.java +++ b/app/web/src/test/java/uk/ac/ebi/fg/annotare2/web/server/login/AuthenticationServiceImplTest.java @@ -19,6 +19,7 @@ import org.junit.Test; import uk.ac.ebi.fg.annotare2.web.server.services.AccountManager; import uk.ac.ebi.fg.annotare2.web.server.login.utils.ValidationErrors; +import uk.ac.ebi.fg.annotare2.web.server.services.EmailSender; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; @@ -37,13 +38,14 @@ public void testExistedLogin() { final String password = "existed_password"; AccountManager accMan = mockAccManager(name, password, true); + EmailSender emailer = mockEmailer(); HttpServletRequest request = mockRequest(name, password); try { - AuthService authService = new AuthServiceImpl(accMan); - ValidationErrors errors = authService.login(request); + AccountService accountService = new AccountServiceImpl(accMan, emailer); + ValidationErrors errors = accountService.login(request); assertTrue(errors.isEmpty()); - } catch (LoginException e) { + } catch (AccountServiceException e) { fail("Existed user should be logged in"); } } @@ -54,40 +56,41 @@ public void testNonExistedLogin() { final String password = "non_existed_password"; AccountManager accMan = mockAccManager(name, password, false); + EmailSender emailer = mockEmailer(); HttpServletRequest request = mockRequest(name, password); try { - AuthService authService = new AuthServiceImpl(accMan); - authService.login(request); + AccountService accountService = new AccountServiceImpl(accMan, emailer); + accountService.login(request); fail("Non-existed user should not be logged in"); - } catch (LoginException e) { + } catch (AccountServiceException e) { //ok } } @Test - public void testInvalidLogin() throws LoginException { - AuthService authService = new AuthServiceImpl(null); + public void testInvalidLogin() throws AccountServiceException { + AccountService accountService = new AccountServiceImpl(null, null); HttpServletRequest request = mockRequest("user", null); - ValidationErrors errors = authService.login(request); + ValidationErrors errors = accountService.login(request); assertFalse(errors.isEmpty()); - assertFalse(errors.getErrors(AuthServiceImpl.LoginParams.PASSWORD_PARAM).isEmpty()); + assertFalse(errors.getErrors(AccountServiceImpl.LoginParams.PASSWORD_PARAM).isEmpty()); request = mockRequest("user", ""); - errors = authService.login(request); + errors = accountService.login(request); assertFalse(errors.isEmpty()); - assertFalse(errors.getErrors(AuthServiceImpl.LoginParams.PASSWORD_PARAM).isEmpty()); + assertFalse(errors.getErrors(AccountServiceImpl.LoginParams.PASSWORD_PARAM).isEmpty()); request = mockRequest(null, "password"); - errors = authService.login(request); + errors = accountService.login(request); assertFalse(errors.isEmpty()); - assertFalse(errors.getErrors(AuthServiceImpl.LoginParams.EMAIL_PARAM).isEmpty()); + assertFalse(errors.getErrors(AccountServiceImpl.LoginParams.EMAIL_PARAM).isEmpty()); request = mockRequest("", "password"); - errors = authService.login(request); + errors = accountService.login(request); assertFalse(errors.isEmpty()); - assertFalse(errors.getErrors(AuthServiceImpl.LoginParams.EMAIL_PARAM).isEmpty()); + assertFalse(errors.getErrors(AccountServiceImpl.LoginParams.EMAIL_PARAM).isEmpty()); } private AccountManager mockAccManager(String user, String password, boolean exists) { @@ -97,6 +100,11 @@ private AccountManager mockAccManager(String user, String password, boolean exis return accMan; } + private EmailSender mockEmailer() { + EmailSender emailer = createMock(EmailSender.class); + return emailer; + } + private HttpServletRequest mockRequest(String name, String password) { HttpSession session = createMock(HttpSession.class); session.setAttribute(isA(String.class), isA(Object.class)); @@ -104,11 +112,11 @@ private HttpServletRequest mockRequest(String name, String password) { HttpServletRequest request = createMock(HttpServletRequest.class); expect(request - .getParameterValues(AuthServiceImpl.LoginParams.EMAIL_PARAM)) + .getParameterValues(AccountServiceImpl.LoginParams.EMAIL_PARAM)) .andReturn(name == null ? null : new String[]{name}).anyTimes(); expect(request - .getParameterValues(AuthServiceImpl.LoginParams.PASSWORD_PARAM)) + .getParameterValues(AccountServiceImpl.LoginParams.PASSWORD_PARAM)) .andReturn(password == null ? null : new String[]{password}).anyTimes(); expect(request.getSession()).andReturn(session).anyTimes();
91b74931a3d858645cf106295090a11e803c3e83
elasticsearch
[TEST] Stabelize MoreLikeThisActionTests--The `testCompareMoreLikeThisDSLWithAPI` test compares results from query-and API which might query different shards. Those shares might use-different doc IDs internally to disambiguate. This commit resorts the-results and compares them after stable disambiguation.-
c
https://github.com/elastic/elasticsearch
diff --git a/src/test/java/org/elasticsearch/mlt/MoreLikeThisActionTests.java b/src/test/java/org/elasticsearch/mlt/MoreLikeThisActionTests.java index 19c577fd1d2ca..1ea485a3c437b 100644 --- a/src/test/java/org/elasticsearch/mlt/MoreLikeThisActionTests.java +++ b/src/test/java/org/elasticsearch/mlt/MoreLikeThisActionTests.java @@ -19,6 +19,7 @@ package org.elasticsearch.mlt; +import org.apache.lucene.util.ArrayUtil; import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus; import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder; import org.elasticsearch.action.index.IndexRequestBuilder; @@ -37,6 +38,7 @@ import org.junit.Test; import java.util.ArrayList; +import java.util.Comparator; import java.util.List; import static org.elasticsearch.client.Requests.*; @@ -407,17 +409,33 @@ public void testCompareMoreLikeThisDSLWithAPI() throws Exception { .setSearchType(SearchType.QUERY_THEN_FETCH) .setTypes("type1") .setQuery(queryBuilder) + .setSize(texts.length) .execute().actionGet(); assertSearchResponse(mltResponseDSL); logger.info("Running MoreLikeThis API"); - MoreLikeThisRequest mltRequest = moreLikeThisRequest("test").type("type1").id("0").minTermFreq(1).minDocFreq(1); + MoreLikeThisRequest mltRequest = moreLikeThisRequest("test").type("type1").searchSize(texts.length).id("0").minTermFreq(1).minDocFreq(1); SearchResponse mltResponseAPI = client.moreLikeThis(mltRequest).actionGet(); assertSearchResponse(mltResponseAPI); logger.info("Ensure the documents and scores returned are the same."); SearchHit[] hitsDSL = mltResponseDSL.getHits().hits(); SearchHit[] hitsAPI = mltResponseAPI.getHits().hits(); + + // we have to resort since the results might come from + // different shards and docIDs that are used for tie-breaking might not be the same on the shards + Comparator<SearchHit> cmp = new Comparator<SearchHit>() { + + @Override + public int compare(SearchHit o1, SearchHit o2) { + if (Float.compare(o1.getScore(), o2.getScore()) == 0) { + return o1.getId().compareTo(o2.getId()); + } + return Float.compare(o1.getScore(), o2.getScore()); + } + }; + ArrayUtil.timSort(hitsDSL, cmp); + ArrayUtil.timSort(hitsAPI, cmp); assertThat("Not the same number of results.", hitsAPI.length, equalTo(hitsDSL.length)); for (int i = 0; i < hitsDSL.length; i++) { assertThat("Expected id: " + hitsDSL[i].getId() + " at position " + i + " but wasn't.",
42fa86735cb89bdde76545946d154c045513c12b
Delta Spike
DELTASPIKE-277 fix JsfMessageProducer
c
https://github.com/apache/deltaspike
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/message/JsfMessageProducer.java b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/message/JsfMessageProducer.java index af4bd70e5..6dc58b8a7 100644 --- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/message/JsfMessageProducer.java +++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/message/JsfMessageProducer.java @@ -34,12 +34,12 @@ public class JsfMessageProducer { @Produces @Dependent - public JsfMessage<?> createJsfMessage(InjectionPoint injectionPoint) + public JsfMessage createJsfMessage(InjectionPoint injectionPoint) { return createJsfMessageFor(injectionPoint, ReflectionUtils.getRawType(injectionPoint.getType())); } - private JsfMessage<?> createJsfMessageFor(InjectionPoint injectionPoint, Class<Object> rawType) + private JsfMessage createJsfMessageFor(InjectionPoint injectionPoint, Class<Object> rawType) { //X TODO check if the JsfMessage should get injected into a UIComponent and use #getClientId()
7313d4beb806bc046636933119053bd0393d0d12
Vala
Add ScanfFormat to used attributes
a
https://github.com/GNOME/vala/
diff --git a/vala/valausedattr.vala b/vala/valausedattr.vala index 0fc5b45645..cdf895d5cc 100644 --- a/vala/valausedattr.vala +++ b/vala/valausedattr.vala @@ -57,6 +57,7 @@ public class Vala.UsedAttr : CodeVisitor { "BooleanType", "", "SimpleType", "", "PrintfFormat", "", + "ScanfFormat", "", "GIR", "name", ""
cf5fb324e3d006d4360c0ae1bba0b2f57d3b6097
restlet-framework-java
Updated Ranges test case.--
p
https://github.com/restlet/restlet-framework-java
diff --git a/modules/org.restlet.test/src/org/restlet/test/RangeTestCase.java b/modules/org.restlet.test/src/org/restlet/test/RangeTestCase.java index 81b1fa31fb..6846d24ed0 100644 --- a/modules/org.restlet.test/src/org/restlet/test/RangeTestCase.java +++ b/modules/org.restlet.test/src/org/restlet/test/RangeTestCase.java @@ -103,7 +103,7 @@ public void handle(Request request, Response response) { String[] tab = value.split("-"); if (tab.length == 2) { index = Long.parseLong(tab[0]); - length = index + Long.parseLong(tab[1]); + length = Long.parseLong(tab[1]) - index; } } @@ -182,7 +182,6 @@ public void testRanges() { assertEquals(Status.SUCCESS_OK, client.handle(request).getStatus()); // Test partial Get. -/* request = new Request(Method.GET, "http://localhost:8182/testGet"); Response response = client.handle(request); assertEquals(Status.SUCCESS_OK, response.getStatus()); @@ -199,12 +198,12 @@ public void testRanges() { assertEquals(Status.SUCCESS_OK, response.getStatus()); assertEquals("12", response.getEntity().getText()); - request.setRanges(Arrays.asList(new Range(3, 2))); + request.setRanges(Arrays.asList(new Range(2, 2))); response = client.handle(request); assertEquals(Status.SUCCESS_OK, response.getStatus()); assertEquals("34", response.getEntity().getText()); - request.setRanges(Arrays.asList(new Range(3, 7))); + request.setRanges(Arrays.asList(new Range(2, 7))); response = client.handle(request); assertEquals(Status.SUCCESS_OK, response.getStatus()); assertEquals("3456789", response.getEntity().getText()); @@ -213,7 +212,7 @@ public void testRanges() { response = client.handle(request); assertEquals(Status.SUCCESS_OK, response.getStatus()); assertEquals("4567890", response.getEntity().getText()); -*/ + component.stop(); } catch (Exception e) { e.printStackTrace();
3b4f5d617969bc4d6bda9f0da17a141cb32bd521
camel
CAMEL-939 - Fix csv test that fails on slower- machines sometimes.--git-svn-id: https://svn.apache.org/repos/asf/activemq/camel/trunk@700232 13f79535-47bb-0310-9956-ffa450edef68-
c
https://github.com/apache/camel
diff --git a/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvRouteTest.java b/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvRouteTest.java index 5c0c336a6720c..e4ea16d6cc753 100644 --- a/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvRouteTest.java +++ b/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvRouteTest.java @@ -70,7 +70,11 @@ public void testSendMessage() throws Exception { log.debug("Received " + text); assertNotNull("Should be able to convert received body to a string", text); - assertEquals("text body", "abc,123", text.trim()); + + // order is not guaranteed with a Map (which was passed in before) + // so we need to check for both combinations + assertTrue("Text body has wrong value.", "abc,123".equals(text.trim()) + || "123,abc".equals(text.trim())); } }
319b1c8ad41b769ff4bc5d8cb2d2eb9e3f5e9569
orientdb
Minor: fixed javadoc
c
https://github.com/orientechnologies/orientdb
diff --git a/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OSchemaShared.java b/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OSchemaShared.java index a917b02364d..4129b9cd427 100644 --- a/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OSchemaShared.java +++ b/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OSchemaShared.java @@ -451,7 +451,7 @@ public void changeClassName(String iOldName, String iNewName) { @Override public void fromStream() { // READ CURRENT SCHEMA VERSION - Integer schemaVersion = (Integer) document.field("schemaVersion"); + final Integer schemaVersion = (Integer) document.field("schemaVersion"); if (schemaVersion == null) { OLogManager .instance() diff --git a/core/src/main/java/com/orientechnologies/orient/core/processor/block/OExecuteBlock.java b/core/src/main/java/com/orientechnologies/orient/core/processor/block/OExecuteBlock.java index 32e5490f405..d362d20134b 100644 --- a/core/src/main/java/com/orientechnologies/orient/core/processor/block/OExecuteBlock.java +++ b/core/src/main/java/com/orientechnologies/orient/core/processor/block/OExecuteBlock.java @@ -112,10 +112,13 @@ private Object executeBlock(OComposableProcessor iManager, final OCommandContext merge = Boolean.FALSE; Object result; - if (isBlock(iValue)) + if (isBlock(iValue)) { // EXECUTE SINGLE BLOCK - result = delegate(iName, iManager, (ODocument) iValue, iContext, iOutput, iReadOnly); - else { + final ODocument value = (ODocument) iValue; + result = delegate(iName, iManager, value, iContext, iOutput, iReadOnly); + if (value.containsField("return")) + return returnValue; + } else { // EXECUTE ENTIRE PROCESS try { result = iManager.processFromFile(iName, iContext, iReadOnly); diff --git a/server/src/main/java/com/orientechnologies/orient/server/network/protocol/http/command/post/OServerCommandPostBatch.java b/server/src/main/java/com/orientechnologies/orient/server/network/protocol/http/command/post/OServerCommandPostBatch.java index dac2e488b04..8aa9509e2f0 100644 --- a/server/src/main/java/com/orientechnologies/orient/server/network/protocol/http/command/post/OServerCommandPostBatch.java +++ b/server/src/main/java/com/orientechnologies/orient/server/network/protocol/http/command/post/OServerCommandPostBatch.java @@ -26,9 +26,9 @@ import com.orientechnologies.orient.server.network.protocol.http.command.OServerCommandDocumentAbstract; /** - * Execute a batch of commands in one shot. This is useful to reduce network latency issuing multiple commands as multiple request. - * Batch command supports transactions.<br> - * Format: { "transaction" : <true|false>, "operations" : [ { "type" : "<type>" }* ] }<br> + * Executes a batch of operations in a single call. This is useful to reduce network latency issuing multiple commands as multiple + * requests. Batch command supports transactions as well.<br><br> + * Format: { "transaction" : &lt;true|false&gt;, "operations" : [ { "type" : "&lt;type&gt;" }* ] }<br> * Where: * <ul> * <li><b>type</b> can be:
a429e230b632c40cf3167cbac54ea87b6ad87297
spring-framework
revised version checks and exception signatures--
p
https://github.com/spring-projects/spring-framework
diff --git a/org.springframework.web.portlet/src/main/java/org/springframework/web/portlet/DispatcherPortlet.java b/org.springframework.web.portlet/src/main/java/org/springframework/web/portlet/DispatcherPortlet.java index d784450b6726..878053a0eb31 100644 --- a/org.springframework.web.portlet/src/main/java/org/springframework/web/portlet/DispatcherPortlet.java +++ b/org.springframework.web.portlet/src/main/java/org/springframework/web/portlet/DispatcherPortlet.java @@ -42,7 +42,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.beans.factory.BeanInitializationException; import org.springframework.beans.factory.NoSuchBeanDefinitionException; @@ -583,10 +582,9 @@ protected <T> List<T> getDefaultStrategies(ApplicationContext context, Class<T> * @param context the current Portlet ApplicationContext * @param clazz the strategy implementation class to instantiate * @return the fully configured strategy instance - * @throws BeansException if initialization failed * @see org.springframework.context.ApplicationContext#getAutowireCapableBeanFactory() */ - protected Object createDefaultStrategy(ApplicationContext context, Class<?> clazz) throws BeansException { + protected Object createDefaultStrategy(ApplicationContext context, Class<?> clazz) { return context.getAutowireCapableBeanFactory().createBean(clazz); } diff --git a/org.springframework.web.portlet/src/main/java/org/springframework/web/portlet/FrameworkPortlet.java b/org.springframework.web.portlet/src/main/java/org/springframework/web/portlet/FrameworkPortlet.java index 75cad59c52e2..3ddac18c10db 100644 --- a/org.springframework.web.portlet/src/main/java/org/springframework/web/portlet/FrameworkPortlet.java +++ b/org.springframework.web.portlet/src/main/java/org/springframework/web/portlet/FrameworkPortlet.java @@ -32,7 +32,6 @@ import javax.portlet.ResourceResponse; import org.springframework.beans.BeanUtils; -import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextException; import org.springframework.context.ApplicationListener; @@ -258,7 +257,7 @@ public void setUserinfoUsernameAttributes(String[] userinfoUsernameAttributes) { * have been set. Creates this portlet's ApplicationContext. */ @Override - protected final void initPortletBean() throws PortletException, BeansException { + protected final void initPortletBean() throws PortletException { getPortletContext().log("Initializing Spring FrameworkPortlet '" + getPortletName() + "'"); if (logger.isInfoEnabled()) { logger.info("FrameworkPortlet '" + getPortletName() + "': initialization started"); @@ -273,7 +272,7 @@ protected final void initPortletBean() throws PortletException, BeansException { logger.error("Context initialization failed", ex); throw ex; } - catch (BeansException ex) { + catch (RuntimeException ex) { logger.error("Context initialization failed", ex); throw ex; } @@ -289,9 +288,8 @@ protected final void initPortletBean() throws PortletException, BeansException { * <p>Delegates to {@link #createPortletApplicationContext} for actual creation. * Can be overridden in subclasses. * @return the ApplicationContext for this portlet - * @throws BeansException if the context couldn't be initialized */ - protected ApplicationContext initPortletApplicationContext() throws BeansException { + protected ApplicationContext initPortletApplicationContext() { ApplicationContext parent = PortletApplicationContextUtils.getWebApplicationContext(getPortletContext()); ApplicationContext pac = createPortletApplicationContext(parent); @@ -320,13 +318,10 @@ protected ApplicationContext initPortletApplicationContext() throws BeansExcepti * ConfigurablePortletApplicationContext. Can be overridden in subclasses. * @param parent the parent ApplicationContext to use, or null if none * @return the Portlet ApplicationContext for this portlet - * @throws BeansException if the context couldn't be initialized * @see #setContextClass * @see org.springframework.web.portlet.context.XmlPortletApplicationContext */ - protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) - throws BeansException { - + protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) { Class<?> contextClass = getContextClass(); if (logger.isDebugEnabled()) { logger.debug("Portlet with name '" + getPortletName() + @@ -338,7 +333,6 @@ protected ApplicationContext createPortletApplicationContext(ApplicationContext "': custom ApplicationContext class [" + contextClass.getName() + "] is not of type ConfigurablePortletApplicationContext"); } - ConfigurablePortletApplicationContext pac = (ConfigurablePortletApplicationContext) BeanUtils.instantiateClass(contextClass); @@ -400,19 +394,17 @@ public final ApplicationContext getPortletApplicationContext() { * <p>The default implementation is empty; subclasses may override this method * to perform any initialization they require. * @throws PortletException in case of an initialization exception - * @throws BeansException if thrown by ApplicationContext methods */ - protected void initFrameworkPortlet() throws PortletException, BeansException { + protected void initFrameworkPortlet() throws PortletException { } /** * Refresh this portlet's application context, as well as the * dependent state of the portlet. - * @throws BeansException in case of errors * @see #getPortletApplicationContext() * @see org.springframework.context.ConfigurableApplicationContext#refresh() */ - public void refresh() throws BeansException { + public void refresh() { ApplicationContext pac = getPortletApplicationContext(); if (!(pac instanceof ConfigurableApplicationContext)) { throw new IllegalStateException("Portlet ApplicationContext does not support refresh: " + pac); @@ -438,10 +430,9 @@ public void onApplicationEvent(ContextRefreshedEvent event) { * Called after successful context refresh. * <p>This implementation is empty. * @param context the current Portlet ApplicationContext - * @throws BeansException in case of errors * @see #refresh() */ - protected void onRefresh(ApplicationContext context) throws BeansException { + protected void onRefresh(ApplicationContext context) { // For subclasses: do nothing by default. } diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/DispatcherServlet.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/DispatcherServlet.java index d94b9907f841..e870cd5525f3 100644 --- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/DispatcherServlet.java +++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/DispatcherServlet.java @@ -35,7 +35,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.beans.factory.BeanInitializationException; import org.springframework.beans.factory.NoSuchBeanDefinitionException; @@ -322,7 +321,7 @@ public void setCleanupAfterInclude(boolean cleanupAfterInclude) { * This implementation calls {@link #initStrategies}. */ @Override - protected void onRefresh(ApplicationContext context) throws BeansException { + protected void onRefresh(ApplicationContext context) { initStrategies(context); } @@ -673,11 +672,10 @@ protected <T> List<T> getDefaultStrategies(ApplicationContext context, Class<T> * @param context the current WebApplicationContext * @param clazz the strategy implementation class to instantiate * @return the fully configured strategy instance - * @throws BeansException if initialization failed * @see org.springframework.context.ApplicationContext#getAutowireCapableBeanFactory() * @see org.springframework.beans.factory.config.AutowireCapableBeanFactory#createBean */ - protected Object createDefaultStrategy(ApplicationContext context, Class clazz) throws BeansException { + protected Object createDefaultStrategy(ApplicationContext context, Class<?> clazz) { return context.getAutowireCapableBeanFactory().createBean(clazz); } @@ -742,7 +740,7 @@ protected void doDispatch(HttpServletRequest request, HttpServletResponse respon int interceptorIndex = -1; try { - ModelAndView mv = null; + ModelAndView mv; boolean errorView = false; try { @@ -1032,13 +1030,11 @@ protected ModelAndView processHandlerException(HttpServletRequest request, * @throws Exception if there's a problem rendering the view */ protected void render(ModelAndView mv, HttpServletRequest request, HttpServletResponse response) throws Exception { - // Determine locale for request and apply it to the response. Locale locale = this.localeResolver.resolveLocale(request); response.setLocale(locale); - View view = null; - + View view; if (mv.isReference()) { // We need to resolve the view name. view = resolveViewName(mv.getViewName(), mv.getModelInternal(), locale, request); @@ -1076,7 +1072,7 @@ protected String getDefaultViewName(HttpServletRequest request) throws Exception /** * Resolve the given view name into a View object (to be rendered). - * <p>Default implementations asks all ViewResolvers of this dispatcher. + * <p>The default implementations asks all ViewResolvers of this dispatcher. * Can be overridden for custom resolution strategies, potentially based on * specific model attributes or request parameters. * @param viewName the name of the view to resolve @@ -1088,9 +1084,7 @@ protected String getDefaultViewName(HttpServletRequest request) throws Exception * (typically in case of problems creating an actual View object) * @see ViewResolver#resolveViewName */ - protected View resolveViewName(String viewName, - Map<String, Object> model, - Locale locale, + protected View resolveViewName(String viewName, Map<String, Object> model, Locale locale, HttpServletRequest request) throws Exception { for (ViewResolver viewResolver : this.viewResolvers) { diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/FrameworkServlet.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/FrameworkServlet.java index 820cd0d702c8..f4fefa855519 100644 --- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/FrameworkServlet.java +++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/FrameworkServlet.java @@ -24,7 +24,6 @@ import javax.servlet.http.HttpServletResponse; import org.springframework.beans.BeanUtils; -import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextException; import org.springframework.context.ApplicationListener; @@ -297,7 +296,7 @@ public void setDispatchTraceRequest(boolean dispatchTraceRequest) { * have been set. Creates this servlet's WebApplicationContext. */ @Override - protected final void initServletBean() throws ServletException, BeansException { + protected final void initServletBean() throws ServletException { getServletContext().log("Initializing Spring FrameworkServlet '" + getServletName() + "'"); if (this.logger.isInfoEnabled()) { this.logger.info("FrameworkServlet '" + getServletName() + "': initialization started"); @@ -312,7 +311,7 @@ protected final void initServletBean() throws ServletException, BeansException { this.logger.error("Context initialization failed", ex); throw ex; } - catch (BeansException ex) { + catch (RuntimeException ex) { this.logger.error("Context initialization failed", ex); throw ex; } @@ -329,11 +328,10 @@ protected final void initServletBean() throws ServletException, BeansException { * <p>Delegates to {@link #createWebApplicationContext} for actual creation * of the context. Can be overridden in subclasses. * @return the WebApplicationContext instance - * @throws BeansException if the context couldn't be initialized * @see #setContextClass * @see #setContextConfigLocation */ - protected WebApplicationContext initWebApplicationContext() throws BeansException { + protected WebApplicationContext initWebApplicationContext() { WebApplicationContext wac = findWebApplicationContext(); if (wac == null) { // No fixed context defined for this servlet - create a local one. @@ -397,12 +395,9 @@ protected WebApplicationContext findWebApplicationContext() { * before returning the context instance. * @param parent the parent ApplicationContext to use, or <code>null</code> if none * @return the WebApplicationContext for this servlet - * @throws BeansException if the context couldn't be initialized * @see org.springframework.web.context.support.XmlWebApplicationContext */ - protected WebApplicationContext createWebApplicationContext(WebApplicationContext parent) - throws BeansException { - + protected WebApplicationContext createWebApplicationContext(WebApplicationContext parent) { Class<?> contextClass = getContextClass(); if (this.logger.isDebugEnabled()) { this.logger.debug("Servlet with name '" + getServletName() + @@ -415,26 +410,27 @@ protected WebApplicationContext createWebApplicationContext(WebApplicationContex "': custom WebApplicationContext class [" + contextClass.getName() + "] is not of type ConfigurableWebApplicationContext"); } - ConfigurableWebApplicationContext wac = (ConfigurableWebApplicationContext) BeanUtils.instantiateClass(contextClass); // Assign the best possible id value. - ServletContext servletContext = getServletContext(); - if (servletContext.getMajorVersion() > 2 || servletContext.getMinorVersion() >= 5) { - // Servlet 2.5's getContextPath available! - wac.setId(ConfigurableWebApplicationContext.APPLICATION_CONTEXT_ID_PREFIX + servletContext.getContextPath() + "/" + getServletName()); - } - else { + ServletContext sc = getServletContext(); + if (sc.getMajorVersion() == 2 && sc.getMinorVersion() < 5) { // Servlet <= 2.4: resort to name specified in web.xml, if any. - String servletContextName = servletContext.getServletContextName(); + String servletContextName = sc.getServletContextName(); if (servletContextName != null) { - wac.setId(ConfigurableWebApplicationContext.APPLICATION_CONTEXT_ID_PREFIX + servletContextName + "." + getServletName()); + wac.setId(ConfigurableWebApplicationContext.APPLICATION_CONTEXT_ID_PREFIX + servletContextName + + "." + getServletName()); } else { wac.setId(ConfigurableWebApplicationContext.APPLICATION_CONTEXT_ID_PREFIX + getServletName()); } } + else { + // Servlet 2.5's getContextPath available! + wac.setId(ConfigurableWebApplicationContext.APPLICATION_CONTEXT_ID_PREFIX + sc.getContextPath() + + "/" + getServletName()); + } wac.setParent(parent); wac.setServletContext(getServletContext()); @@ -485,19 +481,17 @@ public final WebApplicationContext getWebApplicationContext() { * the WebApplicationContext has been loaded. The default implementation is empty; * subclasses may override this method to perform any initialization they require. * @throws ServletException in case of an initialization exception - * @throws BeansException if thrown by ApplicationContext methods */ - protected void initFrameworkServlet() throws ServletException, BeansException { + protected void initFrameworkServlet() throws ServletException { } /** * Refresh this servlet's application context, as well as the * dependent state of the servlet. - * @throws BeansException in case of errors * @see #getWebApplicationContext() * @see org.springframework.context.ConfigurableApplicationContext#refresh() */ - public void refresh() throws BeansException { + public void refresh() { WebApplicationContext wac = getWebApplicationContext(); if (!(wac instanceof ConfigurableApplicationContext)) { throw new IllegalStateException("WebApplicationContext does not support refresh: " + wac); @@ -523,10 +517,9 @@ public void onApplicationEvent(ContextRefreshedEvent event) { * Called after successful context refresh. * <p>This implementation is empty. * @param context the current WebApplicationContext - * @throws BeansException in case of errors * @see #refresh() */ - protected void onRefresh(ApplicationContext context) throws BeansException { + protected void onRefresh(ApplicationContext context) { // For subclasses: do nothing by default. } @@ -540,7 +533,7 @@ protected void onRefresh(ApplicationContext context) throws BeansException { */ @Override protected final void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { + throws ServletException, IOException { processRequest(request, response); } @@ -551,7 +544,7 @@ protected final void doGet(HttpServletRequest request, HttpServletResponse respo */ @Override protected final void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { + throws ServletException, IOException { processRequest(request, response); } @@ -562,7 +555,7 @@ protected final void doPost(HttpServletRequest request, HttpServletResponse resp */ @Override protected final void doPut(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { + throws ServletException, IOException { processRequest(request, response); } @@ -573,7 +566,7 @@ protected final void doPut(HttpServletRequest request, HttpServletResponse respo */ @Override protected final void doDelete(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { + throws ServletException, IOException { processRequest(request, response); } @@ -584,7 +577,9 @@ protected final void doDelete(HttpServletRequest request, HttpServletResponse re * @see #doService */ @Override - protected void doOptions(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + protected void doOptions(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + super.doOptions(request, response); if (this.dispatchOptionsRequest) { processRequest(request, response); @@ -597,7 +592,9 @@ protected void doOptions(HttpServletRequest request, HttpServletResponse respons * @see #doService */ @Override - protected void doTrace(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + protected void doTrace(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + super.doTrace(request, response); if (this.dispatchTraceRequest) { processRequest(request, response); @@ -715,7 +712,7 @@ protected String getUsernameForRequest(HttpServletRequest request) { * @see javax.servlet.http.HttpServlet#doPost */ protected abstract void doService(HttpServletRequest request, HttpServletResponse response) - throws Exception; + throws Exception; /** diff --git a/org.springframework.web/src/main/java/org/springframework/web/context/ContextLoader.java b/org.springframework.web/src/main/java/org/springframework/web/context/ContextLoader.java index d1336917cc2b..22345a31f0a1 100644 --- a/org.springframework.web/src/main/java/org/springframework/web/context/ContextLoader.java +++ b/org.springframework.web/src/main/java/org/springframework/web/context/ContextLoader.java @@ -26,7 +26,6 @@ import org.apache.commons.logging.LogFactory; import org.springframework.beans.BeanUtils; -import org.springframework.beans.BeansException; import org.springframework.beans.factory.access.BeanFactoryLocator; import org.springframework.beans.factory.access.BeanFactoryReference; import org.springframework.context.ApplicationContext; @@ -167,14 +166,10 @@ public class ContextLoader { * "{@link #CONFIG_LOCATION_PARAM contextConfigLocation}" context-params. * @param servletContext current servlet context * @return the new WebApplicationContext - * @throws IllegalStateException if there is already a root application context present - * @throws BeansException if the context failed to initialize * @see #CONTEXT_CLASS_PARAM * @see #CONFIG_LOCATION_PARAM */ - public WebApplicationContext initWebApplicationContext(ServletContext servletContext) - throws IllegalStateException, BeansException { - + public WebApplicationContext initWebApplicationContext(ServletContext servletContext) { if (servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE) != null) { throw new IllegalStateException( "Cannot initialize context because there is already a root application context present - " + @@ -229,32 +224,24 @@ public WebApplicationContext initWebApplicationContext(ServletContext servletCon * Can be overridden in subclasses. * <p>In addition, {@link #customizeContext} gets called prior to refreshing the * context, allowing subclasses to perform custom modifications to the context. - * @param servletContext current servlet context + * @param sc current servlet context * @param parent the parent ApplicationContext to use, or <code>null</code> if none * @return the root WebApplicationContext - * @throws BeansException if the context couldn't be initialized * @see ConfigurableWebApplicationContext */ - protected WebApplicationContext createWebApplicationContext( - ServletContext servletContext, ApplicationContext parent) throws BeansException { - - Class<?> contextClass = determineContextClass(servletContext); + protected WebApplicationContext createWebApplicationContext(ServletContext sc, ApplicationContext parent) { + Class<?> contextClass = determineContextClass(sc); if (!ConfigurableWebApplicationContext.class.isAssignableFrom(contextClass)) { throw new ApplicationContextException("Custom context class [" + contextClass.getName() + "] is not of type [" + ConfigurableWebApplicationContext.class.getName() + "]"); } - ConfigurableWebApplicationContext wac = (ConfigurableWebApplicationContext) BeanUtils.instantiateClass(contextClass); // Assign the best possible id value. - if (servletContext.getMajorVersion() > 2 || servletContext.getMinorVersion() >= 5) { - // Servlet 2.5's getContextPath available! - wac.setId(ConfigurableWebApplicationContext.APPLICATION_CONTEXT_ID_PREFIX + servletContext.getContextPath()); - } - else { + if (sc.getMajorVersion() == 2 && sc.getMinorVersion() < 5) { // Servlet <= 2.4: resort to name specified in web.xml, if any. - String servletContextName = servletContext.getServletContextName(); + String servletContextName = sc.getServletContextName(); if (servletContextName != null) { wac.setId(ConfigurableWebApplicationContext.APPLICATION_CONTEXT_ID_PREFIX + servletContextName); } @@ -262,13 +249,16 @@ protected WebApplicationContext createWebApplicationContext( wac.setId(ConfigurableWebApplicationContext.APPLICATION_CONTEXT_ID_PREFIX); } } + else { + // Servlet 2.5's getContextPath available! + wac.setId(ConfigurableWebApplicationContext.APPLICATION_CONTEXT_ID_PREFIX + sc.getContextPath()); + } wac.setParent(parent); - wac.setServletContext(servletContext); - wac.setConfigLocation(servletContext.getInitParameter(CONFIG_LOCATION_PARAM)); - customizeContext(servletContext, wac); + wac.setServletContext(sc); + wac.setConfigLocation(sc.getInitParameter(CONFIG_LOCATION_PARAM)); + customizeContext(sc, wac); wac.refresh(); - return wac; } @@ -277,11 +267,10 @@ protected WebApplicationContext createWebApplicationContext( * default XmlWebApplicationContext or a custom context class if specified. * @param servletContext current servlet context * @return the WebApplicationContext implementation class to use - * @throws ApplicationContextException if the context class couldn't be loaded * @see #CONTEXT_CLASS_PARAM * @see org.springframework.web.context.support.XmlWebApplicationContext */ - protected Class determineContextClass(ServletContext servletContext) throws ApplicationContextException { + protected Class<?> determineContextClass(ServletContext servletContext) { String contextClassName = servletContext.getInitParameter(CONTEXT_CLASS_PARAM); if (contextClassName != null) { try { @@ -336,12 +325,9 @@ protected void customizeContext( * which also use the same configuration parameters. * @param servletContext current servlet context * @return the parent application context, or <code>null</code> if none - * @throws BeansException if the context couldn't be initialized * @see org.springframework.context.access.ContextSingletonBeanFactoryLocator */ - protected ApplicationContext loadParentContext(ServletContext servletContext) - throws BeansException { - + protected ApplicationContext loadParentContext(ServletContext servletContext) { ApplicationContext parentContext = null; String locatorFactorySelector = servletContext.getInitParameter(LOCATOR_FACTORY_SELECTOR_PARAM); String parentContextKey = servletContext.getInitParameter(LOCATOR_FACTORY_KEY_PARAM);
4a29e164a8ca222fd8b0d2043e1d44494e84544e
spring-framework
Allow binary messages in StompSubProtocolHandler--Issue: SPR-12301-
a
https://github.com/spring-projects/spring-framework
diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/StompSubProtocolHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/messaging/StompSubProtocolHandler.java index e50637e0f013..d90328715398 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/StompSubProtocolHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/messaging/StompSubProtocolHandler.java @@ -49,6 +49,7 @@ import org.springframework.messaging.support.MessageHeaderAccessor; import org.springframework.messaging.support.MessageHeaderInitializer; import org.springframework.util.Assert; +import org.springframework.web.socket.BinaryMessage; import org.springframework.web.socket.CloseStatus; import org.springframework.web.socket.TextMessage; import org.springframework.web.socket.WebSocketMessage; @@ -186,9 +187,16 @@ public void handleMessageFromClient(WebSocketSession session, List<Message<byte[]>> messages; try { - Assert.isInstanceOf(TextMessage.class, webSocketMessage); - TextMessage textMessage = (TextMessage) webSocketMessage; - ByteBuffer byteBuffer = ByteBuffer.wrap(textMessage.asBytes()); + ByteBuffer byteBuffer; + if (webSocketMessage instanceof TextMessage) { + byteBuffer = ByteBuffer.wrap(((TextMessage) webSocketMessage).asBytes()); + } + else if (webSocketMessage instanceof BinaryMessage) { + byteBuffer = ((BinaryMessage) webSocketMessage).getPayload(); + } + else { + throw new IllegalArgumentException("Unexpected WebSocket message type: " + webSocketMessage); + } BufferingStompDecoder decoder = this.decoders.get(session.getId()); if (decoder == null) {
77f3ff5cfc41f43bc51c3ce4505ff1a1aa80e2f1
Search_api
Issue #1064520 by drunken monkey: Added a processor for highlighting.
a
https://github.com/lucidworks/drupal_search_api
diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 6e8d250b..2875d5b5 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,6 @@ Search API 1.x, dev (xx/xx/xxxx): --------------------------------- +- #1064520 by drunken monkey: Added a processor for highlighting. Search API 1.7 (07/01/2013): ---------------------------- diff --git a/search_api.info b/search_api.info index bcb88cd3..c03de9d0 100644 --- a/search_api.info +++ b/search_api.info @@ -21,6 +21,7 @@ files[] = includes/datasource_external.inc files[] = includes/exception.inc files[] = includes/index_entity.inc files[] = includes/processor.inc +files[] = includes/processor_highlight.inc files[] = includes/processor_html_filter.inc files[] = includes/processor_ignore_case.inc files[] = includes/processor_stopwords.inc diff --git a/search_api.module b/search_api.module index 52093680..9b8593bb 100644 --- a/search_api.module +++ b/search_api.module @@ -890,7 +890,7 @@ function search_api_search_api_alter_callback_info() { function search_api_search_api_processor_info() { $processors['search_api_case_ignore'] = array( 'name' => t('Ignore case'), - 'description' => t('This processor will make searches case-insensitive for all fulltext fields (and, optionally, also for filters on string fields).'), + 'description' => t('This processor will make searches case-insensitive for fulltext or string fields.'), 'class' => 'SearchApiIgnoreCase', ); $processors['search_api_html_filter'] = array( @@ -924,6 +924,12 @@ function search_api_search_api_processor_info() { 'class' => 'SearchApiStopWords', 'weight' => 30, ); + $processors['search_api_highlighting'] = array( + 'name' => t('Highlighting'), + 'description' => t('Adds highlighting for search results.'), + 'class' => 'SearchApiHighlight', + 'weight' => 35, + ); return $processors; }
8ebbd1e7b964b6c81a49c7d4c2476584c6279e06
elasticsearch
Recovery Settings: Change settings (still support- old settings) and allow for more dynamic settings
p
https://github.com/elastic/elasticsearch
diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/status/TransportIndicesStatusAction.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/status/TransportIndicesStatusAction.java index d37670caf1332..0dad125120bcf 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/status/TransportIndicesStatusAction.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/status/TransportIndicesStatusAction.java @@ -39,10 +39,10 @@ import org.elasticsearch.index.gateway.SnapshotStatus; import org.elasticsearch.index.service.InternalIndexService; import org.elasticsearch.index.shard.IndexShardState; -import org.elasticsearch.index.shard.recovery.RecoveryStatus; -import org.elasticsearch.index.shard.recovery.RecoveryTarget; import org.elasticsearch.index.shard.service.InternalIndexShard; import org.elasticsearch.indices.IndicesService; +import org.elasticsearch.indices.recovery.RecoveryStatus; +import org.elasticsearch.indices.recovery.RecoveryTarget; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/common/RateLimiter.java b/modules/elasticsearch/src/main/java/org/elasticsearch/common/RateLimiter.java new file mode 100644 index 0000000000000..64b2d31421d93 --- /dev/null +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/common/RateLimiter.java @@ -0,0 +1,82 @@ +/* + * Licensed to Elastic Search and Shay Banon under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. Elastic Search licenses this + * file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.common; + +import org.elasticsearch.ElasticSearchInterruptedException; + +/** + */ +// LUCENE MONITOR: Taken from trunk of Lucene at 06-09-11 +public class RateLimiter { + + private volatile double nsPerByte; + private volatile long lastNS; + + // TODO: we could also allow eg a sub class to dynamically + // determine the allowed rate, eg if an app wants to + // change the allowed rate over time or something + + /** + * mbPerSec is the MB/sec max IO rate + */ + public RateLimiter(double mbPerSec) { + setMaxRate(mbPerSec); + } + + public void setMaxRate(double mbPerSec) { + nsPerByte = 1000000000. / (1024 * 1024 * mbPerSec); + } + + /** + * Pauses, if necessary, to keep the instantaneous IO + * rate at or below the target. NOTE: multiple threads + * may safely use this, however the implementation is + * not perfectly thread safe but likely in practice this + * is harmless (just means in some rare cases the rate + * might exceed the target). It's best to call this + * with a biggish count, not one byte at a time. + */ + public void pause(long bytes) { + + // TODO: this is purely instantenous rate; maybe we + // should also offer decayed recent history one? + final long targetNS = lastNS = lastNS + ((long) (bytes * nsPerByte)); + long curNS = System.nanoTime(); + if (lastNS < curNS) { + lastNS = curNS; + } + + // While loop because Thread.sleep doesn't alway sleep + // enough: + while (true) { + final long pauseNS = targetNS - curNS; + if (pauseNS > 0) { + try { + Thread.sleep((int) (pauseNS / 1000000), (int) (pauseNS % 1000000)); + } catch (InterruptedException ie) { + throw new ElasticSearchInterruptedException("interrupted while rate limiting", ie); + } + curNS = System.nanoTime(); + continue; + } + break; + } + } +} diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/service/InternalIndexShard.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/service/InternalIndexShard.java index d0e5de295372f..0ead6d7276ac4 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/service/InternalIndexShard.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/service/InternalIndexShard.java @@ -65,12 +65,12 @@ import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.index.settings.IndexSettingsService; import org.elasticsearch.index.shard.*; -import org.elasticsearch.index.shard.recovery.RecoveryStatus; import org.elasticsearch.index.store.Store; import org.elasticsearch.index.store.StoreStats; import org.elasticsearch.index.translog.Translog; import org.elasticsearch.indices.IndicesLifecycle; import org.elasticsearch.indices.InternalIndicesLifecycle; +import org.elasticsearch.indices.recovery.RecoveryStatus; import org.elasticsearch.threadpool.ThreadPool; import java.io.IOException; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/indices/IndicesModule.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/IndicesModule.java index 567001710b237..8f55b4395dc69 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/indices/IndicesModule.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/IndicesModule.java @@ -24,13 +24,14 @@ import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.inject.SpawnModules; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.index.shard.recovery.RecoverySource; -import org.elasticsearch.index.shard.recovery.RecoveryTarget; import org.elasticsearch.indices.analysis.IndicesAnalysisModule; import org.elasticsearch.indices.cache.filter.IndicesNodeFilterCache; import org.elasticsearch.indices.cluster.IndicesClusterStateService; import org.elasticsearch.indices.memory.IndexingMemoryBufferController; import org.elasticsearch.indices.query.IndicesQueriesModule; +import org.elasticsearch.indices.recovery.RecoverySettings; +import org.elasticsearch.indices.recovery.RecoverySource; +import org.elasticsearch.indices.recovery.RecoveryTarget; import org.elasticsearch.indices.store.TransportNodesListShardStoreMetaData; /** @@ -53,6 +54,7 @@ public IndicesModule(Settings settings) { bind(IndicesService.class).to(InternalIndicesService.class).asEagerSingleton(); + bind(RecoverySettings.class).asEagerSingleton(); bind(RecoveryTarget.class).asEagerSingleton(); bind(RecoverySource.class).asEagerSingleton(); diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/indices/InternalIndicesService.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/InternalIndicesService.java index a98f130f0c31e..1ac25b53553e5 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/indices/InternalIndicesService.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/InternalIndicesService.java @@ -75,6 +75,7 @@ import org.elasticsearch.index.store.IndexStoreModule; import org.elasticsearch.index.store.StoreStats; import org.elasticsearch.indices.analysis.IndicesAnalysisService; +import org.elasticsearch.indices.recovery.RecoverySettings; import org.elasticsearch.indices.store.IndicesStore; import org.elasticsearch.plugins.IndexPluginsModule; import org.elasticsearch.plugins.PluginsService; @@ -168,6 +169,7 @@ public class InternalIndicesService extends AbstractLifecycleComponent<IndicesSe } @Override protected void doClose() throws ElasticSearchException { + injector.getInstance(RecoverySettings.class).close(); indicesStore.close(); indicesAnalysisService.close(); } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java index 967d0420adb54..0d350ad23c565 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java @@ -61,13 +61,12 @@ import org.elasticsearch.index.settings.IndexSettingsService; import org.elasticsearch.index.shard.IndexShardState; import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.shard.recovery.RecoveryFailedException; -import org.elasticsearch.index.shard.recovery.RecoverySource; -import org.elasticsearch.index.shard.recovery.RecoveryTarget; -import org.elasticsearch.index.shard.recovery.StartRecoveryRequest; import org.elasticsearch.index.shard.service.IndexShard; import org.elasticsearch.index.shard.service.InternalIndexShard; import org.elasticsearch.indices.IndicesService; +import org.elasticsearch.indices.recovery.RecoveryFailedException; +import org.elasticsearch.indices.recovery.RecoveryTarget; +import org.elasticsearch.indices.recovery.StartRecoveryRequest; import org.elasticsearch.threadpool.ThreadPool; import java.util.List; @@ -88,8 +87,6 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent<Indic private final ThreadPool threadPool; - private final RecoverySource recoverySource; - private final RecoveryTarget recoveryTarget; private final ShardStateAction shardStateAction; @@ -113,7 +110,7 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent<Indic private final FailedEngineHandler failedEngineHandler = new FailedEngineHandler(); @Inject public IndicesClusterStateService(Settings settings, IndicesService indicesService, ClusterService clusterService, - ThreadPool threadPool, RecoveryTarget recoveryTarget, RecoverySource recoverySource, + ThreadPool threadPool, RecoveryTarget recoveryTarget, ShardStateAction shardStateAction, NodeIndexCreatedAction nodeIndexCreatedAction, NodeIndexDeletedAction nodeIndexDeletedAction, NodeMappingCreatedAction nodeMappingCreatedAction, NodeMappingRefreshAction nodeMappingRefreshAction, @@ -122,7 +119,6 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent<Indic this.indicesService = indicesService; this.clusterService = clusterService; this.threadPool = threadPool; - this.recoverySource = recoverySource; this.recoveryTarget = recoveryTarget; this.shardStateAction = shardStateAction; this.nodeIndexCreatedAction = nodeIndexCreatedAction; @@ -141,7 +137,6 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent<Indic } @Override protected void doClose() throws ElasticSearchException { - recoverySource.close(); } @Override public void clusterChanged(final ClusterChangedEvent event) { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/IgnoreRecoveryException.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/IgnoreRecoveryException.java similarity index 96% rename from modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/IgnoreRecoveryException.java rename to modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/IgnoreRecoveryException.java index e1185189127f9..08c28d2f1b7da 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/IgnoreRecoveryException.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/IgnoreRecoveryException.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.shard.recovery; +package org.elasticsearch.indices.recovery; import org.elasticsearch.ElasticSearchException; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoverFilesRecoveryException.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoverFilesRecoveryException.java similarity index 97% rename from modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoverFilesRecoveryException.java rename to modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoverFilesRecoveryException.java index e085befed244b..3e12af62b91d1 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoverFilesRecoveryException.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoverFilesRecoveryException.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.shard.recovery; +package org.elasticsearch.indices.recovery; import org.elasticsearch.ElasticSearchWrapperException; import org.elasticsearch.common.unit.ByteSizeValue; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryCleanFilesRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryCleanFilesRequest.java similarity index 97% rename from modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryCleanFilesRequest.java rename to modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryCleanFilesRequest.java index 185381279a1cd..b42df9a941a62 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryCleanFilesRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryCleanFilesRequest.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.shard.recovery; +package org.elasticsearch.indices.recovery; import org.elasticsearch.common.collect.Sets; import org.elasticsearch.common.io.stream.StreamInput; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryFailedException.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryFailedException.java similarity index 96% rename from modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryFailedException.java rename to modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryFailedException.java index f823046b5189e..08ed81b70d143 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryFailedException.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryFailedException.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.shard.recovery; +package org.elasticsearch.indices.recovery; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.cluster.node.DiscoveryNode; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryFileChunkRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryFileChunkRequest.java similarity index 98% rename from modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryFileChunkRequest.java rename to modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryFileChunkRequest.java index 4a04ffc79304b..24f2292fd7d54 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryFileChunkRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryFileChunkRequest.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.shard.recovery; +package org.elasticsearch.indices.recovery; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.io.stream.StreamInput; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryFilesInfoRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryFilesInfoRequest.java similarity index 98% rename from modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryFilesInfoRequest.java rename to modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryFilesInfoRequest.java index ff899e04c9c73..7683172e51eaa 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryFilesInfoRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryFilesInfoRequest.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.shard.recovery; +package org.elasticsearch.indices.recovery; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryFinalizeRecoveryRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryFinalizeRecoveryRequest.java similarity index 97% rename from modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryFinalizeRecoveryRequest.java rename to modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryFinalizeRecoveryRequest.java index 67ec3c2117987..029403e8dfba8 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryFinalizeRecoveryRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryFinalizeRecoveryRequest.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.shard.recovery; +package org.elasticsearch.indices.recovery; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryPrepareForTranslogOperationsRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryPrepareForTranslogOperationsRequest.java similarity index 97% rename from modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryPrepareForTranslogOperationsRequest.java rename to modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryPrepareForTranslogOperationsRequest.java index c784ee2bc259d..65bc7113438e8 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryPrepareForTranslogOperationsRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryPrepareForTranslogOperationsRequest.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.shard.recovery; +package org.elasticsearch.indices.recovery; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryResponse.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryResponse.java similarity index 98% rename from modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryResponse.java rename to modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryResponse.java index cfecc67527615..738b5052a99db 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryResponse.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryResponse.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.shard.recovery; +package org.elasticsearch.indices.recovery; import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.io.stream.StreamInput; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoverySettings.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoverySettings.java new file mode 100644 index 0000000000000..121f7a894b0de --- /dev/null +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoverySettings.java @@ -0,0 +1,135 @@ +/* + * Licensed to Elastic Search and Shay Banon under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. Elastic Search licenses this + * file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.indices.recovery; + +import org.elasticsearch.cluster.metadata.MetaData; +import org.elasticsearch.common.component.AbstractComponent; +import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.unit.ByteSizeUnit; +import org.elasticsearch.common.unit.ByteSizeValue; +import org.elasticsearch.common.unit.TimeValue; +import org.elasticsearch.common.util.concurrent.DynamicExecutors; +import org.elasticsearch.common.util.concurrent.EsExecutors; +import org.elasticsearch.node.settings.NodeSettingsService; + +import java.util.concurrent.ThreadPoolExecutor; + +/** + */ +public class RecoverySettings extends AbstractComponent { + + static { + MetaData.addDynamicSettings("indices.recovery.file_chunk_size"); + MetaData.addDynamicSettings("indices.recovery.translog_ops"); + MetaData.addDynamicSettings("indices.recovery.translog_size"); + MetaData.addDynamicSettings("indices.recovery.compress"); + MetaData.addDynamicSettings("`"); + } + + private volatile ByteSizeValue fileChunkSize; + + private volatile boolean compress; + private volatile int translogOps; + private volatile ByteSizeValue translogSize; + + private volatile int concurrentStreams; + private final ThreadPoolExecutor concurrentStreamPool; + + @Inject public RecoverySettings(Settings settings, NodeSettingsService nodeSettingsService) { + super(settings); + + this.fileChunkSize = componentSettings.getAsBytesSize("file_chunk_size", settings.getAsBytesSize("index.shard.recovery.file_chunk_size", new ByteSizeValue(100, ByteSizeUnit.KB))); + this.translogOps = componentSettings.getAsInt("translog_ops", settings.getAsInt("index.shard.recovery.translog_ops", 1000)); + this.translogSize = componentSettings.getAsBytesSize("translog_size", settings.getAsBytesSize("index.shard.recovery.translog_size", new ByteSizeValue(100, ByteSizeUnit.KB))); + this.compress = componentSettings.getAsBoolean("compress", true); + + this.concurrentStreams = componentSettings.getAsInt("concurrent_streams", settings.getAsInt("index.shard.recovery.concurrent_streams", 5)); + this.concurrentStreamPool = (ThreadPoolExecutor) DynamicExecutors.newScalingThreadPool(1, concurrentStreams, TimeValue.timeValueSeconds(5).millis(), EsExecutors.daemonThreadFactory(settings, "[recovery_stream]")); + + logger.debug("using concurrent_streams [{}], file_chunk_size [{}], translog_size [{}], translog_ops [{}], and compress [{}]", + concurrentStreams, fileChunkSize, translogSize, translogOps, compress); + + nodeSettingsService.addListener(new ApplySettings()); + } + + public void close() { + concurrentStreamPool.shutdown(); + } + + public ByteSizeValue fileChunkSize() { + return fileChunkSize; + } + + public boolean compress() { + return compress; + } + + public int translogOps() { + return translogOps; + } + + public ByteSizeValue translogSize() { + return translogSize; + } + + public int concurrentStreams() { + return concurrentStreams; + } + + public ThreadPoolExecutor concurrentStreamPool() { + return concurrentStreamPool; + } + + class ApplySettings implements NodeSettingsService.Listener { + @Override public void onRefreshSettings(Settings settings) { + ByteSizeValue fileChunkSize = settings.getAsBytesSize("indices.recovery.file_chunk_size", RecoverySettings.this.fileChunkSize); + if (!fileChunkSize.equals(RecoverySettings.this.fileChunkSize)) { + logger.info("updating [indices.recovery.file_chunk_size] from [{}] to [{}]", RecoverySettings.this.fileChunkSize, fileChunkSize); + RecoverySettings.this.fileChunkSize = fileChunkSize; + } + + int translogOps = settings.getAsInt("indices.recovery.translog_ops", RecoverySettings.this.translogOps); + if (translogOps != RecoverySettings.this.translogOps) { + logger.info("updating [indices.recovery.translog_ops] from [{}] to [{}]", RecoverySettings.this.translogOps, translogOps); + RecoverySettings.this.translogOps = translogOps; + } + + ByteSizeValue translogSize = settings.getAsBytesSize("indices.recovery.translog_size", RecoverySettings.this.translogSize); + if (!translogSize.equals(RecoverySettings.this.translogSize)) { + logger.info("updating [indices.recovery.translog_size] from [{}] to [{}]", RecoverySettings.this.translogSize, translogSize); + RecoverySettings.this.translogSize = translogSize; + } + + boolean compress = settings.getAsBoolean("indices.recovery.compress", RecoverySettings.this.compress); + if (compress != RecoverySettings.this.compress) { + logger.info("updating [indices.recovery.compress] from [{}] to [{}]", RecoverySettings.this.compress, compress); + RecoverySettings.this.compress = compress; + } + + int concurrentStreams = settings.getAsInt("indices.recovery.concurrent_streams", RecoverySettings.this.concurrentStreams); + if (concurrentStreams != RecoverySettings.this.concurrentStreams) { + logger.info("updating [indices.recovery.concurrent_streams] from [{}] to [{}]", RecoverySettings.this.concurrentStreams, concurrentStreams); + RecoverySettings.this.concurrentStreams = concurrentStreams; + RecoverySettings.this.concurrentStreamPool.setMaximumPoolSize(concurrentStreams); + } + } + } +} diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoverySource.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoverySource.java similarity index 83% rename from modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoverySource.java rename to modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoverySource.java index 55370faf84cff..c3d912428b2f8 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoverySource.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoverySource.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.shard.recovery; +package org.elasticsearch.indices.recovery; import org.apache.lucene.store.IndexInput; import org.elasticsearch.ElasticSearchException; @@ -28,11 +28,7 @@ import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.unit.ByteSizeUnit; import org.elasticsearch.common.unit.ByteSizeValue; -import org.elasticsearch.common.unit.TimeValue; -import org.elasticsearch.common.util.concurrent.DynamicExecutors; -import org.elasticsearch.common.util.concurrent.EsExecutors; import org.elasticsearch.index.deletionpolicy.SnapshotIndexCommit; import org.elasticsearch.index.engine.Engine; import org.elasticsearch.index.shard.IllegalIndexShardStateException; @@ -42,7 +38,6 @@ import org.elasticsearch.index.store.StoreFileMetaData; import org.elasticsearch.index.translog.Translog; import org.elasticsearch.indices.IndicesService; -import org.elasticsearch.node.settings.NodeSettingsService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.BaseTransportRequestHandler; import org.elasticsearch.transport.TransportChannel; @@ -54,14 +49,11 @@ import java.util.List; import java.util.Set; import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.atomic.AtomicReference; /** * The source recovery accepts recovery requests from other peer shards and start the recovery process from this * source shard to the target shard. - * - * @author kimchy (shay.banon) */ public class RecoverySource extends AbstractComponent { @@ -79,42 +71,19 @@ public static class Actions { private final IndicesService indicesService; + private final RecoverySettings recoverySettings; - private final ByteSizeValue fileChunkSize; - - private final boolean compress; - - private final int translogOps; - private final ByteSizeValue translogSize; - - private volatile int concurrentStreams; - private final ThreadPoolExecutor concurrentStreamPool; @Inject public RecoverySource(Settings settings, ThreadPool threadPool, TransportService transportService, IndicesService indicesService, - NodeSettingsService nodeSettingsService) { + RecoverySettings recoverySettings) { super(settings); this.threadPool = threadPool; this.transportService = transportService; this.indicesService = indicesService; - this.concurrentStreams = componentSettings.getAsInt("concurrent_streams", 5); - this.concurrentStreamPool = (ThreadPoolExecutor) DynamicExecutors.newScalingThreadPool(1, concurrentStreams, TimeValue.timeValueSeconds(5).millis(), EsExecutors.daemonThreadFactory(settings, "[recovery_stream]")); - - this.fileChunkSize = componentSettings.getAsBytesSize("file_chunk_size", new ByteSizeValue(100, ByteSizeUnit.KB)); - this.translogOps = componentSettings.getAsInt("translog_ops", 1000); - this.translogSize = componentSettings.getAsBytesSize("translog_size", new ByteSizeValue(100, ByteSizeUnit.KB)); - this.compress = componentSettings.getAsBoolean("compress", true); - - logger.debug("using concurrent_streams [{}], file_chunk_size [{}], translog_size [{}], translog_ops [{}], and compress [{}]", - concurrentStreams, fileChunkSize, translogSize, translogOps, compress); + this.recoverySettings = recoverySettings; transportService.registerHandler(Actions.START_RECOVERY, new StartRecoveryTransportRequestHandler()); - - nodeSettingsService.addListener(new ApplySettings()); - } - - public void close() { - concurrentStreamPool.shutdown(); } private RecoveryResponse recover(final StartRecoveryRequest request) { @@ -166,11 +135,11 @@ private RecoveryResponse recover(final StartRecoveryRequest request) { final CountDownLatch latch = new CountDownLatch(response.phase1FileNames.size()); final AtomicReference<Exception> lastException = new AtomicReference<Exception>(); for (final String name : response.phase1FileNames) { - concurrentStreamPool.execute(new Runnable() { + recoverySettings.concurrentStreamPool().execute(new Runnable() { @Override public void run() { IndexInput indexInput = null; try { - final int BUFFER_SIZE = (int) fileChunkSize.bytes(); + final int BUFFER_SIZE = (int) recoverySettings.fileChunkSize().bytes(); byte[] buf = new byte[BUFFER_SIZE]; StoreFileMetaData md = shard.store().metaData(name); indexInput = snapshot.getDirectory().openInput(name); @@ -184,7 +153,7 @@ private RecoveryResponse recover(final StartRecoveryRequest request) { long position = indexInput.getFilePointer(); indexInput.readBytes(buf, 0, toRead, false); transportService.submitRequest(request.targetNode(), RecoveryTarget.Actions.FILE_CHUNK, new RecoveryFileChunkRequest(request.shardId(), name, position, len, md.checksum(), buf, toRead), - TransportRequestOptions.options().withCompress(compress).withLowType(), VoidTransportResponseHandler.INSTANCE_SAME).txGet(); + TransportRequestOptions.options().withCompress(recoverySettings.compress()).withLowType(), VoidTransportResponseHandler.INSTANCE_SAME).txGet(); readCount += toRead; } indexInput.close(); @@ -277,9 +246,9 @@ private int sendSnapshot(Translog.Snapshot snapshot) throws ElasticSearchExcepti ops += 1; size += operation.estimateSize(); totalOperations++; - if (ops >= translogOps || size >= translogSize.bytes()) { + if (ops >= recoverySettings.translogOps() || size >= recoverySettings.translogSize().bytes()) { RecoveryTranslogOperationsRequest translogOperationsRequest = new RecoveryTranslogOperationsRequest(request.shardId(), operations); - transportService.submitRequest(request.targetNode(), RecoveryTarget.Actions.TRANSLOG_OPS, translogOperationsRequest, TransportRequestOptions.options().withCompress(compress).withLowType(), VoidTransportResponseHandler.INSTANCE_SAME).txGet(); + transportService.submitRequest(request.targetNode(), RecoveryTarget.Actions.TRANSLOG_OPS, translogOperationsRequest, TransportRequestOptions.options().withCompress(recoverySettings.compress()).withLowType(), VoidTransportResponseHandler.INSTANCE_SAME).txGet(); ops = 0; size = 0; operations.clear(); @@ -288,7 +257,7 @@ private int sendSnapshot(Translog.Snapshot snapshot) throws ElasticSearchExcepti // send the leftover if (!operations.isEmpty()) { RecoveryTranslogOperationsRequest translogOperationsRequest = new RecoveryTranslogOperationsRequest(request.shardId(), operations); - transportService.submitRequest(request.targetNode(), RecoveryTarget.Actions.TRANSLOG_OPS, translogOperationsRequest, TransportRequestOptions.options().withCompress(compress).withLowType(), VoidTransportResponseHandler.INSTANCE_SAME).txGet(); + transportService.submitRequest(request.targetNode(), RecoveryTarget.Actions.TRANSLOG_OPS, translogOperationsRequest, TransportRequestOptions.options().withCompress(recoverySettings.compress()).withLowType(), VoidTransportResponseHandler.INSTANCE_SAME).txGet(); } return totalOperations; } @@ -311,16 +280,5 @@ class StartRecoveryTransportRequestHandler extends BaseTransportRequestHandler<S channel.sendResponse(response); } } - - class ApplySettings implements NodeSettingsService.Listener { - @Override public void onRefreshSettings(Settings settings) { - int concurrentStreams = settings.getAsInt("index.shard.recovery.concurrent_streams", RecoverySource.this.concurrentStreams); - if (concurrentStreams != RecoverySource.this.concurrentStreams) { - logger.info("updating [index.shard.recovery.concurrent_streams] from [{}] to [{}]", RecoverySource.this.concurrentStreams, concurrentStreams); - RecoverySource.this.concurrentStreams = concurrentStreams; - RecoverySource.this.concurrentStreamPool.setMaximumPoolSize(concurrentStreams); - } - } - } } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryStatus.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryStatus.java similarity index 98% rename from modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryStatus.java rename to modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryStatus.java index c20c2f01c3bc2..bc43f54ba5683 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryStatus.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryStatus.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.shard.recovery; +package org.elasticsearch.indices.recovery; import org.apache.lucene.store.IndexOutput; import org.elasticsearch.common.util.concurrent.ConcurrentCollections; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryTarget.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryTarget.java similarity index 99% rename from modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryTarget.java rename to modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryTarget.java index 0385fe9d9969b..428cc7e358448 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryTarget.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryTarget.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.shard.recovery; +package org.elasticsearch.indices.recovery; import org.apache.lucene.store.AlreadyClosedException; import org.apache.lucene.store.IndexOutput; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryTranslogOperationsRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryTranslogOperationsRequest.java similarity index 98% rename from modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryTranslogOperationsRequest.java rename to modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryTranslogOperationsRequest.java index cbcb1830fd657..7db2df0c4dd1e 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryTranslogOperationsRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryTranslogOperationsRequest.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.shard.recovery; +package org.elasticsearch.indices.recovery; import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.io.stream.StreamInput; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/StartRecoveryRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/StartRecoveryRequest.java similarity index 98% rename from modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/StartRecoveryRequest.java rename to modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/StartRecoveryRequest.java index c413eacbcf2c6..bddbd0d803cf4 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/StartRecoveryRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/StartRecoveryRequest.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.shard.recovery; +package org.elasticsearch.indices.recovery; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.collect.Maps;
8e0167a91d4717daead6e14541c7655ee45c1430
tapiji
updated licenses
p
https://github.com/tapiji/tapiji
diff --git a/at.ac.tuwien.inso.eclipse.i18n.jsf/epl-v10.html b/at.ac.tuwien.inso.eclipse.i18n.jsf/epl-v10.html new file mode 100644 index 00000000..ed4b1966 --- /dev/null +++ b/at.ac.tuwien.inso.eclipse.i18n.jsf/epl-v10.html @@ -0,0 +1,328 @@ +<html xmlns:o="urn:schemas-microsoft-com:office:office" +xmlns:w="urn:schemas-microsoft-com:office:word" +xmlns="http://www.w3.org/TR/REC-html40"> + +<head> +<meta http-equiv=Content-Type content="text/html; charset=windows-1252"> +<meta name=ProgId content=Word.Document> +<meta name=Generator content="Microsoft Word 9"> +<meta name=Originator content="Microsoft Word 9"> +<link rel=File-List +href="./Eclipse%20EPL%202003_11_10%20Final_files/filelist.xml"> +<title>Eclipse Public License - Version 1.0</title> +<!--[if gte mso 9]><xml> + <o:DocumentProperties> + <o:Revision>2</o:Revision> + <o:TotalTime>3</o:TotalTime> + <o:Created>2004-03-05T23:03:00Z</o:Created> + <o:LastSaved>2004-03-05T23:03:00Z</o:LastSaved> + <o:Pages>4</o:Pages> + <o:Words>1626</o:Words> + <o:Characters>9270</o:Characters> + <o:Lines>77</o:Lines> + <o:Paragraphs>18</o:Paragraphs> + <o:CharactersWithSpaces>11384</o:CharactersWithSpaces> + <o:Version>9.4402</o:Version> + </o:DocumentProperties> +</xml><![endif]--><!--[if gte mso 9]><xml> + <w:WordDocument> + <w:TrackRevisions/> + </w:WordDocument> +</xml><![endif]--> +<style> +<!-- + /* Font Definitions */ +@font-face + {font-family:Tahoma; + panose-1:2 11 6 4 3 5 4 4 2 4; + mso-font-charset:0; + mso-generic-font-family:swiss; + mso-font-pitch:variable; + mso-font-signature:553679495 -2147483648 8 0 66047 0;} + /* Style Definitions */ +p.MsoNormal, li.MsoNormal, div.MsoNormal + {mso-style-parent:""; + margin:0in; + margin-bottom:.0001pt; + mso-pagination:widow-orphan; + font-size:12.0pt; + font-family:"Times New Roman"; + mso-fareast-font-family:"Times New Roman";} +p + {margin-right:0in; + mso-margin-top-alt:auto; + mso-margin-bottom-alt:auto; + margin-left:0in; + mso-pagination:widow-orphan; + font-size:12.0pt; + font-family:"Times New Roman"; + mso-fareast-font-family:"Times New Roman";} +p.BalloonText, li.BalloonText, div.BalloonText + {mso-style-name:"Balloon Text"; + margin:0in; + margin-bottom:.0001pt; + mso-pagination:widow-orphan; + font-size:8.0pt; + font-family:Tahoma; + mso-fareast-font-family:"Times New Roman";} +@page Section1 + {size:8.5in 11.0in; + margin:1.0in 1.25in 1.0in 1.25in; + mso-header-margin:.5in; + mso-footer-margin:.5in; + mso-paper-source:0;} +div.Section1 + {page:Section1;} +--> +</style> +</head> + +<body lang=EN-US style='tab-interval:.5in'> + +<div class=Section1> + +<p align=center style='text-align:center'><b>Eclipse Public License - v 1.0</b> +</p> + +<p><span style='font-size:10.0pt'>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER +THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE, +REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE +OF THIS AGREEMENT.</span> </p> + +<p><b><span style='font-size:10.0pt'>1. DEFINITIONS</span></b> </p> + +<p><span style='font-size:10.0pt'>&quot;Contribution&quot; means:</span> </p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a) +in the case of the initial Contributor, the initial code and documentation +distributed under this Agreement, and<br clear=left> +b) in the case of each subsequent Contributor:</span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i) +changes to the Program, and</span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii) +additions to the Program;</span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>where +such changes and/or additions to the Program originate from and are distributed +by that particular Contributor. A Contribution 'originates' from a Contributor +if it was added to the Program by such Contributor itself or anyone acting on +such Contributor's behalf. Contributions do not include additions to the +Program which: (i) are separate modules of software distributed in conjunction +with the Program under their own license agreement, and (ii) are not derivative +works of the Program. </span></p> + +<p><span style='font-size:10.0pt'>&quot;Contributor&quot; means any person or +entity that distributes the Program.</span> </p> + +<p><span style='font-size:10.0pt'>&quot;Licensed Patents &quot; mean patent +claims licensable by a Contributor which are necessarily infringed by the use +or sale of its Contribution alone or when combined with the Program. </span></p> + +<p><span style='font-size:10.0pt'>&quot;Program&quot; means the Contributions +distributed in accordance with this Agreement.</span> </p> + +<p><span style='font-size:10.0pt'>&quot;Recipient&quot; means anyone who +receives the Program under this Agreement, including all Contributors.</span> </p> + +<p><b><span style='font-size:10.0pt'>2. GRANT OF RIGHTS</span></b> </p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a) +Subject to the terms of this Agreement, each Contributor hereby grants Recipient +a non-exclusive, worldwide, royalty-free copyright license to<span +style='color:red'> </span>reproduce, prepare derivative works of, publicly +display, publicly perform, distribute and sublicense the Contribution of such +Contributor, if any, and such derivative works, in source code and object code +form.</span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b) +Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide,<span style='color:green'> </span>royalty-free +patent license under Licensed Patents to make, use, sell, offer to sell, import +and otherwise transfer the Contribution of such Contributor, if any, in source +code and object code form. This patent license shall apply to the combination +of the Contribution and the Program if, at the time the Contribution is added +by the Contributor, such addition of the Contribution causes such combination +to be covered by the Licensed Patents. The patent license shall not apply to +any other combinations which include the Contribution. No hardware per se is +licensed hereunder. </span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>c) +Recipient understands that although each Contributor grants the licenses to its +Contributions set forth herein, no assurances are provided by any Contributor +that the Program does not infringe the patent or other intellectual property +rights of any other entity. Each Contributor disclaims any liability to Recipient +for claims brought by any other entity based on infringement of intellectual +property rights or otherwise. As a condition to exercising the rights and +licenses granted hereunder, each Recipient hereby assumes sole responsibility +to secure any other intellectual property rights needed, if any. For example, +if a third party patent license is required to allow Recipient to distribute +the Program, it is Recipient's responsibility to acquire that license before +distributing the Program.</span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>d) +Each Contributor represents that to its knowledge it has sufficient copyright +rights in its Contribution, if any, to grant the copyright license set forth in +this Agreement. </span></p> + +<p><b><span style='font-size:10.0pt'>3. REQUIREMENTS</span></b> </p> + +<p><span style='font-size:10.0pt'>A Contributor may choose to distribute the +Program in object code form under its own license agreement, provided that:</span> +</p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a) +it complies with the terms and conditions of this Agreement; and</span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b) +its license agreement:</span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i) +effectively disclaims on behalf of all Contributors all warranties and +conditions, express and implied, including warranties or conditions of title +and non-infringement, and implied warranties or conditions of merchantability +and fitness for a particular purpose; </span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii) +effectively excludes on behalf of all Contributors all liability for damages, +including direct, indirect, special, incidental and consequential damages, such +as lost profits; </span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iii) +states that any provisions which differ from this Agreement are offered by that +Contributor alone and not by any other party; and</span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iv) +states that source code for the Program is available from such Contributor, and +informs licensees how to obtain it in a reasonable manner on or through a +medium customarily used for software exchange.<span style='color:blue'> </span></span></p> + +<p><span style='font-size:10.0pt'>When the Program is made available in source +code form:</span> </p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a) +it must be made available under this Agreement; and </span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b) a +copy of this Agreement must be included with each copy of the Program. </span></p> + +<p><span style='font-size:10.0pt'>Contributors may not remove or alter any +copyright notices contained within the Program. </span></p> + +<p><span style='font-size:10.0pt'>Each Contributor must identify itself as the +originator of its Contribution, if any, in a manner that reasonably allows +subsequent Recipients to identify the originator of the Contribution. </span></p> + +<p><b><span style='font-size:10.0pt'>4. COMMERCIAL DISTRIBUTION</span></b> </p> + +<p><span style='font-size:10.0pt'>Commercial distributors of software may +accept certain responsibilities with respect to end users, business partners +and the like. While this license is intended to facilitate the commercial use +of the Program, the Contributor who includes the Program in a commercial +product offering should do so in a manner which does not create potential +liability for other Contributors. Therefore, if a Contributor includes the +Program in a commercial product offering, such Contributor (&quot;Commercial +Contributor&quot;) hereby agrees to defend and indemnify every other +Contributor (&quot;Indemnified Contributor&quot;) against any losses, damages and +costs (collectively &quot;Losses&quot;) arising from claims, lawsuits and other +legal actions brought by a third party against the Indemnified Contributor to +the extent caused by the acts or omissions of such Commercial Contributor in +connection with its distribution of the Program in a commercial product +offering. The obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. In order +to qualify, an Indemnified Contributor must: a) promptly notify the Commercial +Contributor in writing of such claim, and b) allow the Commercial Contributor +to control, and cooperate with the Commercial Contributor in, the defense and +any related settlement negotiations. The Indemnified Contributor may participate +in any such claim at its own expense.</span> </p> + +<p><span style='font-size:10.0pt'>For example, a Contributor might include the +Program in a commercial product offering, Product X. That Contributor is then a +Commercial Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance claims and +warranties are such Commercial Contributor's responsibility alone. Under this +section, the Commercial Contributor would have to defend claims against the +other Contributors related to those performance claims and warranties, and if a +court requires any other Contributor to pay any damages as a result, the +Commercial Contributor must pay those damages.</span> </p> + +<p><b><span style='font-size:10.0pt'>5. NO WARRANTY</span></b> </p> + +<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS +AGREEMENT, THE PROGRAM IS PROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, +WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, +MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely +responsible for determining the appropriateness of using and distributing the +Program and assumes all risks associated with its exercise of rights under this +Agreement , including but not limited to the risks and costs of program errors, +compliance with applicable laws, damage to or loss of data, programs or +equipment, and unavailability or interruption of operations. </span></p> + +<p><b><span style='font-size:10.0pt'>6. DISCLAIMER OF LIABILITY</span></b> </p> + +<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS +AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF +THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGES.</span> </p> + +<p><b><span style='font-size:10.0pt'>7. GENERAL</span></b> </p> + +<p><span style='font-size:10.0pt'>If any provision of this Agreement is invalid +or unenforceable under applicable law, it shall not affect the validity or +enforceability of the remainder of the terms of this Agreement, and without +further action by the parties hereto, such provision shall be reformed to the +minimum extent necessary to make such provision valid and enforceable.</span> </p> + +<p><span style='font-size:10.0pt'>If Recipient institutes patent litigation +against any entity (including a cross-claim or counterclaim in a lawsuit) +alleging that the Program itself (excluding combinations of the Program with +other software or hardware) infringes such Recipient's patent(s), then such +Recipient's rights granted under Section 2(b) shall terminate as of the date +such litigation is filed. </span></p> + +<p><span style='font-size:10.0pt'>All Recipient's rights under this Agreement +shall terminate if it fails to comply with any of the material terms or +conditions of this Agreement and does not cure such failure in a reasonable +period of time after becoming aware of such noncompliance. If all Recipient's +rights under this Agreement terminate, Recipient agrees to cease use and +distribution of the Program as soon as reasonably practicable. However, +Recipient's obligations under this Agreement and any licenses granted by +Recipient relating to the Program shall continue and survive. </span></p> + +<p><span style='font-size:10.0pt'>Everyone is permitted to copy and distribute +copies of this Agreement, but in order to avoid inconsistency the Agreement is +copyrighted and may only be modified in the following manner. The Agreement +Steward reserves the right to publish new versions (including revisions) of +this Agreement from time to time. No one other than the Agreement Steward has +the right to modify this Agreement. The Eclipse Foundation is the initial +Agreement Steward. The Eclipse Foundation may assign the responsibility to +serve as the Agreement Steward to a suitable separate entity. Each new version +of the Agreement will be given a distinguishing version number. The Program +(including Contributions) may always be distributed subject to the version of +the Agreement under which it was received. In addition, after a new version of +the Agreement is published, Contributor may elect to distribute the Program +(including its Contributions) under the new version. Except as expressly stated +in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to +the intellectual property of any Contributor under this Agreement, whether +expressly, by implication, estoppel or otherwise. All rights in the Program not +expressly granted under this Agreement are reserved.</span> </p> + +<p><span style='font-size:10.0pt'>This Agreement is governed by the laws of the +State of New York and the intellectual property laws of the United States of +America. No party to this Agreement will bring a legal action under this +Agreement more than one year after the cause of action arose. Each party waives +its rights to a jury trial in any resulting litigation.</span> </p> + +<p class=MsoNormal><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></p> + +</div> + +</body> + +</html> \ No newline at end of file
77048935bbd5ab61f9c3a7e05172c4f8e7fee326
Vala
sqlite3: add binding for sqlite3_update_hook
a
https://github.com/GNOME/vala/
diff --git a/vapi/sqlite3.vapi b/vapi/sqlite3.vapi index 4ae8cd31d1..d44db089dc 100644 --- a/vapi/sqlite3.vapi +++ b/vapi/sqlite3.vapi @@ -85,6 +85,7 @@ namespace Sqlite { public void progress_handler (int n_opcodes, Sqlite.ProgressCallback? progress_handler); public void commit_hook (CommitCallback? commit_hook); public void rollback_hook (RollbackCallback? rollback_hook); + public void update_hook (UpdateCallback? update_hook); public int create_function (string zFunctionName, int nArg, int eTextRep, void * user_data, UserFuncCallback? xFunc, UserFuncCallback? xStep, UserFuncFinishCallback? xFinal); } @@ -101,6 +102,8 @@ namespace Sqlite { public delegate void UserFuncCallback (Sqlite.Context context, [CCode (array_length_pos = 1.1)] Sqlite.Value[] values); [CCode (has_target = false)] public delegate void UserFuncFinishCallback (Sqlite.Context context); + [CCode (instance_pos = 0)] + public delegate void UpdateCallback (Sqlite.Action action, string dbname, string table, int64 rowid); public unowned string? compileoption_get (int n); public int compileoption_used (string option_name);
4cb637b9768b3ba1bcfc55d317ca26401f7b9a95
Vala
gio-2.0: set default value of g_zlib_compressor_new.level to -1
a
https://github.com/GNOME/vala/
diff --git a/vapi/gio-2.0.vapi b/vapi/gio-2.0.vapi index 96863f5e7d..bcf450c55f 100644 --- a/vapi/gio-2.0.vapi +++ b/vapi/gio-2.0.vapi @@ -938,7 +938,7 @@ namespace GLib { [CCode (cheader_filename = "gio/gio.h")] public class ZlibCompressor : GLib.Object, GLib.Converter { [CCode (has_construct_function = false)] - public ZlibCompressor (GLib.ZlibCompressorFormat format, int level); + public ZlibCompressor (GLib.ZlibCompressorFormat format, int level = -1); [NoAccessorMethod] public GLib.ZlibCompressorFormat format { get; construct; } [NoAccessorMethod] diff --git a/vapi/packages/gio-2.0/gio-2.0.metadata b/vapi/packages/gio-2.0/gio-2.0.metadata index 776275a591..feb178db58 100644 --- a/vapi/packages/gio-2.0/gio-2.0.metadata +++ b/vapi/packages/gio-2.0/gio-2.0.metadata @@ -180,3 +180,5 @@ g_volume_monitor_get_mount_for_uuid transfer_ownership="1" g_volume_monitor_get_mounts type_arguments="Mount" transfer_ownership="1" g_volume_monitor_get_volume_for_uuid transfer_ownership="1" g_volume_monitor_get_volumes type_arguments="Volume" transfer_ownership="1" + +g_zlib_compressor_new.level default_value="-1"
53c2131d4411fac6fbe43fc757bc6acea780e2a1
crashub$crash
Add flexibility for plugin a custom class manager
p
https://github.com/crashub/crash
diff --git a/shell/core/src/main/java/org/crsh/shell/impl/command/AbstractClassManager.java b/shell/core/src/main/java/org/crsh/shell/impl/command/AbstractClassManager.java new file mode 100644 index 000000000..f9a8180ba --- /dev/null +++ b/shell/core/src/main/java/org/crsh/shell/impl/command/AbstractClassManager.java @@ -0,0 +1,143 @@ +/* + * Copyright (C) 2012 eXo Platform SAS. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.crsh.shell.impl.command; + +import groovy.lang.GroovyClassLoader; +import groovy.lang.GroovyCodeSource; +import groovy.lang.Script; +import org.codehaus.groovy.control.CompilationFailedException; +import org.codehaus.groovy.control.CompilerConfiguration; +import org.crsh.command.CommandInvoker; +import org.crsh.command.NoSuchCommandException; +import org.crsh.plugin.PluginContext; +import org.crsh.shell.ErrorType; +import org.crsh.util.TimestampedObject; +import org.crsh.vfs.Resource; + +import java.io.UnsupportedEncodingException; + +public abstract class AbstractClassManager<T> { + + /** . */ + private final PluginContext context; + + /** . */ + private final CompilerConfiguration config; + + /** . */ + private final Class<T> baseClass; + + protected AbstractClassManager(PluginContext context, Class<T> baseClass, Class<? extends Script> baseScriptClass) { + CompilerConfiguration config = new CompilerConfiguration(); + config.setRecompileGroovySource(true); + config.setScriptBaseClass(baseScriptClass.getName()); + + // + this.context = context; + this.config = config; + this.baseClass = baseClass; + } + + protected abstract TimestampedObject<Class<? extends T>> loadClass(String name); + + protected abstract void saveClass(String name, TimestampedObject<Class<? extends T>> clazz); + + protected abstract Resource getResource(String name); + + Class<? extends T> getClass(String name) throws NoSuchCommandException, NullPointerException { + if (name == null) { + throw new NullPointerException("No null argument allowed"); + } + + TimestampedObject<Class<? extends T>> providerRef = loadClass(name); + + // + Resource script = getResource(name); + + // + if (script != null) { + if (providerRef != null) { + if (script.getTimestamp() != providerRef.getTimestamp()) { + providerRef = null; + } + } + + // + if (providerRef == null) { + + // + String source; + try { + source = new String(script.getContent(), "UTF-8"); + } + catch (UnsupportedEncodingException e) { + throw new NoSuchCommandException(name, ErrorType.INTERNAL, "Could not compile command script " + name, e); + } + + // + Class<?> clazz; + try { + GroovyCodeSource gcs = new GroovyCodeSource(source, name, "/groovy/shell"); + GroovyClassLoader gcl = new GroovyClassLoader(context.getLoader(), config); + clazz = gcl.parseClass(gcs, false); + } + catch (NoClassDefFoundError e) { + throw new NoSuchCommandException(name, ErrorType.INTERNAL, "Could not compile command script " + name, e); + } + catch (CompilationFailedException e) { + throw new NoSuchCommandException(name, ErrorType.INTERNAL, "Could not compile command script " + name, e); + } + + // + if (baseClass.isAssignableFrom(clazz)) { + Class<? extends T> providerClass = clazz.asSubclass(baseClass); + providerRef = new TimestampedObject<Class<? extends T>>(script.getTimestamp(), providerClass); + saveClass(name, providerRef); + } else { + throw new NoSuchCommandException(name, ErrorType.INTERNAL, "Parsed script " + clazz.getName() + + " does not implements " + CommandInvoker.class.getName()); + } + } + } + + // + if (providerRef == null) { + return null; + } + + // + return providerRef.getObject(); + } + + T getInstance(String name) throws NoSuchCommandException, NullPointerException { + Class<? extends T> clazz = getClass(name); + if (clazz == null) { + return null; + } + + // + try { + return clazz.newInstance(); + } + catch (Exception e) { + throw new NoSuchCommandException(name, ErrorType.INTERNAL, "Could not create command " + name + " instance", e); + } + } +} diff --git a/shell/core/src/main/java/org/crsh/shell/impl/command/CRaSH.java b/shell/core/src/main/java/org/crsh/shell/impl/command/CRaSH.java index ce0d38949..35c96e519 100644 --- a/shell/core/src/main/java/org/crsh/shell/impl/command/CRaSH.java +++ b/shell/core/src/main/java/org/crsh/shell/impl/command/CRaSH.java @@ -19,7 +19,6 @@ package org.crsh.shell.impl.command; -import groovy.lang.Script; import org.crsh.command.GroovyScript; import org.crsh.command.GroovyScriptCommand; import org.crsh.command.NoSuchCommandException; @@ -33,10 +32,10 @@ public class CRaSH { /** . */ - final ClassManager<? extends ShellCommand> commandManager; + final AbstractClassManager<? extends ShellCommand> commandManager; /** . */ - final ClassManager<? extends GroovyScript> scriptManager; + final AbstractClassManager<? extends GroovyScript> scriptManager; /** . */ final PluginContext context; @@ -55,7 +54,7 @@ public CRaSH(PluginContext context) throws NullPointerException { ); } - public CRaSH(PluginContext context, ClassManager<ShellCommand> commandManager, ClassManager<? extends GroovyScript> scriptManager) { + public CRaSH(PluginContext context, AbstractClassManager<ShellCommand> commandManager, AbstractClassManager<? extends GroovyScript> scriptManager) { this.context = context; this.commandManager = commandManager; this.scriptManager = scriptManager; diff --git a/shell/core/src/main/java/org/crsh/shell/impl/command/ClassManager.java b/shell/core/src/main/java/org/crsh/shell/impl/command/ClassManager.java index 1369cee1d..ddf3cfaea 100644 --- a/shell/core/src/main/java/org/crsh/shell/impl/command/ClassManager.java +++ b/shell/core/src/main/java/org/crsh/shell/impl/command/ClassManager.java @@ -19,25 +19,16 @@ package org.crsh.shell.impl.command; -import groovy.lang.GroovyClassLoader; -import groovy.lang.GroovyCodeSource; import groovy.lang.Script; -import org.codehaus.groovy.control.CompilationFailedException; -import org.codehaus.groovy.control.CompilerConfiguration; -import org.crsh.command.CommandInvoker; -import org.crsh.command.GroovyScriptCommand; -import org.crsh.command.NoSuchCommandException; import org.crsh.plugin.PluginContext; import org.crsh.plugin.ResourceKind; -import org.crsh.shell.ErrorType; import org.crsh.util.TimestampedObject; import org.crsh.vfs.Resource; -import java.io.UnsupportedEncodingException; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -class ClassManager<T> { +public class ClassManager<T> extends AbstractClassManager<T> { /** . */ private final Map<String, TimestampedObject<Class<? extends T>>> classes = new ConcurrentHashMap<String, TimestampedObject<Class<? extends T>>>(); @@ -45,104 +36,29 @@ class ClassManager<T> { /** . */ private final PluginContext context; - /** . */ - private final CompilerConfiguration config; - - /** . */ - private final Class<T> baseClass; - /** . */ private final ResourceKind kind; - ClassManager(PluginContext context, ResourceKind kind, Class<T> baseClass, Class<? extends Script> baseScriptClass) { - CompilerConfiguration config = new CompilerConfiguration(); - config.setRecompileGroovySource(true); - config.setScriptBaseClass(baseScriptClass.getName()); + public ClassManager(PluginContext context, ResourceKind kind, Class<T> baseClass, Class<? extends Script> baseScriptClass) { + super(context, baseClass, baseScriptClass); // this.context = context; - this.config = config; - this.baseClass = baseClass; this.kind = kind; } - Class<? extends T> getClass(String name) throws NoSuchCommandException, NullPointerException { - if (name == null) { - throw new NullPointerException("No null argument allowed"); - } - - TimestampedObject<Class<? extends T>> providerRef = classes.get(name); - - // - Resource script = context.loadResource(name, kind); - - // - if (script != null) { - if (providerRef != null) { - if (script.getTimestamp() != providerRef.getTimestamp()) { - providerRef = null; - } - } - - // - if (providerRef == null) { - - // - String source; - try { - source = new String(script.getContent(), "UTF-8"); - } - catch (UnsupportedEncodingException e) { - throw new NoSuchCommandException(name, ErrorType.INTERNAL, "Could not compile command script " + name, e); - } - - // - Class<?> clazz; - try { - GroovyCodeSource gcs = new GroovyCodeSource(source, name, "/groovy/shell"); - GroovyClassLoader gcl = new GroovyClassLoader(context.getLoader(), config); - clazz = gcl.parseClass(gcs, false); - } - catch (NoClassDefFoundError e) { - throw new NoSuchCommandException(name, ErrorType.INTERNAL, "Could not compile command script " + name, e); - } - catch (CompilationFailedException e) { - throw new NoSuchCommandException(name, ErrorType.INTERNAL, "Could not compile command script " + name, e); - } - - // - if (baseClass.isAssignableFrom(clazz)) { - Class<? extends T> providerClass = clazz.asSubclass(baseClass); - providerRef = new TimestampedObject<Class<? extends T>>(script.getTimestamp(), providerClass); - classes.put(name, providerRef); - } else { - throw new NoSuchCommandException(name, ErrorType.INTERNAL, "Parsed script " + clazz.getName() + - " does not implements " + CommandInvoker.class.getName()); - } - } - } - - // - if (providerRef == null) { - return null; - } - - // - return providerRef.getObject(); + @Override + protected TimestampedObject<Class<? extends T>> loadClass(String name) { + return classes.get(name); } - T getInstance(String name) throws NoSuchCommandException, NullPointerException { - Class<? extends T> clazz = getClass(name); - if (clazz == null) { - return null; - } + @Override + protected void saveClass(String name, TimestampedObject<Class<? extends T>> clazz) { + classes.put(name, clazz); + } - // - try { - return clazz.newInstance(); - } - catch (Exception e) { - throw new NoSuchCommandException(name, ErrorType.INTERNAL, "Could not create command " + name + " instance", e); - } + @Override + protected Resource getResource(String name) { + return context.loadResource(name, kind); } }
0338b71df28dc82f5bbb6aa777f51809549dffeb
Delta Spike
DELTASPIKE-241 new weld-arquillian container fixes BDA issues
p
https://github.com/apache/deltaspike
diff --git a/deltaspike/parent/pom.xml b/deltaspike/parent/pom.xml index 18c625680..2410e7799 100644 --- a/deltaspike/parent/pom.xml +++ b/deltaspike/parent/pom.xml @@ -89,7 +89,7 @@ <jacoco.version>0.5.7.201204190339</jacoco.version> <arquillian-openwebbeans.version>1.0.0.CR2</arquillian-openwebbeans.version> - <arquillian-weld.version>1.0.0.CR4</arquillian-weld.version> + <arquillian-weld.version>1.0.0.CR5</arquillian-weld.version> <!-- OSGi bundles properties --> <deltaspike.osgi.import.deltaspike.version>version="[$(version;==;${deltaspike.osgi.version.clean}),$(version;=+;${deltaspike.osgi.version.clean}))"</deltaspike.osgi.import.deltaspike.version>
End of preview. Expand in Data Studio

No dataset card yet

Downloads last month
5