1919public class UploadCommand implements CliCommand
2020{
2121 private static final Logger log = LoggerFactory .getLogger (UploadCommand .class );
22- private final FileListReader fileListReader ;
22+ private final FileListReader fileListReader = new FileListReader ();
23+ private final ConfigurationValidator configurationValidator = new ConfigurationValidator ();
2324 private final SimpleLocalizeClient client ;
2425 private final Configuration configuration ;
25- private final ConfigurationValidator configurationValidator ;
2626
2727 public UploadCommand (SimpleLocalizeClient client , Configuration configuration )
2828 {
2929 this .configuration = configuration ;
3030 this .client = client ;
31- this .fileListReader = new FileListReader ();
32- this .configurationValidator = new ConfigurationValidator ();
3331 }
3432
3533 public void invoke () throws IOException , InterruptedException
@@ -76,12 +74,8 @@ public void invoke() throws IOException, InterruptedException
7674 if (isDryRun )
7775 {
7876 log .info ("Dry run mode enabled, no files will be uploaded" );
79- } else
80- {
81- log .info ("Uploading files..." );
8277 }
8378
84-
8579 for (FileToUpload fileToUpload : filesToUpload )
8680 {
8781 Path path = fileToUpload .path ();
@@ -106,10 +100,10 @@ public void invoke() throws IOException, InterruptedException
106100 continue ;
107101 }
108102
109- String requestLanguageKey = fileLanguageKey ;
103+ String effectiveLanguageKey = fileLanguageKey ;
110104 if (hasConfigurationLanguageKey && !hasFileLanguageKey )
111105 {
112- requestLanguageKey = configurationLanguageKey ;
106+ effectiveLanguageKey = configurationLanguageKey ;
113107 }
114108
115109 boolean isMultiLanguage = isMultiLanguage (configuration );
@@ -118,26 +112,26 @@ public void invoke() throws IOException, InterruptedException
118112 log .info ("Language key not present in '--uploadPath' nor '--languageKey' parameter, file: {}" , path );
119113 }
120114
121- String namespace = fileToUpload .namespace ();
122- if (StringUtils .isBlank (namespace ))
115+ String effectiveNamespace = fileToUpload .namespace ();
116+ if (StringUtils .isBlank (effectiveNamespace ))
123117 {
124- namespace = configuration .getNamespace ();
118+ effectiveNamespace = configuration .getNamespace ();
125119 }
126120 UploadRequest uploadRequest = UploadRequest .builder ()
127121 .withPath (path )
128- .withLanguageKey (requestLanguageKey )
129- .withNamespace (namespace )
122+ .withLanguageKey (effectiveLanguageKey )
123+ .withNamespace (effectiveNamespace )
130124 .withFormat (uploadFormat )
131125 .withCustomerId (customerId )
132126 .withOptions (uploadOptions )
133127 .build ();
134128
135129 if (isDryRun )
136130 {
137- log .info ("[Dry run] Found file to upload, language=[{}], namespace=[{}] = {}" , language , namespace , path );
131+ log .info ("[Dry run] Found file to upload, language=[{}], namespace=[{}] = {}" , effectiveLanguageKey , effectiveNamespace , path );
138132 } else
139133 {
140- log .info ("Uploading language=[{}] namespace=[{}] = {}" , language , namespace , path );
134+ log .info ("Uploading file, language=[{}] namespace=[{}] = {}" , effectiveLanguageKey , effectiveNamespace , path );
141135 client .uploadFile (uploadRequest );
142136 }
143137 }
@@ -167,8 +161,6 @@ private boolean isMultiLanguage(Configuration configuration)
167161 return true ;
168162 }
169163 }
170-
171-
172164 return false ;
173165 }
174166}
0 commit comments