Skip to content
Permalink
Browse files

[COLAB-2918]: Merge DEV; fix XColabErrorDecoder due to version upgrad…

…e of feign/spring
  • Loading branch information...
nkraler committed Jan 3, 2019
1 parent 01d2d90 commit f209b4a826150e5beaa612676e2c6ffacfe68857
Showing 423 changed files with 5,102 additions and 5,260 deletions.
@@ -1,6 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="ActivitiesServiceApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" folderName="Services">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<module name="activities-service" />
<option name="SPRING_BOOT_MAIN_CLASS" value="org.xcolab.service.activities.ActivitiesServiceApplication" />
<option name="VM_PARAMETERS" value="-Xms256M -Xmx512M" />
<option name="ALTERNATIVE_JRE_PATH" />
@@ -16,8 +16,8 @@
<option name="value" value="18084" />
</param>
</additionalParameters>
<module name="activities-service" />
<envs />
<method />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

This file was deleted.

@@ -2,7 +2,7 @@
<configuration default="false" name="TrackingServiceApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" folderName="Services">
<module name="tracking-service" />
<option name="SPRING_BOOT_MAIN_CLASS" value="org.xcolab.service.tracking.TrackingServiceApplication" />
<option name="VM_PARAMETERS" value="-Xms256M -Xmx512M" />
<option name="VM_PARAMETERS" value="-Xms256M -Xmx1024M" />
<option name="ALTERNATIVE_JRE_PATH" />
<additionalParameters>
<param>
@@ -1 +1 @@
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
@@ -1,39 +1,34 @@
package org.xcolab.client.activities;

import org.xcolab.util.activities.enums.ActivityType;
import org.xcolab.client.activities.exceptions.ActivityEntryNotFoundException;
import org.xcolab.client.activities.exceptions.ActivitySubscriptionNotFoundException;
import org.xcolab.client.activities.pojo.ActivityEntry;
import org.xcolab.client.activities.pojo.ActivitySubscription;
import org.xcolab.commons.IdListUtil;
import org.xcolab.util.activities.enums.ActivityCategory;
import org.xcolab.util.activities.enums.ActivityType;
import org.xcolab.util.http.caching.CacheKeys;
import org.xcolab.util.http.caching.CacheName;
import org.xcolab.util.http.client.RestResource;
import org.xcolab.util.http.client.RestResource1;
import org.xcolab.util.http.client.enums.ServiceNamespace;
import org.xcolab.util.http.exceptions.EntityNotFoundException;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public final class ActivitiesClient {

private static final Map<ServiceNamespace, ActivitiesClient> instances = new HashMap<>();

private final RestResource<ActivityEntry, Long> activityEntryResource;

private final RestResource<ActivitySubscription, Long> activitySubscriptionResource;


private ActivitiesClient(ServiceNamespace serviceNamespace) {
public ActivitiesClient() {
activityEntryResource = new RestResource1<>(ActivityResource.ACTIVITY_ENTRY,
ActivityEntry.TYPES, serviceNamespace);
ActivityEntry.TYPES);
activitySubscriptionResource = new RestResource1<>(ActivityResource.ACTIVITY_SUBSCRIPTION,
ActivitySubscription.TYPES, serviceNamespace);
ActivitySubscription.TYPES);
}

