private void validateResourceZip(App app) { FileMeta appZipMeta = app.getSourceFiles(); if (appZipMeta != null) { File fileStoreFile = fileStore.getFile(appZipMeta.getId()); if (fileStoreFile == null) { LOG.error("Resource zip '{}' for app '{}' missing in file store", appZipMeta.getId(), app.getName()); throw new RuntimeException("An error occurred trying to create or update app"); } ZipFile zipFile; try { zipFile = new ZipFile(fileStoreFile); } catch (ZipException e) { LOG.error("Error creating zip file object", e); throw new RuntimeException("An error occurred trying to create or update app"); } if (!zipFile.isValidZipFile()) { throw new MolgenisValidationException(new ConstraintViolation( String.format("'%s' is not a valid zip file.", appZipMeta.getFilename()))); } } } }
violations.add(new ConstraintViolation(message, attr.getName(), null, null, meta, 0)); if (violation.getRownr() > 0) violation.setImportInfo(String.format("Sheet: '%s', row: %d", repository.getName(), violation.getRownr() + 1)); violation.setImportInfo(String.format("Sheet: '%s'", repository.getName()));
for (ConstraintViolation violation : e.getViolations()) sb.append(violation.getMessage()); if (violation.getImportInfo() != null) sb.append(" ").append(violation.getImportInfo());
private void checkFeatureCanOnlyBelongToOneProtocolForOneDataSet() { // RULE: Feature can only belong to one Protocol in a DataSet. Check it (see issue #1136) Iterable<DataSet> dataSets = dataService.findAll(DataSet.ENTITY_NAME, DataSet.class); for (DataSet dataSet : dataSets) { List<Protocol> dataSetProtocols = ProtocolUtils.getProtocolDescendants(dataSet.getProtocolUsed(), true); for (Protocol protocol : dataSetProtocols) { for (ObservableFeature feature : protocol.getFeatures()) { for (Protocol p : dataSetProtocols) { if (!p.equals(protocol) && p.getFeatures().contains(feature)) { String message = String .format("An ObservableFeature can only belong to one Protocol but feature '%s' belongs to both '%s' and '%s'", feature.getIdentifier(), p.getIdentifier(), protocol.getIdentifier()); throw new MolgenisValidationException(Sets.newHashSet(new ConstraintViolation(message, feature.getIdentifier(), feature, null, null, 0))); } } } } } } }