petrovic-d commented on code in PR #7698:
URL: https://github.com/apache/netbeans/pull/7698#discussion_r1734753252


##########
enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/assets/ConfigFileGenerator.java:
##########
@@ -0,0 +1,213 @@
+/*
+ * 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.netbeans.modules.cloud.oracle.assets;
+
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+import java.nio.charset.Charset;
+import java.nio.file.DirectoryStream;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.LinkOption;
+import java.nio.file.Path;
+import java.nio.file.attribute.AclEntry;
+import java.nio.file.attribute.AclEntryPermission;
+import static java.nio.file.attribute.AclEntryPermission.APPEND_DATA;
+import static java.nio.file.attribute.AclEntryPermission.DELETE;
+import static java.nio.file.attribute.AclEntryPermission.READ_ACL;
+import static java.nio.file.attribute.AclEntryPermission.READ_ATTRIBUTES;
+import static java.nio.file.attribute.AclEntryPermission.READ_DATA;
+import static java.nio.file.attribute.AclEntryPermission.READ_NAMED_ATTRS;
+import static java.nio.file.attribute.AclEntryPermission.SYNCHRONIZE;
+import static java.nio.file.attribute.AclEntryPermission.WRITE_ACL;
+import static java.nio.file.attribute.AclEntryPermission.WRITE_ATTRIBUTES;
+import static java.nio.file.attribute.AclEntryPermission.WRITE_DATA;
+import static java.nio.file.attribute.AclEntryPermission.WRITE_NAMED_ATTRS;
+import java.nio.file.attribute.AclFileAttributeView;
+import java.nio.file.attribute.DosFileAttributeView;
+import java.nio.file.attribute.FileAttribute;
+import java.nio.file.attribute.PosixFileAttributeView;
+import java.nio.file.attribute.PosixFilePermission;
+import static java.nio.file.attribute.PosixFilePermission.OWNER_READ;
+import static java.nio.file.attribute.PosixFilePermission.OWNER_WRITE;
+import java.nio.file.attribute.PosixFilePermissions;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.Properties;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author Dusan Petrovic
+ */
+public class ConfigFileGenerator {
+    
+    private static final Logger LOG = 
Logger.getLogger(ConfigFileGenerator.class.getName());
+
+    private static final boolean POSIX = 
FileSystems.getDefault().supportedFileAttributeViews().contains("posix");  // 
NOI18N
+    private static final EnumSet<PosixFilePermission> readWritePosix = 
EnumSet.of(OWNER_READ, OWNER_WRITE);
+    private static final EnumSet<PosixFilePermission> readPosix = 
EnumSet.of(OWNER_READ);
+
+    private static final EnumSet<AclEntryPermission> readOnlyAcl = EnumSet.of(
+                READ_ACL,
+                READ_ATTRIBUTES,
+                WRITE_ATTRIBUTES,
+                READ_DATA,
+                READ_NAMED_ATTRS,
+                DELETE,
+                SYNCHRONIZE
+        );
+
+    private static final EnumSet<AclEntryPermission> readWriteAcl = EnumSet.of(
+                READ_DATA,
+                WRITE_DATA,
+                APPEND_DATA,
+                READ_NAMED_ATTRS,
+                WRITE_NAMED_ATTRS,
+                READ_ATTRIBUTES,
+                WRITE_ATTRIBUTES,
+                READ_ACL,
+                WRITE_ACL
+        );
+    
+    private static final Path tmpdir = 
Path.of(System.getProperty("java.io.tmpdir")); // NOI18N
+
+    private final Boolean readOnly;
+    private final String filePrefix;
+    private final String fileSufix;
+    private final String configPath;
+
+    public ConfigFileGenerator(String filePrefix, String fileSufix, String 
configPath, boolean readOnly) {
+        this.readOnly = readOnly;
+        this.configPath = configPath;
+        this.filePrefix = filePrefix;
+        this.fileSufix = fileSufix;
+    }
+    
+    public Path generateConfigFile() throws IOException {
+        Path dir = generateDirPath();
+
+        if (!Files.isDirectory(dir, LinkOption.NOFOLLOW_LINKS)) {

Review Comment:
   The if statement will return `true` and then line below will throw 
exception...
   Maybe I could add a check before this if it is symlink, and delete it in 
that case?



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to