|
@@ -32,7 +32,6 @@ import java.util.Set;
|
|
|
|
|
|
import org.apache.ambari.server.AmbariException;
|
|
|
import org.apache.ambari.server.DuplicateResourceException;
|
|
|
-import org.apache.ambari.server.api.services.AmbariMetaInfo;
|
|
|
import org.apache.ambari.server.controller.AmbariManagementController;
|
|
|
import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
|
|
|
import org.apache.ambari.server.controller.spi.NoSuchResourceException;
|
|
@@ -52,13 +51,11 @@ import org.apache.ambari.server.orm.entities.HostGroupComponentEntity;
|
|
|
import org.apache.ambari.server.orm.entities.HostGroupEntity;
|
|
|
import org.apache.ambari.server.orm.entities.StackEntity;
|
|
|
import org.apache.ambari.server.stack.NoSuchStackException;
|
|
|
-import org.apache.ambari.server.state.*;
|
|
|
import org.apache.ambari.server.topology.Blueprint;
|
|
|
import org.apache.ambari.server.topology.BlueprintFactory;
|
|
|
import org.apache.ambari.server.topology.InvalidTopologyException;
|
|
|
|
|
|
import com.google.gson.Gson;
|
|
|
-import org.apache.ambari.server.utils.SecretReference;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -119,10 +116,6 @@ public class BlueprintResourceProvider extends AbstractControllerResourceProvide
|
|
|
*/
|
|
|
private static Gson jsonSerializer;
|
|
|
|
|
|
- /**
|
|
|
- * Used to get stack metainfo.
|
|
|
- */
|
|
|
- private static AmbariMetaInfo ambariMetaInfo;
|
|
|
|
|
|
// ----- Constructors ----------------------------------------------------
|
|
|
|
|
@@ -147,11 +140,10 @@ public class BlueprintResourceProvider extends AbstractControllerResourceProvide
|
|
|
* @param dao blueprint data access object
|
|
|
* @param gson json serializer
|
|
|
*/
|
|
|
- public static void init(BlueprintFactory factory, BlueprintDAO dao, Gson gson, AmbariMetaInfo metaInfo) {
|
|
|
+ public static void init(BlueprintFactory factory, BlueprintDAO dao, Gson gson) {
|
|
|
blueprintFactory = factory;
|
|
|
blueprintDAO = dao;
|
|
|
jsonSerializer = gson;
|
|
|
- ambariMetaInfo = metaInfo;
|
|
|
}
|
|
|
|
|
|
// ----- ResourceProvider ------------------------------------------------
|
|
@@ -183,7 +175,7 @@ public class BlueprintResourceProvider extends AbstractControllerResourceProvide
|
|
|
//todo: continue to use dao/entity directly or use blueprint factory?
|
|
|
public Set<Resource> getResources(Request request, Predicate predicate)
|
|
|
throws SystemException, UnsupportedPropertyException,
|
|
|
- NoSuchResourceException, NoSuchParentResourceException {
|
|
|
+ NoSuchResourceException, NoSuchParentResourceException {
|
|
|
|
|
|
List<BlueprintEntity> results = null;
|
|
|
boolean applyPredicate = false;
|
|
@@ -250,8 +242,8 @@ public class BlueprintResourceProvider extends AbstractControllerResourceProvide
|
|
|
modifyResources(new Command<Void>() {
|
|
|
@Override
|
|
|
public Void invoke() throws AmbariException {
|
|
|
- blueprintDAO.removeByName(blueprintName);
|
|
|
- return null;
|
|
|
+ blueprintDAO.removeByName(blueprintName);
|
|
|
+ return null;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -271,7 +263,7 @@ public class BlueprintResourceProvider extends AbstractControllerResourceProvide
|
|
|
*
|
|
|
* @return a new resource instance for the given blueprint entity
|
|
|
*/
|
|
|
- protected Resource toResource(BlueprintEntity entity, Set<String> requestedIds) throws NoSuchResourceException {
|
|
|
+ protected Resource toResource(BlueprintEntity entity, Set<String> requestedIds) {
|
|
|
StackEntity stackEntity = entity.getStack();
|
|
|
Resource resource = new ResourceImpl(Resource.Type.Blueprint);
|
|
|
setResourceProperty(resource, BLUEPRINT_NAME_PROPERTY_ID, entity.getBlueprintName(), requestedIds);
|
|
@@ -312,39 +304,16 @@ public class BlueprintResourceProvider extends AbstractControllerResourceProvide
|
|
|
* @return list of configuration property maps
|
|
|
*/
|
|
|
List<Map<String, Map<String, Object>>> populateConfigurationList(
|
|
|
- Collection<? extends BlueprintConfiguration> configurations) throws NoSuchResourceException {
|
|
|
+ Collection<? extends BlueprintConfiguration> configurations) {
|
|
|
|
|
|
List<Map<String, Map<String, Object>>> listConfigurations = new ArrayList<Map<String, Map<String, Object>>>();
|
|
|
for (BlueprintConfiguration config : configurations) {
|
|
|
Map<String, Map<String, Object>> mapConfigurations = new HashMap<String, Map<String, Object>>();
|
|
|
Map<String, Object> configTypeDefinition = new HashMap<String, Object>();
|
|
|
String type = config.getType();
|
|
|
-
|
|
|
- if(config instanceof BlueprintConfigEntity) {
|
|
|
- Map<String, String> properties = jsonSerializer.<Map<String, String>>fromJson(
|
|
|
- config.getConfigData(), Map.class);
|
|
|
-
|
|
|
- StackEntity stack = ((BlueprintConfigEntity)config).getBlueprintEntity().getStack();
|
|
|
- StackInfo metaInfoStack;
|
|
|
-
|
|
|
- try {
|
|
|
- metaInfoStack = ambariMetaInfo.getStack(stack.getStackName(), stack.getStackVersion());
|
|
|
- } catch (AmbariException e) {
|
|
|
- throw new NoSuchResourceException(e.getMessage());
|
|
|
- }
|
|
|
-
|
|
|
- Map<org.apache.ambari.server.state.PropertyInfo.PropertyType, Set<String>> propertiesTypes =
|
|
|
- metaInfoStack.getConfigPropertiesTypes(type);
|
|
|
-
|
|
|
- SecretReference.replacePasswordsWithReferences(propertiesTypes, properties, type, -1l);
|
|
|
-
|
|
|
- configTypeDefinition.put(PROPERTIES_PROPERTY_ID, properties);
|
|
|
- } else {
|
|
|
- Map<String, Object> properties = jsonSerializer.<Map<String, Object>>fromJson(
|
|
|
- config.getConfigData(), Map.class);
|
|
|
- configTypeDefinition.put(PROPERTIES_PROPERTY_ID, properties);
|
|
|
- }
|
|
|
-
|
|
|
+ Map<String, Object> properties = jsonSerializer.<Map<String, Object>>fromJson(
|
|
|
+ config.getConfigData(), Map.class);
|
|
|
+ configTypeDefinition.put(PROPERTIES_PROPERTY_ID, properties);
|
|
|
Map<String, Map<String, String>> attributes = jsonSerializer.<Map<String, Map<String, String>>>fromJson(
|
|
|
config.getConfigAttributes(), Map.class);
|
|
|
if (attributes != null && !attributes.isEmpty()) {
|