use of org.finos.legend.pure.m3.serialization.filesystem.usercodestorage.RepositoryCodeStorage in project legend-pure by finos.
the class PureCodeStorage method writeContent.
@Override
public void writeContent(String path, String content) {
// Special case: /welcome.pure
if (isWelcomePath(path)) {
if (!hasRootPath()) {
throw new RuntimeException("Error trying to write content to " + path + ": no such file");
}
try {
Files.write(resolveWelcomePath(), content.getBytes(StandardCharsets.UTF_8));
return;
} catch (IOException e) {
throw new RuntimeException("Error trying to write content to " + path, e);
}
}
// General case
RepositoryCodeStorage codeStorage = getCodeStorage(path);
if (!(codeStorage instanceof MutableRepositoryCodeStorage)) {
throw new IllegalArgumentException("Cannot write content to '" + path + "'");
}
((MutableRepositoryCodeStorage) codeStorage).writeContent(path, content);
}
use of org.finos.legend.pure.m3.serialization.filesystem.usercodestorage.RepositoryCodeStorage in project legend-pure by finos.
the class PureCodeStorage method cleanup.
@Override
public void cleanup() {
MutableList<Exception> exceptions = Lists.mutable.empty();
for (RepositoryCodeStorage codeStorage : this.codeStorages) {
if (codeStorage instanceof MutableVersionControlledCodeStorage) {
try {
((MutableVersionControlledCodeStorage) codeStorage).cleanup();
} catch (Exception e) {
exceptions.add(e);
}
}
}
if (exceptions.size() == 1) {
Exception e = exceptions.get(0);
if (e instanceof PureVCSException) {
throw (PureVCSException) e;
}
throw new PureVCSException("Error performing cleanup", e);
}
if (exceptions.size() > 1) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
pw.println("Multiple errors occurred during cleanup:");
for (Exception e : exceptions) {
pw.println("------");
e.printStackTrace(pw);
}
pw.println("------");
pw.flush();
throw new PureVCSException(sw.toString());
}
}
use of org.finos.legend.pure.m3.serialization.filesystem.usercodestorage.RepositoryCodeStorage in project legend-pure by finos.
the class PureCodeStorage method deleteFile.
@Override
public void deleteFile(String path) {
RepositoryCodeStorage codeStorage = getCodeStorage(path);
if (!(codeStorage instanceof MutableRepositoryCodeStorage)) {
throw new IllegalArgumentException("Cannot delete file " + path);
}
((MutableRepositoryCodeStorage) codeStorage).deleteFile(path);
}
use of org.finos.legend.pure.m3.serialization.filesystem.usercodestorage.RepositoryCodeStorage in project legend-pure by finos.
the class PureCodeStorage method createFile.
@Override
public void createFile(String path) {
RepositoryCodeStorage codeStorage = getCodeStorage(path);
if (!(codeStorage instanceof MutableRepositoryCodeStorage)) {
throw new IllegalArgumentException("Cannot create file " + path);
}
((MutableRepositoryCodeStorage) codeStorage).createFile(path);
}
use of org.finos.legend.pure.m3.serialization.filesystem.usercodestorage.RepositoryCodeStorage in project legend-pure by finos.
the class PureCodeStorage method createFolder.
@Override
public void createFolder(String path) {
RepositoryCodeStorage codeStorage = getCodeStorage(path);
if (!(codeStorage instanceof MutableRepositoryCodeStorage)) {
throw new IllegalArgumentException("Cannot create folder " + path);
}
((MutableRepositoryCodeStorage) codeStorage).createFolder(path);
}
Aggregations