Search in sources :

Example 1 with DtoFactory

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);
}
Also used : DtoFactory(org.eclipse.che.dto.server.DtoFactory) Change(org.eclipse.che.ide.ext.java.shared.dto.Change)

Example 2 with DtoFactory

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.");
    }
}
Also used : DtoFactory(org.eclipse.che.dto.server.DtoFactory) ServerException(org.eclipse.che.api.core.ServerException) Attributes(java.util.jar.Attributes) JarFile(java.util.jar.JarFile) Manifest(java.util.jar.Manifest) JarFile(java.util.jar.JarFile) File(java.io.File) URL(java.net.URL) ServerException(org.eclipse.che.api.core.ServerException)

Example 3 with DtoFactory

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")));
}
Also used : DtoFactory(org.eclipse.che.dto.server.DtoFactory) ModelComponentDto(org.eclipse.che.dto.definitions.model.ModelComponentDto) Model(org.eclipse.che.dto.definitions.model.Model) Test(org.testng.annotations.Test)

Example 4 with DtoFactory

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();
}
Also used : DtoFactory(org.eclipse.che.dto.server.DtoFactory) FactoryDto(org.eclipse.che.api.factory.shared.dto.FactoryDto) Test(org.testng.annotations.Test)

Aggregations

DtoFactory (org.eclipse.che.dto.server.DtoFactory)4 Test (org.testng.annotations.Test)2 File (java.io.File)1 URL (java.net.URL)1 Attributes (java.util.jar.Attributes)1 JarFile (java.util.jar.JarFile)1 Manifest (java.util.jar.Manifest)1 ServerException (org.eclipse.che.api.core.ServerException)1 FactoryDto (org.eclipse.che.api.factory.shared.dto.FactoryDto)1 Model (org.eclipse.che.dto.definitions.model.Model)1 ModelComponentDto (org.eclipse.che.dto.definitions.model.ModelComponentDto)1 Change (org.eclipse.che.ide.ext.java.shared.dto.Change)1