Search in sources :

Example 21 with Account

use of org.eclipse.kapua.service.account.Account in project kapua by eclipse.

the class GwtAccountServiceImpl method delete.

public void delete(GwtXSRFToken xsrfToken, GwtAccount gwtAccount) throws GwtKapuaException {
    // 
    // Checking validity of the given XSRF Token
    checkXSRFToken(xsrfToken);
    KapuaId kapuaId = KapuaEid.parseShortId(gwtAccount.getId());
    try {
        KapuaLocator locator = KapuaLocator.getInstance();
        AccountService accountService = locator.getService(AccountService.class);
        Account account = accountService.find(kapuaId);
        if (account != null) {
            accountService.delete(account.getScopeId(), account.getId());
        }
    } catch (Throwable t) {
        KapuaExceptionHandler.handle(t);
    }
}
Also used : KapuaLocator(org.eclipse.kapua.locator.KapuaLocator) Account(org.eclipse.kapua.service.account.Account) GwtAccount(org.eclipse.kapua.app.console.shared.model.GwtAccount) KapuaId(org.eclipse.kapua.model.id.KapuaId) AccountService(org.eclipse.kapua.service.account.AccountService) GwtAccountService(org.eclipse.kapua.app.console.shared.service.GwtAccountService)

Example 22 with Account

use of org.eclipse.kapua.service.account.Account in project kapua by eclipse.

the class GwtAccountServiceImpl method findChildren.

public ListLoadResult<GwtAccount> findChildren(String parentAccountId, boolean recoursive) throws GwtKapuaException {
    KapuaId scopeId = KapuaEid.parseShortId(parentAccountId);
    KapuaLocator locator = KapuaLocator.getInstance();
    AccountService accountService = locator.getService(AccountService.class);
    AccountFactory accountFactory = locator.getFactory(AccountFactory.class);
    List<GwtAccount> gwtAccountList = new ArrayList<GwtAccount>();
    try {
        AccountQuery query = accountFactory.newQuery(scopeId);
        KapuaListResult<Account> list = accountService.query(query);
        for (Account account : list.getItems()) {
            gwtAccountList.add(KapuaGwtConverter.convert(account));
        }
    } catch (Throwable t) {
        KapuaExceptionHandler.handle(t);
    }
    return new BaseListLoadResult<GwtAccount>(gwtAccountList);
}
Also used : BaseListLoadResult(com.extjs.gxt.ui.client.data.BaseListLoadResult) KapuaLocator(org.eclipse.kapua.locator.KapuaLocator) AccountFactory(org.eclipse.kapua.service.account.AccountFactory) Account(org.eclipse.kapua.service.account.Account) GwtAccount(org.eclipse.kapua.app.console.shared.model.GwtAccount) ArrayList(java.util.ArrayList) KapuaId(org.eclipse.kapua.model.id.KapuaId) GwtAccount(org.eclipse.kapua.app.console.shared.model.GwtAccount) AccountService(org.eclipse.kapua.service.account.AccountService) GwtAccountService(org.eclipse.kapua.app.console.shared.service.GwtAccountService) AccountQuery(org.eclipse.kapua.service.account.AccountQuery)

Example 23 with Account

use of org.eclipse.kapua.service.account.Account in project kapua by eclipse.

the class GwtAccountServiceImpl method getAccountInfo.

