Search in sources :

Example 1 with VaultFile

use of com.runwaysdk.system.VaultFile in project geoprism-registry by terraframe.

the class ChangeRequest method delete.

@Override
public void delete() {
    List<? extends AbstractAction> actions = this.getOrderedActions();
    for (AbstractAction action : actions) {
        action.delete();
    }
    OIterator<? extends ChangeRequestHasDocument> it = this.getAllDocumentRel();
    for (ChangeRequestHasDocument rel : it) {
        VaultFile vf = rel.getChild();
        rel.delete();
        vf.delete();
    }
    super.delete();
}
Also used : VaultFile(com.runwaysdk.system.VaultFile)

Example 2 with VaultFile

use of com.runwaysdk.system.VaultFile in project geoprism-registry by terraframe.

the class ETLService method reImportInTrans.

@Transaction
public void reImportInTrans(MultipartFileParameter file, String json) {
    ImportConfiguration config = ImportConfiguration.build(json);
    ImportHistory hist = ImportHistory.get(config.getHistoryId());
    hist.getConfig().enforceExecutePermissions();
    VaultFile vf = VaultFile.get(config.getVaultFileId());
    vf.delete();
    VaultFile vf2 = null;
    try (InputStream is = file.getInputStream()) {
        vf2 = VaultFile.createAndApply(file.getFilename(), is);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    config.setVaultFileId(vf2.getOid());
    config.setFileName(file.getFilename());
    hist = ImportHistory.lock(config.getHistoryId());
    hist.setImportFile(vf2);
    hist.setConfigJson(config.toJSON().toString());
    hist.apply();
}
Also used : InputStream(java.io.InputStream) VaultFile(com.runwaysdk.system.VaultFile) GeoObjectImportConfiguration(net.geoprism.registry.io.GeoObjectImportConfiguration) ImportConfiguration(net.geoprism.registry.etl.upload.ImportConfiguration) IOException(java.io.IOException) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 3 with VaultFile

use of com.runwaysdk.system.VaultFile in project geoprism-registry by terraframe.

the class ChangeRequestService method uploadFileInTransactionCR.

@Transaction
String uploadFileInTransactionCR(String requestId, String fileName, InputStream fileStream) {
    ChangeRequest request = ChangeRequest.get(requestId);
    if (!this.permService.getPermissions(request).contains(ChangeRequestPermissionAction.WRITE_DOCUMENTS)) {
        throw new CGRPermissionException();
    }
    VaultFile vf = VaultFile.createAndApply(fileName, fileStream);
    request.addDocument(vf).apply();
    JsonObject jo = new JsonObject();
    jo.addProperty("fileName", vf.getName());
    jo.addProperty("oid", vf.getOid());
    jo.addProperty("requestId", requestId);
    return jo.toString();
}
Also used : CGRPermissionException(net.geoprism.registry.CGRPermissionException) VaultFile(com.runwaysdk.system.VaultFile) JsonObject(com.google.gson.JsonObject) ChangeRequest(net.geoprism.registry.action.ChangeRequest) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 4 with VaultFile

use of com.runwaysdk.system.VaultFile in project geoprism-registry by terraframe.

the class ChangeRequestService method listDocumentsCR.

String listDocumentsCR(String requestId) {
    JsonArray ja = new JsonArray();
    ChangeRequest request = ChangeRequest.get(requestId);
    if (!this.permService.getPermissions(request).contains(ChangeRequestPermissionAction.READ_DOCUMENTS)) {
        throw new CGRPermissionException();
    }
    OIterator<? extends VaultFile> it = request.getAllDocument();
    try {
        for (VaultFile vf : it) {
            JsonObject jo = new JsonObject();
            jo.addProperty("fileName", vf.getName());
            jo.addProperty("oid", vf.getOid());
            jo.addProperty("requestId", requestId);
            ja.add(jo);
        }
    } finally {
        it.close();
    }
    return ja.toString();
}
Also used : JsonArray(com.google.gson.JsonArray) CGRPermissionException(net.geoprism.registry.CGRPermissionException) VaultFile(com.runwaysdk.system.VaultFile) JsonObject(com.google.gson.JsonObject) ChangeRequest(net.geoprism.registry.action.ChangeRequest)

Example 5 with VaultFile

use of com.runwaysdk.system.VaultFile in project geoprism-registry by terraframe.

the class ChangeRequestService method downloadDocumentCR.

ApplicationResource downloadDocumentCR(String crOid, String vfOid) {
    ChangeRequest request = ChangeRequest.get(crOid);
    if (!this.permService.getPermissions(request).contains(ChangeRequestPermissionAction.READ_DOCUMENTS)) {
        throw new CGRPermissionException();
    }
    VaultFile vf = VaultFile.get(vfOid);
    return vf;
}
Also used : CGRPermissionException(net.geoprism.registry.CGRPermissionException) VaultFile(com.runwaysdk.system.VaultFile) ChangeRequest(net.geoprism.registry.action.ChangeRequest)

Aggregations

VaultFile (com.runwaysdk.system.VaultFile)10 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)4 CGRPermissionException (net.geoprism.registry.CGRPermissionException)4 ChangeRequest (net.geoprism.registry.action.ChangeRequest)4 RunwayException (com.runwaysdk.RunwayException)3 SmartException (com.runwaysdk.business.SmartException)3 ProgrammingErrorException (com.runwaysdk.dataaccess.ProgrammingErrorException)3 InputStream (java.io.InputStream)3 SimpleDateFormat (java.text.SimpleDateFormat)3 JSONObject (org.json.JSONObject)3 JsonObject (com.google.gson.JsonObject)2 IOException (java.io.IOException)2 ExcelDataFormatter (net.geoprism.data.etl.excel.ExcelDataFormatter)2 ExcelSheetReader (net.geoprism.data.etl.excel.ExcelSheetReader)2 InvalidExcelFileException (net.geoprism.data.etl.excel.InvalidExcelFileException)2 ExcelFieldContentsHandler (net.geoprism.registry.excel.ExcelFieldContentsHandler)2 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)2 InvalidFormatException (org.apache.poi.openxml4j.exceptions.InvalidFormatException)2 JsonArray (com.google.gson.JsonArray)1 QueryFactory (com.runwaysdk.query.QueryFactory)1