Skip to content

Commit

Permalink
revert formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
ahakanzn committed Jun 11, 2024
1 parent b53c8a5 commit f600c6c
Show file tree
Hide file tree
Showing 45 changed files with 772 additions and 728 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import com.google.common.base.Strings;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.UUID;
import javax.annotation.Nullable;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.gbif.api.annotation.Generated;
import org.gbif.api.annotation.ParamName;
import org.gbif.api.model.registry.Endpoint;
Expand All @@ -31,6 +24,14 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.Nullable;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.UUID;

/**
* Class used to create or update an Endpoint for legacy (GBRDS/IPT) API. Previously known as a
* Service in the GBRDS. A set of HTTP Form parameters coming from a POST request are injected.
Expand All @@ -48,17 +49,6 @@ public class LegacyEndpoint extends Endpoint implements LegacyEntity {
// injected from HTTP form parameters
private UUID datasetKey;

/**
* Get the endpoint's dataset key.
*
* @return dataset key
*/
@XmlElement(name = LegacyResourceConstants.RESOURCE_KEY_PARAM)
@NotNull
public UUID getDatasetKey() {
return datasetKey;
}

/**
* Set the endpoint's dataset key. Mandatory field, injected on both create and update requests.
*
Expand All @@ -73,6 +63,17 @@ public void setDatasetKey(String resourceKey) {
}
}

/**
* Get the endpoint's dataset key.
*
* @return dataset key
*/
@XmlElement(name = LegacyResourceConstants.RESOURCE_KEY_PARAM)
@NotNull
public UUID getDatasetKey() {
return datasetKey;
}

/**
* Set the endpoint description.
*
Expand Down Expand Up @@ -135,21 +136,6 @@ public EndpointType getEndpointType() {
return getType();
}

/**
* Get the endpoint URL. This method is not used but it is needed otherwise this Object can't be
* converted into an XML document via JAXB.
*
* @return url of the endpoint
*/
@XmlElement(name = LegacyResourceConstants.ACCESS_POINT_URL_PARAM)
@NotNull
public String getEndpointUrl() {
if (getUrl() == null) {
throw new IllegalStateException("Null is not acceptable");
}
return getUrl().toASCIIString();
}

/**
* Set the endpoint URL.
*
Expand All @@ -167,6 +153,21 @@ public void setEndpointUrl(String url) {
}
}

/**
* Get the endpoint URL. This method is not used but it is needed otherwise this Object can't be
* converted into an XML document via JAXB.
*
* @return url of the endpoint
*/
@XmlElement(name = LegacyResourceConstants.ACCESS_POINT_URL_PARAM)
@NotNull
public String getEndpointUrl() {
if (getUrl() == null) {
throw new IllegalStateException("Null is not acceptable");
}
return getUrl().toASCIIString();
}

@Generated
@Override
public boolean equals(Object o) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,25 @@
*/
package org.gbif.registry.domain.ws;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import org.gbif.api.annotation.Generated;
import org.gbif.registry.domain.ws.util.LegacyResourceConstants;

import java.io.IOException;

import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.namespace.QName;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator;
import com.google.common.base.Objects;

import lombok.Setter;
import org.gbif.api.annotation.Generated;
import org.gbif.registry.domain.ws.util.LegacyResourceConstants;

/**
* Class used to generate response for legacy (GBRDS/IPT) API. </br> JAXB annotations allow the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,6 @@
*/
package org.gbif.registry.domain.ws;

import com.google.common.base.Joiner;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import com.google.common.base.Strings;
import java.util.Optional;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import lombok.Setter;
import org.gbif.api.annotation.Generated;
import org.gbif.api.model.registry.Contact;
import org.gbif.api.model.registry.Node;
Expand All @@ -30,6 +21,19 @@
import org.gbif.api.vocabulary.Language;
import org.gbif.registry.domain.ws.util.LegacyResourceConstants;

import java.util.Optional;

import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import com.google.common.base.Joiner;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import com.google.common.base.Strings;

import lombok.Setter;

/**
* Class used to generate response for legacy (GBRDS/IPT) API. Previously known as an Organisation
* with an s in the GBRDS. </br> JAXB annotations allow the class to be converted into an XML
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@
*/
package org.gbif.registry.identity.model;

import static org.gbif.registry.identity.model.ModelMutationError.CONSTRAINT_VIOLATION;

import com.google.common.base.MoreObjects;
import org.gbif.api.model.common.AbstractGbifUser;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import javax.validation.ConstraintViolation;
import org.gbif.api.model.common.AbstractGbifUser;

import com.google.common.base.Objects;

import static org.gbif.registry.identity.model.ModelMutationError.CONSTRAINT_VIOLATION;

/**
* Model containing result of mutations to user data. Mostly used to return significant modelError
Expand All @@ -33,23 +37,6 @@ public class UserModelMutationResult {
private ModelMutationError modelError;
private Map<String, String> constraintViolation;

private UserModelMutationResult(String username, String email) {
this.username = username;
this.email = email;
}

private UserModelMutationResult(ModelMutationError modelError) {
this.modelError = modelError;
}

/** Only for JSON serialisation */
public UserModelMutationResult() {}

