Search in sources :

Example 1 with RequisitionImport

use of org.opennms.netmgt.provision.service.operations.RequisitionImport in project opennms by OpenNMS.

the class Provisioner method importModelFromResource.

/**
 * <p>importModelFromResource</p>
 *
 * @param resource a {@link org.springframework.core.io.Resource} object.
 * @param rescanExisting a {@link java.lang.String} object - Valid values are "true", "false" and "dbonly".
 * @param monitor a {@link org.opennms.netmgt.provision.service.operations.ProvisionMonitor} object.
 * @throws java.lang.Exception if any.
 */
protected void importModelFromResource(final Resource resource, final String rescanExisting, final ProvisionMonitor monitor) throws Exception {
    final LifeCycleInstance doImport = m_lifeCycleRepository.createLifeCycleInstance("import", m_importActivities);
    doImport.setAttribute("resource", resource);
    doImport.setAttribute("rescanExisting", rescanExisting);
    doImport.trigger();
    doImport.waitFor();
    final RequisitionImport ri = doImport.findAttributeByType(RequisitionImport.class);
    if (ri.isAborted()) {
        throw new ModelImportException("Import failed for resource " + resource.toString(), ri.getError());
    }
}
Also used : LifeCycleInstance(org.opennms.netmgt.provision.service.lifecycle.LifeCycleInstance) RequisitionImport(org.opennms.netmgt.provision.service.operations.RequisitionImport)

Example 2 with RequisitionImport

use of org.opennms.netmgt.provision.service.operations.RequisitionImport in project opennms by OpenNMS.

the class CoreImportActivities method loadSpecFile.

@Activity(lifecycle = "import", phase = "validate", schedulingHint = "import")
public RequisitionImport loadSpecFile(final Resource resource) {
    final RequisitionImport ri = new RequisitionImport();
    info("Loading requisition from resource {}", resource);
    try {
        final Requisition specFile = m_provisionService.loadRequisition(resource);
        ri.setRequisition(specFile);
        debug("Finished loading requisition.");
    } catch (final Throwable t) {
        ri.abort(t);
    }
    return ri;
}
Also used : RequisitionImport(org.opennms.netmgt.provision.service.operations.RequisitionImport) OnmsNodeRequisition(org.opennms.netmgt.provision.persist.OnmsNodeRequisition) Requisition(org.opennms.netmgt.provision.persist.requisition.Requisition) Activity(org.opennms.netmgt.provision.service.lifecycle.annotations.Activity)

Aggregations

RequisitionImport (org.opennms.netmgt.provision.service.operations.RequisitionImport)2 OnmsNodeRequisition (org.opennms.netmgt.provision.persist.OnmsNodeRequisition)1 Requisition (org.opennms.netmgt.provision.persist.requisition.Requisition)1 LifeCycleInstance (org.opennms.netmgt.provision.service.lifecycle.LifeCycleInstance)1 Activity (org.opennms.netmgt.provision.service.lifecycle.annotations.Activity)1