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