public ListLoadResult<GwtGroupedNVPair> getAccountInfo(String accountIdString) throws GwtKapuaException {
    KapuaId accountId = KapuaEid.parseShortId(accountIdString);
    KapuaLocator locator = KapuaLocator.getInstance();
    AccountService accountService = locator.getService(AccountService.class);
    List<GwtGroupedNVPair> accountPropertiesPairs = new ArrayList<GwtGroupedNVPair>();
    try {
        Account account = accountService.find(accountId);
        accountPropertiesPairs.add(new GwtGroupedNVPair("accountInfo", "accountName", account.getName()));
        accountPropertiesPairs.add(new GwtGroupedNVPair("accountInfo", "accountModifiedOn", account.getModifiedOn().toString()));
        accountPropertiesPairs.add(new GwtGroupedNVPair("accountInfo", "accountModifiedBy", account.getModifiedBy().getShortId()));
        accountPropertiesPairs.add(new GwtGroupedNVPair("accountInfo", "accountCreatedOn", account.getCreatedOn().toString()));
        accountPropertiesPairs.add(new GwtGroupedNVPair("accountInfo", "accountCreatedBy", account.getCreatedBy().getShortId()));
        accountPropertiesPairs.add(new GwtGroupedNVPair("deploymentInfo", "deploymentBrokerURL", SystemUtils.getBrokerURI().toString()));
        accountPropertiesPairs.add(new GwtGroupedNVPair("organizationInfo", "organizationName", account.getOrganization().getName()));
        accountPropertiesPairs.add(new GwtGroupedNVPair("organizationInfo", "organizationPersonName", account.getOrganization().getPersonName()));
        accountPropertiesPairs.add(new GwtGroupedNVPair("organizationInfo", "organizationEmail", account.getOrganization().getEmail()));
        accountPropertiesPairs.add(new GwtGroupedNVPair("organizationInfo", "organizationPhoneNumber", account.getOrganization().getPhoneNumber()));
        accountPropertiesPairs.add(new GwtGroupedNVPair("organizationInfo", "organizationAddress1", account.getOrganization().getAddressLine1()));
        accountPropertiesPairs.add(new GwtGroupedNVPair("organizationInfo", "organizationAddress2", account.getOrganization().getAddressLine2()));
        accountPropertiesPairs.add(new GwtGroupedNVPair("organizationInfo", "organizationZip", account.getOrganization().getZipPostCode()));
        accountPropertiesPairs.add(new GwtGroupedNVPair("organizationInfo", "organizationCity", account.getOrganization().getCity()));
        accountPropertiesPairs.add(new GwtGroupedNVPair("organizationInfo", "organizationState", account.getOrganization().getStateProvinceCounty()));
        accountPropertiesPairs.add(new GwtGroupedNVPair("organizationInfo", "organizationCountry", account.getOrganization().getCountry()));
    } catch (Throwable t) {
        KapuaExceptionHandler.handle(t);
    }
    return new BaseListLoadResult<GwtGroupedNVPair>(accountPropertiesPairs);
}
Also used : BaseListLoadResult(com.extjs.gxt.ui.client.data.BaseListLoadResult) KapuaLocator(org.eclipse.kapua.locator.KapuaLocator) Account(org.eclipse.kapua.service.account.Account) GwtAccount(org.eclipse.kapua.app.console.shared.model.GwtAccount) ArrayList(java.util.ArrayList) KapuaId(org.eclipse.kapua.model.id.KapuaId) AccountService(org.eclipse.kapua.service.account.AccountService) GwtAccountService(org.eclipse.kapua.app.console.shared.service.GwtAccountService) GwtGroupedNVPair(org.eclipse.kapua.app.console.shared.model.GwtGroupedNVPair)

Example 24 with Account

use of org.eclipse.kapua.service.account.Account in project kapua by eclipse.

the class GwtAccountServiceImpl method findAll.

public ListLoadResult<GwtAccount> findAll(String scopeIdString) throws GwtKapuaException {
    List<GwtAccount> gwtAccountList = new ArrayList<GwtAccount>();
    KapuaId scopeId = KapuaEid.parseShortId(scopeIdString);
    try {
        KapuaLocator locator = KapuaLocator.getInstance();
        AccountService accountService = locator.getService(AccountService.class);
        AccountFactory accountFactory = locator.getFactory(AccountFactory.class);
        AccountQuery query = accountFactory.newQuery(scopeId);
        KapuaListResult<Account> list = accountService.query(query);
        for (Account account : list.getItems()) {
            gwtAccountList.add(KapuaGwtConverter.convert(account));
        }
    } catch (Throwable t) {
        KapuaExceptionHandler.handle(t);
    }
    return new BaseListLoadResult<GwtAccount>(gwtAccountList);
}
Also used : BaseListLoadResult(com.extjs.gxt.ui.client.data.BaseListLoadResult) KapuaLocator(org.eclipse.kapua.locator.KapuaLocator) AccountFactory(org.eclipse.kapua.service.account.AccountFactory) Account(org.eclipse.kapua.service.account.Account) GwtAccount(org.eclipse.kapua.app.console.shared.model.GwtAccount) ArrayList(java.util.ArrayList) GwtAccount(org.eclipse.kapua.app.console.shared.model.GwtAccount) KapuaId(org.eclipse.kapua.model.id.KapuaId) AccountService(org.eclipse.kapua.service.account.AccountService) GwtAccountService(org.eclipse.kapua.app.console.shared.service.GwtAccountService) AccountQuery(org.eclipse.kapua.service.account.AccountQuery)

