@Test public void testDeleteMetaField() { Map<String, Object> newConfigs = new HashMap<String, Object>(); newConfigs.put(CMSDBConfig.SYS_ALLOW_METADATA_DELETE, true); server.config(newConfigs); String metaType = "ServiceCluster"; String fieldName = "poolClusters"; server.deleteMetaField(CMSPriority.NEUTRAL, DEPLOY_REPO, metaType, fieldName, metaContext); MetaClass mc = server.getMetaClass(CMSPriority.NEUTRAL, DEPLOY_REPO, metaType); Assert.assertNotNull(mc); Assert.assertNull(mc.getFieldByName(fieldName)); MetaClass oldMC = server.getMetaClass(CMSPriority.NEUTRAL, DEPLOY_REPO, metaType, mc.getVersion() - 1); Assert.assertNotNull(oldMC); Assert.assertNotNull(oldMC.getFieldByName(fieldName)); List<IEntity> entities = server.getMetaHistory(CMSPriority.NEUTRAL, DEPLOY_REPO, metaType, metaContext); Assert.assertEquals(1, entities.size()); String opType = (String) entities.get(0).getFieldValues(HistoryMetaClass.OperType).get(0); Assert.assertEquals("deleteMetaField", opType); }
public void deleteMetaField(CMSPriority p, String repoName, String metaclassName, String fieldName, MetadataContext context) { logger.info("cms deleteMetaField: {}, {}, {}, {}", new Object[] { repoName, metaclassName, fieldName, context.getSourceIp() }); checkServerState(p, true); String id = requestId.getNext(); context.setRequestId(id); context.setDbConfig(dbConfig); long current = System.currentTimeMillis(); context.setStartProcessingTime(current); Object value = getDBConfig().get(CMSDBConfig.SYS_ALLOW_METADATA_DELETE); if (value instanceof Boolean && (Boolean) value) { IMetadataService metaService = repositoryService.getRepository(repoName).getMetadataService(); metaService.deleteMetaField(metaclassName, fieldName, context); long total = System.currentTimeMillis() - current; context.setTotalTimeCost(total); context.addDbTimeCost(context.getDbTimeCost()); } else { throw new NotSupportOperationException("Delete meta field not enabled!"); } }
CMSServer { public void deleteMetaField(CMSPriority p, String repoName, String metaclassName, String fieldName, MetadataContext context) { logger.info("cms deleteMetaField: {}, {}, {}, {}", new Object[] { repoName, metaclassName, fieldName, context.getSourceIp() }); checkServerState(p, true); String id = requestId.getNext(); context.setRequestId(id); context.setDbConfig(dbConfig); long current = System.currentTimeMillis(); context.setStartProcessingTime(current); Object value = getDBConfig().get(CMSDBConfig.SYS_ALLOW_METADATA_DELETE); if (value instanceof Boolean && (Boolean) value) { IMetadataService metaService = repositoryService.getRepository(repoName).getMetadataService(); metaService.deleteMetaField(metaclassName, fieldName, context); long total = System.currentTimeMillis() - current; context.setTotalTimeCost(total); context.addDbTimeCost(context.getDbTimeCost()); } else { throw new NotSupportOperationException("Delete meta field not enabled!"); } } }
CMSServer { public void deleteMetaField(CMSPriority p, String repoName, String metaclassName, String fieldName, MetadataContext context) { logger.info("cms deleteMetaField: {}, {}, {}, {}", new Object[] { repoName, metaclassName, fieldName, context.getSourceIp() }); checkServerState(p, true); String id = requestId.getNext(); context.setRequestId(id); context.setDbConfig(dbConfig); long current = System.currentTimeMillis(); context.setStartProcessingTime(current); Object value = getDBConfig().get(CMSDBConfig.SYS_ALLOW_METADATA_DELETE); if (value instanceof Boolean && (Boolean) value) { IMetadataService metaService = repositoryService.getRepository(repoName).getMetadataService(); metaService.deleteMetaField(metaclassName, fieldName, context); long total = System.currentTimeMillis() - current; context.setTotalTimeCost(total); context.addDbTimeCost(context.getDbTimeCost()); } else { throw new NotSupportOperationException("Delete meta field not enabled!"); } } private  CMSServer(ICMSConfig config); }
CMSServer { public void deleteMetaField(CMSPriority p, String repoName, String metaclassName, String fieldName, MetadataContext context) { logger.info("cms deleteMetaField: {}, {}, {}, {}", new Object[] { repoName, metaclassName, fieldName, context.getSourceIp() }); checkServerState(p, true); String id = requestId.getNext(); context.setRequestId(id); context.setDbConfig(dbConfig); long current = System.currentTimeMillis(); context.setStartProcessingTime(current); Object value = getDBConfig().get(CMSDBConfig.SYS_ALLOW_METADATA_DELETE); if (value instanceof Boolean && (Boolean) value) { IMetadataService metaService = repositoryService.getRepository(repoName).getMetadataService(); metaService.deleteMetaField(metaclassName, fieldName, context); long total = System.currentTimeMillis() - current; context.setTotalTimeCost(total); context.addDbTimeCost(context.getDbTimeCost()); } else { throw new NotSupportOperationException("Delete meta field not enabled!"); } } private  CMSServer(ICMSConfig config); Registration getDalImplementation(String id); void addWriteRequest(int value, long timestamp, Object detail, boolean isSuccess); MonitorStatisticsManager getMonitorStatisticsManager(); CMSDBConfig getDBConfig(); void start(); void pause(); void resume(); void shutdown(); IBranch createBranch(CMSPriority p, IBranch branch, EntityContext context); IBranch getBranch(CMSPriority p, String repoName, String branchId, EntityContext context); List<IBranch> getMainBranches(CMSPriority p, String repoName, EntityContext context); Map<String, IManagementServices.ServiceStatus> getServiceStatuses(); IManagementServices.ServiceStatus getServiceStatus(String serviceName); void setServiceStatus(String serviceName, IManagementServices.ServiceStatus status); Map<String, Object> getStatistics(); Map<String, Object> getStatistics(String metricName); CMSState.State getState(); List<Repository> getRepositories(CMSPriority p, MetadataContext context); Repository getRepository(CMSPriority p, String repoName); Repository createRepository(CMSPriority p, Repository repo); void updateRepository(CMSPriority p, Repository repo); void deleteRepository(CMSPriority p, String repoName); List<MetaClass> getMetaClasses(CMSPriority p, String repoName, MetadataContext context); MetaClass getMetaClass(CMSPriority p, String repoName, String metaclassName); Map<String, List<String>> getMetaClassHierarchy(CMSPriority p, String repoName, String metaclassName, MetadataContext context); MetaClass getMetaClass(CMSPriority p, String repoName, String metaclassName, int version); void addIndex(CMSPriority p, String repoName, String metaclassName, List<IndexInfo> index,
			MetadataContext context); void deleteIndex(CMSPriority p, String repoName, String metaclassName, String indexName,
			MetadataContext context); List<IEntity> getMetaHistory(CMSPriority p, String repositoryId, String metaType, MetadataContext context); List<MetaClass> batchUpsert(CMSPriority p, String repoName, List<MetaClass> metas, MetadataContext context); MetaClass updateMetaField(CMSPriority p, String repoName, MetaClass meta, String fieldName,
			MetadataContext context); void deleteMetadata(CMSPriority p, String repoName, String metaclassName, MetadataContext context); void validateMetadata(CMSPriority p, String repoName, String metaclassName, MetadataContext context); void deleteMetaField(CMSPriority p, String repoName, String metaclassName, String fieldName,
			MetadataContext context); IEntity get(CMSPriority p, IEntity queryEntity, Map<String, List<String>> params, EntityContext context); void delete(CMSPriority p, IEntity queryEntity, EntityContext context); String create(CMSPriority p, IEntity entity, EntityContext context); List<String> batchCreate(CMSPriority p, List<IEntity> entities, EntityContext context, List<String> parseFails); List<String> batchUpdate(CMSPriority p, List<IEntity> entities, EntityContext context, List<String> parseFails); List<String> batchDelete(CMSPriority p, List<IEntity> entities, EntityContext context, List<String> parseFails); IQueryResult batchGet(CMSPriority p, String metadata, Map<String, List<String>> params, QueryContext context); void replace(CMSPriority p, IEntity queryEntity, IEntity entity, EntityContext context); void modify(CMSPriority p, IEntity queryEntity, IEntity entity, EntityContext context); void modifyField(CMSPriority p, IEntity queryEntity, IEntity entity, String fieldName, EntityContext context); void casModifyField(CMSPriority p, IEntity queryEntity, IEntity entity, String fieldName, Object oldValue,
			EntityContext context); void deleteField(CMSPriority p, IEntity queryEntity, String fieldName, EntityContext context); IQueryResult query(CMSPriority p, String query, QueryContext context); Map<String, MetaClass> getQueryMetaClass(CMSPriority priority, String query, QueryContext context); void registerEvent(IEventListener listener); boolean removeEvent(IEventListener listener); static synchronized CMSServer getCMSServer(); static synchronized CMSServer getCMSServer(Map<String, String> configs); void setEntityOperationCallback(IEntityOperationCallback callback); Map<String, Object> getCurrentConfigurations(); Set<String> getConfigNames(); void config(Map<String, Object> configs); ConsistentPolicy parsePolicy(String policy); PaginationMode parsePaginationMode(String mode); void pullField(CMSPriority p, IEntity queryEntity,
            IEntity entity, String fieldName, EntityContext context); int getThrottlingLevel(); void setThrottlingLevel(int throttlingLevel); MongoDataSource getDataSource(); }
