use of org.n52.faroe.ConfigurationError in project arctic-sea by 52North.
the class OwsServiceIdentificationFactory method setAbstract.
@Setting(OwsServiceIdentificationFactorySettings.ABSTRACT)
public void setAbstract(Object description) throws ConfigurationError {
Validation.notNull("Service Identification Abstract", description);
if (description instanceof MultilingualString) {
this.abstrakt = (MultilingualString) description;
} else if (description instanceof String) {
this.abstrakt = createFromString(description);
} else {
throw new ConfigurationError(String.format("%s is not supported as abstract!", description.getClass().getName()));
}
setRecreate();
}
use of org.n52.faroe.ConfigurationError in project arctic-sea by 52North.
the class OwsServiceIdentificationFactory method setTitle.
@Setting(OwsServiceIdentificationFactorySettings.TITLE)
public void setTitle(Object title) throws ConfigurationError {
Validation.notNull("Service Identification Title", title);
if (title instanceof MultilingualString) {
this.title = (MultilingualString) title;
} else if (title instanceof String) {
this.title = createFromString(title);
} else {
throw new ConfigurationError(String.format("%s is not supported as title!", title.getClass().getName()));
}
setRecreate();
}
use of org.n52.faroe.ConfigurationError in project arctic-sea by 52North.
the class ElasticsearchAdminHandler method addUuidToMetadataIfNeeded.
@SuppressWarnings("unchecked")
private void addUuidToMetadataIfNeeded(String uuid) throws ElasticsearchException {
GetResponse resp = client.prepareGet(settings.getIndexId(), MetadataDataMapping.METADATA_TYPE_NAME, MetadataDataMapping.METADATA_ROW_ID).setOperationThreaded(false).get();
Object retValues = resp.getSourceAsMap().get(MetadataDataMapping.METADATA_UUIDS_FIELD.getName());
List<String> values;
if (retValues instanceof String) {
values = new LinkedList<>();
values.add((String) retValues);
} else if (retValues instanceof List<?>) {
values = (List<String>) retValues;
} else {
throw new ConfigurationError("Invalid %s field type %s should have String or java.util.Collection<String>", MetadataDataMapping.METADATA_UUIDS_FIELD, retValues.getClass());
}
// add new uuid if needed
if (!values.stream().anyMatch(m -> m.equals(uuid))) {
Map<String, Object> uuids = new HashMap<>();
values.add(uuid);
uuids.put(MetadataDataMapping.METADATA_UUIDS_FIELD.getName(), values);
uuids.put(MetadataDataMapping.METADATA_UPDATE_TIME_FIELD.getName(), Calendar.getInstance(DateTimeZone.UTC.toTimeZone()));
client.prepareUpdate(settings.getIndexId(), MetadataDataMapping.METADATA_TYPE_NAME, "1").setDoc(uuids).get();
logger.info("UUID {} is added to the {} type", uuid, MetadataDataMapping.METADATA_TYPE_NAME);
}
}
use of org.n52.faroe.ConfigurationError in project arctic-sea by 52North.
the class ElasticsearchAdminHandler method createSchema.
@Override
public synchronized void createSchema() {
IndicesAdminClient indices = client.admin().indices();
if (indices.prepareExists(settings.getIndexId()).get().isExists()) {
logger.info("Index {} already exists", settings.getIndexId());
// update mapping
Integer version = getCurrentVersion();
logger.info("Elasticsearch schema version is {}", version);
if (version == null) {
throw new ConfigurationError("Database inconsistency. Metadata version not found in type %s", MetadataDataMapping.METADATA_TYPE_NAME);
}
if (version != schemas.getSchemaVersion()) {
throw new ConfigurationError("Database schema version inconsistency. Version numbers don't match. " + "Database version number %d <-> Application version number %d", version, schemas.getSchemaVersion());
}
addUuidToMetadataIfNeeded(settings.getUuid());
} else {
logger.info("Index {} not exists creating a new one now.", settings.getIndexId());
// create metadata table and index table table
CreateIndexResponse response = indices.prepareCreate(settings.getIndexId()).addMapping(MetadataDataMapping.METADATA_TYPE_NAME, schemas.getMetadataSchema()).addMapping(settings.getTypeId(), schemas.getSchema()).get();
logger.debug("Created indices: {}", response);
// insert metadata values
createMetadataType(schemas.getSchemaVersion());
}
}
use of org.n52.faroe.ConfigurationError in project arctic-sea by 52North.
the class AbstractPropertyFileHandler method save.
public void save(String m, String value) throws ConfigurationError {
lock.writeLock().lock();
try {
Properties p = load();
p.setProperty(m, value);
save(p);
} catch (IOException e) {
throw new ConfigurationError(ERROR_WRITING_MESSAGE, e);
} finally {
lock.writeLock().unlock();
}
}
Aggregations