Skip to content

Commit

Permalink
Merge pull request #500 from vmware/refactor/498-remove-org-id
Browse files Browse the repository at this point in the history
[maven,artifact-manager,installer] (#498) Remove `vrang.org.id` and `vrang_org_id` configuration properties
  • Loading branch information
Michaelpalacce authored Nov 12, 2024
2 parents 3c023c7 + a32e085 commit 79340ce
Show file tree
Hide file tree
Showing 20 changed files with 1,287 additions and 1,256 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ public class ConfigurationVraNg extends Configuration {
* param PROJECT_NAME.
*/
public static final String PROJECT_NAME = "project.name";
/**
* param ORGANIZATION_ID.
*/
public static final String ORGANIZATION_ID = "org.id";
/**
* param ORGANIZATION_NAME.
*/
Expand Down Expand Up @@ -141,13 +137,6 @@ public String getProjectName() {
return this.properties.getProperty(PROJECT_NAME);
}

/**
* @return String
*/
public String getOrgId() {
return this.properties.getProperty(ORGANIZATION_ID);
}

/**
* @return String
*/
Expand Down Expand Up @@ -244,8 +233,8 @@ public void validate(boolean domainOptional) throws ConfigurationException {
message.append("Project name ");
}

if (StringUtils.isEmpty(getOrgId()) && StringUtils.isEmpty(getOrgName())) {
message.append("Organization id and Organization Name ");
if (StringUtils.isEmpty(getOrgName())) {
message.append("Organization Name ");
}

if (StringUtils.isEmpty(getRefreshToken()) && StringUtils.isEmpty(super.getUsername())) {
Expand All @@ -264,7 +253,8 @@ public void deprecationWarnings() {
String[] deprecatedFlags = new String[] {
"bp.ignore.versions",
"bp.release",
"project.id"
"project.id",
"org.id"
};

for (String flag : deprecatedFlags) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,12 @@ public static ConfigurationVroNg fromProperties(Properties props) throws Configu
}

// Important - when modify properties refer to comments in @Configuration
public static final String ORGANIZATION_ID = "org.id";
public static final String REFRESH_TOKEN = "refresh.token";

/**
* vRA Package Import content conflict resolution mode
*/

public String getOrgId() {
return this.properties.getProperty(ORGANIZATION_ID);
}

public String getRefreshToken() {
return this.properties.getProperty(REFRESH_TOKEN);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,22 @@
import com.vmware.pscoe.iac.artifact.rest.RestClientVraNgPrimitive;
import org.apache.commons.lang3.StringUtils;

public class VraNgOrganizationUtil {
public final class VraNgOrganizationUtil {

private VraNgOrganizationUtil() {}
private VraNgOrganizationUtil() {
}

public static VraNgOrganization getOrganization(RestClientVraNgPrimitive restClient, ConfigurationVraNg config) {
VraNgOrganization orgByName = null, orgById = null;
if (StringUtils.isNotEmpty(config.getOrgId())) {
orgById = restClient.getOrganizationById(config.getOrgId());
}
VraNgOrganization orgByName = null;
if (StringUtils.isNotEmpty(config.getOrgName())) {
orgByName = restClient.getOrganizationByName(config.getOrgName());
}
if(orgByName == null && orgById == null) {
throw new RuntimeException(String.format("Couldn't find organization by the provided criteria - ID '%s' or Name '%s'.",
config.getOrgId(), config.getOrgName()));
}
if(orgByName != null && orgById != null && !orgByName.getId().equalsIgnoreCase(orgById.getId())) {
throw new RuntimeException("Organization ID and Organization Name provided from the configuration refer to different Organizations.");

if (orgByName == null) {
throw new RuntimeException(String.format("Couldn't find organization by the provided criteria - Name '%s'.",
config.getOrgName()));
}

return orgById != null ? orgById : orgByName;
return orgByName;
}
}
Loading

0 comments on commit 79340ce

Please sign in to comment.