@@ -0,0 +1,2146 @@
+/*%0A * CODENVY CONFIDENTIAL%0A * __________________%0A * %0A *  %5B2012%5D - %5B2013%5D Codenvy, S.A. %0A *  All Rights Reserved.%0A * %0A * NOTICE:  All information contained herein is, and remains%0A * the property of Codenvy S.A. and its suppliers,%0A * if any.  The intellectual and technical concepts contained%0A * herein are proprietary to Codenvy S.A.%0A * and its suppliers and may be covered by U.S. and Foreign Patents,%0A * patents in process, and are protected by trade secret or copyright law.%0A * Dissemination of this information or reproduction of this material%0A * is strictly forbidden unless prior written permission is obtained%0A * from Codenvy S.A..%0A */%0Apackage com.codenvy.factory;%0A%0Aimport com.codenvy.commons.lang.UrlUtils;%0A%0Aimport javax.inject.Singleton;%0Aimport javax.servlet.ServletException;%0Aimport javax.servlet.http.*;%0Aimport javax.ws.rs.core.UriBuilder;%0Aimport java.io.IOException;%0Aimport java.net.URL;%0Aimport java.net.URLEncoder;%0Aimport java.util.List;%0Aimport java.util.Map;%0A%0A/**%0A * Convert bitbucket edit repo endpoint to factory url.%0A *%0A * @author Alexander Garagatyi%0A */%0A@Singleton%0Apublic class BitbucketIntegrationFactoryServlet extends HttpServlet %7B%0A    @Override%0A    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException %7B%0A        URL currentUrl =%0A                UriBuilder.fromUri(req.getRequestURL().toString()).replaceQuery(req.getQueryString()).build().toURL();%0A%0A        Map%3CString, List%3CString%3E%3E params = UrlUtils.getQueryParameters(currentUrl);%0A%0A        List%3CString%3E urls = params.get(%22url%22);%0A        if (urls != null && !urls.isEmpty()) %7B%0A            UriBuilder factoryUrl = UriBuilder.fromPath(%22/factory%22);%0A            factoryUrl.queryParam(%22v%22, %221.0%22);%0A            factoryUrl.queryParam(%22vcs%22, %22git%22);%0A            factoryUrl.queryParam(%22vcsurl%22, URLEncoder.encode(urls.iterator().next(), %22UTF-8%22));%0A            factoryUrl.queryParam(%22vcsinfo%22, %22true%22);%0A%0A            resp.sendRedirect(factoryUrl.build().toString());%0A        %7D else %7B%0A            resp.sendRedirect(UriBuilder.fromUri(%22/site/error/error-invalid-factory-url%22).build().toString()); // To error page%0A        %7D%0A    %7D%0A%7D%0A

add servlet for converting bitbucket api endpoint to factory