Search in sources :

Example 6 with SiteConfig

use of com.enonic.xp.site.SiteConfig in project xp by enonic.

the class SiteConfigProcessorTest method processConfigs.

private PatternIndexConfigDocument processConfigs(final SiteConfigs siteConfigs, final Form... forms) {
    for (int i = 0; i < siteConfigs.getSize(); i++) {
        final SiteConfig siteConfig = siteConfigs.get(i);
        final SiteDescriptor descriptor = SiteDescriptor.create().form(forms[i]).build();
        Mockito.when(siteService.getDescriptor(siteConfig.getApplicationKey())).thenReturn(descriptor);
    }
    final SiteConfigProcessor configProcessor = new SiteConfigProcessor(getConfigForms(siteService, siteConfigs));
    return configProcessor.processDocument(PatternIndexConfigDocument.create()).build();
}
Also used : SiteDescriptor(com.enonic.xp.site.SiteDescriptor) SiteConfig(com.enonic.xp.site.SiteConfig)

Example 7 with SiteConfig

use of com.enonic.xp.site.SiteConfig in project xp by enonic.

the class ValidateContentDataCommandTest method testSiteConfigTextRegexpFailure.

@Test
public void testSiteConfigTextRegexpFailure() {
    final ContentType contentType = ContentType.create().superType(ContentTypeName.structured()).name(ContentTypeName.site()).build();
    Mockito.when(contentTypeService.getByName(Mockito.isA(GetContentTypeParams.class))).thenReturn(contentType);
    PropertyTree rootDataSet = new PropertyTree();
    PropertyTree siteConfigDataSet = new PropertyTree();
    siteConfigDataSet.setString("textInput-1", "test");
    SiteConfig siteConfig = SiteConfig.create().application(ApplicationKey.from("myapp")).config(siteConfigDataSet).build();
    new SiteConfigsDataSerializer().toProperties(SiteConfigs.from(siteConfig), rootDataSet.getRoot());
    Mockito.when(siteService.getDescriptor(Mockito.isA(ApplicationKey.class))).thenReturn(createSiteDescriptor());
    // exercise
    final ValidationErrors result = executeValidation(rootDataSet, ContentTypeName.site());
    assertThat(result.stream()).hasSize(1);
}
Also used : GetContentTypeParams(com.enonic.xp.schema.content.GetContentTypeParams) ApplicationKey(com.enonic.xp.app.ApplicationKey) ContentType(com.enonic.xp.schema.content.ContentType) SiteConfigsDataSerializer(com.enonic.xp.site.SiteConfigsDataSerializer) ValidationErrors(com.enonic.xp.content.ValidationErrors) PropertyTree(com.enonic.xp.data.PropertyTree) SiteConfig(com.enonic.xp.site.SiteConfig) Test(org.junit.jupiter.api.Test)

Example 8 with SiteConfig

use of com.enonic.xp.site.SiteConfig in project xp by enonic.

the class SiteConfigsValidator method validate.

@Override
public void validate(final ContentValidatorParams params, final ValidationErrors.Builder validationErrorsBuilder) {
    final SiteConfigs siteConfigs = new SiteConfigsDataSerializer().fromProperties(params.getData().getRoot()).build();
    for (final SiteConfig siteConfig : siteConfigs) {
        final ApplicationKey applicationKey = siteConfig.getApplicationKey();
        final SiteDescriptor siteDescriptor = siteService.getDescriptor(applicationKey);
        if (siteDescriptor != null) {
            OccurrenceValidator.validate(siteDescriptor.getForm(), siteConfig.getConfig().getRoot(), validationErrorsBuilder);
            try {
                InputValidator.create().form(siteDescriptor.getForm()).inputTypeResolver(InputTypes.BUILTIN).build().validate(siteConfig.getConfig());
            } catch (final Exception e) {
                validationErrorsBuilder.add(ValidationError.generalError(ValidationErrorCode.from(ApplicationKey.SYSTEM, "cms.validation.siteConfigInvalid")).args(siteConfig.getApplicationKey()).build());
            }
        }
    }
}
Also used : SiteDescriptor(com.enonic.xp.site.SiteDescriptor) ApplicationKey(com.enonic.xp.app.ApplicationKey) SiteConfigsDataSerializer(com.enonic.xp.site.SiteConfigsDataSerializer) SiteConfig(com.enonic.xp.site.SiteConfig) SiteConfigs(com.enonic.xp.site.SiteConfigs)