public UserModelMutationResult(Map<String, String> constraintViolation) {
this.modelError = CONSTRAINT_VIOLATION;
this.constraintViolation = constraintViolation;
}

public static UserModelMutationResult onSuccess() {
return new UserModelMutationResult(null, null);
}
Expand Down Expand Up @@ -86,36 +73,53 @@ public static <T extends AbstractGbifUser> UserModelMutationResult withError(
return new UserModelMutationResult(cvMap);
}

public String getUsername() {
return username;
private UserModelMutationResult(String username, String email) {
this.username = username;
this.email = email;
}

public void setUsername(String username) {
this.username = username;
private UserModelMutationResult(ModelMutationError modelError) {
this.modelError = modelError;
}

public String getEmail() {
return email;
/** Only for JSON serialisation */
public UserModelMutationResult() {}

public void setUsername(String username) {
this.username = username;
}

public void setEmail(String email) {
this.email = email;
}

public Map<String, String> getConstraintViolation() {
return constraintViolation;
public void setError(ModelMutationError modelError) {
this.modelError = modelError;
}

public void setConstraintViolation(Map<String, String> constraintViolation) {
this.constraintViolation = constraintViolation;
}

public ModelMutationError getError() {
return modelError;
public UserModelMutationResult(Map<String, String> constraintViolation) {
this.modelError = CONSTRAINT_VIOLATION;
this.constraintViolation = constraintViolation;
}

public void setError(ModelMutationError modelError) {
this.modelError = modelError;
public String getUsername() {
return username;
}

public String getEmail() {
return email;
}

public Map<String, String> getConstraintViolation() {
return constraintViolation;
}

public ModelMutationError getError() {
return modelError;
}

public boolean containsError() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gbif.registry.test.mocks;

import java.util.List;
import org.gbif.api.model.common.paging.PagingRequest;
import org.gbif.api.model.common.paging.PagingResponse;
import org.gbif.vocabulary.api.AddTagAction;
Expand All @@ -24,6 +10,8 @@
import org.gbif.vocabulary.model.*;
import org.gbif.vocabulary.model.search.KeyNameResult;

import java.util.List;

public class ConceptClientMock implements ConceptClient {
@Override
public PagingResponse<ConceptView> listConcepts(String s, ConceptListParams conceptListParams) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
package org.gbif.registry.ws.it;

import com.zaxxer.hikari.HikariDataSource;
import java.util.Collections;
import java.util.Date;
import org.apache.commons.beanutils.BeanUtilsBean;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.beanutils.ConvertUtilsBean;
Expand Down Expand Up @@ -58,6 +56,9 @@
import org.springframework.test.context.ActiveProfiles;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;

import java.util.Collections;
import java.util.Date;

@TestConfiguration
@SpringBootApplication(
exclude = {
Expand Down Expand Up @@ -124,22 +125,6 @@ public class RegistryIntegrationTestsConfiguration {

public static final String TEST_PROPERTIES = "classpath:application-test.yml";

public static void setSecurityPrincipal(
SimplePrincipalProvider simplePrincipalProvider, UserRole userRole) {
SecurityContext ctx = SecurityContextHolder.createEmptyContext();
SecurityContextHolder.setContext(ctx);

ctx.setAuthentication(
new UsernamePasswordAuthenticationToken(
simplePrincipalProvider.get().getName(),
"",
Collections.singleton(new SimpleGrantedAuthority(userRole.name()))));
}

public static void main(String[] args) {
SpringApplication.run(RegistryIntegrationTestsConfiguration.class, args);
}

@Bean
public BeanUtilsBean beanUtilsBean() {
DateTimeConverter dateConverter = new DateConverter(null);
Expand Down Expand Up @@ -198,11 +183,6 @@ public RequestMappingHandlerMapping getRequestMappingHandlerMapping() {
};
}

@Bean
public ConceptClient conceptClient() {
return new ConceptClientMock();
}

private static class FeignFilterRequestMappingHandlerMapping
extends RequestMappingHandlerMapping {
@Override
Expand All @@ -211,4 +191,25 @@ protected boolean isHandler(Class<?> beanType) {
&& (AnnotationUtils.findAnnotation(beanType, FeignClient.class) == null);
}
}

public static void setSecurityPrincipal(
SimplePrincipalProvider simplePrincipalProvider, UserRole userRole) {
SecurityContext ctx = SecurityContextHolder.createEmptyContext();
SecurityContextHolder.setContext(ctx);

ctx.setAuthentication(
new UsernamePasswordAuthenticationToken(
simplePrincipalProvider.get().getName(),
"",
Collections.singleton(new SimpleGrantedAuthority(userRole.name()))));
}

public static void main(String[] args) {
SpringApplication.run(RegistryIntegrationTestsConfiguration.class, args);
}

@Bean
public ConceptClient conceptClient() {
return new ConceptClientMock();
}
}
Loading

0 comments on commit f600c6c

Please sign in to comment.