001package co.codewizards.cloudstore.rest.client.request;
002
003import static co.codewizards.cloudstore.core.util.AssertUtil.*;
004
005import javax.ws.rs.client.WebTarget;
006import javax.ws.rs.core.MediaType;
007
008import co.codewizards.cloudstore.core.dto.ChangeSetDto;
009
010public class GetChangeSetDto extends AbstractRequest<ChangeSetDto> {
011
012        private final String repositoryName;
013        private final boolean localSync;
014
015        public GetChangeSetDto(final String repositoryName, final boolean localSync) {
016                this.repositoryName = assertNotNull(repositoryName, "repositoryName");
017                this.localSync = localSync;
018        }
019
020        @Override
021        public ChangeSetDto execute() {
022                WebTarget webTarget = createWebTarget(getPath(ChangeSetDto.class), urlEncode(repositoryName));
023
024                if (localSync)
025                        webTarget = webTarget.queryParam("localSync", localSync);
026
027                final ChangeSetDto changeSetDto = assignCredentials(webTarget.request(MediaType.APPLICATION_XML)).get(ChangeSetDto.class);
028                return changeSetDto;
029        }
030
031        @Override
032        public boolean isResultNullable() {
033                return false;
034        }
035
036}