Search in sources :

Example 11 with Descriptor

use of org.alfresco.service.descriptor.Descriptor in project acs-community-packaging by Alfresco.

the class NavigationBean method setHelpUrl.

/**
 * @param helpUrl The helpUrl to set.
 */
public void setHelpUrl(String helpUrl) {
    if (this.helpUrl == null) {
        Descriptor serverDescriptor = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getDescriptorService().getServerDescriptor();
        // search / replace each available key occurrence in the template string
        // Note: server descriptor is looking for "version.major", "version.minor", etc.
        Pattern p = Pattern.compile("\\{(\\w+\\.?\\w+)\\}");
        Matcher m = p.matcher(helpUrl);
        boolean result = m.find();
        if (result) {
            StringBuffer sb = new StringBuffer();
            String value = null;
            do {
                value = serverDescriptor.getDescriptor(m.group(1));
                m.appendReplacement(sb, value != null ? value : m.group(1));
                result = m.find();
            } while (result);
            m.appendTail(sb);
            helpUrl = sb.toString();
        }
        this.helpUrl = helpUrl;
    }
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) Descriptor(org.alfresco.service.descriptor.Descriptor)

Example 12 with Descriptor

use of org.alfresco.service.descriptor.Descriptor in project acs-community-packaging by Alfresco.

the class UIRepositoryProperties method getDebugData.

/**
 * @see org.alfresco.web.ui.common.component.debug.BaseDebugComponent#getDebugData()
 */
@SuppressWarnings("unchecked")
public Map getDebugData() {
    // note: sort properties
    Map properties = new TreeMap();
    FacesContext fc = FacesContext.getCurrentInstance();
    ServiceRegistry services = Repository.getServiceRegistry(fc);
    DescriptorService descriptorService = services.getDescriptorService();
    Descriptor installedRepoDescriptor = descriptorService.getInstalledRepositoryDescriptor();
    properties.put("Installed Version", installedRepoDescriptor.getVersion());
    properties.put("Installed Schema", installedRepoDescriptor.getSchema());
    Descriptor systemDescriptor = descriptorService.getServerDescriptor();
    properties.put("Server Version", systemDescriptor.getVersion());
    properties.put("Server Schema", systemDescriptor.getSchema());
    WebApplicationContext cx = FacesContextUtils.getRequiredWebApplicationContext(fc);
    PatchService patchService = (PatchService) cx.getBean("PatchService");
    List<AppliedPatch> patches = patchService.getPatches(null, null);
    for (AppliedPatch patch : patches) {
        StringBuilder data = new StringBuilder(256);
        data.append(patch.getAppliedOnDate()).append(" - ").append(patch.getDescription()).append(" - ").append(patch.getSucceeded() == true ? Application.getMessage(fc, "repository_patch_succeeded") : Application.getMessage(fc, "repository_patch_failed"));
        properties.put(patch.getId(), data);
    }
    return properties;
}
Also used : FacesContext(javax.faces.context.FacesContext) Descriptor(org.alfresco.service.descriptor.Descriptor) ServiceRegistry(org.alfresco.service.ServiceRegistry) TreeMap(java.util.TreeMap) DescriptorService(org.alfresco.service.descriptor.DescriptorService) TreeMap(java.util.TreeMap) Map(java.util.Map) PatchService(org.alfresco.repo.admin.patch.PatchService) WebApplicationContext(org.springframework.web.context.WebApplicationContext) AppliedPatch(org.alfresco.repo.admin.patch.AppliedPatch)

Example 13 with Descriptor

use of org.alfresco.service.descriptor.Descriptor in project alfresco-remote-api by Alfresco.

the class DiscoveryApiWebscript method getRepositoryInfo.

