diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/ChildrenProvider.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/ChildrenProvider.java index b1a85887e416..f37d5500cd3a 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/ChildrenProvider.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/ChildrenProvider.java @@ -37,7 +37,7 @@ public interface ChildrenProvider { */ public interface SessionAware extends ChildrenProvider { public default List apply(T t) { - return apply(t, OCIManager.getDefault().getActiveSession()); + return apply(t, OCIManager.getDefault().getActiveProfile(t)); } /** diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/OCIManager.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/OCIManager.java index 1abcfcdc6aaa..9ea4a1c01f39 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/OCIManager.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/OCIManager.java @@ -470,7 +470,22 @@ public List getConnectedProfiles() { return new ArrayList<>(toReturn); } - + + /** + * Returns the active profile based on OCI Item. + * @return + */ + public OCIProfile getActiveProfile(OCIItem ociItem) { + List profiles = getConnectedProfiles(); + return profiles.stream().filter(p -> isMatchingProfile(ociItem, p)).findFirst().orElse(null); + } + + private static boolean isMatchingProfile(OCIItem ociItem, OCIProfile profile) { + if (profile.getTenancy().isEmpty()) return profile.getRegion().getRegionCode().equals(ociItem.getRegionCode()); + return profile.getRegion().getRegionCode().equals(ociItem.getRegionCode()) && + profile.getTenancy().get().getKey().getValue().equals(ociItem.getTenancyId()); + } + /** * Returns the active profile. * @return @@ -488,7 +503,7 @@ public OCIProfile getActiveProfile() { Preferences prefs = NbPreferences.forModule(OCIManager.class); String confPath = prefs.get("activeProfilePath", null); String id = null; - + Path path = null; if (confPath != null) { try { diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/OCIProfile.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/OCIProfile.java index 65bc063d7d40..6a9e5ae38ddc 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/OCIProfile.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/OCIProfile.java @@ -215,7 +215,8 @@ public T newClient(Class clientClass) { } private TenancyItem createTenancyItem(Tenancy tenancy) { - TenancyItem item = new TenancyItem(OCID.of(tenancy.getId(), "Tenancy"), tenancy.getName()); + String regionCode = configProvider.getRegion().getRegionCode(); + TenancyItem item = new TenancyItem(OCID.of(tenancy.getId(), "Tenancy"), tenancy.getName(), regionCode); item.setDescription(Bundle.LBL_HomeRegion(tenancy.getHomeRegionKey())); return item; } diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/AddADBAction.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/AddADBAction.java index f890f65bbc07..22fc911e6913 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/AddADBAction.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/AddADBAction.java @@ -242,6 +242,9 @@ private Map getFlatCompartment(TenancyItem tenancy) { Identity identityClient = session.newClient(IdentityClient.class); String nextPageToken = null; + String tenancyId = session.getTenancy().isPresent() ? session.getTenancy().get().getKey().getValue() : null; + String regionCode = session.getRegion().getRegionCode(); + do { ListCompartmentsResponse response = identityClient.listCompartments( @@ -254,7 +257,7 @@ private Map getFlatCompartment(TenancyItem tenancy) { .page(nextPageToken) .build()); for (Compartment comp : response.getItems()) { - FlatCompartmentItem ci = new FlatCompartmentItem(comp) { + FlatCompartmentItem ci = new FlatCompartmentItem(comp, tenancyId, regionCode) { FlatCompartmentItem getItem(OCID compId) { return compartments.get(compId); } @@ -281,8 +284,8 @@ private abstract class FlatCompartmentItem extends CompartmentItem { private final OCID parentId; private String flatName; - private FlatCompartmentItem(Compartment ociComp) { - super(OCID.of(ociComp.getId(), "Compartment"), ociComp.getCompartmentId(), ociComp.getName()); // NOI18N + private FlatCompartmentItem(Compartment ociComp, String tenancyId, String regionCode) { + super(OCID.of(ociComp.getId(), "Compartment"), ociComp.getCompartmentId(), ociComp.getName(), tenancyId, regionCode); // NOI18N setDescription(ociComp.getDescription()); parentId = OCID.of(ociComp.getCompartmentId(), "Compartment"); // NOI18N } diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/CreateContainerRepositoryCommand.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/CreateContainerRepositoryCommand.java index 89676f218cc6..8b28451f460c 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/CreateContainerRepositoryCommand.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/CreateContainerRepositoryCommand.java @@ -40,6 +40,8 @@ ContainerRepositoryItem callCreate(OCIItemCreationDetails itemCreator) { CreateContainerRepositoryResponse response = client.createContainerRepository(request); ContainerRepository res = response.getContainerRepository(); + String tenancyId = this.getProfile().getTenancy().isPresent() ? this.getProfile().getTenancy().get().getKey().getValue() : null; + return new ContainerRepositoryItem( OCID.of(res.getId(), "ContainerRepository"), //NOI18N res.getCompartmentId(), @@ -47,7 +49,8 @@ ContainerRepositoryItem callCreate(OCIItemCreationDetails itemCreator) { this.getProfile().getRegion().getRegionCode(), res.getNamespace(), res.getIsPublic(), - res.getImageCount() + res.getImageCount(), + tenancyId ); } diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/adm/KnowledgeBaseItem.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/adm/KnowledgeBaseItem.java index ac6120559c83..62eaf680e4cf 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/adm/KnowledgeBaseItem.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/adm/KnowledgeBaseItem.java @@ -43,8 +43,8 @@ public class KnowledgeBaseItem extends OCIItem implements URLProvider{ protected final Date timeUpdated; - public KnowledgeBaseItem(OCID id, String compartmentId, String displayName, Date timeUpdated) { - super(id, compartmentId, displayName); + public KnowledgeBaseItem(OCID id, String compartmentId, String displayName, Date timeUpdated, String tenancyId, String regionCode) { + super(id, compartmentId, displayName, tenancyId, regionCode); this.timeUpdated = timeUpdated; registerItem(); } diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/adm/KnowledgeBaseNode.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/adm/KnowledgeBaseNode.java index eaaa0a7ef595..154ee62e86b4 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/adm/KnowledgeBaseNode.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/adm/KnowledgeBaseNode.java @@ -76,26 +76,34 @@ public static NodeProvider createNode() { // } // // } - + // @ChildrenProvider.Registration(parentPath = "Oracle/Compartment") public static ChildrenProvider.SessionAware listKnowledgeBases() { return (compartment, session) -> { - try ( ApplicationDependencyManagementClient client + try ( ApplicationDependencyManagementClient client = session.newClient(ApplicationDependencyManagementClient.class)) { - + ListKnowledgeBasesRequest request = ListKnowledgeBasesRequest.builder() .compartmentId(compartment.getKey().getValue()) .lifecycleState(KnowledgeBase.LifecycleState.Active) .build(); ListKnowledgeBasesResponse response = client.listKnowledgeBases(request); List projects = response.getKnowledgeBaseCollection().getItems(); + + String tenancyId = session.getTenancy().isPresent() ? + session.getTenancy().get().getKey().getValue() : null; + String regionCode = session.getRegion().getRegionCode(); + return projects.stream() .map(p -> new KnowledgeBaseItem( - OCID.of(p.getId(), "KnowledgeBase"), // NOI18N - p.getCompartmentId(), - p.getDisplayName(), p.getTimeUpdated())).collect(Collectors.toList()); + OCID.of(p.getId(), "KnowledgeBase"), // NOI18N + p.getCompartmentId(), + p.getDisplayName(), + p.getTimeUpdated(), + tenancyId, + regionCode)).collect(Collectors.toList()); } }; } - + } diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/adm/ProjectVulnerability.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/adm/ProjectVulnerability.java index 3b03cd98aea4..7e0bf1fd66c6 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/adm/ProjectVulnerability.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/adm/ProjectVulnerability.java @@ -31,6 +31,7 @@ import org.netbeans.api.project.ProjectUtils; import org.netbeans.modules.cloud.oracle.OCIManager; import org.netbeans.modules.cloud.oracle.OCIProfile; +import org.netbeans.modules.cloud.oracle.OCISessionInitiator; import org.netbeans.modules.cloud.oracle.items.OCID; import org.netbeans.spi.project.AuxiliaryProperties; import org.netbeans.spi.project.LookupProvider.Registration.ProjectType; @@ -105,10 +106,16 @@ public KnowledgeBaseItem getProjectKnowledgeBase() { GetKnowledgeBaseResponse resp = admClient.getKnowledgeBase(req); KnowledgeBase p = resp.getKnowledgeBase(); + String tenancyId = active.getTenancy().isPresent() ? + active.getTenancy().get().getKey().getValue() : null; + String regionCode = active.getRegion().getRegionCode(); + item = new KnowledgeBaseItem( OCID.of(p.getId(), "KnowledgeBase"), // NOI18N p.getCompartmentId(), - p.getDisplayName(), p.getTimeUpdated() + p.getDisplayName(), p.getTimeUpdated(), + tenancyId, + regionCode ); } catch (IllegalArgumentException | BmcException ex) { item = knowledgeBaseItem; @@ -162,12 +169,19 @@ public CompletableFuture findKnowledgeBase(String knowledgeBa .knowledgeBaseId(knowledgeBaseId). build(); + OCISessionInitiator session = OCIManager.getDefault().getActiveProfile(); + String tenancyId = session.getTenancy().isPresent() ? + session.getTenancy().get().getKey().getValue() : null; + String regionCode = session.getRegion().getRegionCode(); + GetKnowledgeBaseResponse response = client.getKnowledgeBase(request); KnowledgeBase p = response.getKnowledgeBase(); result.complete(new KnowledgeBaseItemProxy( OCID.of(p.getId(), "KnowledgeBase"), // NOI18N p.getCompartmentId(), - p.getDisplayName(), p.getTimeUpdated()) + p.getDisplayName(), p.getTimeUpdated(), + tenancyId, + regionCode) ); } catch (ThreadDeath x) { throw x; @@ -186,8 +200,8 @@ public CompletableFuture findKnowledgeBase(String knowledgeBa * + presented in the IDE UI. */ static class KnowledgeBaseItemProxy extends KnowledgeBaseItem { - public KnowledgeBaseItemProxy(OCID id, String compartmenId, String displayName, Date timeUpdated) { - super(id, compartmenId, displayName, timeUpdated); + public KnowledgeBaseItemProxy(OCID id, String compartmenId, String displayName, Date timeUpdated, String tenancyId, String regionCode) { + super(id, compartmenId, displayName, timeUpdated, tenancyId, regionCode); } @Override diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/assets/CreateNewResourceItem.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/assets/CreateNewResourceItem.java index 8e2e5e352e77..87bcdd20222b 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/assets/CreateNewResourceItem.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/assets/CreateNewResourceItem.java @@ -29,7 +29,7 @@ public class CreateNewResourceItem extends OCIItem { private static final String DISPLAY_NAME = ""; public CreateNewResourceItem() { - super(null, null, DISPLAY_NAME); + super(null, null, DISPLAY_NAME, null, null); } } diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/assets/SuggestedItem.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/assets/SuggestedItem.java index ed1092b33d12..36f03523ad33 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/assets/SuggestedItem.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/assets/SuggestedItem.java @@ -43,7 +43,7 @@ public final class SuggestedItem extends OCIItem { private final Set exclusivePaths; public SuggestedItem(String path, String name, Set exclusivePaths) { - super(OCID.of("", "Suggested"), null, name); //NOI18N + super(OCID.of("", "Suggested"), null, name, null, null); //NOI18N this.path = path; this.exclusivePaths = exclusivePaths; } diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/bucket/BucketItem.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/bucket/BucketItem.java index 1dcdbf1ea078..c4f08dce7156 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/bucket/BucketItem.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/bucket/BucketItem.java @@ -29,8 +29,8 @@ public final class BucketItem extends OCIItem { private String namespace; - public BucketItem(OCID id, String compartmentId, String name, String namespace) { - super(id, compartmentId, name); + public BucketItem(OCID id, String compartmentId, String name, String namespace, String tenancyId, String regionCode) { + super(id, compartmentId, name, tenancyId, regionCode); this.namespace = namespace; } diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/bucket/BucketNode.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/bucket/BucketNode.java index fc4c0f218a40..be6025d70d7a 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/bucket/BucketNode.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/bucket/BucketNode.java @@ -69,6 +69,9 @@ public static ChildrenProvider.SessionAware getBuck .limit(88) .build(); + String tenancyId = session.getTenancy().isPresent() ? session.getTenancy().get().getKey().getValue() : null; + String regionCode = session.getRegion().getRegionCode(); + List x = client.listBuckets(listBucketsRequest) .getItems() .stream() @@ -76,7 +79,9 @@ public static ChildrenProvider.SessionAware getBuck OCID.of(d.getName(), "Bucket"), //NOI18N compartmentId.getKey().getValue(), d.getName(), - d.getNamespace()) + d.getNamespace(), + tenancyId, + regionCode) ) .collect(Collectors.toList()); return x; diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/compartment/CompartmentItem.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/compartment/CompartmentItem.java index d39f8016b07c..4dd68940467a 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/compartment/CompartmentItem.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/compartment/CompartmentItem.java @@ -27,8 +27,8 @@ */ public class CompartmentItem extends OCIItem { - public CompartmentItem(OCID id, String compartmentId, String name) { - super(id, compartmentId, name); + public CompartmentItem(OCID id, String compartmentId, String name, String tenancyId, String regionCode) { + super(id, compartmentId, name, tenancyId, regionCode); } } diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/compartment/CompartmentNode.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/compartment/CompartmentNode.java index 524a3f150553..8eddb70f84fa 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/compartment/CompartmentNode.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/compartment/CompartmentNode.java @@ -68,6 +68,9 @@ public static ChildrenProvider.SessionAware getCompart List compartments = new ArrayList<>(); + String tenancyId = session.getTenancy().isPresent() ? session.getTenancy().get().getKey().getValue() : null; + String regionCode = session.getRegion().getRegionCode(); + String nextPageToken = null; do { ListCompartmentsResponse response @@ -79,7 +82,12 @@ public static ChildrenProvider.SessionAware getCompart .page(nextPageToken) .build()); response.getItems().stream() - .map(c -> new CompartmentItem(OCID.of(c.getId(), "Compartment"), parent.getKey().getValue(), c.getName())) // NOI18N + .map(c -> new CompartmentItem( + OCID.of(c.getId(), "Compartment"), + parent.getKey().getValue(), + c.getName(), + tenancyId, + regionCode)) // NOI18N .collect(Collectors.toCollection(() -> compartments)); nextPageToken = response.getOpcNextPage(); } while (nextPageToken != null); diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/compute/ClusterItem.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/compute/ClusterItem.java index 324f813b9428..dbf225421ea3 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/compute/ClusterItem.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/compute/ClusterItem.java @@ -27,8 +27,8 @@ */ public final class ClusterItem extends OCIItem { - public ClusterItem(OCID id, String compartmentId, String name) { - super(id, compartmentId, name); + public ClusterItem(OCID id, String compartmentId, String name, String tenancyId, String regionCode) { + super(id, compartmentId, name, tenancyId, regionCode); } public ClusterItem() { diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/compute/ClusterNode.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/compute/ClusterNode.java index 45df0673ef0d..0fb5bc8d658e 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/compute/ClusterNode.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/compute/ClusterNode.java @@ -67,14 +67,20 @@ public static ChildrenProvider.SessionAware getClu .limit(88) .build(); + String tenancyId = session.getTenancy().isPresent() ? + session.getTenancy().get().getKey().getValue() : null; + String regionCode = session.getRegion().getRegionCode(); + return client.listClusters(listClustersRequest) .getItems() .stream() .filter(c -> !c.getLifecycleState().equals(Instance.LifecycleState.Terminated)) .map(d -> new ClusterItem( - OCID.of(d.getId(), "Cluster"), //NOI18N + OCID.of(d.getId(), "Cluster"), //NOI18N compartmentId.getKey().getValue(), - d.getName() + d.getName(), + tenancyId, + regionCode )) .collect(Collectors.toList()); }; diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/compute/ComputeInstanceItem.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/compute/ComputeInstanceItem.java index 2f2cfab50990..1fa5f04ef367 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/compute/ComputeInstanceItem.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/compute/ComputeInstanceItem.java @@ -31,8 +31,8 @@ public final class ComputeInstanceItem extends OCIItem { private String username; private String imageId; - public ComputeInstanceItem(OCID id, String compartmentId, String name, String processorDescription, String imageId, String publicIp, String username) { - super(id, compartmentId, name); + public ComputeInstanceItem(OCID id, String compartmentId, String name, String processorDescription, String imageId, String publicIp, String username, String tenancyId, String regionCode) { + super(id, compartmentId, name, tenancyId, regionCode); this.processorDescription = processorDescription; this.publicIp = publicIp; this.username = username; diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/compute/ComputeInstanceNode.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/compute/ComputeInstanceNode.java index 2780fd1d599a..2ff24a54e57a 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/compute/ComputeInstanceNode.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/compute/ComputeInstanceNode.java @@ -134,6 +134,9 @@ public static ChildrenProvider.SessionAware createNode() { * @return List of {@code OCIItem} describing databases in a given * Compartment */ - public static ChildrenProvider getDatabases() { - return compartmentId -> { + public static ChildrenProvider.SessionAware getDatabases() { + return (compartmentId, session) -> { DatabaseClient client = new DatabaseClient(getDefault().getConfigProvider()); ListAutonomousDatabasesRequest listAutonomousDatabasesRequest = ListAutonomousDatabasesRequest.builder() .compartmentId(compartmentId.getKey().getValue()) .limit(88) .build(); - - + + String tenancyId = session.getTenancy().isPresent() ? session.getTenancy().get().getKey().getValue() : null; + String regionCode = session.getRegion().getRegionCode(); + return client.listAutonomousDatabases(listAutonomousDatabasesRequest) .getItems() .stream() @@ -85,7 +87,9 @@ public static ChildrenProvider getDatabases() { compartmentId.getKey().getValue(), d.getDbName(), d.getConnectionUrls().getOrdsUrl() + SERVICE_CONSOLE_SUFFIX, - getConnectionName(profiles)); + getConnectionName(profiles), + tenancyId, + regionCode); StringBuilder sb = new StringBuilder(); sb.append(Bundle.LBL_WorkloadType(d.getDbWorkload().getValue())); sb.append(Bundle.LBL_DatabaseVersion(d.getDbVersion())); diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/developer/ContainerRepositoryItem.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/developer/ContainerRepositoryItem.java index 75b1655c20c2..a8be6d54fd5a 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/developer/ContainerRepositoryItem.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/developer/ContainerRepositoryItem.java @@ -29,12 +29,10 @@ public final class ContainerRepositoryItem extends OCIItem { private Boolean isPublic; private Integer imageCount; - private String regionCode; private String namespace; - public ContainerRepositoryItem(OCID id, String compartmentId, String name, String regionCode, String namespace, Boolean isPublic, Integer imageCount) { - super(id, compartmentId, name); - this.regionCode = regionCode; + public ContainerRepositoryItem(OCID id, String compartmentId, String name, String regionCode, String namespace, Boolean isPublic, Integer imageCount, String tenancyId) { + super(id, compartmentId, name, tenancyId, regionCode); this.namespace = namespace; this.isPublic = isPublic; this.imageCount = imageCount; @@ -56,10 +54,6 @@ public void setImageCount(Integer imageCount) { this.imageCount = imageCount; } - public String getRegionCode() { - return regionCode; - } - public String getNamespace() { return namespace; } diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/developer/ContainerRepositoryNode.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/developer/ContainerRepositoryNode.java index 5b58f1f535e8..4e309309a7b0 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/developer/ContainerRepositoryNode.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/developer/ContainerRepositoryNode.java @@ -83,6 +83,8 @@ public static ChildrenProvider.SessionAware new MetricsNamespaceItem( compartmentId.getKey().getValue(), - d.getNamespace() + d.getNamespace(), + tenancyId, + session.getRegion().getRegionCode() )) .collect(Collectors.toList()); }; diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/developer/MetricsNode.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/developer/MetricsNode.java index cb4ed990ea98..d1c7edd82f12 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/developer/MetricsNode.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/developer/MetricsNode.java @@ -72,6 +72,7 @@ public static ChildrenProvider.SessionAware g .build(); Set uniqueMetrics = new HashSet<>(); + String tenancyId = session.getTenancy().isPresent() ? session.getTenancy().get().getKey().getValue() : null; return client.listMetrics(request) .getItems() @@ -81,7 +82,8 @@ public static ChildrenProvider.SessionAware g d.getCompartmentId(), d.getName(), d.getNamespace(), - session.getRegion().getRegionId() + session.getRegion(), + tenancyId )) .collect(Collectors.toList()); }; diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/BuildPipelineItem.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/BuildPipelineItem.java index 17628c5cf281..d2002cbfc3a9 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/BuildPipelineItem.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/BuildPipelineItem.java @@ -28,16 +28,16 @@ */ public class BuildPipelineItem extends OCIItem { - public BuildPipelineItem(OCID id, String compartmentId, String name) { - super(id, compartmentId, name); + public BuildPipelineItem(OCID id, String compartmentId, String name, String tenancyId, String regionCode) { + super(id, compartmentId, name, tenancyId, regionCode); } public static class BuildPipelineFolder extends OCIItem { private final List pipelines; - public BuildPipelineFolder(OCID project, String compartmentId, String name, List pipelines) { - super(project, compartmentId, name); + public BuildPipelineFolder(OCID project, String compartmentId, String name, List pipelines, String tenancyId, String regionCode) { + super(project, compartmentId, name, tenancyId, regionCode); this.pipelines = pipelines; } diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/BuildPipelineNode.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/BuildPipelineNode.java index 942828e4121f..6a8c2db0c0a4 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/BuildPipelineNode.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/BuildPipelineNode.java @@ -58,13 +58,24 @@ public static ChildrenProvider.SessionAware projects = response.getBuildPipelineCollection().getItems(); + String tenancyId = session.getTenancy().isPresent() ? + session.getTenancy().get().getKey().getValue() : null; + String regionCode = session.getRegion().getRegionCode(); + return Collections.singletonList( new BuildPipelineItem.BuildPipelineFolder(OCID.of(project.getKey().getValue(), "BuildPipelineFolder"), project.getCompartmentId(), Bundle.BuildPipelines(), projects.stream() - .map(p -> new BuildPipelineItem(OCID.of(p.getId(), "BuildPipeline"), project.getCompartmentId(), p.getDisplayName())) // NOI18N - .collect(Collectors.toList())) + .map(p -> new BuildPipelineItem( + OCID.of(p.getId(), "BuildPipeline"), + project.getCompartmentId(), + p.getDisplayName(), + tenancyId, + regionCode)) // NOI18N + .collect(Collectors.toList()), + tenancyId, + regionCode) ); } }; diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/BuildRunFolderItem.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/BuildRunFolderItem.java index 693744afc5a1..cf675802a772 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/BuildRunFolderItem.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/BuildRunFolderItem.java @@ -27,8 +27,8 @@ */ public class BuildRunFolderItem extends OCIItem { - public BuildRunFolderItem(OCID project, String compartmentId, String name) { - super(project, compartmentId, name); + public BuildRunFolderItem(OCID project, String compartmentId, String name, String tenancyId, String regionCode) { + super(project, compartmentId, name, tenancyId, regionCode); } } diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/BuildRunItem.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/BuildRunItem.java index 91f4dbf3c56d..9a3565962142 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/BuildRunItem.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/BuildRunItem.java @@ -29,8 +29,8 @@ public class BuildRunItem extends OCIItem { private final String lifecycleState; - public BuildRunItem(OCID id, String compartmentId, String name, String lifecycleState) { - super(id, compartmentId, name); + public BuildRunItem(OCID id, String compartmentId, String name, String lifecycleState, String tenancyId, String regionCode) { + super(id, compartmentId, name, tenancyId, regionCode); this.lifecycleState = lifecycleState; } diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/BuildRunNode.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/BuildRunNode.java index 20ad0f24dad9..79845e11c942 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/BuildRunNode.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/BuildRunNode.java @@ -63,14 +63,19 @@ public static NodeProvider createNode() { return BuildRunNode::new; } - public static ChildrenProvider listBuildRuns() { - return project -> Collections.singletonList( - new BuildRunFolderItem(OCID.of(project.getKey().getValue(), "BuildRunFolder"), project.getCompartmentId(), Bundle.BuildRuns()) + public static ChildrenProvider.SessionAware listBuildRuns() { + return (project, session) -> Collections.singletonList( + new BuildRunFolderItem( + OCID.of(project.getKey().getValue(), "BuildRunFolder"), + project.getCompartmentId(), + Bundle.BuildRuns(), + session.getTenancy().isPresent() ? session.getTenancy().get().getKey().getValue() : null, + session.getRegion().getRegionCode()) ); } - public static ChildrenProvider expandBuildRuns() { - return project -> { + public static ChildrenProvider.SessionAware expandBuildRuns() { + return (project, session) -> { try ( DevopsClient client = new DevopsClient(OCIManager.getDefault().getConfigProvider())) { ListBuildRunsRequest request = ListBuildRunsRequest.builder() .projectId(project.getKey().getValue()) @@ -79,12 +84,19 @@ public static ChildrenProvider expandBuildRuns .build(); ListBuildRunsResponse response = client.listBuildRuns(request); List projects = response.getBuildRunSummaryCollection().getItems(); + + String tenancyId = session.getTenancy().isPresent() ? + session.getTenancy().get().getKey().getValue() : null; + String regionCode = session.getRegion().getRegionCode(); + return projects.stream() .map(p -> new BuildRunItem( OCID.of(p.getId(), "BuildRun"), project.getCompartmentId(), p.getDisplayName(), - p.getLifecycleState().getValue() + p.getLifecycleState().getValue(), + tenancyId, + regionCode )) .collect(Collectors.toList() ); diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/DeployArtifactItem.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/DeployArtifactItem.java index 753af98220ee..0f8d7664287c 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/DeployArtifactItem.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/DeployArtifactItem.java @@ -28,16 +28,16 @@ */ public class DeployArtifactItem extends OCIItem { - public DeployArtifactItem(OCID id, String compartmentId, String name) { - super(id, compartmentId, name); + public DeployArtifactItem(OCID id, String compartmentId, String name, String tenancyId, String regionCode) { + super(id, compartmentId, name, tenancyId, regionCode); } public static class DeployArtifactFolder extends OCIItem { private final List artifacts; - public DeployArtifactFolder(OCID project, String compartmentId, String name, List artifacts) { - super(project, compartmentId, name); + public DeployArtifactFolder(OCID project, String compartmentId, String name, List artifacts, String tenancyId, String regionCode) { + super(project, compartmentId, name, tenancyId, regionCode); this.artifacts = artifacts; } diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/DeployArtifactNode.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/DeployArtifactNode.java index c8bcd09df91a..890cbcec53ba 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/DeployArtifactNode.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/DeployArtifactNode.java @@ -53,20 +53,32 @@ public static NodeProvider createNode() { return DeployArtifactNode::new; } - public static ChildrenProvider listDeployArtifacts() { - return project -> { + public static ChildrenProvider.SessionAware listDeployArtifacts() { + return (project, session) -> { try ( DevopsClient client = new DevopsClient(OCIManager.getDefault().getConfigProvider())) { ListDeployArtifactsRequest request = ListDeployArtifactsRequest.builder() .projectId(project.getKey().getValue()).build(); ListDeployArtifactsResponse response = client.listDeployArtifacts(request); List projects = response.getDeployArtifactCollection().getItems(); + + String tenancyId = session.getTenancy().isPresent() ? + session.getTenancy().get().getKey().getValue() : null; + String regionCode = session.getRegion().getRegionCode(); + return Collections.singletonList( new DeployArtifactItem.DeployArtifactFolder(OCID.of(project.getKey().getValue(), "DeployArtifactFolder"), project.getCompartmentId(), Bundle.DeployArtifacts(), projects.stream() - .map(p -> new DeployArtifactItem(OCID.of(p.getId(), "DeployArtifact"), project.getCompartmentId(), p.getDisplayName())) - .collect(Collectors.toList())) + .map(p -> new DeployArtifactItem( + OCID.of(p.getId(), "DeployArtifact"), + project.getCompartmentId(), + p.getDisplayName(), + tenancyId, + regionCode)) + .collect(Collectors.toList()), + tenancyId, + regionCode) ); } }; diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/DevopsProjectItem.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/DevopsProjectItem.java index 2c3993aaa6a8..2e4f0a581372 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/DevopsProjectItem.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/DevopsProjectItem.java @@ -27,8 +27,8 @@ */ public class DevopsProjectItem extends OCIItem { - public DevopsProjectItem(OCID id, String compartmentId, String name) { - super(id, compartmentId, name); + public DevopsProjectItem(OCID id, String compartmentId, String name, String tenancyId, String regionCode) { + super(id, compartmentId, name, tenancyId, regionCode); } @Override diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/DevopsProjectNode.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/DevopsProjectNode.java index cad1d5f26e96..c25c94d14c26 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/DevopsProjectNode.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/DevopsProjectNode.java @@ -54,8 +54,8 @@ public static NodeProvider createNode() { return DevopsProjectNode::new; } - public static ChildrenProvider listDevopsProjects() { - return compartmentId -> { + public static ChildrenProvider.SessionAware listDevopsProjects() { + return (compartmentId, session) -> { try ( DevopsClient client = new DevopsClient(OCIManager.getDefault().getConfigProvider()); ) { @@ -67,9 +67,17 @@ public static ChildrenProvider listDevopsPro project.getNotificationConfig().getTopicId(); } - return projects.stream().map(p -> new DevopsProjectItem(OCID.of(p.getId(), "DevopsProject"), + + String tenancyId = session.getTenancy().isPresent() ? + session.getTenancy().get().getKey().getValue() : null; + String regionCode = session.getRegion().getRegionCode(); + + return projects.stream().map(p -> new DevopsProjectItem( + OCID.of(p.getId(), "DevopsProject"), compartmentId.getKey().getValue(), - p.getName())).collect(Collectors.toList()); + p.getName(), + tenancyId, + regionCode)).collect(Collectors.toList()); } }; } diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/RepositoryItem.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/RepositoryItem.java index 8eea18f9f8c8..12d52cc6f138 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/RepositoryItem.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/RepositoryItem.java @@ -28,16 +28,16 @@ */ public class RepositoryItem extends OCIItem { - public RepositoryItem(OCID id, String compartmentId, String name) { - super(id, compartmentId, name); + public RepositoryItem(OCID id, String compartmentId, String name, String tenancyId, String regionCode) { + super(id, compartmentId, name, tenancyId, regionCode); } public static class RepositoryFolder extends OCIItem { private final List repositories; - public RepositoryFolder(OCID project, String compartmentId, String name, List repositories) { - super(project, compartmentId, name); + public RepositoryFolder(OCID project, String compartmentId, String name, List repositories, String tenancyId, String regionCode) { + super(project, compartmentId, name, tenancyId, regionCode); this.repositories = repositories; } diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/RepositoryNode.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/RepositoryNode.java index 604ecb8b1958..0c5315c69ca6 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/RepositoryNode.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/devops/RepositoryNode.java @@ -54,20 +54,32 @@ public static NodeProvider createNode() { return RepositoryNode::new; } - public static ChildrenProvider listRepositories() { - return project -> { + public static ChildrenProvider.SessionAware listRepositories() { + return (project, session) -> { try ( DevopsClient client = new DevopsClient(OCIManager.getDefault().getConfigProvider())) { ListRepositoriesRequest listRepositoriesRequest = ListRepositoriesRequest.builder() .projectId(project.getKey().getValue()).build(); ListRepositoriesResponse response = client.listRepositories(listRepositoriesRequest); List projects = response.getRepositoryCollection().getItems(); + + String tenancyId = session.getTenancy().isPresent() ? + session.getTenancy().get().getKey().getValue() : null; + String regionCode = session.getRegion().getRegionCode(); + return Collections.singletonList( new RepositoryFolder(OCID.of(project.getKey().getValue(), "RepositoryFolder"), project.getCompartmentId(), Bundle.Repositories(), projects.stream() - .map(p -> new RepositoryItem(OCID.of(p.getId(), "Repository"), project.getCompartmentId(), p.getName())) - .collect(Collectors.toList())) + .map(p -> new RepositoryItem( + OCID.of(p.getId(), "Repository"), + project.getCompartmentId(), + p.getName(), + tenancyId, + regionCode)) + .collect(Collectors.toList()), + tenancyId, + regionCode) ); } }; diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/items/OCIItem.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/items/OCIItem.java index 69243f29dea5..31bb0a8dc713 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/items/OCIItem.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/items/OCIItem.java @@ -31,6 +31,8 @@ public abstract class OCIItem { final OCID id; final String name; final String compartmentId; + final String tenancyId; + final String regionCode; String description; final transient PropertyChangeSupport changeSupport; @@ -40,16 +42,20 @@ public abstract class OCIItem { * @param id OCID of the item * @param compartmentId OCID of the compartmentId * @param name Name of the item + * @param tenancyId Tenancy OCID of the item + * @param regionCode Region code of the item */ - public OCIItem(OCID id, String compartmentId, String name) { + public OCIItem(OCID id, String compartmentId, String name, String tenancyId, String regionCode) { this.id = id; this.name = name; this.compartmentId = compartmentId; + this.tenancyId = tenancyId; + this.regionCode = regionCode; changeSupport = new PropertyChangeSupport(this); } public OCIItem() { - this(null, null, null); + this(null, null, null, null, null); } /** @@ -87,6 +93,24 @@ public String getDescription() { public String getCompartmentId() { return compartmentId; } + + /** + * OCID of the tenancyId. + * + * @return OCID of the tenancyId + */ + public String getTenancyId() { + return tenancyId; + } + + /** + * 3 digit region code. + * + * @return 3 digit region code + */ + public String getRegionCode() { + return regionCode; + } /** * Short description of the item. diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/items/TenancyItem.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/items/TenancyItem.java index 1350064a5213..01feecf71aca 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/items/TenancyItem.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/items/TenancyItem.java @@ -24,8 +24,8 @@ */ public class TenancyItem extends OCIItem { - public TenancyItem(OCID id, String name) { - super(id, null, name); + public TenancyItem(OCID id, String name, String regionCode) { + super(id, null, name, id.getValue(), regionCode); } public TenancyItem() { diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/steps/CompartmentStep.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/steps/CompartmentStep.java index 891e12b442c4..6c50d88a829a 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/steps/CompartmentStep.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/steps/CompartmentStep.java @@ -102,6 +102,8 @@ static private Map getFlatCompartment(TenancyItem tenancy) { OCISessionInitiator session = OCIManager.getDefault().getActiveSession(); Identity identityClient = session.newClient(IdentityClient.class); String nextPageToken = null; + String tenancyId = session.getTenancy().isPresent() ? session.getTenancy().get().getKey().getValue() : null; + String regionCode = session.getRegion().getRegionCode(); do { ListCompartmentsResponse response @@ -115,7 +117,7 @@ static private Map getFlatCompartment(TenancyItem tenancy) { .page(nextPageToken) .build()); for (Compartment comp : response.getItems()) { - FlatCompartmentItem ci = new FlatCompartmentItem(comp) { + FlatCompartmentItem ci = new FlatCompartmentItem(comp, tenancyId, regionCode) { @Override FlatCompartmentItem getItem(OCID compId) { return compartments.get(compId); @@ -148,8 +150,8 @@ static private abstract class FlatCompartmentItem extends CompartmentItem { private final OCID parentId; private String flatName; - private FlatCompartmentItem(Compartment ociComp) { - super(OCID.of(ociComp.getId(), "Compartment"), ociComp.getCompartmentId(), ociComp.getName()); // NOI18N + private FlatCompartmentItem(Compartment ociComp, String tenancyId, String regionCode) { + super(OCID.of(ociComp.getId(), "Compartment"), ociComp.getCompartmentId(), ociComp.getName(), tenancyId, regionCode); // NOI18N setDescription(ociComp.getDescription()); parentId = OCID.of(ociComp.getCompartmentId(), "Compartment"); // NOI18N } diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/steps/DatabaseConnectionStep.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/steps/DatabaseConnectionStep.java index acc3733bb8e0..ccfab3e06f9f 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/steps/DatabaseConnectionStep.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/steps/DatabaseConnectionStep.java @@ -25,6 +25,8 @@ import java.util.Map.Entry; import org.netbeans.api.db.explorer.ConnectionManager; import org.netbeans.api.db.explorer.DatabaseConnection; +import org.netbeans.modules.cloud.oracle.OCIManager; +import org.netbeans.modules.cloud.oracle.OCISessionInitiator; import org.netbeans.modules.cloud.oracle.assets.AbstractStep; import org.netbeans.modules.cloud.oracle.database.DatabaseItem; import org.netbeans.modules.cloud.oracle.items.OCID; @@ -56,8 +58,12 @@ public DatabaseConnectionStep() { String compartmentId = connections[i].getConnectionProperties().getProperty("CompartmentOCID"); //NOI18N String description = connections[i].getConnectionProperties().getProperty("Description"); //NOI18N if (ocid != null && compartmentId != null) { + OCISessionInitiator session = OCIManager.getDefault().getActiveProfile(); + String tenancyId = session.getTenancy().isPresent() ? session.getTenancy().get().getKey().getValue() : null; + String regionCode = session.getRegion().getRegionCode(); + DatabaseItem dbItem - = new DatabaseItem(OCID.of(ocid, "Databases"), compartmentId, name, null, name); //NOI18N + = new DatabaseItem(OCID.of(ocid, "Databases"), compartmentId, name, null, name, tenancyId, regionCode); //NOI18N dbItem.setDescription(description); adbConnections.put(name, dbItem); } diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/steps/DevopsStep.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/steps/DevopsStep.java index 63cfb7742f99..dc75b737424d 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/steps/DevopsStep.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/steps/DevopsStep.java @@ -29,6 +29,7 @@ import java.util.stream.Collectors; import org.netbeans.api.progress.ProgressHandle; import org.netbeans.modules.cloud.oracle.OCIManager; +import org.netbeans.modules.cloud.oracle.OCISessionInitiator; import org.netbeans.modules.cloud.oracle.assets.AbstractStep; import org.netbeans.modules.cloud.oracle.assets.Steps; import org.netbeans.modules.cloud.oracle.assets.Steps.Values; @@ -104,8 +105,17 @@ protected static Map getDevopsProjects(String compart for (ProjectSummary project : projects) { project.getNotificationConfig().getTopicId(); } - return projects.stream().map(p -> new DevopsProjectItem(OCID.of(p.getId(), "DevopsProject"), // NOI18N - compartmentId, p.getName())).collect(Collectors.toMap(DevopsProjectItem::getName, Function.identity())); + + OCISessionInitiator session = OCIManager.getDefault().getActiveProfile(); + String tenancyId = session.getTenancy().isPresent() ? session.getTenancy().get().getKey().getValue() : null; + String regionCode = session.getRegion().getRegionCode(); + + return projects.stream().map(p -> new DevopsProjectItem( + OCID.of(p.getId(), "DevopsProject"), // NOI18N + compartmentId, + p.getName(), + tenancyId, + regionCode)).collect(Collectors.toMap(DevopsProjectItem::getName, Function.identity())); } } diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/vault/KeyItem.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/vault/KeyItem.java index d1653ac1c0d6..430515952200 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/vault/KeyItem.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/vault/KeyItem.java @@ -27,8 +27,8 @@ */ public class KeyItem extends OCIItem { - public KeyItem(OCID id, String compartmentId, String name) { - super(id, compartmentId, name); + public KeyItem(OCID id, String compartmentId, String name, String tenancyId, String regionCode) { + super(id, compartmentId, name, tenancyId, regionCode); } public KeyItem() { diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/vault/KeyNode.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/vault/KeyNode.java index 812ffda7e43f..1943a05174b4 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/vault/KeyNode.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/vault/KeyNode.java @@ -72,13 +72,18 @@ public static ChildrenProvider.SessionAware getKeys() { .limit(88) .build(); + String tenancyId = session.getTenancy().isPresent() ? session.getTenancy().get().getKey().getValue() : null; + String regionCode = session.getRegion().getRegionCode(); + return client.listKeys(listKeysRequest) .getItems() .stream() .map(d -> new KeyItem( - OCID.of(d.getId(), "Vault/Key"), //NOI18N + OCID.of(d.getId(), "Vault/Key"), //NOI18N d.getCompartmentId(), - d.getDisplayName()) + d.getDisplayName(), + tenancyId, + regionCode) ) .collect(Collectors.toList()); }; diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/vault/SecretItem.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/vault/SecretItem.java index 9338ab4f4dfb..f27f3a8390aa 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/vault/SecretItem.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/vault/SecretItem.java @@ -31,8 +31,8 @@ public class SecretItem extends OCIItem { private String lifecycleState; private Date deletionTime; - public SecretItem(OCID id, String compartmentId, String name, String lifecycleState, Date deletionTime) { - super(id, compartmentId, name); + public SecretItem(OCID id, String compartmentId, String name, String lifecycleState, Date deletionTime, String tenancyId, String regionCode) { + super(id, compartmentId, name, tenancyId, regionCode); this.lifecycleState = lifecycleState; this.deletionTime = deletionTime; } diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/vault/SecretNode.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/vault/SecretNode.java index 002a0ae096bb..3d3b7065b97e 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/vault/SecretNode.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/vault/SecretNode.java @@ -198,7 +198,10 @@ public static ChildrenProvider.SessionAware getSecrets() .vaultId(vault.getKey().getValue()) .limit(88) .build(); - + + String tenancyId = session.getTenancy().isPresent() ? session.getTenancy().get().getKey().getValue() : null; + String regionCode = session.getRegion().getRegionCode(); + return client.listSecrets(listSecretsRequest) .getItems() .stream() @@ -207,7 +210,9 @@ public static ChildrenProvider.SessionAware getSecrets() d.getCompartmentId(), d.getSecretName(), d.getLifecycleState().getValue(), - d.getTimeOfDeletion()) + d.getTimeOfDeletion(), + tenancyId, + regionCode) ) .collect(Collectors.toList()); }; diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/vault/VaultItem.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/vault/VaultItem.java index d6c8da3d22c1..6d38767103bc 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/vault/VaultItem.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/vault/VaultItem.java @@ -28,8 +28,8 @@ public class VaultItem extends OCIItem { private String managementEndpoint; - public VaultItem(OCID id, String compartment, String name, String managementEndpoint) { - super(id, compartment, name); + public VaultItem(OCID id, String compartment, String name, String managementEndpoint, String tenancyId, String regionCode) { + super(id, compartment, name, tenancyId, regionCode); this.managementEndpoint = managementEndpoint; } diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/vault/VaultNode.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/vault/VaultNode.java index 26237eae6221..9f76fe7870da 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/vault/VaultNode.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/vault/VaultNode.java @@ -67,16 +67,21 @@ public static ChildrenProvider.SessionAware getVault .compartmentId(compartmentId.getKey().getValue()) .limit(88) .build(); - + + String tenancyId = session.getTenancy().isPresent() ? session.getTenancy().get().getKey().getValue() : null; + String regionCode = session.getRegion().getRegionCode(); + return client.listVaults(listVaultsRequest) .getItems() .stream() .filter(v -> v.getLifecycleState().equals(VaultSummary.LifecycleState.Active)) .map(d -> new VaultItem( - OCID.of(d.getId(), "Vault"), //NOI18N - d.getCompartmentId(), //NOI18N - d.getDisplayName(), - d.getManagementEndpoint()) + OCID.of(d.getId(), "Vault"), //NOI18N + d.getCompartmentId(), //NOI18N + d.getDisplayName(), + d.getManagementEndpoint(), + tenancyId, + regionCode) ) .collect(Collectors.toList()); }; diff --git a/enterprise/cloud.oracle/test/unit/src/org/netbeans/modules/cloud/oracle/assets/CloudAssetsTest.java b/enterprise/cloud.oracle/test/unit/src/org/netbeans/modules/cloud/oracle/assets/CloudAssetsTest.java index 4f96801180a0..3bb20f221dad 100644 --- a/enterprise/cloud.oracle/test/unit/src/org/netbeans/modules/cloud/oracle/assets/CloudAssetsTest.java +++ b/enterprise/cloud.oracle/test/unit/src/org/netbeans/modules/cloud/oracle/assets/CloudAssetsTest.java @@ -36,9 +36,9 @@ public class CloudAssetsTest { public void testStoreLoad() throws URISyntaxException { CloudAssets instance = new CloudAssets(); instance.loadAssets(); - instance.addItem(new DatabaseItem(OCID.of("db-ocid", "Databases"), "db-comp-id", "DB1", "http://test", "DB1")); - instance.addItem(new ClusterItem(OCID.of("cluster-ocid", "Cluster"), "cluster-comp-id", "Cluster1")); - instance.addItem(new ContainerRepositoryItem(OCID.of("container-repo-ocid", "ContainerRepository"), "container-repo-comp-id", "Repo1", "reg", "namespace", true, 2)); + instance.addItem(new DatabaseItem(OCID.of("db-ocid", "Databases"), "db-comp-id", "DB1", "http://test", "DB1", "tenancy-id", "reg")); + instance.addItem(new ClusterItem(OCID.of("cluster-ocid", "Cluster"), "cluster-comp-id", "Cluster1", "tenancy-id", "reg")); + instance.addItem(new ContainerRepositoryItem(OCID.of("container-repo-ocid", "ContainerRepository"), "container-repo-comp-id", "Repo1", "reg", "namespace", true, 2, "tenancy-id")); instance.storeAssets(); CloudAssets instance1 = new CloudAssets();