Search in sources :

Example 6 with TenantModuleDescriptor

use of org.folio.okapi.bean.TenantModuleDescriptor in project okapi by folio-org.

the class InternalModule method getModuleForTenant.

private void getModuleForTenant(String id, String mod, Handler<ExtendedAsyncResult<String>> fut) {
    tenantManager.get(id, res -> {
        if (res.failed()) {
            fut.handle(new Failure<>(res.getType(), res.cause()));
            return;
        }
        Tenant t = res.result();
        // Convert the list of module names
        Set<String> ml = t.listModules();
        if (!ml.contains(mod)) {
            fut.handle(new Failure<>(NOT_FOUND, mod));
            return;
        }
        TenantModuleDescriptor tmd = new TenantModuleDescriptor();
        tmd.setId(mod);
        String s = Json.encodePrettily(tmd);
        fut.handle(new Success<>(s));
    });
}
Also used : TenantModuleDescriptor(org.folio.okapi.bean.TenantModuleDescriptor) Tenant(org.folio.okapi.bean.Tenant)

Example 7 with TenantModuleDescriptor

use of org.folio.okapi.bean.TenantModuleDescriptor in project okapi by folio-org.

the class InternalModule method listModulesForTenant.

private void listModulesForTenant(String id, Handler<ExtendedAsyncResult<String>> fut) {
    tenantManager.listModules(id, res -> {
        if (res.failed()) {
            fut.handle(new Failure<>(res.getType(), res.cause()));
            return;
        }
        List<String> ml = res.result();
        // into a list of objects
        Iterator<String> mli = ml.iterator();
        ArrayList<TenantModuleDescriptor> ta = new ArrayList<>();
        while (mli.hasNext()) {
            TenantModuleDescriptor tmd = new TenantModuleDescriptor();
            tmd.setId(mli.next());
            ta.add(tmd);
        }
        String s = Json.encodePrettily(ta);
        fut.handle(new Success<>(s));
    });
}
Also used : TenantModuleDescriptor(org.folio.okapi.bean.TenantModuleDescriptor) ArrayList(java.util.ArrayList)

Example 8 with TenantModuleDescriptor

use of org.folio.okapi.bean.TenantModuleDescriptor in project okapi by folio-org.

the class InternalModule method listModulesFromInterface.

private void listModulesFromInterface(ProxyContext pc, String id, String intId, Handler<ExtendedAsyncResult<String>> fut) {
    final String type = pc.getCtx().request().getParam("type");
    tenantManager.listModulesFromInterface(id, intId, type, res -> {
        if (res.failed()) {
            fut.handle(new Failure<>(res.getType(), res.cause()));
            return;
        }
        List<ModuleDescriptor> mdL = res.result();
        ArrayList<TenantModuleDescriptor> ta = new ArrayList<>();
        for (ModuleDescriptor md : mdL) {
            TenantModuleDescriptor tmd = new TenantModuleDescriptor();
            tmd.setId(md.getId());
            ta.add(tmd);
        }
        String s = Json.encodePrettily(ta);
        fut.handle(new Success<>(s));
    });
}
Also used : TenantModuleDescriptor(org.folio.okapi.bean.TenantModuleDescriptor) ModuleDescriptor(org.folio.okapi.bean.ModuleDescriptor) TenantModuleDescriptor(org.folio.okapi.bean.TenantModuleDescriptor) ArrayList(java.util.ArrayList)

Example 9 with TenantModuleDescriptor

use of org.folio.okapi.bean.TenantModuleDescriptor in project okapi by folio-org.

the class InternalModule method enableModuleForTenant.

private void enableModuleForTenant(ProxyContext pc, String id, String body, Handler<ExtendedAsyncResult<String>> fut) {
    try {
        final TenantModuleDescriptor td = Json.decodeValue(body, TenantModuleDescriptor.class);
        String moduleTo = td.getId();
        tenantManager.enableAndDisableModule(id, null, moduleTo, pc, eres -> {
            if (eres.failed()) {
                fut.handle(new Failure<>(eres.getType(), eres.cause()));
                return;
            }
            td.setId(eres.result());
            location(pc, td.getId(), null, Json.encodePrettily(td), fut);
        });
    } catch (DecodeException ex) {
        fut.handle(new Failure<>(USER, ex));
    }
}
Also used : TenantModuleDescriptor(org.folio.okapi.bean.TenantModuleDescriptor) DecodeException(io.vertx.core.json.DecodeException) Failure(org.folio.okapi.common.Failure)

Example 10 with TenantModuleDescriptor

use of org.folio.okapi.bean.TenantModuleDescriptor in project okapi by folio-org.

the class TenantManager method installCommit2.

/* phase 2 enable modules for tenant */
private void installCommit2(Tenant tenant, ProxyContext pc, TenantInstallOptions options, Map<String, ModuleDescriptor> modsAvailable, List<TenantModuleDescriptor> tml, Iterator<TenantModuleDescriptor> it, Handler<ExtendedAsyncResult<Void>> fut) {
    if (it.hasNext()) {
        TenantModuleDescriptor tm = it.next();
        ModuleDescriptor mdFrom = null;
        ModuleDescriptor mdTo = null;
        if ("enable".equals(tm.getAction())) {
            if (tm.getFrom() != null) {
                mdFrom = modsAvailable.get(tm.getFrom());
            }
            mdTo = modsAvailable.get(tm.getId());
        } else if ("disable".equals(tm.getAction())) {
            mdFrom = modsAvailable.get(tm.getId());
        }
        if (mdFrom == null && mdTo == null) {
            installCommit2(tenant, pc, options, modsAvailable, tml, it, fut);
        } else {
            ead1TenantInterface(tenant, mdFrom, mdTo, pc, res -> {
                if (res.failed()) {
                    fut.handle(new Failure<>(res.getType(), res.cause()));
                } else {
                    installCommit2(tenant, pc, options, modsAvailable, tml, it, fut);
                }
            });
        }
    } else {
        installCommit3(tenant, pc, options, modsAvailable, tml, tml.iterator(), fut);
    }
}
Also used : TenantModuleDescriptor(org.folio.okapi.bean.TenantModuleDescriptor) ModuleDescriptor(org.folio.okapi.bean.ModuleDescriptor) TenantModuleDescriptor(org.folio.okapi.bean.TenantModuleDescriptor)

Aggregations

TenantModuleDescriptor (org.folio.okapi.bean.TenantModuleDescriptor)17 ModuleDescriptor (org.folio.okapi.bean.ModuleDescriptor)9 LinkedList (java.util.LinkedList)4 InterfaceDescriptor (org.folio.okapi.bean.InterfaceDescriptor)4 DecodeException (io.vertx.core.json.DecodeException)3 Failure (org.folio.okapi.common.Failure)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Tenant (org.folio.okapi.bean.Tenant)2 ModuleId (org.folio.okapi.common.ModuleId)2 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 TenantInstallOptions (org.folio.okapi.util.TenantInstallOptions)1