public RepositoryInfo getRepositoryInfo() {
    LicenseInfo licenseInfo = null;
    if (descriptorService.getLicenseDescriptor() != null) {
        licenseInfo = new LicenseInfo(descriptorService.getLicenseDescriptor());
    }
    Descriptor serverDescriptor = descriptorService.getServerDescriptor();
    return new RepositoryInfo().setId(descriptorService.getCurrentRepositoryDescriptor().getId()).setEdition(serverDescriptor.getEdition()).setVersion(new VersionInfo(serverDescriptor)).setLicense(licenseInfo).setModules(getModules()).setStatus(new StatusInfo().setReadOnly(repoAdminService.getUsage().isReadOnly()).setAuditEnabled(auditService.isAuditEnabled()).setQuickShareEnabled(quickShareService.isQuickShareEnabled()).setThumbnailGenerationEnabled(thumbnailService.getThumbnailsEnabled()));
}
Also used : LicenseInfo(org.alfresco.rest.api.model.RepositoryInfo.LicenseInfo) VersionInfo(org.alfresco.rest.api.model.RepositoryInfo.VersionInfo) RepositoryInfo(org.alfresco.rest.api.model.RepositoryInfo) StatusInfo(org.alfresco.rest.api.model.RepositoryInfo.StatusInfo) Descriptor(org.alfresco.service.descriptor.Descriptor)

Example 14 with Descriptor

use of org.alfresco.service.descriptor.Descriptor in project alfresco-repository by Alfresco.

the class SiteLoadPatch method applyInternalImpl.

/**
 * Load the site in.<br/>
 * Site will be loaded as admin user.
 */
private String applyInternalImpl() throws Exception {
    if (descriptorService != null) {
        // if the descriptor service is wired up only load the site at install time (and not on upgrade)
        Descriptor installed = descriptorService.getInstalledRepositoryDescriptor();
        Descriptor live = descriptorService.getServerDescriptor();
        if (!installed.getVersion().equals(live.getVersion())) {
            return I18NUtil.getMessage(MSG_SITE_NOT_CREATED, siteName);
        }
    }
    if (bootstrapViews == null || bootstrapViews.size() == 0) {
        if (logger.isDebugEnabled()) {
            logger.debug("No Bootstraps given to import from - bootstrap import ignored");
        }
        return I18NUtil.getMessage(MSG_NO_BOOTSTRAP_VIEWS_GIVEN, siteName);
    }
    // (Run now as we need DB + Security Context)
    if (siteService.getSite(siteName) != null) {
        if (logger.isDebugEnabled()) {
            logger.debug("Site " + siteName + " already exists - bootstrap import ignored");
        }
        return I18NUtil.getMessage(MSG_SITE_ALREADY_EXISTS, siteName);
    }
    // If we get here, we're good to go!
    if (logger.isDebugEnabled()) {
        logger.debug("Performing bootstrap of site " + siteName);
    }
    // Create the site as the admin user
    SiteInfo site = siteService.createSite(siteName, siteName, siteName, null, SiteVisibility.PUBLIC);
    // At this point we can go back to being the system
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());
    // Setup the Importer Bootstrap Beans
    for (ImporterBootstrap bootstrap : new ImporterBootstrap[] { spacesBootstrap, usersBootstrap }) {
        bootstrap.setAllowWrite(true);
        bootstrap.setUseExistingStore(true);
        bootstrap.setUuidBinding(UUID_BINDING.REPLACE_EXISTING);
    }
    // the defaults where they weren't
    for (String type : DEFAULT_PATHS.keySet()) {
        Properties props = bootstrapViews.get(type);
        if (props != null && DEFAULT_PATHS.get(type) != null) {
            if (!props.containsKey("path")) {
                props.setProperty("path", DEFAULT_PATHS.get(type));
            }
        }
    }
    // Load any users requested
    if (bootstrapViews.containsKey(PROPERTIES_USERS)) {
        List<Properties> views = new ArrayList<Properties>(1);
        views.add(bootstrapViews.get(PROPERTIES_USERS));
        usersBootstrap.setBootstrapViews(views);
        usersBootstrap.bootstrap();
    }
    // Load any people requested
    if (bootstrapViews.containsKey(PROPERTIES_PEOPLE)) {
        List<Properties> views = new ArrayList<Properties>(1);
        views.add(bootstrapViews.get(PROPERTIES_PEOPLE));
        spacesBootstrap.setBootstrapViews(views);
        spacesBootstrap.bootstrap();
    }
    // Put people into groups
    if (bootstrapViews.containsKey(PROPERTIES_GROUPS)) {
        try {
            doGroupImport(bootstrapViews.get(PROPERTIES_GROUPS).getProperty("location"));
        } catch (Throwable t) {
            throw new AlfrescoRuntimeException("Bootstrap failed", t);
        }
    }
    // Load the Main (ACP) Contents
    if (bootstrapViews.containsKey(PROPERTIES_CONTENTS)) {
        // Disable the behaviour which prevents site deletion.
        behaviourFilter.disableBehaviour(site.getNodeRef(), ContentModel.ASPECT_UNDELETABLE);
        try {
            // Clear up the stub content that createSite gave us, first
            // apply the temporary aspect though to prevent the node from
            // being archived
            nodeService.addAspect(site.getNodeRef(), ContentModel.ASPECT_TEMPORARY, null);
            nodeService.deleteNode(site.getNodeRef());
        } finally {
            behaviourFilter.enableBehaviour(site.getNodeRef(), ContentModel.ASPECT_UNDELETABLE);
        }
        // Now load in the real content from the ACP
        List<Properties> views = new ArrayList<Properties>(1);
        views.add(bootstrapViews.get(PROPERTIES_CONTENTS));
        spacesBootstrap.setBootstrapViews(views);
        spacesBootstrap.bootstrap();
    }
    return I18NUtil.getMessage(MSG_SITE_CREATED, siteName);
}
Also used : SiteInfo(org.alfresco.service.cmr.site.SiteInfo) ArrayList(java.util.ArrayList) Descriptor(org.alfresco.service.descriptor.Descriptor) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) Properties(java.util.Properties) ImporterBootstrap(org.alfresco.repo.importer.ImporterBootstrap)

