Skip to content

Commit

Permalink
Fix compile warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
aledsage committed Oct 12, 2017
1 parent 3ec4c8e commit 3029220
Show file tree
Hide file tree
Showing 23 changed files with 84 additions and 142 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,6 @@
import java.util.Map;
import java.util.Set;

import alien4cloud.model.components.AttributeDefinition;
import alien4cloud.model.components.CSARDependency;
import alien4cloud.model.components.CapabilityDefinition;
import alien4cloud.model.components.Csar;
import alien4cloud.model.components.IValue;
import alien4cloud.model.components.IndexedNodeType;
import alien4cloud.model.components.Interface;
import alien4cloud.model.components.Operation;
import alien4cloud.model.components.PropertyDefinition;
import alien4cloud.model.components.RequirementDefinition;
import alien4cloud.plugin.model.ManagedPlugin;
import alien4cloud.tosca.ArchiveParser;
import alien4cloud.tosca.normative.ToscaType;
import alien4cloud.tosca.parser.ParsingException;
import alien4cloud.tosca.parser.ParsingResult;
import lombok.extern.slf4j.Slf4j;

import org.apache.brooklyn.api.catalog.BrooklynCatalog;
import org.apache.brooklyn.rest.client.BrooklynApi;
import org.apache.brooklyn.rest.domain.CatalogEntitySummary;
Expand All @@ -38,18 +21,18 @@
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;

import alien4cloud.component.repository.ICsarRepositry;
import alien4cloud.csar.services.CsarService;
import alien4cloud.model.components.AttributeDefinition;
import alien4cloud.model.components.CSARDependency;
import alien4cloud.model.components.CapabilityDefinition;
import alien4cloud.model.components.Csar;
import alien4cloud.model.components.IValue;
import alien4cloud.model.components.IndexedNodeType;
import alien4cloud.model.components.Interface;
import alien4cloud.model.components.Operation;
import alien4cloud.model.components.PropertyDefinition;
import alien4cloud.model.components.RequirementDefinition;
import alien4cloud.plugin.model.ManagedPlugin;
import alien4cloud.tosca.ArchiveImageLoader;
import alien4cloud.tosca.ArchiveIndexer;
import alien4cloud.tosca.ArchiveParser;
import alien4cloud.tosca.model.ArchiveRoot;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package alien4cloud.brooklyn;

import io.cloudsoft.tosca.metadata.BrooklynToscaTypeProvider;
import io.cloudsoft.tosca.metadata.DefaultToscaTypeProvider;
import io.cloudsoft.tosca.metadata.ToscaTypeProvider;
import org.apache.brooklyn.rest.client.BrooklynApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

import io.cloudsoft.tosca.metadata.BrooklynToscaTypeProvider;
import io.cloudsoft.tosca.metadata.DefaultToscaTypeProvider;

