jease.cms.service.Informations.java Source code

Java tutorial

Introduction

Here is the source code for jease.cms.service.Informations.java

Source

/*
Copyright (C) 2016 maik.jablonski@jease.org
    
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
    
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
    
You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package jease.cms.service;

import java.io.File;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Map;
import java.util.TreeMap;

import org.apache.commons.io.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;

@Service
public class Informations {
    private static final String KEY_BLOB_STORE_DIR = "cms.blob.store.dir";

    @Autowired
    private Environment env;

    public String getDatabaseDirectory() {
        return env.getProperty(KEY_BLOB_STORE_DIR);
    }

    public String getDatabaseSize() {
        return FileUtils.byteCountToDisplaySize(FileUtils.sizeOfDirectory(new File(getDatabaseDirectory())));
    }

    public Collection<Object> getDatabaseObjectCount() {
        //      return Database.query(Persistent.class);
        return Collections.emptyList();
    }

    public Map<Class<?>, Integer> getDatabaseClassCount() {
        Map<Class<?>, Integer> resultMap = new TreeMap<>(Comparator.comparing(Class::getName));
        //      for (Persistent obj : Database.query(Persistent.class)) {
        //         Class<?> clazz = obj.getClass();
        //         if (!resultMap.containsKey(clazz)) {
        //            resultMap.put(clazz, 0);
        //         }
        //         resultMap.put(clazz, resultMap.get(clazz) + 1);
        //      }
        return resultMap;
    }

}