/*
 * Copyright 2017 flow.ci
 *
 * 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.
 */

package com.flow.platform.api.git;

import com.flow.platform.api.domain.envs.GitEnvs;
import com.flow.platform.api.domain.node.Node;
import com.flow.platform.core.exception.IllegalParameterException;
import com.flow.platform.util.git.GitClient;
import com.flow.platform.util.git.GitHttpClient;
import com.google.common.base.Strings;
import java.nio.file.Path;

/**
 * @author yang
 */
public class GitHttpClientBuilder extends GitClientBuilder {

    private final String user;

    private final String pass;

    public GitHttpClientBuilder(Node node, Path sourceFolder) {
        super(node, sourceFolder);

        user = node.getEnv(GitEnvs.FLOW_GIT_HTTP_USER);
        pass = node.getEnv(GitEnvs.FLOW_GIT_HTTP_PASS);
    }

    @Override
    public GitClient build() {
        if (Strings.isNullOrEmpty(user) || Strings.isNullOrEmpty(pass)) {
            throw new IllegalParameterException("Username or password of http connection are required");
        }
        return new GitHttpClient(url, sourceFolder, user, pass);
    }
}

@@ -746,48 +746,23 @@
 orm.
-core.exception.IllegalParameterException
+util.StringUtil
 ;%0Aim
@@ -857,47 +857,8 @@
 nt;%0A
-import com.google.common.base.Strings;%0A
 impo
@@ -975,30 +975,24 @@
     private 
-final 
 String user;
@@ -1009,14 +1009,8 @@
 ate 
-final 
 Stri
@@ -1299,173 +1299,135 @@
 if (
-Strings.isNullOrEmpty(user) %7C%7C Strings.isNullOrEmpty(pass)) %7B%0A            throw new IllegalParameterException(%22Username or password of http connection are required%22)
+user == null) %7B%0A            user = StringUtil.EMPTY;%0A        %7D%0A%0A        if (pass == null) %7B%0A            pass = StringUtil.EMPTY
 ;%0A  
@@ -1434,16 +1434,17 @@
       %7D%0A
+%0A
         

set default empty username and password for http git client