/**
* Plugin spring configuration entry point.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package io.cloudsoft.tosca.metadata;

import com.google.common.base.Objects;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import java.util.Collection;
import java.util.Map;

import org.apache.brooklyn.rest.client.BrooklynApi;
import org.apache.brooklyn.rest.domain.CatalogEntitySummary;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Collection;
import java.util.Map;
import com.google.common.base.Objects;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;

public class BrooklynToscaTypeProvider implements ToscaTypeProvider, RequiresBrooklynApi {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;

import com.google.common.collect.ImmutableMap;
import org.apache.brooklyn.entity.database.mysql.MySqlNode;
import java.util.Collection;

import org.apache.brooklyn.entity.webapp.tomcat.TomcatServer;
import org.apache.brooklyn.rest.api.CatalogApi;
import org.apache.brooklyn.rest.client.BrooklynApi;
Expand All @@ -18,8 +18,7 @@

import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;

import java.util.Collection;
import com.google.common.collect.ImmutableMap;

public class ToscaMetadataProviderTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@

import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;

import alien4cloud.model.topology.AbstractPolicy;
import alien4cloud.model.topology.Capability;
import alien4cloud.model.topology.GenericPolicy;
import alien4cloud.model.topology.NodeGroup;
import alien4cloud.model.topology.NodeTemplate;
Expand Down Expand Up @@ -211,8 +209,8 @@ private boolean isABrooklynPolicy(Optional<String> policyType, ManagementContext
return false;
}

Class clazz;
CatalogItem catalogItem = CatalogUtils.getCatalogItemOptionalVersion(mgmt, policyType.get());
Class<?> clazz;
CatalogItem<?, ?> catalogItem = CatalogUtils.getCatalogItemOptionalVersion(mgmt, policyType.get());
if (catalogItem != null) {
clazz = catalogItem.getCatalogItemJavaType();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,10 @@
import org.apache.brooklyn.api.entity.Entity;
import org.apache.brooklyn.api.entity.EntitySpec;
import org.apache.brooklyn.api.mgmt.ManagementContext;
import org.apache.brooklyn.api.sensor.EnricherSpec;
import org.apache.brooklyn.camp.brooklyn.BrooklynCampConstants;
import org.apache.brooklyn.core.sensor.Sensors;
import org.apache.brooklyn.enricher.stock.Enrichers;
import org.apache.brooklyn.enricher.stock.Propagator;
import org.apache.brooklyn.entity.software.base.SoftwareProcess;
import org.apache.brooklyn.util.collections.MutableMap;
import org.apache.brooklyn.util.collections.MutableSet;
import org.apache.brooklyn.util.core.task.Tasks;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.BeanDefinition;
Expand All @@ -29,7 +24,6 @@

import com.google.common.base.Optional;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Multimap;

Expand All @@ -54,7 +48,7 @@ public class Alien4CloudApplicationSpecsBuilder implements ApplicationSpecsBuild
private ToscaFacade<Alien4CloudApplication> alien4CloudFacade;

@Inject
public Alien4CloudApplicationSpecsBuilder(ManagementContext managementContext, EntitySpecFactory entitySpecFactory, Collection<EntitySpecModifier> specModifiers, ToscaFacade<Alien4CloudApplication> alien4CloudFacade) {
public Alien4CloudApplicationSpecsBuilder(ManagementContext managementContext, EntitySpecFactory<?> entitySpecFactory, Collection<EntitySpecModifier> specModifiers, ToscaFacade<Alien4CloudApplication> alien4CloudFacade) {
this.alien4CloudFacade = alien4CloudFacade;
this.mgmt = checkNotNull(managementContext, "managementContext");
this.entitySpecFactory = checkNotNull(entitySpecFactory, "entitySpecFactory");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,10 +498,10 @@ private Map<String, Object> joinPropertiesAndValueTypes(Map<String, Object> prop
Object oldPropertyValue = properties.get(newPropertyKey);
if ((oldPropertyValue instanceof Map)
&& (newPropertyValue instanceof Map)) {
((Map) oldPropertyValue).putAll((Map) newPropertyValue);
((Map<Object, Object>) oldPropertyValue).putAll((Map<?,?>) newPropertyValue);
} else if ((oldPropertyValue instanceof List)
&& (newPropertyValue instanceof List)) {
((List) oldPropertyValue).addAll((List) newPropertyValue);
((List<Object>) oldPropertyValue).addAll((List<?>) newPropertyValue);
} else {
LOG.debug("New Property type {} can not be classified in {}, " +
"it should be a Map or a List",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.apache.brooklyn.camp.brooklyn.spi.creation.BrooklynEntityDecorationResolver;
import org.apache.brooklyn.camp.brooklyn.spi.creation.BrooklynYamlTypeInstantiator;
import org.apache.brooklyn.core.mgmt.classloading.JavaBrooklynClassLoadingContext;
import org.apache.brooklyn.util.collections.MutableMap;
import org.apache.brooklyn.util.core.config.ConfigBag;

import com.google.common.base.Optional;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.Map;

import org.apache.brooklyn.core.plan.PlanNotRecognizedException;
import org.apache.brooklyn.core.typereg.UnsupportedTypePlanException;
import org.apache.brooklyn.util.core.ResourceUtils;
import org.apache.brooklyn.util.exceptions.Exceptions;
import org.apache.brooklyn.util.exceptions.UserFacingException;
Expand All @@ -17,7 +17,6 @@
import alien4cloud.tosca.ArchiveUploadService;
import alien4cloud.tosca.parser.ParsingErrorLevel;
import alien4cloud.tosca.parser.ParsingResult;
import io.cloudsoft.tosca.a4c.platform.Alien4CloudToscaPlatform;

public class ToscaParser {

Expand Down Expand Up @@ -79,7 +78,7 @@ public ParsingResult<Csar> parse(String plan) {
PlanTypeChecker type = new PlanTypeChecker(plan);
if (!type.isTosca) {
if (type.csarLink == null) {
throw new PlanNotRecognizedException("Does not look like TOSCA");
throw new UnsupportedTypePlanException("Does not look like TOSCA");
}
tp = uploader.uploadArchive(new ResourceUtils(this).getResourceFromUrl(type.csarLink), "submitted-tosca-archive");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;

import io.cloudsoft.tosca.a4c.brooklyn.AlienPlatformFactory;
import io.cloudsoft.tosca.a4c.brooklyn.ApplicationSpecsBuilder;
import io.cloudsoft.tosca.a4c.brooklyn.ToscaApplication;

import org.apache.brooklyn.api.entity.Application;
import org.apache.brooklyn.api.entity.EntitySpec;
import org.apache.brooklyn.api.internal.AbstractBrooklynObjectSpec;
Expand All @@ -23,21 +19,21 @@
import org.apache.brooklyn.core.typereg.AbstractTypePlanTransformer;
import org.apache.brooklyn.core.typereg.BasicTypeImplementationPlan;
import org.apache.brooklyn.core.typereg.RegisteredTypes;
import org.apache.brooklyn.core.typereg.UnsupportedTypePlanException;
import org.apache.brooklyn.entity.stock.BasicApplication;
import org.apache.brooklyn.util.exceptions.Exceptions;
import org.apache.brooklyn.util.guava.Maybe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;

import com.google.common.annotations.VisibleForTesting;

import io.cloudsoft.tosca.a4c.platform.Alien4CloudSpringContext;
import io.cloudsoft.tosca.a4c.brooklyn.AlienPlatformFactory;
import io.cloudsoft.tosca.a4c.brooklyn.ApplicationSpecsBuilder;
import io.cloudsoft.tosca.a4c.brooklyn.ToscaApplication;
import io.cloudsoft.tosca.a4c.platform.Alien4CloudToscaPlatform;
import io.cloudsoft.tosca.a4c.platform.ToscaPlatform;

import org.springframework.core.io.ResourceLoader;

public class ToscaTypePlanTransformer extends AbstractTypePlanTransformer {

private static final Logger log = LoggerFactory.getLogger(ToscaTypePlanTransformer.class);
Expand Down Expand Up @@ -126,7 +122,7 @@ protected EntitySpec<? extends Application> createApplicationSpec(ToscaApplicati
Alien4CloudToscaPlatform.grantAdminAuth();
return createApplicationSpec(platform.parse(planYaml));
} catch (Exception e) {
if (e instanceof PlanNotRecognizedException) {
if (e instanceof PlanNotRecognizedException || e instanceof UnsupportedTypePlanException) {
if (log.isTraceEnabled())
log.trace("Failed to create entity from TOSCA spec:\n" + planYaml, e);
} else {
Expand All @@ -147,9 +143,9 @@ private boolean isEnabled() {
*/
private void assertAvailable() {
if (!BrooklynFeatureEnablement.isEnabled(FEATURE_TOSCA_ENABLED)) {
throw new PlanNotRecognizedException("Brooklyn TOSCA support is disabled");
throw new UnsupportedTypePlanException("Brooklyn TOSCA support is disabled");
} else if (!alienInitialised.get()) {
throw new PlanNotRecognizedException("Alien4Cloud platform is uninitialised for " + this);
throw new UnsupportedTypePlanException("Alien4Cloud platform is uninitialised for " + this);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ public ConfigKeyModifier(ManagementContext mgmt, ToscaFacade<? extends ToscaAppl
super(mgmt, alien4CloudFacade);
}

protected void configureConfigKeysSpec(EntitySpec spec, ConfigBag bag) {
protected void configureConfigKeysSpec(EntitySpec<?> spec, ConfigBag bag) {
Set<String> keyNamesUsed = new LinkedHashSet<>();
configureWithAllRecords(findAllFlagsAndConfigKeys(spec, bag), spec, keyNamesUsed);
setUnusedKeysAsAnonymousKeys(spec, keyNamesUsed, bag);
}

private void configureWithAllRecords(Collection<FlagUtils.FlagConfigKeyAndValueRecord> records, EntitySpec spec, Set<String> keyNamesUsed) {
private void configureWithAllRecords(Collection<FlagUtils.FlagConfigKeyAndValueRecord> records, EntitySpec<?> spec, Set<String> keyNamesUsed) {
for (FlagUtils.FlagConfigKeyAndValueRecord r : records) {
if (r.getFlagMaybeValue().isPresent()) {
configureWithResolvedFlag(r, spec, keyNamesUsed);
Expand All @@ -47,7 +47,7 @@ private void configureWithAllRecords(Collection<FlagUtils.FlagConfigKeyAndValueR
}
}

private void configureWithResolvedFlag(FlagUtils.FlagConfigKeyAndValueRecord r, EntitySpec spec, Set<String> keyNamesUsed) {
private void configureWithResolvedFlag(FlagUtils.FlagConfigKeyAndValueRecord r, EntitySpec<?> spec, Set<String> keyNamesUsed) {
Optional<Object> resolvedValue = resolveValue(r.getFlagMaybeValue().get(), Optional.<TypeToken>absent());
Optional<Object> oldValue = findFlagValue(spec, r);

Expand Down Expand Up @@ -99,9 +99,9 @@ private Optional<Object> joinOldAndNewSpecConfigValues(Optional<Object> oldValue

protected Object joinOldAndNewValues(Object oldValue, Object newValue) {
if ((oldValue instanceof Map) && (newValue instanceof Map)) {
return combineCurrentAndResolvedValueMaps((Map) oldValue, (Map) newValue);
return combineCurrentAndResolvedValueMaps((Map<?,?>) oldValue, (Map<?,?>) newValue);
} else if ((oldValue instanceof List) && (newValue instanceof List)) {
return combineCurrentAndResolvedValueList((List) oldValue, (List) newValue);
return combineCurrentAndResolvedValueList((List<?>) oldValue, (List<?>) newValue);
} else {
LOG.debug("Types of oldValue {} and newValue {} are not the same, so {} is not able " +
"to join them. Then, new type will be returned ",
Expand All @@ -110,28 +110,28 @@ protected Object joinOldAndNewValues(Object oldValue, Object newValue) {
}
}

private Map combineCurrentAndResolvedValueMaps(Map currentValue, Map resolvedVaue) {
return MutableMap.copyOf(currentValue).add(resolvedVaue);
private Map combineCurrentAndResolvedValueMaps(Map<?,?> currentValue, Map<?,?> resolvedVaue) {
return MutableMap.<Object, Object>copyOf(currentValue).add(resolvedVaue);
}

private List combineCurrentAndResolvedValueList(List currentValue, List resolvedVaue) {
MutableList result = MutableList.copyOf(currentValue);
private List combineCurrentAndResolvedValueList(List<?> currentValue, List<?> resolvedVaue) {
MutableList<Object> result = MutableList.<Object>copyOf(currentValue);
result.addAll(resolvedVaue);
return result;
}

private Optional<Object> getConfigKeyValue(EntitySpec spec,
private Optional<Object> getConfigKeyValue(EntitySpec<?> spec,
FlagUtils.FlagConfigKeyAndValueRecord r) {
return Optional.fromNullable(spec.getConfig().get(r.getConfigKey()));
}

private Optional<Object> findFlagValue(EntitySpec spec,
private Optional<Object> findFlagValue(EntitySpec<?> spec,
FlagUtils.FlagConfigKeyAndValueRecord r) {
return Optional.fromNullable(spec.getFlags().get(r.getFlagName()));
}


private void setUnusedKeysAsAnonymousKeys(EntitySpec spec, Set<String> keyNamesUsed, ConfigBag bag) {
private void setUnusedKeysAsAnonymousKeys(EntitySpec<?> spec, Set<String> keyNamesUsed, ConfigBag bag) {
// they aren't flags or known config keys, so must be passed as config keys in order for
// EntitySpec to know what to do with them (as they are passed to the spec as flags)
for (String key : MutableSet.copyOf(bag.getUnusedConfig().keySet())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void apply(EntitySpec<?> entitySpec, String nodeId, ToscaApplication tosc
}

// We know that formatString will return a BrooklynDslDeferredSupplier as the 2nd argument is not yet resolved
BrooklynDslDeferredSupplier deferredInstallDir = (BrooklynDslDeferredSupplier) BrooklynDslCommon.formatString("%s/%s/%s", BrooklynDslCommon.attributeWhenReady("install.dir"), directoryPrefix, artifactId);
BrooklynDslDeferredSupplier<String> deferredInstallDir = (BrooklynDslDeferredSupplier<String>) BrooklynDslCommon.formatString("%s/%s/%s", BrooklynDslCommon.attributeWhenReady("install.dir"), directoryPrefix, artifactId);
entitySpec.configure(SoftwareProcess.SHELL_ENVIRONMENT.subKey(artifactId), deferredInstallDir);

// Copy all files in resource.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.google.common.base.Optional;

import io.cloudsoft.tosca.a4c.brooklyn.ToscaApplication;
import io.cloudsoft.tosca.a4c.brooklyn.ToscaFacade;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.cloudsoft.tosca.a4c.platform;

import java.io.Closeable;
import java.nio.file.Path;

import io.cloudsoft.tosca.a4c.brooklyn.ToscaApplication;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package io.cloudsoft.tosca.a4c.brooklyn;

import static org.mockito.Mockito.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import java.util.Map;

import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
Expand Down
Loading

0 comments on commit 3029220

Please sign in to comment.