/** * @return whether a stored resource state exists for the given resource */ protected boolean doesStorageExist(final StorageAwareResource resource) { final ResourceStorageProviderAdapter stateProvider = IterableExtensions.<ResourceStorageProviderAdapter>head(Iterables.<ResourceStorageProviderAdapter>filter(resource.getResourceSet().eAdapters(), ResourceStorageProviderAdapter.class)); if (((stateProvider != null) && (stateProvider.getResourceStorageLoadable(resource) != null))) { return true; } boolean _exists = resource.getResourceSet().getURIConverter().exists(this.getBinaryStorageURI(resource.getURI()), CollectionLiterals.<Object, Object>emptyMap()); if (_exists) { return true; } boolean _isArchive = resource.getURI().isArchive(); if (_isArchive) { return false; } final AbstractFileSystemAccess2 fsa = this.getFileSystemAccess(resource); final String outputRelativePath = this.computeOutputPath(resource); final URI uri = fsa.getURI(outputRelativePath); return ((uri != null) && resource.getResourceSet().getURIConverter().exists(uri, null)); }
private void configureFileSystemAccess(final File baseDir, AbstractFileSystemAccess2 fsa) { Set<OutputConfiguration> confsForFsa = Sets.newHashSet(); Set<OutputConfiguration> pomOutputConfigs = getConfiguredOutputConfigs(); if (pomOutputConfigs != null && !pomOutputConfigs.isEmpty()) { for (OutputConfiguration pomConfig : pomOutputConfigs) { if (getOutputConfigurationProvider().getOutputConfigurations().contains(pomConfig)) { confsForFsa.add(pomConfig); } else { LOG.warn("Output '" + pomConfig.getName() + "' is not configured in OutputConfigurationProvider. Used provider " + getOutputConfigurationProvider().getClass().getName()); } } } confsForFsa.addAll(getOutputConfigurationProvider().getOutputConfigurations()); Map<String, OutputConfiguration> asMap = IterableExtensions.toMap( Iterables.transform(confsForFsa, new Function<OutputConfiguration, OutputConfiguration>() { @Override public OutputConfiguration apply(OutputConfiguration output) { output.setOutputDirectory(resolveToBaseDir(output.getOutputDirectory(), baseDir)); for (SourceMapping sourceMapping : output.getSourceMappings()) { sourceMapping.setOutputDirectory(resolveToBaseDir(sourceMapping.getOutputDirectory(), baseDir)); } return output; } }), new Function1<OutputConfiguration, String>() { @Override public String apply(final OutputConfiguration it) { return it.getName(); } }); fsa.setOutputConfigurations(asMap); }
/** * Finds or creates a ResourceStorageLoadable for the given resource. * Clients should first call shouldLoadFromStorage to check whether there exists a storage version * of the given resource. * * @return an IResourceStorageLoadable */ @Override public ResourceStorageLoadable getOrCreateResourceStorageLoadable(final StorageAwareResource resource) { try { final ResourceStorageProviderAdapter stateProvider = IterableExtensions.<ResourceStorageProviderAdapter>head(Iterables.<ResourceStorageProviderAdapter>filter(resource.getResourceSet().eAdapters(), ResourceStorageProviderAdapter.class)); if ((stateProvider != null)) { final ResourceStorageLoadable inputStream = stateProvider.getResourceStorageLoadable(resource); if ((inputStream != null)) { return inputStream; } } InputStream _xifexpression = null; boolean _exists = resource.getResourceSet().getURIConverter().exists(this.getBinaryStorageURI(resource.getURI()), CollectionLiterals.<Object, Object>emptyMap()); if (_exists) { _xifexpression = resource.getResourceSet().getURIConverter().createInputStream(this.getBinaryStorageURI(resource.getURI())); } else { InputStream _xblockexpression = null; { final AbstractFileSystemAccess2 fsa = this.getFileSystemAccess(resource); final String outputRelativePath = this.computeOutputPath(resource); _xblockexpression = fsa.readBinaryFile(outputRelativePath); } _xifexpression = _xblockexpression; } final InputStream inputStream_1 = _xifexpression; return this.createResourceStorageLoadable(inputStream_1); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
protected AbstractFileSystemAccess2 getFileSystemAccess(final StorageAwareResource resource) { final AbstractFileSystemAccess2 fsa = this.fileSystemAccessProvider.get(); fsa.setContext(resource); final Function1<OutputConfiguration, String> _function = (OutputConfiguration it) -> { return it.getName(); }; fsa.setOutputConfigurations(IterableExtensions.<String, OutputConfiguration>toMap(this.outputConfigurationProvider.getOutputConfigurations(resource), _function)); return fsa; }
public Class<? extends AbstractFileSystemAccess2> bindAbstractFileSystemAccess2() { return JavaIoFileSystemAccess.class; }