use of org.eclipse.che.dto.server.DtoFactory in project che by eclipse.
the class DocumentChangeListener method documentChanged.
@Override
public void documentChanged(DocumentEvent event) {
final DtoFactory dtoFactory = DtoFactory.getInstance();
Change dto = dtoFactory.createDto(Change.class);
dto.setLength(event.getLength());
dto.setOffset(event.getOffset());
dto.setText(event.getText());
changes.add(dto);
}
use of org.eclipse.che.dto.server.DtoFactory in project che by eclipse.
the class ApiInfoService method readApiInfo.
private ApiInfo readApiInfo() throws ServerException {
try {
URL url = ApiInfoService.class.getProtectionDomain().getCodeSource().getLocation();
try (JarFile jar = new JarFile(new File(url.toURI()))) {
final Manifest manifest = requireNonNull(jar.getManifest(), "Manifest must not be null");
final Attributes mainAttributes = manifest.getMainAttributes();
final DtoFactory dtoFactory = DtoFactory.getInstance();
return dtoFactory.createDto(ApiInfo.class).withSpecificationVendor(mainAttributes.getValue("Specification-Vendor")).withImplementationVendor(mainAttributes.getValue("Implementation-Vendor")).withSpecificationTitle("Codenvy REST API").withSpecificationVersion(mainAttributes.getValue("Specification-Version")).withImplementationVersion(mainAttributes.getValue("Implementation-Version")).withScmRevision(mainAttributes.getValue("SCM-Revision"));
}
} catch (Exception e) {
LOG.error(e.getMessage(), e);
throw new ServerException("Unable read info about API. Contact support for assistance.");
}
}
use of org.eclipse.che.dto.server.DtoFactory in project che by eclipse.
the class ServerDtoTest method shouldBeAbleToExtendModelSkeletonWithDTOs.
@Test
public void shouldBeAbleToExtendModelSkeletonWithDTOs() {
final DtoFactory factory = DtoFactory.getInstance();
final Model model = factory.createDto(ModelDto.class).withPrimary(factory.createDto(ModelComponentDto.class).withName("primary name")).withComponents(asList(factory.createDto(ModelComponentDto.class).withName("name"), factory.createDto(ModelComponentDto.class).withName("name2"), factory.createDto(ModelComponentDto.class).withName("name3")));
assertEquals(model.getPrimary(), factory.createDto(ModelComponentDto.class).withName("primary name"));
assertEquals(model.getComponents().size(), 3);
assertTrue(model.getComponents().contains(factory.createDto(ModelComponentDto.class).withName("name")));
assertTrue(model.getComponents().contains(factory.createDto(ModelComponentDto.class).withName("name2")));
assertTrue(model.getComponents().contains(factory.createDto(ModelComponentDto.class).withName("name3")));
}
use of org.eclipse.che.dto.server.DtoFactory in project che by eclipse.
the class FactoryBaseValidatorTest method shouldValidateTrackedParamsIfOrgIdIsMissingButOnPremisesTrue.
@Test
public void shouldValidateTrackedParamsIfOrgIdIsMissingButOnPremisesTrue() throws Exception {
final DtoFactory dtoFactory = getInstance();
FactoryDto factory = dtoFactory.createDto(FactoryDto.class);
factory.withV("4.0").withPolicies(dtoFactory.createDto(PoliciesDto.class).withSince(System.currentTimeMillis() + 1_000_000).withUntil(System.currentTimeMillis() + 10_000_000).withReferer("codenvy.com"));
validator = new TesterFactoryBaseValidator();
}
Aggregations