Skip to content

Commit

Permalink
- Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rathnapandi committed Nov 15, 2023
1 parent 246e97a commit ace24e5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 28 deletions.
2 changes: 1 addition & 1 deletion modules/apim-adapter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>2.7.0</version>
<version>2.8.0</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public class APIManagerAdapter {
private static APIManagerAdapter instance;
private String apiManagerVersion = null;
private String apiManagerName = null;
private boolean initialized;
public static final ObjectMapper mapper = new ObjectMapper();
private static final Map<String, ClientApplication> clientCredentialToAppMap = new HashMap<>();
private boolean usingOrgAdmin = false;
Expand Down Expand Up @@ -122,7 +121,6 @@ public synchronized void deleteInstance() {
instance = null;
APIMHttpClient.deleteInstances();
}
initialized = false;
}

private void setApiManagerVersion() throws AppException {
Expand Down Expand Up @@ -152,11 +150,6 @@ private APIManagerAdapter() {
this.oauthClientAdapter = new APIManagerOAuthClientProfilesAdapter(this);
this.appAdapter = new APIMgrAppsAdapter(this);
this.userAdapter = new APIManagerUserAdapter(this);
initialized = true;
}

public boolean isInitialized() {
return initialized;
}

public APIMCLICacheManager getCacheManager() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,40 +16,24 @@ public class OrganizationDeserializer extends StdDeserializer<Organization> {

private static final long serialVersionUID = 1L;

public OrganizationDeserializer() {
this(null);
}

public OrganizationDeserializer(Class<Organization> organization) {
super(organization);
}

@Override
public Organization deserialize(JsonParser jp, DeserializationContext ctxt)
throws IOException {
public Organization deserialize(JsonParser jp, DeserializationContext context)
throws IOException {
APIManagerAdapter apiManagerAdapter = APIManagerAdapter.getInstance();
APIManagerOrganizationAdapter organizationAdapter = apiManagerAdapter.getOrgAdapter();
JsonNode node = jp.getCodec().readTree(jp);
// Deserialization depends on the direction
if ("organizationId".equals(jp.currentName())) {
// APIManagerAdapter is not yet initialized
if (!apiManagerAdapter.isInitialized()) {
Organization organization = new Organization();
organization.setId(node.asText());
return organization;
}
// organizationId is given by API-Manager
return organizationAdapter.getOrgForId(node.asText());
} else {
// APIManagerAdapter is not yet initialized
if (!apiManagerAdapter.isInitialized()) {
Organization organization = new Organization();
organization.setName(node.asText());
return organization;
}
// Otherwise make sure the organization exists and try to load it
Organization organization =organizationAdapter.getOrgForName(node.asText());
if (organization == null && validateOrganization(ctxt)) {
Organization organization = organizationAdapter.getOrgForName(node.asText());
if (organization == null && validateOrganization(context)) {
throw new AppException("The given organization: '" + node.asText() + "' is unknown.", ErrorCode.UNKNOWN_ORGANIZATION);
}
return organization;
Expand Down

0 comments on commit ace24e5

Please sign in to comment.