use of com.emc.storageos.model.tenant.TenantOrgRestRep in project coprhd-controller by CoprHD.
the class VCenters method getVcenterTenantOptions.
public static void getVcenterTenantOptions(String id) {
List<TenantOrgRestRep> vCenterTenantOptions = new ArrayList<TenantOrgRestRep>();
if (StringUtils.isBlank(id) || id.equalsIgnoreCase("null")) {
renderJSON(vCenterTenantOptions);
return;
}
List<ACLEntry> vcenterAcls = VCenterUtils.getAcl(uri(id));
if (CollectionUtils.isEmpty(vcenterAcls)) {
renderJSON(vCenterTenantOptions);
return;
}
addNoneTenantOption(id, vCenterTenantOptions);
Iterator<ACLEntry> aclEntryIterator = vcenterAcls.iterator();
while (aclEntryIterator.hasNext()) {
ACLEntry aclEntry = aclEntryIterator.next();
if (aclEntry == null) {
continue;
}
TenantOrgRestRep tenantOrgRestRep = TenantUtils.getTenant(aclEntry.getTenant());
if (tenantOrgRestRep != null) {
vCenterTenantOptions.add(tenantOrgRestRep);
}
}
renderJSON(vCenterTenantOptions);
}
use of com.emc.storageos.model.tenant.TenantOrgRestRep in project coprhd-controller by CoprHD.
the class TenantUtils method findRootTenant.
public static TenantOrgRestRep findRootTenant() {
URI userTenantId = getViprClient().getUserTenantId();
TenantOrgRestRep currentTenant = getViprClient().tenants().get(userTenantId);
while (currentTenant.getParentTenant() != null) {
currentTenant = getViprClient().tenants().get(currentTenant.getParentTenant());
}
return currentTenant;
}
use of com.emc.storageos.model.tenant.TenantOrgRestRep in project coprhd-controller by CoprHD.
the class TenantsCall method call.
@Override
public List<TenantOrgRestRep> call() {
List<TenantOrgRestRep> tenants = Lists.newArrayList();
TenantOrgRestRep rootTenant = findRootTenant();
tenants.add(rootTenant);
tenants.addAll(getSubTenants(id(rootTenant)));
return tenants;
}
use of com.emc.storageos.model.tenant.TenantOrgRestRep in project coprhd-controller by CoprHD.
the class MarshallUtil method convertTenantUserMappingToString.
/**
* leveraging TenantOrgRestRep's JAXB representation, converts given tenant's user-mapping to a string.
*
* @param tenant
* @return
* @throws Exception
*/
public static String convertTenantUserMappingToString(TenantOrg tenant) throws Exception {
TenantOrgRestRep response = new TenantOrgRestRep();
if (tenant.getUserMappings() != null) {
for (AbstractChangeTrackingSet<String> userMappingSet : tenant.getUserMappings().values()) {
for (String existingMapping : userMappingSet) {
response.getUserMappings().add(BasePermissionsHelper.UserMapping.toParam(BasePermissionsHelper.UserMapping.fromString(existingMapping)));
}
}
}
StringWriter writer = new StringWriter();
JAXBContext jaxbContext = JAXBContext.newInstance(TenantOrgRestRep.class);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
jaxbMarshaller.marshal(response, writer);
return writer.toString();
}
use of com.emc.storageos.model.tenant.TenantOrgRestRep in project coprhd-controller by CoprHD.
the class MarshallUtil method convertStringToUserMappingList.
/**
* leveraging TenantOrgRestRep's JAXB representation, converting its string to List of UserMapping object.
*
* @param strUserMappings
* @return
*/
public static List<BasePermissionsHelper.UserMapping> convertStringToUserMappingList(String strUserMappings) {
List<BasePermissionsHelper.UserMapping> userMappingList = null;
try {
JAXBContext jaxbContext = JAXBContext.newInstance(TenantOrgRestRep.class);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
TenantOrgRestRep response = (TenantOrgRestRep) unmarshaller.unmarshal(new StringReader(strUserMappings));
userMappingList = BasePermissionsHelper.UserMapping.fromParamList(response.getUserMappings());
} catch (JAXBException e) {
log.error("An error occurred when converting string {} to list. Cause: {}", strUserMappings, e);
}
return userMappingList;
}
Aggregations