Example 15 with Descriptor

use of org.alfresco.service.descriptor.Descriptor in project alfresco-repository by Alfresco.

the class SessionsUsageDataCollectorTest method setUp.

@Before
public void setUp() {
    mockDescriptorDAO = mock(DescriptorDAO.class);
    mockCollectorService = mock(HBDataCollectorService.class);
    mockScheduler = mock(HeartBeatJobScheduler.class);
    repoServerMgmtMBean = mock(RepoServerMgmtMBean.class);
    when(repoServerMgmtMBean.getTicketCountNonExpired()).thenReturn(TICKET_NON_EXPIRED);
    Descriptor mockDescriptor = mock(Descriptor.class);
    when(mockDescriptor.getId()).thenReturn("mock_id");
    when(mockDescriptorDAO.getDescriptor()).thenReturn(mockDescriptor);
    sessionsUsageDataCollector = new SessionsUsageDataCollector("acs.repository.usage.sessions", "1.0", "0 0 0/1 ? * *", mockScheduler);
    sessionsUsageDataCollector.setHbDataCollectorService(mockCollectorService);
    sessionsUsageDataCollector.setCurrentRepoDescriptorDAO(mockDescriptorDAO);
    sessionsUsageDataCollector.setRepoServerMgmt(repoServerMgmtMBean);
    collectedData = sessionsUsageDataCollector.collectData();
}
Also used : RepoServerMgmtMBean(org.alfresco.repo.admin.RepoServerMgmtMBean) HeartBeatJobScheduler(org.alfresco.heartbeat.jobs.HeartBeatJobScheduler) HBDataCollectorService(org.alfresco.service.cmr.repository.HBDataCollectorService) Descriptor(org.alfresco.service.descriptor.Descriptor) DescriptorDAO(org.alfresco.repo.descriptor.DescriptorDAO) Before(org.junit.Before)

Aggregations

Descriptor (org.alfresco.service.descriptor.Descriptor)26 DescriptorService (org.alfresco.service.descriptor.DescriptorService)7 HeartBeatJobScheduler (org.alfresco.heartbeat.jobs.HeartBeatJobScheduler)6 DescriptorDAO (org.alfresco.repo.descriptor.DescriptorDAO)6 HBDataCollectorService (org.alfresco.service.cmr.repository.HBDataCollectorService)6 Before (org.junit.Before)6 RetryingTransactionHelper (org.alfresco.repo.transaction.RetryingTransactionHelper)5 ServiceRegistry (org.alfresco.service.ServiceRegistry)5 NodeRef (org.alfresco.service.cmr.repository.NodeRef)4 LicenseDescriptor (org.alfresco.service.license.LicenseDescriptor)4 BaseSpringTest (org.alfresco.util.BaseSpringTest)4 Test (org.junit.Test)4 Date (java.util.Date)3 HashMap (java.util.HashMap)3 RetryingTransactionCallback (org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback)3 IOException (java.io.IOException)2 Serializable (java.io.Serializable)2 Connection (java.sql.Connection)2 SQLException (java.sql.SQLException)2 Properties (java.util.Properties)2