Example 25 with Account

use of org.eclipse.kapua.service.account.Account in project kapua by eclipse.

the class GwtAccountServiceImpl method findChildrenAsStrings.

public ListLoadResult<GwtAccountStringListItem> findChildrenAsStrings(String parentAccountId, boolean recoursive) throws GwtKapuaException {
    KapuaId scopeId = KapuaEid.parseShortId(parentAccountId);
    List<GwtAccountStringListItem> gwtAccountStrings = new ArrayList<GwtAccountStringListItem>();
    KapuaLocator locator = KapuaLocator.getInstance();
    AccountService accountService = locator.getService(AccountService.class);
    AccountListResult list;
    try {
        list = accountService.findChildsRecursively(scopeId);
        for (Account account : list.getItems()) {
            GwtAccountStringListItem item = new GwtAccountStringListItem();
            item.setId(account.getId().getShortId());
            item.setValue(account.getName());
            // FIXME: add check to see if account has or noe childs
            item.setHasChildAccount(false);
            gwtAccountStrings.add(item);
        }
    } catch (Throwable t) {
        KapuaExceptionHandler.handle(t);
    }
    return new BaseListLoadResult<GwtAccountStringListItem>(gwtAccountStrings);
}
Also used : BaseListLoadResult(com.extjs.gxt.ui.client.data.BaseListLoadResult) KapuaLocator(org.eclipse.kapua.locator.KapuaLocator) Account(org.eclipse.kapua.service.account.Account) GwtAccount(org.eclipse.kapua.app.console.shared.model.GwtAccount) ArrayList(java.util.ArrayList) AccountListResult(org.eclipse.kapua.service.account.AccountListResult) KapuaId(org.eclipse.kapua.model.id.KapuaId) AccountService(org.eclipse.kapua.service.account.AccountService) GwtAccountService(org.eclipse.kapua.app.console.shared.service.GwtAccountService) GwtAccountStringListItem(org.eclipse.kapua.app.console.shared.model.GwtAccountStringListItem)

Aggregations

Account (org.eclipse.kapua.service.account.Account)42 KapuaLocator (org.eclipse.kapua.locator.KapuaLocator)37 AccountService (org.eclipse.kapua.service.account.AccountService)31 KapuaId (org.eclipse.kapua.model.id.KapuaId)14 KapuaEntityNotFoundException (org.eclipse.kapua.KapuaEntityNotFoundException)12 Device (org.eclipse.kapua.service.device.registry.Device)11 DeviceRegistryService (org.eclipse.kapua.service.device.registry.DeviceRegistryService)11 KapuaException (org.eclipse.kapua.KapuaException)10 GwtAccount (org.eclipse.kapua.app.console.shared.model.GwtAccount)10 KapuaIllegalAccessException (org.eclipse.kapua.KapuaIllegalAccessException)9 GwtAccountService (org.eclipse.kapua.app.console.shared.service.GwtAccountService)9 KapuaIllegalArgumentException (org.eclipse.kapua.KapuaIllegalArgumentException)8 EntityManager (org.eclipse.kapua.commons.jpa.EntityManager)8 AuthorizationService (org.eclipse.kapua.service.authorization.AuthorizationService)7 PermissionFactory (org.eclipse.kapua.service.authorization.permission.PermissionFactory)7 Date (java.util.Date)5 AccountCreator (org.eclipse.kapua.service.account.AccountCreator)5 KuraRequestChannel (org.eclipse.kapua.service.device.call.message.app.request.kura.KuraRequestChannel)5 KuraRequestMessage (org.eclipse.kapua.service.device.call.message.app.request.kura.KuraRequestMessage)5 KuraRequestPayload (org.eclipse.kapua.service.device.call.message.app.request.kura.KuraRequestPayload)5