Example 9 with SiteConfig

use of com.enonic.xp.site.SiteConfig in project xp by enonic.

the class TestDataFixtures method newSite.

public static Site newSite() {
    final PropertyTree siteConfigConfig = new PropertyTree();
    siteConfigConfig.setLong("Field", 42L);
    final SiteConfig siteConfig = SiteConfig.create().application(ApplicationKey.from("myapplication")).config(siteConfigConfig).build();
    final Site.Builder site = Site.create();
    site.id(ContentId.from("100123"));
    site.siteConfigs(SiteConfigs.from(siteConfig));
    site.name("my-content");
    site.parentPath(ContentPath.ROOT);
    site.permissions(AccessControlList.of(AccessControlEntry.create().principal(RoleKeys.EVERYONE).allow(Permission.READ).build()));
    return site.build();
}
Also used : Site(com.enonic.xp.site.Site) PropertyTree(com.enonic.xp.data.PropertyTree) SiteConfig(com.enonic.xp.site.SiteConfig)

Example 10 with SiteConfig

use of com.enonic.xp.site.SiteConfig in project xp by enonic.

the class TestDataFixtures method newSite.

public static Site.Builder newSite() {
    final PropertyTree siteConfigConfig = new PropertyTree();
    siteConfigConfig.setLong("Field", 42L);
    final SiteConfig siteConfig = SiteConfig.create().application(ApplicationKey.from("myapplication")).config(siteConfigConfig).build();
    final Site.Builder site = Site.create();
    site.id(ContentId.from("100123"));
    site.siteConfigs(SiteConfigs.from(siteConfig));
    site.name("my-content");
    site.parentPath(ContentPath.ROOT);
    site.permissions(AccessControlList.of(AccessControlEntry.create().principal(RoleKeys.EVERYONE).allow(Permission.READ).build()));
    return site;
}
Also used : Site(com.enonic.xp.site.Site) PropertyTree(com.enonic.xp.data.PropertyTree) SiteConfig(com.enonic.xp.site.SiteConfig)

Aggregations

SiteConfig (com.enonic.xp.site.SiteConfig)16 PropertyTree (com.enonic.xp.data.PropertyTree)11 Site (com.enonic.xp.site.Site)6 ApplicationKey (com.enonic.xp.app.ApplicationKey)5 SiteConfigsDataSerializer (com.enonic.xp.site.SiteConfigsDataSerializer)4 SiteDescriptor (com.enonic.xp.site.SiteDescriptor)4 Test (org.junit.jupiter.api.Test)3 ValidationErrors (com.enonic.xp.content.ValidationErrors)2 Page (com.enonic.xp.page.Page)2 ContentType (com.enonic.xp.schema.content.ContentType)2 GetContentTypeParams (com.enonic.xp.schema.content.GetContentTypeParams)2 ResponseProcessorDescriptor (com.enonic.xp.site.processor.ResponseProcessorDescriptor)2 MacroDescriptor (com.enonic.xp.macro.MacroDescriptor)1 MacroDescriptors (com.enonic.xp.macro.MacroDescriptors)1 PortalResponse (com.enonic.xp.portal.PortalResponse)1 PortalError (com.enonic.xp.portal.impl.error.PortalError)1 SiteConfigs (com.enonic.xp.site.SiteConfigs)1 ResponseProcessorDescriptors (com.enonic.xp.site.processor.ResponseProcessorDescriptors)1 ArrayList (java.util.ArrayList)1