CMSServer { public void deleteMetaField(CMSPriority p, String repoName, String metaclassName, String fieldName, MetadataContext context) { logger.info("cms deleteMetaField: {}, {}, {}, {}", new Object[] { repoName, metaclassName, fieldName, context.getSourceIp() }); checkServerState(p, true); String id = requestId.getNext(); context.setRequestId(id); context.setDbConfig(dbConfig); long current = System.currentTimeMillis(); context.setStartProcessingTime(current); Object value = getDBConfig().get(CMSDBConfig.SYS_ALLOW_METADATA_DELETE); if (value instanceof Boolean && (Boolean) value) { IMetadataService metaService = repositoryService.getRepository(repoName).getMetadataService(); metaService.deleteMetaField(metaclassName, fieldName, context); long total = System.currentTimeMillis() - current; context.setTotalTimeCost(total); context.addDbTimeCost(context.getDbTimeCost()); } else { throw new NotSupportOperationException("Delete meta field not enabled!"); } } private  CMSServer(ICMSConfig config); Registration getDalImplementation(String id); void addWriteRequest(int value, long timestamp, Object detail, boolean isSuccess); MonitorStatisticsManager getMonitorStatisticsManager(); CMSDBConfig getDBConfig(); void start(); void pause(); void resume(); void shutdown(); IBranch createBranch(CMSPriority p, IBranch branch, EntityContext context); IBranch getBranch(CMSPriority p, String repoName, String branchId, EntityContext context); List<IBranch> getMainBranches(CMSPriority p, String repoName, EntityContext context); Map<String, IManagementServices.ServiceStatus> getServiceStatuses(); IManagementServices.ServiceStatus getServiceStatus(String serviceName); void setServiceStatus(String serviceName, IManagementServices.ServiceStatus status); Map<String, Object> getStatistics(); Map<String, Object> getStatistics(String metricName); CMSState.State getState(); List<Repository> getRepositories(CMSPriority p, MetadataContext context); Repository getRepository(CMSPriority p, String repoName); Repository createRepository(CMSPriority p, Repository repo); void updateRepository(CMSPriority p, Repository repo); void deleteRepository(CMSPriority p, String repoName); List<MetaClass> getMetaClasses(CMSPriority p, String repoName, MetadataContext context); MetaClass getMetaClass(CMSPriority p, String repoName, String metaclassName); Map<String, List<String>> getMetaClassHierarchy(CMSPriority p, String repoName, String metaclassName, MetadataContext context); MetaClass getMetaClass(CMSPriority p, String repoName, String metaclassName, int version); void addIndex(CMSPriority p, String repoName, String metaclassName, List<IndexInfo> index,
			MetadataContext context); void deleteIndex(CMSPriority p, String repoName, String metaclassName, String indexName,
			MetadataContext context); List<IEntity> getMetaHistory(CMSPriority p, String repositoryId, String metaType, MetadataContext context); List<MetaClass> batchUpsert(CMSPriority p, String repoName, List<MetaClass> metas, MetadataContext context); MetaClass updateMetaField(CMSPriority p, String repoName, MetaClass meta, String fieldName,
			MetadataContext context); void deleteMetadata(CMSPriority p, String repoName, String metaclassName, MetadataContext context); void validateMetadata(CMSPriority p, String repoName, String metaclassName, MetadataContext context); void deleteMetaField(CMSPriority p, String repoName, String metaclassName, String fieldName,
			MetadataContext context); IEntity get(CMSPriority p, IEntity queryEntity, Map<String, List<String>> params, EntityContext context); void delete(CMSPriority p, IEntity queryEntity, EntityContext context); String create(CMSPriority p, IEntity entity, EntityContext context); List<String> batchCreate(CMSPriority p, List<IEntity> entities, EntityContext context, List<String> parseFails); List<String> batchUpdate(CMSPriority p, List<IEntity> entities, EntityContext context, List<String> parseFails); List<String> batchDelete(CMSPriority p, List<IEntity> entities, EntityContext context, List<String> parseFails); IQueryResult batchGet(CMSPriority p, String metadata, Map<String, List<String>> params, QueryContext context); void replace(CMSPriority p, IEntity queryEntity, IEntity entity, EntityContext context); void modify(CMSPriority p, IEntity queryEntity, IEntity entity, EntityContext context); void modifyField(CMSPriority p, IEntity queryEntity, IEntity entity, String fieldName, EntityContext context); void casModifyField(CMSPriority p, IEntity queryEntity, IEntity entity, String fieldName, Object oldValue,
			EntityContext context); void deleteField(CMSPriority p, IEntity queryEntity, String fieldName, EntityContext context); IQueryResult query(CMSPriority p, String query, QueryContext context); Map<String, MetaClass> getQueryMetaClass(CMSPriority priority, String query, QueryContext context); void registerEvent(IEventListener listener); boolean removeEvent(IEventListener listener); static synchronized CMSServer getCMSServer(); static synchronized CMSServer getCMSServer(Map<String, String> configs); void setEntityOperationCallback(IEntityOperationCallback callback); Map<String, Object> getCurrentConfigurations(); Set<String> getConfigNames(); void config(Map<String, Object> configs); ConsistentPolicy parsePolicy(String policy); PaginationMode parsePaginationMode(String mode); void pullField(CMSPriority p, IEntity queryEntity,
            IEntity entity, String fieldName, EntityContext context); int getThrottlingLevel(); void setThrottlingLevel(int throttlingLevel); MongoDataSource getDataSource(); static final String MONITOR_SERVICE; static final String HEALTHY_SERVICE; static final String THROTTLING_SERVICE; static final List<DalErrCodeEnum> CMS_FAILURE_ERROR_CODES; }