public CloudFoundrySpace(CloudSpace space) { this(space.getOrganization().getName(), space.getName()); this.space = space; }
private CloudSpace createDummySpace(Pair<String, String> orgAndSpace) { CloudOrganization org = createDummyOrg(orgAndSpace._1); return new CloudSpace(null, orgAndSpace._2, org); }
private boolean isSameSpace(CloudSpace space, String spaceId) { return space.getMeta() .getGuid() .toString() .equals(spaceId); }
@Override public List<CloudDomain> getDomainsForOrg() { assertSpaceProvided("access organization domains"); return doGetDomains(sessionSpace.getOrganization()); }
private List<UUID> getSpaceUserGuids(String orgName, String spaceName, String urlPath) { if (orgName == null || spaceName == null) { assertSpaceProvided("get space users"); } UUID spaceGuid; if (spaceName == null) { spaceGuid = sessionSpace.getMeta().getGuid(); } else { CloudOrganization organization = (orgName == null ? sessionSpace.getOrganization() : getOrgByName(orgName, true)); spaceGuid = getSpaceGuid(spaceName, organization.getMeta().getGuid()); } Map<String, Object> urlVars = new HashMap<String, Object>(); urlVars.put("guid", spaceGuid); List<UUID> managersGuid = new ArrayList<UUID>(); List<Map<String, Object>> resourceList = getAllResources(urlPath, urlVars); for (Map<String, Object> resource : resourceList) { UUID userGuid = resourceMapper.getGuidOfResource(resource); managersGuid.add(userGuid); } return managersGuid; }
public CloudSpace getSpace(String orgName, String spaceName) { List<CloudSpace> oSpaces = orgIDtoSpaces.get(orgName); if (oSpaces != null) { for (CloudSpace clSpace : oSpaces) { if (clSpace.getName().equals(spaceName)) { return clSpace; } } } return null; }
protected void setValues() { orgIDtoSpaces = new HashMap<String, List<CloudSpace>>(); orgIDtoOrg = new HashMap<String, CloudOrganization>(); // Parse the orgs and restructure the spaces per org for quick lookup, // as the original list of spaces is flat and does // not convey the org -> spaces structure. for (CloudSpace clSpace : originalSpaces) { CloudOrganization org = clSpace.getOrganization(); List<CloudSpace> spaces = orgIDtoSpaces.get(org.getName()); if (spaces == null) { spaces = new ArrayList<CloudSpace>(); orgIDtoSpaces.put(org.getName(), spaces); orgIDtoOrg.put(org.getName(), org); } spaces.add(clSpace); } }
private List<UUID> getSpaceUserGuids(String orgName, String spaceName, String urlPath) { if (orgName == null || spaceName == null) { assertSpaceProvided("get space users"); } UUID spaceGuid; if (spaceName == null) { spaceGuid = sessionSpace.getMeta() .getGuid(); } else { CloudOrganization organization = (orgName == null ? sessionSpace.getOrganization() : getOrganization(orgName)); spaceGuid = getSpaceGuid(spaceName, organization.getMeta() .getGuid()); } return getSpaceUserGuids(spaceGuid, urlPath); }
@Override public String toString() { return "CloudApplication [staging=" + staging + ", instances=" + instances + ", name=" + getName() + ", memory=" + memory + ", diskQuota=" + diskQuota + ", state=" + state + ", debug=" + debug + ", uris=" + uris + ", services=" + services + ", env=" + env + ", space=" + space.getName() + "]"; }
private boolean isSameSpace(CloudSpace space, String orgName, String spaceName) { CloudOrganization org = space.getOrganization(); if (orgName != null && !org.getName() .equals(orgName)) { return false; } return spaceName == null || space.getName() .equals(spaceName); }
@Override public List<CloudDomain> getDomainsForOrg() { assertSpaceProvided("access organization domains"); return doGetDomains(sessionSpace.getOrganization()); }
public void saveToken(URI target, OAuth2AccessToken token, CloudInfo cloudInfo, CloudSpace space) { TargetInfos targetInfos = getTokensFromFile(); if (targetInfos == null) { targetInfos = new TargetInfos(); } HashMap<String, String> targetInfo = targetInfos.get(target); if (targetInfo == null) { targetInfo = new LinkedHashMap<String, String>(); } targetInfos.putToken(targetInfo, token); targetInfos.putRefreshToken(targetInfo, token.getRefreshToken()); targetInfos.putVersion(targetInfo, cloudInfo.getVersion()); targetInfos.putSpace(targetInfo, space.getMeta().getGuid().toString()); targetInfos.putOrganization(targetInfo, space.getOrganization().getMeta().getGuid().toString()); targetInfos.put(target, targetInfo); saveTokensToFile(targetInfos); }
public String computeSpaceId(String orgName, String spaceName) { CloudSpace space = spaceGetter.findSpace(client, orgName, spaceName); if (space != null) { return space.getMeta() .getGuid() .toString(); } return null; }
@Override public String toString() { return "CloudApplication [staging=" + staging + ", instances=" + instances + ", name=" + getName() + ", memory=" + memory + ", diskQuota=" + diskQuota + ", state=" + state + ", debug=" + debug + ", uris=" + uris + ", services=" + services + ", env=" + env + ", space=" + space.getName() + "]"; } }
private CloudSpace createDummySpace(Pair<String, String> orgAndSpace) { CloudOrganization org = createDummyOrg(orgAndSpace._1); return new CloudSpace(null, orgAndSpace._2, org); }
private CloudSpace validateSpaceAndOrg(String spaceName, String orgName, CloudControllerClientImpl client) { List<CloudSpace> spaces = client.getSpaces(); for (CloudSpace space : spaces) { if (space.getName().equals(spaceName)) { CloudOrganization org = space.getOrganization(); if (orgName == null || org.getName().equals(orgName)) { return space; } } } throw new IllegalArgumentException("No matching organization and space found for org: " + orgName + " space: " + spaceName); }
private UUID doCreateDomain(String domainName) { String urlPath = "/v2/private_domains"; HashMap<String, Object> domainRequest = new HashMap<String, Object>(); domainRequest.put("owning_organization_guid", sessionSpace.getOrganization().getMeta().getGuid()); domainRequest.put("name", domainName); domainRequest.put("wildcard", true); String resp = getRestTemplate().postForObject(getUrl(urlPath), domainRequest, String.class); Map<String, Object> respMap = JsonUtil.convertJsonToMap(resp); return resourceMapper.getGuidOfResource(respMap); }
public void saveToken(URI target, OAuth2AccessToken token, CloudInfo cloudInfo, CloudSpace space) { TargetInfos targetInfos = getTokensFromFile(); if (targetInfos == null) { targetInfos = new TargetInfos(); } HashMap<String, String> targetInfo = targetInfos.get(target); if (targetInfo == null) { targetInfo = new LinkedHashMap<String, String>(); } targetInfos.putToken(targetInfo, token); targetInfos.putRefreshToken(targetInfo, token.getRefreshToken()); targetInfos.putVersion(targetInfo, cloudInfo.getVersion()); targetInfos.putSpace(targetInfo, space.getMeta() .getGuid() .toString()); targetInfos.putOrganization(targetInfo, space.getOrganization() .getMeta() .getGuid() .toString()); targetInfos.put(target, targetInfo); saveTokensToFile(targetInfos); }
private Map<String, Object> findApplicationResource(String appName, boolean fetchServiceInfo) { Map<String, Object> urlVars = new HashMap<String, Object>(); String urlPath = "/v2"; if (sessionSpace != null) { urlVars.put("space", sessionSpace.getMeta().getGuid()); urlPath = urlPath + "/spaces/{space}"; } urlVars.put("q", "name:" + appName); urlPath = urlPath + "/apps?inline-relations-depth=1&q={q}"; List<Map<String, Object>> allResources = getAllResources(urlPath, urlVars); if(!allResources.isEmpty()) { return processApplicationResource(allResources.get(0), fetchServiceInfo); } return null; }
" not found in current space " + sessionSpace.getName());