use of com.enonic.xp.site.Site in project xp by enonic.
the class ContentResolverTest method resolve_self_in_edit_mode.
@Test
void resolve_self_in_edit_mode() {
final Site site = newSite();
final PortalRequest request = new PortalRequest();
request.setMode(RenderMode.EDIT);
request.setContentPath(ContentPath.from("/c8da0c10-0002-4b68-b407-87412f3e45c9"));
when(this.contentService.getById(ContentId.from("c8da0c10-0002-4b68-b407-87412f3e45c9"))).thenReturn(site);
when(this.contentService.getNearestSite(ContentId.from("c8da0c10-0002-4b68-b407-87412f3e45c9"))).thenReturn(site);
final ContentResolverResult result = new ContentResolver(contentService).resolve(request);
assertSame(site, result.getContent());
assertSame(site, result.getNearestSite());
assertEquals("/", result.getSiteRelativePath());
}
use of com.enonic.xp.site.Site in project xp by enonic.
the class ContentResolverTest method resolve_in_live_mode.
@Test
void resolve_in_live_mode() {
final Content content = newContent();
final Site site = newSite();
final PortalRequest request = new PortalRequest();
request.setContentPath(ContentPath.from("/mysite/landing-page"));
when(this.contentService.getByPath(ContentPath.from("/mysite/landing-page"))).thenReturn(content);
when(this.contentService.findNearestSiteByPath(ContentPath.from("/mysite/landing-page"))).thenReturn(site);
final ContentResolverResult result = new ContentResolver(contentService).resolve(request);
assertSame(content, result.getContent());
assertSame(site, result.getNearestSite());
assertEquals("/landing-page", result.getSiteRelativePath());
}
use of com.enonic.xp.site.Site in project xp by enonic.
the class HtmlLinkProcessor method getStyleDescriptors.
private StyleDescriptors getStyleDescriptors(final PortalRequest portalRequest) {
final ImmutableList.Builder<ApplicationKey> applicationKeyList = new ImmutableList.Builder<ApplicationKey>().add(SYSTEM_APPLICATION_KEY);
if (portalRequest != null) {
final Site site = portalRequest.getSite();
if (site != null) {
final ImmutableSet<ApplicationKey> siteApplicationKeySet = site.getSiteConfigs().getApplicationKeys();
applicationKeyList.addAll(siteApplicationKeySet);
}
}
final ApplicationKeys applicationKeys = ApplicationKeys.from(applicationKeyList.build());
return styleDescriptorService.getByApplications(applicationKeys);
}
use of com.enonic.xp.site.Site in project xp by enonic.
the class UpdateNodeParamsFactory method toNodeEditor.
private NodeEditor toNodeEditor(final UpdateContentTranslatorParams params) {
final Content content = params.getEditedContent();
final PropertyTree nodeData = contentDataSerializer.toUpdateNodeData(params);
final ContentIndexConfigFactory indexConfigFactory = ContentIndexConfigFactory.create().contentTypeService(contentTypeService).pageDescriptorService(pageDescriptorService).partDescriptorService(partDescriptorService).layoutDescriptorService(layoutDescriptorService).siteService(this.siteService).xDataService(this.xDataService).contentTypeName(content.getType()).page(content.getPage()).siteConfigs(content.isSite() ? ((Site) content).getSiteConfigs() : null).extraDatas(content.getAllExtraData()).language(content.getLanguage() != null ? content.getLanguage().getLanguage() : null).build();
return editableNode -> {
editableNode.indexConfigDocument = indexConfigFactory.produce();
editableNode.data = nodeData;
editableNode.manualOrderValue = content.getManualOrderValue();
editableNode.permissions = content.getPermissions();
editableNode.inheritPermissions = content.inheritsPermissions();
};
}
use of com.enonic.xp.site.Site in project xp by enonic.
the class ProjectAccessSiteProcessor method processUpdate.
@Override
public ProcessUpdateResult processUpdate(final ProcessUpdateParams params) {
final Site editedSite = (Site) params.getEditedContent();
final SiteConfigs editedSiteConfigs = editedSite.getSiteConfigs();
final Site originalSite = (Site) params.getOriginalContent();
final SiteConfigs originalSiteConfigs = originalSite.getSiteConfigs();
final Context context = ContextAccessor.current();
final AuthenticationInfo authenticationInfo = context.getAuthInfo();
final ProjectName projectName = ProjectName.from(context.getRepositoryId());
if (!Objects.equals(originalSiteConfigs, editedSiteConfigs)) {
if (!ProjectAccessHelper.hasAdminAccess(authenticationInfo)) {
if (ProjectConstants.DEFAULT_PROJECT_NAME.equals(projectName)) {
throw new ProjectAccessRequiredException(authenticationInfo.getUser().getKey());
} else if (!this.projectPermissionsContextManager.hasAnyProjectRole(authenticationInfo, projectName, Set.of(ProjectRole.OWNER))) {
throw new ProjectAccessRequiredException(authenticationInfo.getUser().getKey(), ProjectRole.OWNER);
}
}
}
return null;
}
Aggregations