@@ -144,34 +144,36 @@ public String uploadAppConnResourceNew(String userName, String projectName, DSSF
144144 logger .info ("nodeResourcePath:{}" , nodeResourcePath );
145145 File file = new File (nodeResourcePath );
146146 if (file .exists ()) {
147- InputStream resourceInputStream = bmlService .readLocalResourceFile (userName , nodeResourcePath );
148- Supplier <Map <String , Object >> bmlResourceMap = () -> {
149- BmlResource resource = bmlService .upload (userName , resourceInputStream , UUID .randomUUID ().toString () + ".json" ,
150- projectName );
151- return ImmutableMap .of (
152- "resourceId" , resource .getResourceId (),
153- "version" , resource .getVersion ()
154- );
155- };
156- Supplier <Map <String , Object >> streamResourceMap = () -> MapUtils .newCommonMap (ImportRequestRef .INPUT_STREAM_KEY , resourceInputStream );
157- try {
158- nodeExportContent = nodeService .importNode (userName , appConnNode , bmlResourceMap , streamResourceMap , orcVersion );
159- } catch (ExternalOperationFailedException e ) {
160- logger .error ("failed to import node." , e );
161- throw new DSSRuntimeException (e .getErrCode (), e .getMessage ());
162- } catch (Exception e ) {
163- logger .error ("failed to import node." , e );
164- throw new DSSRuntimeException (90011 , e .getMessage ());
165- }
166- if (nodeExportContent != null ) {
167- if (nodeExportContent .get ("project_id" ) != null ) {
168- Long newProjectId = Long .parseLong (nodeExportContent .get ("project_id" ).toString ());
169- logger .warn (String .format ("new appConn node add into dss,dssProjectId: %s,newProjectId: %s" , appConnNode .getProjectId (), newProjectId ));
170- nodeExportContent .remove ("project_id" );
147+ try (InputStream resourceInputStream = bmlService .readLocalResourceFile (userName , nodeResourcePath )) {
148+ Supplier <Map <String , Object >> bmlResourceMap = () -> {
149+ BmlResource resource = bmlService .upload (userName , resourceInputStream , UUID .randomUUID ().toString () + ".json" ,
150+ projectName );
151+ return ImmutableMap .of (
152+ "resourceId" , resource .getResourceId (),
153+ "version" , resource .getVersion ()
154+ );
155+ };
156+
157+ Supplier <Map <String , Object >> streamResourceMap = () -> MapUtils .newCommonMap (ImportRequestRef .INPUT_STREAM_KEY , resourceInputStream );
158+ try {
159+ nodeExportContent = nodeService .importNode (userName , appConnNode , bmlResourceMap , streamResourceMap , orcVersion );
160+ } catch (ExternalOperationFailedException e ) {
161+ logger .error ("failed to import node." , e );
162+ throw new DSSRuntimeException (e .getErrCode (), e .getMessage ());
163+ } catch (Exception e ) {
164+ logger .error ("failed to import node." , e );
165+ throw new DSSRuntimeException (90011 , e .getMessage ());
166+ }
167+ if (nodeExportContent != null ) {
168+ if (nodeExportContent .get ("project_id" ) != null ) {
169+ Long newProjectId = Long .parseLong (nodeExportContent .get ("project_id" ).toString ());
170+ logger .warn (String .format ("new appConn node add into dss,dssProjectId: %s,newProjectId: %s" , appConnNode .getProjectId (), newProjectId ));
171+ nodeExportContent .remove ("project_id" );
172+ }
173+ nodeJsonMap .replace ("jobContent" , nodeExportContent );
174+ appConnNode .setJobContent (nodeExportContent );
175+ return BDPJettyServerHelper .jacksonJson ().writeValueAsString (nodeJsonMap );
171176 }
172- nodeJsonMap .replace ("jobContent" , nodeExportContent );
173- appConnNode .setJobContent (nodeExportContent );
174- return BDPJettyServerHelper .jacksonJson ().writeValueAsString (nodeJsonMap );
175177 }
176178 } else {
177179 logger .warn ("appConn node resource file does not exists. nodeId: {}" + nodeId );
@@ -209,34 +211,35 @@ public String uploadAppConnResource(String userName, String projectName, DSSFlow
209211 logger .info ("nodeResourcePath:{}" , nodeResourcePath );
210212 File file = new File (nodeResourcePath );
211213 if (file .exists ()) {
212- InputStream resourceInputStream = bmlService .readLocalResourceFile (userName , nodeResourcePath );
213- Supplier <Map <String , Object >> bmlResourceMap = () -> {
214- BmlResource resource = bmlService .upload (userName , resourceInputStream , UUID .randomUUID ().toString () + ".json" ,
215- projectName );
216- return ImmutableMap .of (
217- "resourceId" , resource .getResourceId (),
218- "version" , resource .getVersion ()
219- );
220- };
221- Supplier <Map <String , Object >> streamResourceMap = () -> MapUtils .newCommonMap (ImportRequestRef .INPUT_STREAM_KEY , resourceInputStream );
222- try {
223- nodeExportContent = nodeService .importNode (userName , appConnNode , bmlResourceMap , streamResourceMap , orcVersion );
224- } catch (ExternalOperationFailedException e ) {
225- logger .error ("failed to import node." , e );
226- throw new DSSRuntimeException (e .getErrCode (), e .getMessage ());
227- } catch (Exception e ) {
228- logger .error ("failed to import node." , e );
229- throw new DSSRuntimeException (90011 , e .getMessage ());
230- }
231- if (nodeExportContent != null ) {
232- if (nodeExportContent .get ("project_id" ) != null ) {
233- Long newProjectId = Long .parseLong (nodeExportContent .get ("project_id" ).toString ());
234- logger .warn (String .format ("new appConn node add into dss,dssProjectId: %s,newProjectId: %s" , appConnNode .getProjectId (), newProjectId ));
235- nodeExportContent .remove ("project_id" );
214+ try (InputStream resourceInputStream = bmlService .readLocalResourceFile (userName , nodeResourcePath )) {
215+ Supplier <Map <String , Object >> bmlResourceMap = () -> {
216+ BmlResource resource = bmlService .upload (userName , resourceInputStream , UUID .randomUUID ().toString () + ".json" ,
217+ projectName );
218+ return ImmutableMap .of (
219+ "resourceId" , resource .getResourceId (),
220+ "version" , resource .getVersion ()
221+ );
222+ };
223+ Supplier <Map <String , Object >> streamResourceMap = () -> MapUtils .newCommonMap (ImportRequestRef .INPUT_STREAM_KEY , resourceInputStream );
224+ try {
225+ nodeExportContent = nodeService .importNode (userName , appConnNode , bmlResourceMap , streamResourceMap , orcVersion );
226+ } catch (ExternalOperationFailedException e ) {
227+ logger .error ("failed to import node." , e );
228+ throw new DSSRuntimeException (e .getErrCode (), e .getMessage ());
229+ } catch (Exception e ) {
230+ logger .error ("failed to import node." , e );
231+ throw new DSSRuntimeException (90011 , e .getMessage ());
232+ }
233+ if (nodeExportContent != null ) {
234+ if (nodeExportContent .get ("project_id" ) != null ) {
235+ Long newProjectId = Long .parseLong (nodeExportContent .get ("project_id" ).toString ());
236+ logger .warn (String .format ("new appConn node add into dss,dssProjectId: %s,newProjectId: %s" , appConnNode .getProjectId (), newProjectId ));
237+ nodeExportContent .remove ("project_id" );
238+ }
239+ nodeJsonMap .replace ("jobContent" , nodeExportContent );
240+ appConnNode .setJobContent (nodeExportContent );
241+ return BDPJettyServerHelper .jacksonJson ().writeValueAsString (nodeJsonMap );
236242 }
237- nodeJsonMap .replace ("jobContent" , nodeExportContent );
238- appConnNode .setJobContent (nodeExportContent );
239- return BDPJettyServerHelper .jacksonJson ().writeValueAsString (nodeJsonMap );
240243 }
241244 } else {
242245 logger .warn ("appConn node resource file does not exists. nodeId: {}" + nodeId );
0 commit comments