DBService implements RolesProvider { void executePutEntity(ResourceContext ctx, String domainName, String entityName, Entity entity, String auditRef, String caller) { for (int retryCount = defaultRetryCount; ; retryCount--) { try (ObjectStoreConnection con = store.getConnection(false, true)) { checkDomainAuditEnabled(con, domainName, auditRef, caller, getPrincipalName(ctx), AUDIT_TYPE_ENTITY); quotaCheck.checkEntityQuota(con, domainName, entity, caller); Entity originalEntity = con.getEntity(domainName, entityName); boolean requestSuccess; if (originalEntity == null) { requestSuccess = con.insertEntity(domainName, entity); } else { requestSuccess = con.updateEntity(domainName, entity); } if (!requestSuccess) { con.rollbackChanges(); throw ZMSUtils.internalServerError("unable to put entity: " + entity.getName(), caller); } saveChanges(con, domainName); auditLogRequest(ctx, domainName, auditRef, caller, ZMSConsts.HTTP_PUT, entity.getName(), JSON.string(entity.getValue())); return; } catch (ResourceException ex) { if (!shouldRetryOperation(ex, retryCount)) { throw ex; } } } } DBService(ObjectStore store, AuditLogger auditLogger, ZMSConfig zmsConfig, AuditReferenceValidator auditReferenceValidator); DomainRoleMembers listOverdueReviewRoleMembers(String domainName); @Override List<Role> getRolesByDomain(String domain); ResourceAccessList getResourceAccessList(String principal, String action); AthenzDomain getAthenzDomain(final String domainName, boolean masterCopy); Quota getQuota(String domainName); void executePutRoleSystemMeta(ResourceContext ctx, final String domainName, final String roleName,
           RoleSystemMeta meta, final String attribute, final String auditRef, final String caller); void executePutGroupSystemMeta(ResourceContext ctx, final String domainName, final String groupName,
                                          GroupSystemMeta meta, final String attribute, final String auditRef); void executePutServiceIdentitySystemMeta(ResourceContext ctx, String domainName, String serviceName,
            ServiceIdentitySystemMeta meta, String attribute, String auditRef, String caller); void executePutRoleMeta(ResourceContext ctx, String domainName, String roleName, Role originalRole,
                                   RoleMeta meta, String auditRef, String caller); void executePutGroupMeta(ResourceContext ctx, final String domainName, final String groupName,
                                    GroupMeta meta, final String auditRef); Set<String> getPendingMembershipApproverRoles(int delayDays); Set<String> getPendingGroupMembershipApproverRoles(int delayDays); Map<String, DomainRoleMember> getRoleExpiryMembers(int delayDays); Map<String, DomainRoleMember> getRoleReviewMembers(int delayDays); Map<String, DomainGroupMember> getGroupExpiryMembers(int delayDays); void processExpiredPendingMembers(int pendingRoleMemberLifespan, final String monitorIdentity); void processExpiredPendingGroupMembers(int pendingGroupMemberLifespan, final String monitorIdentity); static int AUDIT_TYPE_ROLE; static int AUDIT_TYPE_POLICY; static int AUDIT_TYPE_SERVICE; static int AUDIT_TYPE_DOMAIN; static int AUDIT_TYPE_ENTITY; static int AUDIT_TYPE_TENANCY; static int AUDIT_TYPE_TEMPLATE; static int AUDIT_TYPE_GROUP; }
@Test public void testExecutePutEntity() { String domainName = "createentitydom1"; String entityName = "entity1"; TopLevelDomain dom1 = createTopLevelDomainObject(domainName, "Test Domain1", "testOrg", adminUser); zms.postTopLevelDomain(mockDomRsrcCtx, auditRef, dom1); Entity entity1 = createEntityObject(entityName); zms.dbService.executePutEntity(mockDomRsrcCtx, domainName, entityName, entity1, auditRef, "putEntity"); Entity entity2 = zms.getEntity(mockDomRsrcCtx, domainName, entityName); assertNotNull(entity2); assertEquals(entity2.getName(), entityName); Struct value = entity2.getValue(); assertEquals("Value1", value.getString("Key1")); zms.deleteTopLevelDomain(mockDomRsrcCtx, domainName, auditRef); }