You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by al...@apache.org on 2016/06/29 14:38:04 UTC
[05/10] ambari git commit: Revert "AMBARI-17079. Moved Hue to Ambari
migrator to standard view architecture (Pradarttana Panda via dipayanb)"
http://git-wip-us.apache.org/repos/asf/ambari/blob/c40ec582/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/migration/revertchange/RevertChangeUtility.java
----------------------------------------------------------------------
diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/migration/revertchange/RevertChangeUtility.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/migration/revertchange/RevertChangeUtility.java
deleted file mode 100644
index 7e1bbf4..0000000
--- a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/migration/revertchange/RevertChangeUtility.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.apache.ambari.view.huetoambarimigration.migration.revertchange;
-
-import java.beans.PropertyVetoException;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.security.PrivilegedExceptionAction;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
-
-import org.apache.ambari.view.ViewContext;
-import org.apache.ambari.view.huetoambarimigration.resources.scripts.models.MigrationModel;
-import org.apache.ambari.view.huetoambarimigration.persistence.utils.ItemNotFound;
-import org.apache.ambari.view.huetoambarimigration.resources.PersonalCRUDResourceManager;
-import org.apache.ambari.view.huetoambarimigration.resources.scripts.MigrationResourceManager;
-import org.apache.ambari.view.huetoambarimigration.resources.scripts.models.MigrationResponse;
-import org.apache.log4j.Logger;
-import org.jdom.Document;
-import org.jdom.Element;
-import org.jdom.JDOMException;
-import org.jdom.input.SAXBuilder;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.security.UserGroupInformation;
-
-import org.apache.ambari.view.huetoambarimigration.datasource.DataSourceAmbariDatabase;
-import org.apache.ambari.view.huetoambarimigration.migration.configuration.ConfigurationCheckImplementation;
-
-
-public class RevertChangeUtility {
-
-
-
- protected MigrationResourceManager resourceManager = null;
-
- public synchronized PersonalCRUDResourceManager<MigrationResponse> getResourceManager(ViewContext view) {
- if (resourceManager == null) {
- resourceManager = new MigrationResourceManager(view);
- }
- return resourceManager;
- }
-
- public boolean stringtoDatecompare(String datefromservlet,
- String datefromfile) throws ParseException {
-
- SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
- Date date1 = formatter.parse(datefromservlet);
- Date date2 = formatter.parse(datefromfile);
- if (date1.compareTo(date2) < 0) {
- return true;
- } else {
- return false;
- }
-
- }
-
- public void removedir(final String dir, final String namenodeuri)
- throws IOException, URISyntaxException {
-
- try {
- UserGroupInformation ugi = UserGroupInformation
- .createRemoteUser("hdfs");
-
- ugi.doAs(new PrivilegedExceptionAction<Void>() {
-
- public Void run() throws Exception {
-
- Configuration conf = new Configuration();
- conf.set("fs.hdfs.impl",
- org.apache.hadoop.hdfs.DistributedFileSystem.class
- .getName());
- conf.set("fs.file.impl",
- org.apache.hadoop.fs.LocalFileSystem.class
- .getName());
- conf.set("fs.defaultFS", namenodeuri);
- conf.set("hadoop.job.ugi", "hdfs");
-
- FileSystem fs = FileSystem.get(conf);
- Path src = new Path(dir);
- fs.delete(src, true);
- return null;
- }
- });
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- public MigrationModel revertChangeUtility(String instance, String revertDate,String jobid,ViewContext view,MigrationResponse migrationresult) throws IOException, ItemNotFound {
-
- long startTime = System.currentTimeMillis();
-
- final Logger logger = Logger.getLogger(RevertChangeUtility.class);
-
- logger.info("------------------------------");
- logger.info("Reverting the changes Start:");
- logger.info("------------------------------");
-
- logger.info("Revert Date " + revertDate);
- logger.info("instance name " + instance);
- int i = 0;
-
- BufferedReader br = null;
- Connection connectionAmbariDatabase = null;
-
- try {
- connectionAmbariDatabase = DataSourceAmbariDatabase.getInstance(view.getProperties().get("ambaridrivername"), view.getProperties().get("ambarijdbcurl"), view.getProperties().get("ambaridbusername"), view.getProperties().get("ambaridbpassword")).getConnection();
- connectionAmbariDatabase.setAutoCommit(false);
-
- Statement stmt = null;
- stmt = connectionAmbariDatabase.createStatement();
- SAXBuilder builder = new SAXBuilder();
- File xmlFile = new File(ConfigurationCheckImplementation.getHomeDir() + "RevertChangesService.xml");
- try {
-
- Document document = (Document) builder.build(xmlFile);
- Element rootNode = document.getRootElement();
- List list = rootNode.getChildren("RevertRecord");
- logger.info("list size is = "+list.size());
- for (i = 0; i < list.size(); i++) {
-
- float calc = ((float) (i + 1)) / list.size() * 100;
- int progressPercentage = Math.round(calc);
-
- migrationresult.setIsNoQuerySelected("yes");
- migrationresult.setProgressPercentage(progressPercentage);
- migrationresult.setNumberOfQueryTransfered(i+1);
- migrationresult.setTotalNoQuery(list.size());
-
- getResourceManager(view).update(migrationresult, jobid);
-
- Element node = (Element) list.get(i);
-
- if (node.getChildText("instance").equals(instance)) {
- logger.info("instance matched");
-
- if (stringtoDatecompare(revertDate, node.getChildText("datetime").toString())) {
- logger.info("date is less query is sucess");
- String sql = node.getChildText("query");
- logger.info(sql);
- stmt.executeUpdate(sql);
- removedir(node.getChildText("dirname").toString(), view.getProperties().get("namenode_URI_Ambari"));
- logger.info(node.getChildText("dirname").toString() + " deleted");
-
- }
- else {
- logger.info("date is big query is failed");
- }
-
- }
-
- }
-
- connectionAmbariDatabase.commit();
-
-
-
-
-
-
-
-
- logger.info("------------------------------");
- logger.info("Reverting the changes End");
- logger.info("------------------------------");
-
- } catch (IOException e) {
- logger.error("IOException: ", e);
- } catch (ParseException e) {
- logger.error("ParseException: ", e);
- } catch (JDOMException e) {
- logger.error("JDOMException: ", e);
- } catch (URISyntaxException e) {
- logger.error("URISyntaxException: ", e);
- }
- } catch (SQLException e1) {
- logger.error("SqlException ", e1);
- try {
- connectionAmbariDatabase.rollback();
- logger.info("Rollback done");
- } catch (SQLException e2) {
- logger.error("SqlException in Rollback ", e2);
- }
- } catch (PropertyVetoException e) {
- logger.error("PropertyVetoException: ", e);
- }
-
- long stopTime = System.currentTimeMillis();
- long elapsedTime = stopTime - startTime;
-
- MigrationModel model = new MigrationModel();
-// model.setInstanceName(instance);
-// model.setNumberofQueryTransfered(i + 1);
-// model.setTimeTakentotransfer(String.valueOf(elapsedTime));
-
- return model;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/c40ec582/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/model/PojoHive.java
----------------------------------------------------------------------
diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/model/PojoHive.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/model/PojoHive.java
new file mode 100644
index 0000000..f8d731d
--- /dev/null
+++ b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/model/PojoHive.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.apache.ambari.view.huetoambarimigration.model;
+
+public class PojoHive {
+
+ private String database;
+ private String owner;
+ private String query;
+
+ public String getDatabase() {
+ return database;
+ }
+
+ public void setDatabase(String database) {
+ this.database = database;
+ }
+
+ public String getOwner() {
+ return owner;
+ }
+
+ public void setOwner(String owner) {
+ this.owner = owner;
+ }
+
+ public String getQuery() {
+ return query;
+ }
+
+ public void setQuery(String query) {
+ this.query = query;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/c40ec582/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/model/PojoPig.java
----------------------------------------------------------------------
diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/model/PojoPig.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/model/PojoPig.java
new file mode 100644
index 0000000..05d0da9
--- /dev/null
+++ b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/model/PojoPig.java
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.apache.ambari.view.huetoambarimigration.model;
+
+import java.util.Date;
+
+public class PojoPig {
+
+ private Date dt;
+ private String script;
+ private String Status;
+ private String title;
+ private String dir;
+
+ public Date getDt() {
+ return dt;
+ }
+
+ public void setDt(Date dt) {
+ this.dt = dt;
+ }
+
+ public String getScript() {
+ return script;
+ }
+
+ public void setScript(String script) {
+ this.script = script;
+ }
+
+ public String getStatus() {
+ return Status;
+ }
+
+ public void setStatus(String status) {
+ Status = status;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public String getDir() {
+ return dir;
+ }
+
+ public void setDir(String dir) {
+ this.dir = dir;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/c40ec582/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/DataStoreStorage.java
----------------------------------------------------------------------
diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/DataStoreStorage.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/DataStoreStorage.java
deleted file mode 100644
index 24b7959..0000000
--- a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/DataStoreStorage.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.ambari.view.huetoambarimigration.persistence;
-
-import org.apache.ambari.view.PersistenceException;
-import org.apache.ambari.view.ViewContext;
-
-import org.apache.ambari.view.huetoambarimigration.utils.ServiceFormattedException;
-import org.apache.ambari.view.huetoambarimigration.persistence.utils.*;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.ws.rs.WebApplicationException;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * Engine for storing objects to context DataStore storage
- */
-public class DataStoreStorage implements Storage {
- private final static Logger LOG =
- LoggerFactory.getLogger(DataStoreStorage.class);
- protected ViewContext context;
-
- /**
- * Constructor
- * @param context View Context instance
- */
- public DataStoreStorage(ViewContext context) {
- this.context = context;
- }
-
- @Override
- public void store(Indexed obj) {
- try {
- if (obj.getId() == null) {
- int id = nextIdForEntity(context, obj.getClass());
- obj.setId(String.valueOf(id));
- }
- context.getDataStore().store(obj);
- } catch (PersistenceException e) {
- throw new ServiceFormattedException("Error while saving object to DataStorage", e);
- }
- }
-
- private static int nextIdForEntity(ViewContext context, Class aClass) {
- // auto increment id implementation
- String lastId = context.getInstanceData(aClass.getName());
- int newId;
- if (lastId == null) {
- newId = 1;
- } else {
- newId = Integer.parseInt(lastId) + 1;
- }
- context.putInstanceData(aClass.getName(), String.valueOf(newId));
- return newId;
- }
-
- @Override
- public <T extends Indexed> T load(Class<T> model, int id) throws ItemNotFound {
- LOG.debug(String.format("Loading %s #%d", model.getName(), id));
- try {
- T obj = context.getDataStore().find(model, String.valueOf(id));
- if (obj != null) {
- return obj;
- } else {
- throw new ItemNotFound();
- }
- } catch (PersistenceException e) {
- throw new ServiceFormattedException("Error while finding object in DataStorage", e);
- }
- }
-
- @Override
- public synchronized <T extends Indexed> List<T> loadAll(Class<T> model, FilteringStrategy filter) {
- LinkedList<T> list = new LinkedList<T>();
- LOG.debug(String.format("Loading all %s-s", model.getName()));
- try {
- for(T item: context.getDataStore().findAll(model, null)) {
- if ((filter == null) || filter.isConform(item)) {
- list.add(item);
- }
- }
- } catch (PersistenceException e) {
- throw new ServiceFormattedException("Error while finding all objects in DataStorage", e);
- }
- return list;
- }
-
- @Override
- public synchronized <T extends Indexed> List<T> loadAll(Class<T> model) {
- return loadAll(model, new OnlyOwnersFilteringStrategy(this.context.getUsername()));
- }
-
- @Override
- public synchronized void delete(Class model, int id) throws ItemNotFound {
- LOG.debug(String.format("Deleting %s:%d", model.getName(), id));
- Object obj = load(model, id);
- try {
- context.getDataStore().remove(obj);
- } catch (PersistenceException e) {
- throw new ServiceFormattedException("Error while removing object from DataStorage", e);
- }
- }
-
- @Override
- public boolean exists(Class model, int id) {
- try {
- return context.getDataStore().find(model, String.valueOf(id)) != null;
- } catch (PersistenceException e) {
- throw new ServiceFormattedException("Error while finding object in DataStorage", e);
- }
- }
-
- public static void storageSmokeTest(ViewContext context) {
- try {
- SmokeTestEntity entity = new SmokeTestEntity();
- entity.setData("42");
- DataStoreStorage storage = new DataStoreStorage(context);
- storage.store(entity);
-
- if (entity.getId() == null) throw new ServiceFormattedException("Ambari Views instance data DB doesn't work properly (auto increment id doesn't work)", null);
- int id = Integer.parseInt(entity.getId());
- SmokeTestEntity entity2 = storage.load(SmokeTestEntity.class, id);
- boolean status = entity2.getData().compareTo("42") == 0;
- storage.delete(SmokeTestEntity.class, id);
- if (!status) throw new ServiceFormattedException("Ambari Views instance data DB doesn't work properly", null);
- } catch (WebApplicationException ex) {
- throw ex;
- } catch (Exception ex) {
- throw new ServiceFormattedException(ex.getMessage(), ex);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/c40ec582/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/InstanceKeyValueStorage.java
----------------------------------------------------------------------
diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/InstanceKeyValueStorage.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/InstanceKeyValueStorage.java
deleted file mode 100644
index ec57f0a..0000000
--- a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/InstanceKeyValueStorage.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.ambari.view.huetoambarimigration.persistence;
-
-import org.apache.ambari.view.ViewContext;
-import org.apache.ambari.view.huetoambarimigration.persistence.utils.*;
-import org.apache.ambari.view.huetoambarimigration.utils.ServiceFormattedException;
-import org.apache.commons.configuration.Configuration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.ws.rs.WebApplicationException;
-
-
-/**
- * Persistent storage engine for storing java beans to
- * instance data
- */
-@Deprecated
-public class InstanceKeyValueStorage extends KeyValueStorage {
- private final static Logger LOG =
- LoggerFactory.getLogger(InstanceKeyValueStorage.class);
-
- private ContextConfigurationAdapter config = null;
- private int VALUE_LENGTH_LIMIT = 254;
-
- /**
- * Constructor.
- * @param context View Context instance
- */
- public InstanceKeyValueStorage(ViewContext context) {
- super(context);
- }
-
- /**
- * Returns config instance, adapter to Persistence API
- * @return config instance
- */
- @Override
- protected synchronized Configuration getConfig() {
- if (config == null) {
- config = new ContextConfigurationAdapter(context);
- }
- return config;
- }
-
- /**
- * Value is limited to 256 symbols, this code splits value into chunks and saves them as <key>#<chunk_id>
- * @param modelPropName key
- * @param json value
- */
- protected void write(String modelPropName, String json) {
- int saved = 0;
- int page = 1;
- while (saved < json.length()) {
- int end = Math.min(saved + VALUE_LENGTH_LIMIT, json.length());
- String substring = json.substring(saved, end);
- getConfig().setProperty(modelPropName + "#" + page, substring);
- saved += VALUE_LENGTH_LIMIT;
- page += 1;
- LOG.debug("Chunk saved: " + modelPropName + "#" + page + "=" + substring);
- }
- getConfig().setProperty(modelPropName, page - 1);
- LOG.debug("Write finished: " + modelPropName + " pages:" + (page - 1));
- }
-
- /**
- * Read chunked value (keys format <key>#<chunk_id>)
- * @param modelPropName key
- * @return value
- */
- protected String read(String modelPropName) {
- StringBuilder result = new StringBuilder();
- int pages = getConfig().getInt(modelPropName);
- LOG.debug("Read started: " + modelPropName + " pages:" + pages);
-
- for(int page = 1; page <= pages; page++) {
- String substring = getConfig().getString(modelPropName + "#" + page);
- LOG.debug("Chunk read: " + modelPropName + "#" + page + "=" + substring);
- if (substring != null) {
- result.append(substring);
- }
- }
-
- return result.toString();
- }
-
- /**
- * Remove chunked value (keys format <key>#<chunk_id>)
- * @param modelPropName key
- */
- protected void clear(String modelPropName) {
- int pages = getConfig().getInt(modelPropName);
- LOG.debug("Clean started: " + modelPropName + " pages:" + pages);
-
- for(int page = 1; page <= pages; page++) {
- getConfig().clearProperty(modelPropName + "#" + page);
- LOG.debug("Chunk clean: " + modelPropName + "#" + page);
- }
- getConfig().clearProperty(modelPropName);
- }
-
- public static void storageSmokeTest(ViewContext context) {
- try {
- final String property = "test.smoke.property";
- context.putInstanceData(property, "42");
- boolean status = context.getInstanceData(property).equals("42");
- context.removeInstanceData(property);
- if (!status) throw new ServiceFormattedException("Ambari Views instance data DB doesn't work properly", null);
- } catch (WebApplicationException ex) {
- throw ex;
- } catch (Exception ex) {
- throw new ServiceFormattedException(ex.getMessage(), ex);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/c40ec582/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/KeyValueStorage.java
----------------------------------------------------------------------
diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/KeyValueStorage.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/KeyValueStorage.java
deleted file mode 100644
index fd07a39..0000000
--- a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/KeyValueStorage.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.ambari.view.huetoambarimigration.persistence;
-
-import com.google.gson.Gson;
-import org.apache.ambari.view.ViewContext;
-import org.apache.ambari.view.huetoambarimigration.persistence.utils.FilteringStrategy;
-import org.apache.ambari.view.huetoambarimigration.persistence.utils.Indexed;
-import org.apache.ambari.view.huetoambarimigration.persistence.utils.ItemNotFound;
-import org.apache.ambari.view.huetoambarimigration.persistence.utils.OnlyOwnersFilteringStrategy;
-import org.apache.commons.configuration.Configuration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Engine for storing objects to key-value storage
- */
-public abstract class KeyValueStorage implements Storage {
- private final static Logger LOG =
- LoggerFactory.getLogger(KeyValueStorage.class);
- protected final Gson gson = new Gson();
- protected ViewContext context;
-
- /**
- * Constructor
- * @param context View Context instance
- */
- public KeyValueStorage(ViewContext context) {
- this.context = context;
- }
-
- /**
- * Returns config instance, adapter to Persistence API
- * @return config instance
- */
- protected abstract Configuration getConfig();
-
- @Override
- public synchronized void store(Indexed obj) {
- String modelIndexingPropName = getIndexPropertyName(obj.getClass());
-
- if (obj.getId() == null) {
- int lastIndex = getConfig().getInt(modelIndexingPropName, 0);
- lastIndex ++;
- getConfig().setProperty(modelIndexingPropName, lastIndex);
- obj.setId(Integer.toString(lastIndex));
- }
-
- String modelPropName = getItemPropertyName(obj.getClass(), Integer.parseInt(obj.getId()));
- String json = serialize(obj);
- write(modelPropName, json);
- }
-
- @Override
- public <T extends Indexed> T load(Class<T> model, int id) throws ItemNotFound {
- String modelPropName = getItemPropertyName(model, id);
- LOG.debug(String.format("Loading %s", modelPropName));
- if (getConfig().containsKey(modelPropName)) {
- String json = read(modelPropName);
- LOG.debug(String.format("json: %s", json));
- return deserialize(model, json);
- } else {
- throw new ItemNotFound();
- }
- }
-
- /**
- * Write json to storage
- * @param modelPropName key
- * @param json value
- */
- protected void write(String modelPropName, String json) {
- getConfig().setProperty(modelPropName, json);
- }
-
- /**
- * Read json from storage
- * @param modelPropName key
- * @return value
- */
- protected String read(String modelPropName) {
- return getConfig().getString(modelPropName);
- }
-
- /**
- * Remove line from storage
- * @param modelPropName key
- */
- protected void clear(String modelPropName) {
- getConfig().clearProperty(modelPropName);
- }
-
- protected String serialize(Indexed obj) {
- return gson.toJson(obj);
- }
-
- protected <T extends Indexed> T deserialize(Class<T> model, String json) {
- return gson.fromJson(json, model);
- }
-
- @Override
- public synchronized <T extends Indexed> List<T> loadAll(Class<T> model, FilteringStrategy filter) {
- ArrayList<T> list = new ArrayList<T>();
- String modelIndexingPropName = getIndexPropertyName(model);
- LOG.debug(String.format("Loading all %s-s", model.getName()));
- int lastIndex = getConfig().getInt(modelIndexingPropName, 0);
- for(int i=1; i<=lastIndex; i++) {
- try {
- T item = load(model, i);
- if ((filter == null) || filter.isConform(item)) {
- list.add(item);
- }
- } catch (ItemNotFound ignored) {
- }
- }
- return list;
- }
-
- @Override
- public synchronized <T extends Indexed> List<T> loadAll(Class<T> model) {
- return loadAll(model, new OnlyOwnersFilteringStrategy(this.context.getUsername()));
- }
-
- @Override
- public synchronized void delete(Class model, int id) {
- LOG.debug(String.format("Deleting %s:%d", model.getName(), id));
- String modelPropName = getItemPropertyName(model, id);
- clear(modelPropName);
- }
-
- @Override
- public boolean exists(Class model, int id) {
- return getConfig().containsKey(getItemPropertyName(model, id));
- }
-
- private String getIndexPropertyName(Class model) {
- return String.format("%s:index", model.getName());
- }
-
- private String getItemPropertyName(Class model, int id) {
- return String.format("%s.%d", model.getName(), id);
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/c40ec582/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/LocalKeyValueStorage.java
----------------------------------------------------------------------
diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/LocalKeyValueStorage.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/LocalKeyValueStorage.java
deleted file mode 100644
index cfbe7f7..0000000
--- a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/LocalKeyValueStorage.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.ambari.view.huetoambarimigration.persistence;
-
-import org.apache.ambari.view.ViewContext;
-import org.apache.ambari.view.huetoambarimigration.utils.MisconfigurationFormattedException;
-import org.apache.commons.configuration.ConfigurationException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * Persistent storage engine for storing java beans to
- * properties file
- * Path to file should be in 'dataworker.storagePath' parameter
- */
-@Deprecated
-public class LocalKeyValueStorage extends KeyValueStorage {
- private final static Logger LOG =
- LoggerFactory.getLogger(LocalKeyValueStorage.class);
-
- private PersistentConfiguration config = null;
-
- /**
- * Constructor
- * @param context View Context instance
- */
- public LocalKeyValueStorage(ViewContext context) {
- super(context);
- }
-
- /**
- * Returns config instance
- * @return config instance
- */
- @Override
- protected synchronized PersistentConfiguration getConfig() {
- if (config == null) {
- String fileName = context.getProperties().get("dataworker.storagePath");
- if (fileName == null) {
- String msg = "dataworker.storagePath is not configured!";
- LOG.error(msg);
- throw new MisconfigurationFormattedException("dataworker.storagePath");
- }
- try {
- config = new PersistentConfiguration(fileName);
- } catch (ConfigurationException e) {
- e.printStackTrace();
- }
- }
- return config;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/c40ec582/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/PersistentConfiguration.java
----------------------------------------------------------------------
diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/PersistentConfiguration.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/PersistentConfiguration.java
deleted file mode 100644
index a97c5f7..0000000
--- a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/PersistentConfiguration.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.ambari.view.huetoambarimigration.persistence;
-
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.commons.configuration.reloading.FileChangedReloadingStrategy;
-
-import java.io.File;
-
-/**
- * Configuration enables all necessary options for PropertiesConfiguration:
- * auto-save, auto-reloading, no delimiter parsing and other
- */
-@Deprecated
-public class PersistentConfiguration extends PropertiesConfiguration {
- /**
- * Constructor
- * @param fileName path to data file
- * @throws ConfigurationException
- */
- public PersistentConfiguration(String fileName) throws ConfigurationException {
- super();
-
- File config = new File(fileName);
- setFile(config);
- this.setAutoSave(true);
- this.setReloadingStrategy(new FileChangedReloadingStrategy());
- this.setDelimiterParsingDisabled(true);
- this.setListDelimiter((char) 0);
-
- if (config.exists()) {
- this.load();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/c40ec582/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/SmokeTestEntity.java
----------------------------------------------------------------------
diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/SmokeTestEntity.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/SmokeTestEntity.java
deleted file mode 100644
index 2369781..0000000
--- a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/SmokeTestEntity.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.ambari.view.huetoambarimigration.persistence;
-
-import org.apache.ambari.view.huetoambarimigration.persistence.utils.Indexed;
-
-/**
- * DataStore entity to test whether DS interface works correctly.
- */
-public class SmokeTestEntity implements Indexed {
- private String id = null;
- private String data = null;
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getData() {
- return data;
- }
-
- public void setData(String data) {
- this.data = data;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/c40ec582/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/Storage.java
----------------------------------------------------------------------
diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/Storage.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/Storage.java
deleted file mode 100644
index ccfca6b..0000000
--- a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/Storage.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.ambari.view.huetoambarimigration.persistence;
-
-import org.apache.ambari.view.huetoambarimigration.persistence.utils.FilteringStrategy;
-import org.apache.ambari.view.huetoambarimigration.persistence.utils.Indexed;
-import org.apache.ambari.view.huetoambarimigration.persistence.utils.ItemNotFound;
-
-import java.util.List;
-
-/**
- * Object storage interface
- */
-public interface Storage {
- /**
- * Persist object to DB. It should be Indexed
- * @param obj object to save
- */
- void store(Indexed obj);
-
- /**
- * Load object
- * @param model bean class
- * @param id identifier
- * @param <T> bean class
- * @return bean instance
- * @throws ItemNotFound thrown if item with id was not found in DB
- */
- <T extends Indexed> T load(Class<T> model, int id) throws ItemNotFound;
-
- /**
- * Load all objects of given bean class
- * @param model bean class
- * @param filter filtering strategy (return only those objects that conform condition)
- * @param <T> bean class
- * @return list of filtered objects
- */
- <T extends Indexed> List<T> loadAll(Class<T> model, FilteringStrategy filter);
-
- /**
- * Load all objects of given bean class
- * @param model bean class
- * @param <T> bean class
- * @return list of all objects
- */
- <T extends Indexed> List<T> loadAll(Class<T> model);
-
- /**
- * Delete object
- * @param model bean class
- * @param id identifier
- */
- void delete(Class model, int id) throws ItemNotFound;
-
- /**
- * Check is object exists
- * @param model bean class
- * @param id identifier
- * @return true if exists
- */
- boolean exists(Class model, int id);
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/c40ec582/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/utils/ContextConfigurationAdapter.java
----------------------------------------------------------------------
diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/utils/ContextConfigurationAdapter.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/utils/ContextConfigurationAdapter.java
deleted file mode 100644
index 082687e..0000000
--- a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/utils/ContextConfigurationAdapter.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.ambari.view.huetoambarimigration.persistence.utils;
-
-import org.apache.ambari.view.ViewContext;
-import org.apache.commons.configuration.Configuration;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-/**
- * Persistence API to Apache Configuration adapter
- */
-@Deprecated
-public class ContextConfigurationAdapter implements Configuration {
- private ViewContext context;
-
- /**
- * Constructor of adapter
- * @param context View Context
- */
- public ContextConfigurationAdapter(ViewContext context) {
- this.context = context;
- }
-
- @Override
- public Configuration subset(String prefix) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean isEmpty() {
- return context.getInstanceData().isEmpty();
- }
-
- @Override
- public boolean containsKey(String s) {
- Map<String, String> data = context.getInstanceData();
- return data.containsKey(s);
- }
-
- @Override
- public void addProperty(String s, Object o) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void setProperty(String s, Object o) {
- context.putInstanceData(s, o.toString());
- }
-
- @Override
- public void clearProperty(String key) {
- context.removeInstanceData(key);
- }
-
- @Override
- public void clear() {
- for (String key : context.getInstanceData().keySet())
- context.removeInstanceData(key);
- }
-
- @Override
- public Object getProperty(String key) {
- return context.getInstanceData(key);
- }
-
- @Override
- public Iterator getKeys(String s) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Iterator getKeys() {
- return context.getInstanceData().keySet().iterator();
- }
-
- @Override
- public Properties getProperties(String s) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean getBoolean(String s) {
- return getBoolean(s, null);
- }
-
- @Override
- public boolean getBoolean(String s, boolean b) {
- return getBoolean(s, (Boolean)b);
- }
-
- @Override
- public Boolean getBoolean(String s, Boolean aBoolean) {
- String data = context.getInstanceData(s);
- return (data != null)?Boolean.parseBoolean(data):aBoolean;
- }
-
- @Override
- public byte getByte(String s) {
- return getByte(s, null);
- }
-
- @Override
- public byte getByte(String s, byte b) {
- return getByte(s, (Byte)b);
- }
-
- @Override
- public Byte getByte(String s, Byte aByte) {
- String data = context.getInstanceData(s);
- return (data != null)?Byte.parseByte(data):aByte;
- }
-
- @Override
- public double getDouble(String s) {
- return getDouble(s, null);
- }
-
- @Override
- public double getDouble(String s, double v) {
- return getDouble(s, (Double)v);
- }
-
- @Override
- public Double getDouble(String s, Double aDouble) {
- String data = context.getInstanceData(s);
- return (data != null)?Double.parseDouble(data):aDouble;
- }
-
- @Override
- public float getFloat(String s) {
- return getFloat(s, null);
- }
-
- @Override
- public float getFloat(String s, float v) {
- return getFloat(s, (Float)v);
- }
-
- @Override
- public Float getFloat(String s, Float aFloat) {
- String data = context.getInstanceData(s);
- return (data != null)?Float.parseFloat(data):aFloat;
- }
-
- @Override
- public int getInt(String s) {
- return getInteger(s, null);
- }
-
- @Override
- public int getInt(String s, int i) {
- return getInteger(s, i);
- }
-
- @Override
- public Integer getInteger(String s, Integer integer) {
- String data = context.getInstanceData(s);
- return (data != null)?Integer.parseInt(data):integer;
- }
-
- @Override
- public long getLong(String s) {
- return getLong(s, null);
- }
-
- @Override
- public long getLong(String s, long l) {
- return getLong(s, (Long)l);
- }
-
- @Override
- public Long getLong(String s, Long aLong) {
- String data = context.getInstanceData(s);
- return (data != null)?Long.parseLong(data):aLong;
- }
-
- @Override
- public short getShort(String s) {
- return getShort(s, null);
- }
-
- @Override
- public short getShort(String s, short i) {
- return getShort(s, (Short)i);
- }
-
- @Override
- public Short getShort(String s, Short aShort) {
- String data = context.getInstanceData(s);
- return (data != null)?Short.parseShort(data):aShort;
- }
-
- @Override
- public BigDecimal getBigDecimal(String s) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public BigDecimal getBigDecimal(String s, BigDecimal bigDecimal) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public BigInteger getBigInteger(String s) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public BigInteger getBigInteger(String s, BigInteger bigInteger) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String getString(String s) {
- return context.getInstanceData(s);
- }
-
- @Override
- public String getString(String s, String s2) {
- String data = getString(s);
- return (data != null)?data:s2;
- }
-
- @Override
- public String[] getStringArray(String s) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public List getList(String s) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public List getList(String s, List list) {
- throw new UnsupportedOperationException();
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/c40ec582/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/utils/FilteringStrategy.java
----------------------------------------------------------------------
diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/utils/FilteringStrategy.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/utils/FilteringStrategy.java
deleted file mode 100644
index 671aad9..0000000
--- a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/utils/FilteringStrategy.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.ambari.view.huetoambarimigration.persistence.utils;
-
-/**
- * Filtering strategy for stored objects
- */
-public interface FilteringStrategy {
- /**
- * Check whether item conforms chosen filter or not
- * @param item item to check
- * @return true if item conforms this filter
- */
- boolean isConform(Indexed item);
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/c40ec582/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/utils/Indexed.java
----------------------------------------------------------------------
diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/utils/Indexed.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/utils/Indexed.java
deleted file mode 100644
index 31a3940..0000000
--- a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/utils/Indexed.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.ambari.view.huetoambarimigration.persistence.utils;
-
-/**
- * Interface to represent item with identifier
- */
-public interface Indexed {
- /**
- * Get the ID
- * @return ID
- */
- String getId();
-
- /**
- * Set ID
- * @param id ID
- */
- void setId(String id);
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/c40ec582/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/utils/ItemNotFound.java
----------------------------------------------------------------------
diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/utils/ItemNotFound.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/utils/ItemNotFound.java
deleted file mode 100644
index c6e9c6f..0000000
--- a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/utils/ItemNotFound.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.ambari.view.huetoambarimigration.persistence.utils;
-
-/**
- * Thrown when item was not found in DB
- */
-public class ItemNotFound extends Exception {
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/c40ec582/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/utils/OnlyOwnersFilteringStrategy.java
----------------------------------------------------------------------
diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/utils/OnlyOwnersFilteringStrategy.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/utils/OnlyOwnersFilteringStrategy.java
deleted file mode 100644
index 15ac1e7..0000000
--- a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/utils/OnlyOwnersFilteringStrategy.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.ambari.view.huetoambarimigration.persistence.utils;
-
-public class OnlyOwnersFilteringStrategy implements FilteringStrategy {
- private final String username;
-
- public OnlyOwnersFilteringStrategy(String username) {
- this.username = username;
- }
-
- @Override
- public boolean isConform(Indexed item) {
- Owned object = (Owned) item;
- return object.getOwner().compareTo(username) == 0;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/c40ec582/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/utils/Owned.java
----------------------------------------------------------------------
diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/utils/Owned.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/utils/Owned.java
deleted file mode 100644
index b99983e..0000000
--- a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/utils/Owned.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.ambari.view.huetoambarimigration.persistence.utils;
-
-/**
- * Interface to represent item with owner
- */
-public interface Owned {
- /**
- * Get the owner
- * @return owner
- */
- String getOwner();
-
- /**
- * Set owner
- * @param owner owner
- */
- void setOwner(String owner);
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/c40ec582/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/utils/PersonalResource.java
----------------------------------------------------------------------
diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/utils/PersonalResource.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/utils/PersonalResource.java
deleted file mode 100644
index 9978659..0000000
--- a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/utils/PersonalResource.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.ambari.view.huetoambarimigration.persistence.utils;
-
-public interface PersonalResource extends Indexed, Owned {
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/c40ec582/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/utils/StorageUtil.java
----------------------------------------------------------------------
diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/utils/StorageUtil.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/utils/StorageUtil.java
deleted file mode 100644
index 86ebe60..0000000
--- a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/persistence/utils/StorageUtil.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.ambari.view.huetoambarimigration.persistence.utils;
-
-import org.apache.ambari.view.ViewContext;
-import org.apache.ambari.view.huetoambarimigration.persistence.DataStoreStorage;
-import org.apache.ambari.view.huetoambarimigration.persistence.LocalKeyValueStorage;
-import org.apache.ambari.view.huetoambarimigration.persistence.Storage;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Storage factory, creates storage of Local or Persistence API type.
- * Type depends on context configuration: if "dataworker.storagePath" is set,
- * storage of Local type will be created. Otherwise, Persistence API will be used.
- *
- * Storage is singleton.
- */
-public class StorageUtil {
- private Storage storageInstance = null;
-
- protected final static Logger LOG =
- LoggerFactory.getLogger(StorageUtil.class);
-
-
- private static Map<String, StorageUtil> viewSingletonObjects = new HashMap<String, StorageUtil>();
- public static StorageUtil getInstance(ViewContext context) {
- if (!viewSingletonObjects.containsKey(context.getInstanceName()))
- viewSingletonObjects.put(context.getInstanceName(), new StorageUtil(context));
- return viewSingletonObjects.get(context.getInstanceName());
- }
-
- public static void dropAllConnections() {
- viewSingletonObjects.clear();
- }
-
- private ViewContext context;
-
- /**
- * Constructor of storage util
- * @param context View Context instance
- */
- public StorageUtil(ViewContext context) {
- this.context = context;
- }
-
- /**
- * Get storage instance. If one is not created, creates instance.
- * @return storage instance
- */
- public synchronized Storage getStorage() {
- if (storageInstance == null) {
- String fileName = context.getProperties().get("dataworker.storagePath");
- if (fileName != null) {
- LOG.debug("Using local storage in " + fileName + " to store data");
- // If specifed, use LocalKeyValueStorage - key-value file based storage
- storageInstance = new LocalKeyValueStorage(context);
- } else {
- LOG.debug("Using Persistence API to store data");
- // If not specifed, use ambari-views Persistence API
- storageInstance = new DataStoreStorage(context);
- }
- }
- return storageInstance;
- }
-
- /**
- * Set storage to use across all application.
- * Used in unit tests.
- * @param storage storage instance
- */
- public void setStorage(Storage storage) {
- storageInstance = storage;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/c40ec582/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/resources/CRUDResourceManager.java
----------------------------------------------------------------------
diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/resources/CRUDResourceManager.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/resources/CRUDResourceManager.java
deleted file mode 100644
index cc338a3..0000000
--- a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/resources/CRUDResourceManager.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.ambari.view.huetoambarimigration.resources;
-
-import org.apache.ambari.view.ViewContext;
-import org.apache.ambari.view.huetoambarimigration.persistence.Storage;
-import org.apache.ambari.view.huetoambarimigration.persistence.utils.FilteringStrategy;
-import org.apache.ambari.view.huetoambarimigration.persistence.utils.Indexed;
-import org.apache.ambari.view.huetoambarimigration.persistence.utils.ItemNotFound;
-import org.apache.ambari.view.huetoambarimigration.persistence.utils.StorageUtil;
-
-import java.util.List;
-
-/**
- * CRUD resource manager
- * @param <T> Data type with ID
- */
-abstract public class CRUDResourceManager<T extends Indexed> {
- private Storage storage = null;
-
- protected final Class<T> resourceClass;
-
- /**
- * Constructor
- * @param responseClass model class
- */
- public CRUDResourceManager(Class<T> responseClass) {
- this.resourceClass = responseClass;
- }
- // CRUD operations
-
- /**
- * Create operation
- * @param object object
- * @return model object
- */
- public T create(T object) {
- object.setId(null);
- return this.save(object);
- }
-
- /**
- * Read operation
- * @param id identifier
- * @return model object
- * @throws ItemNotFound
- */
- public T read(String id) throws ItemNotFound {
- T object = null;
- object = getMigrationStorage().load(this.resourceClass, Integer.parseInt(id));
- if (!checkPermissions(object))
- throw new ItemNotFound();
- return object;
- }
-
- /**
- * Read all objects
- * @param filteringStrategy filtering strategy
- * @return list of filtered objects
- */
- public List<T> readAll(FilteringStrategy filteringStrategy) {
- return getMigrationStorage().loadAll(this.resourceClass, filteringStrategy);
- }
-
- /**
- * Update operation
- * @param newObject new object
- * @param id identifier of previous object
- * @return model object
- * @throws ItemNotFound
- */
- public T update(T newObject, String id) throws ItemNotFound {
- newObject.setId(id);
- this.save(newObject);
- return newObject;
- }
-
- /**
- * Delete operation
- * @param resourceId object identifier
- * @throws ItemNotFound
- */
- public void delete(String resourceId) throws ItemNotFound {
- int id = Integer.parseInt(resourceId);
- if (!getMigrationStorage().exists(this.resourceClass, id)) {
- throw new ItemNotFound();
- }
- getMigrationStorage().delete(this.resourceClass, id);
- }
-
- // UTILS
-
- protected T save(T object) {
- getMigrationStorage().store(object);
- return object;
- }
-
- protected Storage getMigrationStorage() {
- if (storage == null) {
- storage = StorageUtil.getInstance(getContext()).getStorage();
- }
- return storage;
- }
-
- protected abstract boolean checkPermissions(T object);
- protected abstract ViewContext getContext();
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/c40ec582/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/resources/PersonalCRUDResourceManager.java
----------------------------------------------------------------------
diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/resources/PersonalCRUDResourceManager.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/resources/PersonalCRUDResourceManager.java
deleted file mode 100644
index 37409f0..0000000
--- a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/resources/PersonalCRUDResourceManager.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.ambari.view.huetoambarimigration.resources;
-
-import org.apache.ambari.view.ViewContext;
-import org.apache.ambari.view.huetoambarimigration.persistence.utils.ItemNotFound;
-import org.apache.ambari.view.huetoambarimigration.persistence.utils.PersonalResource;
-
-import java.util.concurrent.Callable;
-
-/**
- * Resource manager that returns only user owned elements from DB
- * @param <T> Data type with ID and Owner
- */
-public class PersonalCRUDResourceManager<T extends PersonalResource> extends CRUDResourceManager<T> {
- protected ViewContext context;
- protected boolean ignorePermissions = false;
-
- /**
- * Constructor
- * @param responseClass model class
- * @param context View Context instance
- */
- public PersonalCRUDResourceManager(Class<T> responseClass, ViewContext context) {
- super(responseClass);
- this.context = context;
- }
-
- @Override
- public T update(T newObject, String id) throws ItemNotFound {
- T object = getMigrationStorage().load(this.resourceClass, Integer.parseInt(id));
- if (object.getOwner().compareTo(this.context.getUsername()) != 0) {
- throw new ItemNotFound();
- }
-
- newObject.setOwner(this.context.getUsername());
- return super.update(newObject, id);
- }
-
- @Override
- public T save(T object) {
- if (!ignorePermissions) {
- // in threads permissions should be ignored,
- // because context.getUsername doesn't work. See BUG-27093.
- object.setOwner(this.context.getUsername());
- }
- return super.save(object);
- }
-
- @Override
- protected boolean checkPermissions(T object) {
- if (ignorePermissions)
- return true;
- return object.getOwner().compareTo(this.context.getUsername()) == 0;
- }
-
- @Override
- public ViewContext getContext() {
- return context;
- }
-
- /**
- * Execute action ignoring objects owner
- * @param actions callable to execute
- * @return value returned from actions
- * @throws Exception
- */
- public <T> T ignorePermissions(Callable<T> actions) throws Exception {
- ignorePermissions = true;
- T result;
- try {
- result = actions.call();
- } finally {
- ignorePermissions = false;
- }
- return result;
- }
-
- protected static String getUsername(ViewContext context) {
- String userName = context.getProperties().get("dataworker.username");
- if (userName == null || userName.compareTo("null") == 0 || userName.compareTo("") == 0)
- userName = context.getUsername();
- return userName;
- }
-
- protected String getUsername() {
- return getUsername(context);
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/c40ec582/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/resources/SharedCRUDResourceManager.java
----------------------------------------------------------------------
diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/resources/SharedCRUDResourceManager.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/resources/SharedCRUDResourceManager.java
deleted file mode 100644
index c4b9cbd..0000000
--- a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/resources/SharedCRUDResourceManager.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.ambari.view.huetoambarimigration.resources;
-
-import org.apache.ambari.view.ViewContext;
-import org.apache.ambari.view.huetoambarimigration.persistence.utils.Indexed;
-
-/**
- * Resource manager that doesn't restrict access (Allow all)
- * @param <T> Data type with ID
- */
-public class SharedCRUDResourceManager<T extends Indexed> extends CRUDResourceManager<T> {
- protected ViewContext context;
-
- /**
- * Constructor
- * @param responseClass model class
- * @param context View Context instance
- */
- public SharedCRUDResourceManager(Class<T> responseClass, ViewContext context) {
- super(responseClass);
- this.context = context;
- }
-
- @Override
- protected boolean checkPermissions(T object) {
- return true; //everyone has permission
- }
-
- @Override
- protected ViewContext getContext() {
- return context;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/c40ec582/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/resources/scripts/MigrationResourceManager.java
----------------------------------------------------------------------
diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/resources/scripts/MigrationResourceManager.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/resources/scripts/MigrationResourceManager.java
deleted file mode 100644
index a7af714..0000000
--- a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/resources/scripts/MigrationResourceManager.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.ambari.view.huetoambarimigration.resources.scripts;
-
-import org.apache.ambari.view.ViewContext;
-import org.apache.ambari.view.huetoambarimigration.resources.PersonalCRUDResourceManager;
-import org.apache.ambari.view.huetoambarimigration.resources.scripts.models.MigrationResponse;
-import org.apache.log4j.Logger;
-
-/**
- * Object that provides CRUD operations for script objects
- */
-public class MigrationResourceManager extends PersonalCRUDResourceManager<MigrationResponse> {
- final Logger logger = Logger.getLogger(MigrationResourceManager.class);
-
- /**
- * Constructor
- * @param context View Context instance
- */
- public MigrationResourceManager(ViewContext context) {
- super(MigrationResponse.class, context);
- }
-
- @Override
- public MigrationResponse create(MigrationResponse object) {
-
- super.create(object);
-
- return object;
- }
-
- private void createDefaultScriptFile(MigrationResponse object) {
- getMigrationStorage().store(object);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/c40ec582/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/resources/scripts/MigrationResourceProvider.java
----------------------------------------------------------------------
diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/resources/scripts/MigrationResourceProvider.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/resources/scripts/MigrationResourceProvider.java
deleted file mode 100644
index b93cb15..0000000
--- a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/resources/scripts/MigrationResourceProvider.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.ambari.view.huetoambarimigration.resources.scripts;
-
-import com.google.inject.Inject;
-import org.apache.ambari.view.*;
-import org.apache.ambari.view.huetoambarimigration.persistence.utils.ItemNotFound;
-import org.apache.ambari.view.huetoambarimigration.persistence.utils.OnlyOwnersFilteringStrategy;
-import org.apache.ambari.view.huetoambarimigration.resources.PersonalCRUDResourceManager;
-import org.apache.ambari.view.huetoambarimigration.resources.scripts.models.MigrationResponse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Resource provider for Scripts
- */
-public class MigrationResourceProvider implements ResourceProvider<MigrationResponse> {
- @Inject
- ViewContext context;
-
- protected MigrationResourceManager resourceManager = null;
- final org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(MigrationResourceManager.class);
-
- protected synchronized PersonalCRUDResourceManager<MigrationResponse> getResourceManager() {
- if (resourceManager == null) {
- resourceManager = new MigrationResourceManager(context);
- }
- return resourceManager;
- }
-
- @Override
- public MigrationResponse getResource(String resourceId, Set<String> properties) throws SystemException, NoSuchResourceException, UnsupportedPropertyException {
- try {
- return getResourceManager().read(resourceId);
- } catch (ItemNotFound itemNotFound) {
- throw new NoSuchResourceException(resourceId);
- }
- }
-
- @Override
- public Set<MigrationResponse> getResources(ReadRequest readRequest) throws SystemException, NoSuchResourceException, UnsupportedPropertyException {
- return new HashSet<MigrationResponse>(getResourceManager().readAll(
- new OnlyOwnersFilteringStrategy(this.context.getUsername())));
- }
-
- @Override
- public void createResource(String s, Map<String, Object> stringObjectMap) throws SystemException, ResourceAlreadyExistsException, NoSuchResourceException, UnsupportedPropertyException {
- MigrationResponse mr = null;
- try {
- mr = new MigrationResponse(stringObjectMap);
- } catch (InvocationTargetException e) {
- throw new SystemException("error on creating resource", e);
- } catch (IllegalAccessException e) {
- throw new SystemException("error on creating resource", e);
- }
- getResourceManager().create(mr);
- }
-
- @Override
- public boolean updateResource(String resourceId, Map<String, Object> stringObjectMap) throws SystemException, NoSuchResourceException, UnsupportedPropertyException {
- MigrationResponse script = null;
- try {
- script = new MigrationResponse(stringObjectMap);
- } catch (InvocationTargetException e) {
- throw new SystemException("error on updating resource", e);
- } catch (IllegalAccessException e) {
- throw new SystemException("error on updating resource", e);
- }
- try {
- getResourceManager().update(script, resourceId);
- } catch (ItemNotFound itemNotFound) {
- throw new NoSuchResourceException(resourceId);
- }
- return true;
- }
-
- @Override
- public boolean deleteResource(String resourceId) throws SystemException, NoSuchResourceException, UnsupportedPropertyException {
- try {
- getResourceManager().delete(resourceId);
- } catch (ItemNotFound itemNotFound) {
- throw new NoSuchResourceException(resourceId);
- }
- return true;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/c40ec582/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/resources/scripts/models/ConfigurationModel.java
----------------------------------------------------------------------
diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/resources/scripts/models/ConfigurationModel.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/resources/scripts/models/ConfigurationModel.java
deleted file mode 100644
index 4a29699..0000000
--- a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/resources/scripts/models/ConfigurationModel.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.apache.ambari.view.huetoambarimigration.resources.scripts.models;
-
-
-public class ConfigurationModel {
-
-
- private int id;
- private String configParameter;
- private String configStatus;
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getConfigParameter() {
- return configParameter;
- }
-
- public void setConfigParameter(String configParameter) {
- this.configParameter = configParameter;
- }
-
- public String getConfigStatus() {
- return configStatus;
- }
-
- public void setConfigStatus(String configStatus) {
- this.configStatus = configStatus;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/c40ec582/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/resources/scripts/models/HiveModel.java
----------------------------------------------------------------------
diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/resources/scripts/models/HiveModel.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/resources/scripts/models/HiveModel.java
deleted file mode 100644
index fb9496a..0000000
--- a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/resources/scripts/models/HiveModel.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.apache.ambari.view.huetoambarimigration.resources.scripts.models;
-
-public class HiveModel {
-
- private String database;
- private String owner;
- private String query;
-
- public String getDatabase() {
- return database;
- }
-
- public void setDatabase(String database) {
- this.database = database;
- }
-
- public String getOwner() {
- return owner;
- }
-
- public void setOwner(String owner) {
- this.owner = owner;
- }
-
- public String getQuery() {
- return query;
- }
-
- public void setQuery(String query) {
- this.query = query;
- }
-
-}