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;
}
}
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;
}
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()));
}
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);
}
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();
}
Aggregations