gemmellr commented on code in PR #4246:
URL: https://github.com/apache/activemq-artemis/pull/4246#discussion_r1010609164


##########
artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Upgrade.java:
##########
@@ -0,0 +1,299 @@
+/*
+ * 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.activemq.artemis.cli.commands;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.nio.file.Files;
+import java.nio.file.StandardCopyOption;
+import java.util.Iterator;
+import java.util.stream.Stream;
+
+import io.airlift.airline.Command;
+
+@Command(name = "upgrade", description = "Update an artemis instance to the 
current artemis.home, keeping all the data and broker.xml. Warning: backup your 
instance before using this command and compare the files.")
+public class Upgrade extends InstallAbstract {
+
+   /**
+    * Checks that the directory provided either exists and is writable or 
doesn't exist but can be created.
+    */
+   protected void checkDirectory() {
+      if (!directory.exists()) {
+         throw new RuntimeException(String.format("Could not find path '%s' to 
upgrade.", directory));
+      } else if (!directory.canWrite()) {
+         throw new RuntimeException(String.format("The path '%s' is not 
writable.", directory));
+      }
+   }
+
+
+   @Override
+   public Object execute(ActionContext context) throws Exception {
+      this.checkDirectory();
+      super.execute(context);
+
+      return run(context);
+   }
+
+
+   public Object run(ActionContext context) throws Exception {
+      File bkpFolder = findBackup();
+      File bkpBin = new File(bkpFolder, "bin");
+      File etcBkp = new File(bkpFolder, "etc");
+      bkpBin.mkdirs();
+      etcBkp.mkdirs();
+
+      File bin = new File(directory, "bin");
+      File etcFolder = new File(directory, etc);

Review Comment:
   Ah, I didnt know about that. "If the child pathname string is absolute then 
it is converted into a relative pathname in a system-dependent way." Could 
still generate an ugly value if 'directory' isnt the parent, but should work.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to