use of org.alfresco.service.cmr.site.SiteInfo in project alfresco-remote-api by Alfresco.
the class ReadOnlyTransactionInGetRestApiTest method tearDown.
/* (non-Javadoc)
* @see junit.framework.TestCase#tearDown()
*/
@Override
protected void tearDown() throws Exception {
super.tearDown();
SiteInfo site = siteService.getSite(TEST_SITE_NAME);
// use retrying transaction to delete the site
this.transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable {
// delete the test site
siteService.deleteSite(TEST_SITE_NAME);
return null;
}
});
nodeArchiveService.purgeArchivedNode(nodeArchiveService.getArchivedNode(site.getNodeRef()));
AuthenticationUtil.clearCurrentSecurityContext();
}
use of org.alfresco.service.cmr.site.SiteInfo in project alfresco-repository by Alfresco.
the class RenameSiteAuthorityDisplayName method renameDispayNames.
/**
* Rename display names of authorities of sites.
*
* @param siteInfos
* list of sites
*/
private void renameDispayNames(final List<SiteInfo> siteInfos) {
final String tenantDomain = tenantAdminService.getCurrentUserDomain();
final Iterator<SiteInfo> pathItr = siteInfos.listIterator();
BatchProcessWorkProvider<SiteInfo> siteWorkProvider = new BatchProcessWorkProvider<SiteInfo>() {
@Override
public int getTotalEstimatedWorkSize() {
return siteInfos.size();
}
@Override
public Collection<SiteInfo> getNextWork() {
int batchCount = 0;
List<SiteInfo> nodes = new ArrayList<SiteInfo>(BATCH_SIZE);
while (pathItr.hasNext() && batchCount++ != BATCH_SIZE) {
nodes.add(pathItr.next());
}
return nodes;
}
};
// prepare the batch processor and worker object
BatchProcessor<SiteInfo> siteBatchProcessor = new BatchProcessor<SiteInfo>("RenameSiteAuthorityDisplayName", this.transactionHelper, siteWorkProvider, BATCH_THREADS, BATCH_SIZE, this.applicationEventPublisher, progress_logger, BATCH_SIZE * 10);
BatchProcessWorker<SiteInfo> worker = new BatchProcessWorker<SiteInfo>() {
@Override
public String getIdentifier(SiteInfo entry) {
return entry.getShortName();
}
@Override
public void beforeProcess() throws Throwable {
// Disable rules
ruleService.disableRules();
// Authentication
String systemUser = AuthenticationUtil.getSystemUserName();
systemUser = tenantAdminService.getDomainUser(systemUser, tenantDomain);
AuthenticationUtil.setRunAsUser(systemUser);
}
@Override
public void afterProcess() throws Throwable {
// Enable rules
ruleService.enableRules();
// Clear authentication
AuthenticationUtil.clearCurrentSecurityContext();
}
@Override
public void process(SiteInfo siteInfo) throws Throwable {
// Set all the permissions of site
Set<AccessPermission> sitePermissions = permissionService.getAllSetPermissions(siteInfo.getNodeRef());
for (AccessPermission sitePermission : sitePermissions) {
// Use only GROUP authority
if (sitePermission.getAuthorityType() == AuthorityType.GROUP) {
String authorityName = sitePermission.getAuthority();
String currDisplayName = authorityService.getAuthorityDisplayName(authorityName);
String necessaryName = ((SiteServiceImpl) siteService).getSiteRoleGroup(siteInfo.getShortName(), sitePermission.getPermission(), false);
String alternativeName = ((SiteServiceImpl) siteService).getSiteRoleGroup(siteInfo.getShortName(), sitePermission.getPermission(), true);
// check for correct displayName
if ((!necessaryName.equalsIgnoreCase(currDisplayName)) || (!alternativeName.equalsIgnoreCase(currDisplayName))) {
// fix incorrect display name
authorityService.setAuthorityDisplayName(authorityName, necessaryName);
}
}
}
}
};
siteBatchProcessor.process(worker, true);
}
use of org.alfresco.service.cmr.site.SiteInfo in project alfresco-repository by Alfresco.
the class CalendarAllDayEventDatesCorrectingPatch method applyInternal.
@Override
protected String applyInternal() throws Exception {
int updatedEventsAmount = 0;
NodeRef siteRoot = siteService.getSiteRoot();
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Site root: " + siteRoot);
}
List<ChildAssociationRef> allSites = (null != siteRoot) ? (nodeService.getChildAssocs(siteRoot)) : (null);
if ((null != allSites) && !allSites.isEmpty()) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Starting processing of " + allSites.size() + " sites...");
}
PagingResults<CalendarEntry> entries = null;
String queryId = null;
int maxItems = (batchEnabled) ? (batchSize) : (Integer.MAX_VALUE);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Batching info:\n\t- batching enabled: " + batchEnabled + ";\n\t-batch size: " + batchSize);
}
for (ChildAssociationRef siteAssoc : allSites) {
SiteInfo site = siteService.getSite(siteAssoc.getChildRef());
if (null != site) {
int skipCount = 0;
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Processing a site: [short name: " + site.getShortName() + ", title: " + site.getTitle() + ", visibility: " + site.getVisibility() + "]");
}
do {
PagingRequest paging = new PagingRequest(skipCount, maxItems, queryId);
entries = calendarService.listCalendarEntries(site.getShortName(), paging);
List<CalendarEntry> page = (null != entries) ? (entries.getPage()) : (null);
if (null != page) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Processing " + page.size() + " Calendar Events...");
}
queryId = entries.getQueryExecutionId();
for (CalendarEntry entry : page) {
if (isAllDay(entry)) {
updatedEventsAmount++;
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("'All Day' Calendar event has been detected: [title: " + entry.getTitle() + ", start: " + entry.getStart() + ", end: " + entry.getEnd() + ", isOutlook: " + entry.isOutlook() + "]");
}
nodeService.setProperty(entry.getNodeRef(), CalendarModel.PROP_TO_DATE, adjustOldDate(entry.getEnd()));
nodeService.setProperty(entry.getNodeRef(), CalendarModel.PROP_FROM_DATE, adjustOldDate(entry.getStart()));
}
}
skipCount += maxItems;
}
} while (batchEnabled && entries.hasMoreItems());
} else {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Not site object has been detected. Skipping...");
}
}
}
} else {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("No one site has been found! Skipping patch execution...");
}
}
return I18NUtil.getMessage(MSG_SUCCESS, updatedEventsAmount);
}
use of org.alfresco.service.cmr.site.SiteInfo in project alfresco-repository by Alfresco.
the class SWSDPPatch method applyInternal.
@Override
protected String applyInternal() throws Exception {
SiteInfo siteInfo = siteService.getSite("swsdp");
if (siteInfo != null) {
NodeRef nodeRef = siteInfo.getNodeRef();
NodeRef surfConfigNodeRef = nodeService.getChildByName(nodeRef, ContentModel.ASSOC_CONTAINS, "surf-config");
if (surfConfigNodeRef == null) {
return I18NUtil.getMessage(MSG_MISSING_SURFCONFIG);
} else {
for (ChildAssociationRef childRef : nodeService.getChildAssocs(surfConfigNodeRef, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL)) {
hiddenAspect.showNode(childRef.getChildRef(), true);
}
}
return I18NUtil.getMessage(MSG_SITE_PATCHED);
} else {
return I18NUtil.getMessage(MSG_SKIPPED);
}
}
use of org.alfresco.service.cmr.site.SiteInfo in project alfresco-repository by Alfresco.
the class FavouritesServiceImpl method removeFavouriteSite.
private boolean removeFavouriteSite(String userName, NodeRef nodeRef) {
PrefKeys prefKeys = getPrefKeys(Type.SITE);
boolean exists = false;
SiteInfo siteInfo = siteService.getSite(nodeRef);
if (siteInfo != null) {
StringBuilder sitePrefKeyBuilder = new StringBuilder(prefKeys.getSharePrefKey());
sitePrefKeyBuilder.append(siteInfo.getShortName());
String sitePrefKey = sitePrefKeyBuilder.toString();
String siteFavouritedKey = siteFavouritedKey(siteInfo);
exists = preferenceService.getPreference(userName, siteFavouritedKey) != null;
preferenceService.clearPreferences(userName, sitePrefKey);
} else {
throw new IllegalArgumentException("NodeRef " + nodeRef + " is not a site");
}
return exists;
}
Aggregations