26
26
import org .apache .taverna .robundle .manifest .Agent ;
27
27
import org .apache .taverna .robundle .manifest .Manifest ;
28
28
import org .apache .taverna .robundle .manifest .PathMetadata ;
29
+ import org .apache .taverna .robundle .manifest .Proxy ;
29
30
import org .commonwl .viewer .services .GitHubService ;
30
31
import org .eclipse .egit .github .core .RepositoryContents ;
31
32
import org .slf4j .Logger ;
49
50
public class ROBundle {
50
51
51
52
private final Logger logger = LoggerFactory .getLogger (this .getClass ());
52
-
53
53
private GitHubService githubService ;
54
54
55
55
private Bundle bundle ;
@@ -139,36 +139,44 @@ private void addFiles(List<RepositoryContents> repoContents, Path path) throws I
139
139
} else if (repoContent .getType ().equals ("file" )) {
140
140
141
141
try {
142
- // Where to store the new file in bundle
143
- Path bundleFilePath = path .resolve (repoContent .getName ());
144
-
145
142
// Raw URI of the bundle
146
143
GithubDetails githubFile = new GithubDetails (githubInfo .getOwner (),
147
144
githubInfo .getRepoName (), githubInfo .getBranch (), repoContent .getPath ());
148
145
URI rawURI = new URI ("https://raw.githubusercontent.com/" + githubFile .getOwner () + "/" +
149
146
githubFile .getRepoName () + "/" + commitSha + "/" + githubFile .getPath ());
150
147
151
- // Variable to store file contents
148
+ // Variable to store file contents and aggregation
152
149
String fileContent = null ;
150
+ PathMetadata aggregation ;
153
151
154
152
// Download or externally link if oversized
155
153
if (repoContent .getSize () <= singleFileSizeLimit ) {
156
154
// Get the content of this file from Github
157
155
fileContent = githubService .downloadFile (githubFile , commitSha );
158
156
159
157
// Save file to research object bundle
158
+ Path bundleFilePath = path .resolve (repoContent .getName ());
160
159
Bundles .setStringValue (bundleFilePath , fileContent );
160
+
161
+ // Set retrieved information for this file in the manifest
162
+ aggregation = bundle .getManifest ().getAggregation (bundleFilePath );
163
+ aggregation .setRetrievedFrom (rawURI );
164
+ aggregation .setRetrievedBy (thisApp );
165
+ aggregation .setRetrievedOn (aggregation .getCreatedOn ());
161
166
} else {
162
- logger .info ("File " + repoContent .getName () + " is too large to download -" +
167
+ logger .info ("File " + repoContent .getName () + " is too large to download - " +
163
168
FileUtils .byteCountToDisplaySize (repoContent .getSize ()) + "/" +
164
169
FileUtils .byteCountToDisplaySize (singleFileSizeLimit ) +
165
- " + linking externally to RO bundle" );
166
- bundleFilePath = Bundles .setReference (bundleFilePath , rawURI );
170
+ ", linking externally to RO bundle" );
171
+
172
+ // Set information for this file in the manifest
173
+ aggregation = bundle .getManifest ().getAggregation (rawURI );
174
+ Proxy bundledAs = new Proxy ();
175
+ bundledAs .setURI ();
176
+ bundledAs .setFolder (path );
177
+ aggregation .setBundledAs (bundledAs );
167
178
}
168
179
169
- // Manifest aggregation
170
- PathMetadata aggregation = bundle .getManifest ().getAggregation (bundleFilePath );
171
-
172
180
// Special handling for cwl files
173
181
if (FilenameUtils .getExtension (repoContent .getName ()).equals ("cwl" )) {
174
182
// Correct mime type (no official standard for yaml)
@@ -188,11 +196,6 @@ private void addFiles(List<RepositoryContents> repoContents, Path path) throws I
188
196
authors .addAll (fileAuthors );
189
197
aggregation .setAuthoredBy (new ArrayList <Agent >(fileAuthors ));
190
198
191
- // Set retrieved information for this file in the manifest
192
- aggregation .setRetrievedFrom (rawURI );
193
- aggregation .setRetrievedBy (thisApp );
194
- aggregation .setRetrievedOn (aggregation .getCreatedOn ());
195
-
196
199
} catch (URISyntaxException ex ) {
197
200
logger .error ("Error creating URI for RO Bundle" , ex );
198
201
}
0 commit comments