2626import com .flow .platform .api .service .job .JobService ;
2727import com .flow .platform .api .util .PlatformURL ;
2828import com .flow .platform .core .exception .HttpException ;
29+ import com .flow .platform .core .exception .IllegalParameterException ;
2930import com .flow .platform .core .exception .IllegalStatusException ;
3031import com .flow .platform .core .service .ApplicationEventService ;
3132import com .flow .platform .domain .Agent ;
3839import com .flow .platform .domain .Jsonable ;
3940import com .flow .platform .util .CollectionUtil ;
4041import com .flow .platform .util .Logger ;
42+ import com .flow .platform .util .StringUtil ;
4143import com .flow .platform .util .http .HttpClient ;
4244import com .flow .platform .util .http .HttpResponse ;
4345import com .flow .platform .util .http .HttpURL ;
@@ -144,6 +146,10 @@ public Boolean shutdown(String zone, String name, String password) {
144146
145147 @ Override
146148 public AgentWithFlow create (AgentPath agentPath ) {
149+ if (StringUtil .hasSpace (agentPath .getZone ()) || StringUtil .hasSpace (agentPath .getName ())) {
150+ throw new IllegalParameterException ("Zone name or agent name cannot contain empty space" );
151+ }
152+
147153 try {
148154 AgentPathWithWebhook pathWithWebhook = new AgentPathWithWebhook (agentPath , buildAgentWebhook ());
149155
@@ -158,9 +164,7 @@ public AgentWithFlow create(AgentPath agentPath) {
158164 }
159165
160166 Agent agent = Agent .parse (response .getBody (), Agent .class );
161-
162- AgentWithFlow agentWithFlow = new AgentWithFlow (agent , null );
163- return agentWithFlow ;
167+ return new AgentWithFlow (agent , null );
164168
165169 } catch (UnsupportedEncodingException | JsonSyntaxException e ) {
166170 throw new IllegalStatusException ("Unable to create agent" , e );
0 commit comments