public ActivityEntry createActivityEntry(ActivityType activityType, long userId,
@@ -180,7 +175,10 @@ public boolean isSubscribedToActivity(Long receiverId, ActivityCategory activity
return getActivitySubscriptions(null, null, userId);
}

public static ActivitiesClient fromNamespace(ServiceNamespace serviceNamespace) {
return instances.computeIfAbsent(serviceNamespace, ActivitiesClient::new);
public List<ActivityEntry> getActivitiesByCategoryId(String activityCategory, Long categoryId) {
return activityEntryResource.list()
.queryParam("activityCategory", activityCategory)
.queryParam("categoryId", categoryId)
.execute();
}
}
@@ -1,20 +1,18 @@
package org.xcolab.client.activities;

import org.xcolab.util.activities.enums.ActivityType;
import org.xcolab.client.activities.exceptions.ActivityEntryNotFoundException;
import org.xcolab.client.activities.exceptions.ActivitySubscriptionNotFoundException;
import org.xcolab.client.activities.pojo.ActivityEntry;
import org.xcolab.client.activities.pojo.ActivitySubscription;
import org.xcolab.util.activities.enums.ActivityCategory;
import org.xcolab.util.http.client.enums.ServiceNamespace;
import org.xcolab.util.activities.enums.ActivityType;

import java.util.Date;
import java.util.List;

public class ActivitiesClientUtil {

private static final ActivitiesClient activitiesClient = ActivitiesClient.fromNamespace(
ServiceNamespace.instance());
private static final ActivitiesClient activitiesClient = new ActivitiesClient();

public static ActivitiesClient getClient() {
return activitiesClient;
@@ -100,6 +98,10 @@ public static boolean isSubscribedToActivity(Long receiverId, ActivityCategory a
receiverId);
}

public static List<ActivityEntry> getActivitiesByCategoryId(String activityCategory, Long categoryId) {
return activitiesClient.getActivitiesByCategoryId(activityCategory, categoryId);
}

public static List<ActivitySubscription> getActivitySubscriptionsForMember(Long userId) {
return activitiesClient.getActivitySubscriptionsForMember( userId);
}
@@ -1,6 +1,9 @@
package org.xcolab.client.activities.pojo;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.springframework.core.ParameterizedTypeReference;

@@ -13,6 +16,8 @@
import java.util.List;
import java.util.Objects;

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(Include.NON_NULL)
public class ActivityEntry implements Serializable {

public static final TypeProvider<ActivityEntry> TYPES = new TypeProvider<>(ActivityEntry.class,
@@ -1,6 +1,9 @@
package org.xcolab.client.activities.pojo;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.springframework.core.ParameterizedTypeReference;

@@ -12,6 +15,8 @@
import java.util.List;
import java.util.Objects;

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(Include.NON_NULL)
public class ActivitySubscription implements Serializable {

public static final TypeProvider<ActivitySubscription> TYPES =
@@ -4,21 +4,17 @@
import org.xcolab.client.admin.pojo.EmailTemplate;
import org.xcolab.util.http.client.RestResource;
import org.xcolab.util.http.client.RestResource1;
import org.xcolab.util.http.client.enums.ServiceNamespace;
import org.xcolab.util.http.exceptions.EntityNotFoundException;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public final class EmailTemplateClient {

private static final Map<ServiceNamespace, EmailTemplateClient> instances = new HashMap<>();
private final RestResource<EmailTemplate, String> emailTemplatesResource;

private EmailTemplateClient(ServiceNamespace serviceNamespace) {
public EmailTemplateClient() {
emailTemplatesResource = new RestResource1<>(
AdminResource.EMAIL_TEMPLATE, EmailTemplate.TYPES, serviceNamespace);
AdminResource.EMAIL_TEMPLATE, EmailTemplate.TYPES);
}

public List<EmailTemplate> listAllContestEmailTemplates() {
@@ -41,8 +37,4 @@ public void updateContestEmailTemplate(EmailTemplate contestEmailTemplate) {
public EmailTemplate createEmailTemplate(EmailTemplate template) {
return emailTemplatesResource.create(template).execute();
}

public static EmailTemplateClient fromNamespace(ServiceNamespace serviceNamespace) {
return instances.computeIfAbsent(serviceNamespace, EmailTemplateClient::new);
}
}
@@ -1,14 +1,12 @@
package org.xcolab.client.admin;

import org.xcolab.client.admin.pojo.EmailTemplate;
import org.xcolab.util.http.client.enums.ServiceNamespace;

import java.util.List;

public class EmailTemplateClientUtil {

private static final EmailTemplateClient emailTemplateClient = EmailTemplateClient.fromNamespace(
ServiceNamespace.instance());
private static final EmailTemplateClient emailTemplateClient = new EmailTemplateClient();

public static List<EmailTemplate> listAllContestEmailTemplates() {
return emailTemplateClient.listAllContestEmailTemplates();
@@ -106,11 +106,6 @@ private ConfigurationAttributeKey() {
.defaultValue("")
.build();

public static final AttributeGetter<String> TYPEKIT_KIT_ID_LOCALHOST =
ConfigurationAttributes.newStringAttribute("TYPEKIT_KIT_ID_LOCALHOST")
.defaultValue(TYPEKIT_KIT_ID)
.build();

public static final AttributeGetter<String> PINGDOM_RUM_ID =
ConfigurationAttributes.newStringAttribute("PINGDOM_RUM_ID")
.defaultValue("")
@@ -31,11 +31,6 @@
s -> "/" + s.toLowerCase()))
.build();

public static final AttributeGetter<String> FRIENDLY_URL_STRING_CONTESTS =
ContestTypeAttributes.newStringAttribute("FRIENDLY_URL_STRING_CONTESTS")
.defaultValue(TransformedAttribute.of(CONTEST_NAME_PLURAL, String::toLowerCase))
.build();

public static final AttributeGetter<String> FRIENDLY_URL_STRING_PROPOSAL =
ContestTypeAttributes.newStringAttribute("FRIENDLY_URL_STRING_PROPOSAL")
.defaultValue(TransformedAttribute.of(PROPOSAL_NAME, String::toLowerCase))
@@ -101,4 +96,7 @@
.defaultValue(true)
.build();

public static final AttributeGetter<Long> PERMISSIONS_ACCESSIBLE_BY_ROLE_GROUP =
ContestTypeAttributes.newLongAttribute("PERMISSIONS_ACCESSIBLE_BY_ROLE_GROUP")
.build();
}
@@ -9,6 +9,7 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;

import static org.xcolab.commons.attributes.i18n.LocalizableAttributeGetter.localizable;

@@ -51,12 +52,16 @@ public String getLanguage() {
}

private <T> T getAttribute(AttributeGetter<T> getter) {
return getOptionalAttribute(getter).orElse(null);
}

private <T> Optional<T> getOptionalAttribute(AttributeGetter<T> getter) {
//noinspection unchecked
return (T) attributeCache.computeIfAbsent(getter, key -> {
return (Optional<T>) attributeCache.computeIfAbsent(getter, key -> {
if (getter instanceof LocalizableAttributeGetter) {
return localizable(getter).get(language, id);
return localizable(getter).getOpt(language, id);
}
return getter.get(id);
return getter.getOpt(id);
});
}

@@ -112,10 +117,6 @@ public String getContestBaseUrl() {
return getAttribute(ContestTypeAttributeKey.CONTEST_BASE_URL);
}

public String getFriendlyUrlStringContests() {
return getAttribute(ContestTypeAttributeKey.FRIENDLY_URL_STRING_CONTESTS);
}

public String getFriendlyUrlStringProposal() {
return getAttribute(ContestTypeAttributeKey.FRIENDLY_URL_STRING_PROPOSAL);
}
@@ -177,6 +178,15 @@ public boolean isActive() {
return getAttribute(ContestTypeAttributeKey.IS_ACTIVE);
}

public boolean isRestrictedAccess() {
return getOptionalAttribute(ContestTypeAttributeKey.PERMISSIONS_ACCESSIBLE_BY_ROLE_GROUP)
.isPresent();
}

public Long getRoleGroup() {
return getAttribute(ContestTypeAttributeKey.PERMISSIONS_ACCESSIBLE_BY_ROLE_GROUP);
}

/**
* Formats the given String by replacing references to contest or proposal names.
* The following substitutions are made:
@@ -55,11 +55,6 @@ public String getContestBaseUrl() {
return "/contests";
}

@Override
public String getFriendlyUrlStringContests() {
return "contests";
}

@Override
public String getFriendlyUrlStringProposal() {
return "proposal";
@@ -3,55 +3,42 @@
import org.xcolab.client.comment.exceptions.CategoryGroupNotFoundException;
import org.xcolab.client.comment.exceptions.CategoryNotFoundException;
import org.xcolab.client.comment.pojo.Category;
import org.xcolab.client.comment.pojo.CategoryDto;
import org.xcolab.client.comment.pojo.CategoryGroup;
import org.xcolab.util.http.caching.CacheName;
import org.xcolab.util.http.client.enums.ServiceNamespace;
import org.xcolab.util.http.dto.DtoUtil;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class CategoryClient {

private final CommentServiceWrapper commentServiceWrapper;
private final ServiceNamespace serviceNamespace;
// Default instance when used statically
private static final CategoryClient INSTANCE = new CategoryClient();

private static final Map<ServiceNamespace, CategoryClient> instances = new HashMap<>();
private final CommentServiceWrapper commentServiceWrapper = new CommentServiceWrapper();

public CategoryClient(ServiceNamespace serviceNamespace) {
commentServiceWrapper = CommentServiceWrapper.fromService(serviceNamespace);
this.serviceNamespace = serviceNamespace;
public static CategoryClient instance() {
return INSTANCE;
}

public List<Category> listCategories(int start, int last, long groupId) {
return DtoUtil.toPojos(commentServiceWrapper
.listCategories(start, last, "sort", null, groupId, CacheName.MISC_LONG),
serviceNamespace);
return commentServiceWrapper
.listCategories(start, last, "sort", null, groupId, CacheName.MISC_LONG);
}

public Category getCategory(long categoryId) throws CategoryNotFoundException {
return commentServiceWrapper.getCategory(categoryId, CacheName.MISC_RUNTIME)
.toPojo(serviceNamespace);
return commentServiceWrapper.getCategory(categoryId, CacheName.MISC_RUNTIME);
}

public boolean updateCategory(Category category) {
return commentServiceWrapper.updateCategory(new CategoryDto(category));
return commentServiceWrapper.updateCategory(category);
}

public Category createCategory(Category category) {
return commentServiceWrapper.createCategory(new CategoryDto(category))
.toPojo(serviceNamespace);
return commentServiceWrapper.createCategory(category);
}

public CategoryGroup getCategoryGroup(long groupId)
throws CategoryGroupNotFoundException {
return commentServiceWrapper.getCategoryGroup(groupId, CacheName.MISC_RUNTIME)
.toPojo(serviceNamespace);
return commentServiceWrapper.getCategoryGroup(groupId, CacheName.MISC_RUNTIME);
}

public static CategoryClient fromService(ServiceNamespace serviceNamespace) {
return instances.computeIfAbsent(serviceNamespace, CategoryClient::new);
}
}

0 comments on commit f209b4a

Please sign in to comment.
You can’t perform that action at this time.