当前位置: 首页>>代码示例>>Java>>正文


Java RepoUsageStatus.getUsage方法代码示例

本文整理汇总了Java中org.alfresco.service.cmr.admin.RepoUsageStatus.getUsage方法的典型用法代码示例。如果您正苦于以下问题:Java RepoUsageStatus.getUsage方法的具体用法?Java RepoUsageStatus.getUsage怎么用?Java RepoUsageStatus.getUsage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.alfresco.service.cmr.admin.RepoUsageStatus的用法示例。


在下文中一共展示了RepoUsageStatus.getUsage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: executeImpl

import org.alfresco.service.cmr.admin.RepoUsageStatus; //导入方法依赖的package包/类
@Override
protected Map<String, Object> executeImpl(final WebScriptRequest req, final Status status, final Cache cache)
{
    // Runas system to obtain the info
    RunAsWork<Map<String, Object>> runAs = new RunAsWork<Map<String,Object>>()
    {
        @Override
        public Map<String, Object> doWork() throws Exception
        {
            Map<String, Object> model = new HashMap<String, Object>(7);
            
            RepoUsageStatus usageStatus = repoAdminService.getUsageStatus();
            RepoUsage usage = usageStatus.getUsage();
            
            putUsageInModel(
                    model,
                    usage,
                    false);
          
            // Add usage messages
            model.put(JSON_KEY_LEVEL, usageStatus.getLevel().ordinal());
            model.put(JSON_KEY_WARNINGS, usageStatus.getWarnings());
            model.put(JSON_KEY_ERRORS, usageStatus.getErrors());
          
            // Done
            if (logger.isDebugEnabled())
            {
                logger.debug("Result: \n\tRequest: " + req + "\n\tModel: " + model);
            }
            return model;
        }
    };
    return AuthenticationUtil.runAs(runAs, AuthenticationUtil.getSystemUserName());
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:35,代码来源:RepoUsageGet.java

示例2: testGetUsage

import org.alfresco.service.cmr.admin.RepoUsageStatus; //导入方法依赖的package包/类
public void testGetUsage() throws Exception
{
    RepoUsageStatus usageStatus = repoAdminService.getUsageStatus();
    RepoUsage usage = usageStatus.getUsage();
    LicenseDescriptor licenseDescriptor = descriptorService.getLicenseDescriptor();
    Date validUntil = (licenseDescriptor == null) ? null : licenseDescriptor.getValidUntil(); // might be null
    Integer checkLevel = new Integer(usageStatus.getLevel().ordinal());
    
    String url = "/api/admin/usage";
    TestWebScriptServer.GetRequest req = new TestWebScriptServer.GetRequest(url);
    
    Response response = sendRequest(req, Status.STATUS_OK, guest);
    System.out.println(response.getContentAsString());
    JSONObject json = new JSONObject(response.getContentAsString());
    Long users = json.isNull(AbstractAdminWebScript.JSON_KEY_USERS) ? null : json.getLong(AbstractAdminWebScript.JSON_KEY_USERS);
    assertEquals("Mismatched users", usage.getUsers(), users);
    Long documents = json.isNull(AbstractAdminWebScript.JSON_KEY_DOCUMENTS) ? null : json.getLong(AbstractAdminWebScript.JSON_KEY_DOCUMENTS);
    assertEquals("Mismatched documents", usage.getDocuments(), documents);
    String licenseMode = json.isNull(AbstractAdminWebScript.JSON_KEY_LICENSE_MODE) ? null : json.getString(AbstractAdminWebScript.JSON_KEY_LICENSE_MODE);
    assertEquals("Mismatched licenseMode", usage.getLicenseMode().toString(), licenseMode);
    boolean readOnly = json.getBoolean(AbstractAdminWebScript.JSON_KEY_READ_ONLY);
    assertEquals("Mismatched readOnly", usage.isReadOnly(), readOnly);
    boolean updated = json.getBoolean(AbstractAdminWebScript.JSON_KEY_UPDATED);
    assertEquals("Mismatched updated", false, updated);
    Long licenseValidUntil = json.isNull(AbstractAdminWebScript.JSON_KEY_LICENSE_VALID_UNTIL) ? null : json.getLong(AbstractAdminWebScript.JSON_KEY_LICENSE_VALID_UNTIL);
    assertEquals("Mismatched licenseValidUntil",
            (validUntil == null) ? null : validUntil.getTime(),
            licenseValidUntil);
    Integer level = json.isNull(AbstractAdminWebScript.JSON_KEY_LEVEL) ? null : json.getInt(AbstractAdminWebScript.JSON_KEY_LEVEL);
    assertEquals("Mismatched level", checkLevel, level);
    json.getJSONArray(AbstractAdminWebScript.JSON_KEY_WARNINGS);
    json.getJSONArray(AbstractAdminWebScript.JSON_KEY_ERRORS);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:34,代码来源:AdminWebScriptTest.java


注:本文中的org.alfresco.service.cmr.admin.RepoUsageStatus.getUsage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。