@@ -74,7 +74,7 @@ private List<Resource> findResources(String basePath, String... paths) throws IO
7474 return list ;
7575 }
7676
77- protected void loadFile (String uri , InputStream inputStream , AppConfig config ) throws IOException {
77+ protected Content prepContent (String uri , InputStream inputStream , AppConfig config ) throws IOException {
7878 ContentCreateOptions options = new ContentCreateOptions ();
7979 options .setFormat (documentFormatGetter .getDocumentFormat (new File (uri )));
8080 options .setPermissions (permissionsParser .parsePermissions (this .permissions ));
@@ -95,11 +95,7 @@ protected void loadFile(String uri, InputStream inputStream, AppConfig config) t
9595 }
9696
9797 Content content = ContentFactory .newContent (uri , fileContents , options );
98- try {
99- activeSession .insertContent (content );
100- } catch (RequestException re ) {
101- throw new RuntimeException ("Unable to insert content at URI: " + uri + "; cause: " + re .getMessage (), re );
102- }
98+ return content ;
10399 }
104100
105101 protected void initializeActiveSession (CommandContext context ) {
@@ -110,7 +106,6 @@ protected void initializeActiveSession(CommandContext context) {
110106 ContentSource cs = ContentSourceFactory .newContentSource (config .getHost (), port , config .getRestAdminUsername (), config .getRestAdminPassword (), config .getModulesDatabaseName (),
111107 securityOptions );
112108 activeSession = cs .newSession ();
113- activeSession .setTransactionMode (TransactionMode .UPDATE );
114109 }
115110
116111 @ Override
@@ -125,6 +120,7 @@ public void execute(CommandContext context) {
125120 classpaths .add ("/com.marklogic.hub/**/*.x??" );
126121 classpaths .add ("/trace-ui/**/*" );
127122
123+ ArrayList <Content > content = new ArrayList <Content >();
128124 for (String classpath : classpaths ) {
129125 List <Resource > resources = findResources ("classpath*:" + rootPath , classpath );
130126 for (Resource r : resources ) {
@@ -146,10 +142,13 @@ public void execute(CommandContext context) {
146142 }
147143 }
148144
149- loadFile ( path , r .getInputStream (), appConfig );
145+ content . add ( prepContent ( path , r .getInputStream (), appConfig ) );
150146 }
151147 }
152- activeSession .commit ();
148+
149+ if (content .size () > 0 ) {
150+ activeSession .insertContent (content .toArray (new Content [0 ]));
151+ }
153152
154153 logger .info ("Loading Service Extensions" );
155154 long startTime = System .nanoTime ();
0 commit comments