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);
}
}
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);
}
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);
}
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);
}
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);
}
Aggregations