OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 142 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 142 Rev 182
Line 1... Line 1...
1
/*
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 * 
3
 * 
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
4
 * Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
5
 * 
5
 * 
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
9
 * language governing permissions and limitations under the License.
9
 * language governing permissions and limitations under the License.
Line 18... Line 18...
18
 
18
 
19
import org.openconcerto.sql.model.LoadingListener.StructureLoadingEvent;
19
import org.openconcerto.sql.model.LoadingListener.StructureLoadingEvent;
20
import org.openconcerto.sql.model.graph.TablesMap;
20
import org.openconcerto.sql.model.graph.TablesMap;
21
import org.openconcerto.sql.utils.SQL_URL;
21
import org.openconcerto.sql.utils.SQL_URL;
22
import org.openconcerto.utils.CollectionUtils;
22
import org.openconcerto.utils.CollectionUtils;
-
 
23
import org.openconcerto.utils.NetUtils;
-
 
24
import org.openconcerto.utils.Tuple2.List2;
23
import org.openconcerto.utils.cc.CopyOnWriteMap;
25
import org.openconcerto.utils.cc.CopyOnWriteMap;
24
import org.openconcerto.utils.cc.IClosure;
26
import org.openconcerto.utils.cc.IClosure;
25
import org.openconcerto.utils.cc.ITransformer;
27
import org.openconcerto.utils.cc.ITransformer;
26
import org.openconcerto.utils.change.CollectionChangeEventCreator;
28
import org.openconcerto.utils.change.CollectionChangeEventCreator;
27
 
29
 
Line 282... Line 284...
282
                        }
284
                        }
283
                    }
285
                    }
284
 
286
 
285
                    // fire once all the bases are loaded so that the graph is coherent
287
                    // fire once all the bases are loaded so that the graph is coherent
286
                    return this.getDBSystemRoot().getGraph().atomicRefresh(new Callable<Map<String, TablesMap>>() {
288
                    return this.getDBSystemRoot().getGraph().atomicRefresh(new Callable<Map<String, TablesMap>>() {
-
 
289
 
287
                        @Override
290
                        @Override
288
                        public Map<String, TablesMap> call() throws Exception {
291
                        public Map<String, TablesMap> call() throws Exception {
289
                            final Map<String, TablesMap> res = new HashMap<String, TablesMap>();
292
                            final Map<String, TablesMap> res = new HashMap<String, TablesMap>();
290
                            // add or refresh
293
                            // add or refresh
291
                            for (final String cat : cats) {
294
                            for (final String cat : cats) {
Line 571... Line 574...
571
 
574
 
572
    public final DBFileCache getFileCache() {
575
    public final DBFileCache getFileCache() {
573
        return DBFileCache.create(this);
576
        return DBFileCache.create(this);
574
    }
577
    }
575
 
578
 
-
 
579
    /**
-
 
580
     * The host name of this server.
-
 
581
     * 
-
 
582
     * @return the host name, <code>null</code> if not accessed through network.
-
 
583
     */
576
    public final String getHostname() {
584
    public final String getHostname() {
-
 
585
        return this.getHostnameAndPath().get0();
-
 
586
    }
-
 
587
 
-
 
588
    public final List2<String> getHostnameAndPath() {
577
        return this.getSQLSystem().getHostname(this.getName());
589
        return this.getSQLSystem().getHostnameAndPath(this.getName());
-
 
590
    }
-
 
591
 
-
 
592
    public final boolean isPermanent() {
-
 
593
        return this.getSQLSystem().isPermanent(this.getName());
-
 
594
    }
-
 
595
 
-
 
596
    /**
-
 
597
     * Whether this server runs on the local machine.
-
 
598
     * 
-
 
599
     * @return <code>true</code> if the JVM runs on the same machine than <code>this</code>.
-
 
600
     */
-
 
601
    protected final boolean isLocalhost() {
-
 
602
        // this method cannot be in SQLSyntax since it is used in the constructor of SQLDataSource
-
 
603
        // (which is needed by SQLSyntax.create())
-
 
604
 
-
 
605
        final String host = this.getHostname();
-
 
606
        if (host == null)
-
 
607
            return true;
-
 
608
        final int colonIndex = host.indexOf(':');
-
 
609
        final String hostWOPort = colonIndex < 0 ? host : host.substring(0, colonIndex);
-
 
610
        return NetUtils.isSelfAddr(hostWOPort);
-
 
611
    }
-
 
612
 
-
 
613
    public final boolean isPersistent() {
-
 
614
        return this.getSQLSystem() != SQLSystem.H2 || !this.getName().equals(SQLSystem.H2_IN_MEMORY);
578
    }
615
    }
579
}
616
}