package com.boissinot.jenkins.csvexporter.service.extractor.maven.pom;

import com.boissinot.jenkins.csvexporter.domain.jenkins.job.ConfigJob;
import com.boissinot.jenkins.csvexporter.maven.extractor.POMRemoteObj;

import java.util.Map;

/**
 * @author Gregory Boisisnot
 */
public class POMFileInfoExtractor {

    private String csvViewerRootUrl;

    private Map<String, Map<String, String>> contextModuleMap;

    public POMFileInfoExtractor(Map<String, Map<String, String>> contextMap, String csvViewerRootUrl) {
        if (contextMap == null) {
            throw new NullPointerException("A CVS Module map is required.");
        }
        this.contextModuleMap = contextMap;
        this.csvViewerRootUrl = csvViewerRootUrl;
    }

    public POMRemoteObj getPomUrl(ConfigJob configJob) {

        //Remove Template JOB
        if (configJob.getJobName().contains("template")) {
            System.out.println("Exclude Template JOB");
            return null;
        }

        if (configJob.getSvnURL() != null) {
            return new POMRemoteObj(configJob.getJobName(), configJob.getSvnURL() + "/pom.xml");
        }

        if (configJob.getGitURL() != null) {
            System.out.println("GIT URL with pom.xml " + configJob.getGitURL() + "/pom.xml");
            return null;
        }

        if (configJob.getCvsModule() != null) {
            String cvsModule = configJob.getCvsModule();
            final Map<String, String> cvsMap = contextModuleMap.get("CVS");
            String modulePath = cvsMap.get(cvsModule) == null ? cvsModule : cvsMap.get(cvsModule);
            if (configJob.getCvsBranche() != null) {
                return new POMRemoteObj(configJob.getJobName(), csvViewerRootUrl + modulePath + "/pom.xml?revision=" + configJob.getCvsBranche());
            } else {
                return new POMRemoteObj(configJob.getJobName(), csvViewerRootUrl + modulePath + "/pom.xml?view=co");
            }
        }

        return null;
    }
}

@@ -1477,24 +1477,62 @@
 get(%22CVS%22);%0A
+            if (cvsMap != null) %7B%0A    
             
@@ -1622,32 +1622,36 @@
 e);%0A            
+    
 if (configJob.ge
@@ -1683,32 +1683,36 @@
                 
+   
+ 
 return new POMRe
@@ -1838,16 +1838,20 @@
         
+    
 %7D else %7B
@@ -1851,16 +1851,20 @@
  else %7B%0A
+    
         
@@ -1968,24 +1968,42 @@
 ?view=co%22);%0A
+                %7D%0A
             

Add check null