Search in sources :

Example 1 with SDatabaseInformation

use of org.bimserver.interfaces.objects.SDatabaseInformation in project BIMserver by opensourceBIM.

the class AdminServiceImpl method getBimServerInfo.

@Override
public SBimServerInfo getBimServerInfo() throws ServerException, UserException {
    requireAdminOrMonitorAuthentication();
    SBimServerInfo bimServerInfo = new SBimServerInfo();
    SVersion version = getBimServer().getVersionChecker().getLocalVersion();
    SVersion latestVersion = getBimServer().getVersionChecker().getOnlineVersion();
    SDatabaseInformation databaseInformation = getDatabaseInformation();
    bimServerInfo.setCurrentVersion(version.getFullString());
    bimServerInfo.setCurrentDate(version.getDate());
    if (latestVersion != null) {
        bimServerInfo.setLatestVersion(latestVersion.getMajor() + "." + latestVersion.getMinor() + "." + latestVersion.getRevision());
        bimServerInfo.setLatestDate(latestVersion.getDate());
    }
    bimServerInfo.setCheckouts(databaseInformation.getNumberOfCheckouts());
    bimServerInfo.setRevisions(databaseInformation.getNumberOfRevisions());
    bimServerInfo.setUsers(databaseInformation.getNumberOfUsers());
    bimServerInfo.setProjects(databaseInformation.getNumberOfProjects());
    bimServerInfo.setSchemaVersion(databaseInformation.getSchemaVersion());
    bimServerInfo.setServerLogUrl(getBimServer().getServerSettingsCache().getServerSettings().getSiteAddress() + "/download?token=" + getServiceMap().getAuthorization().asHexToken(getBimServer().getEncryptionKey()) + "&action=getfile&type=serverlog");
    bimServerInfo.setStarted(getServerStartTime());
    return bimServerInfo;
}
Also used : SBimServerInfo(org.bimserver.interfaces.objects.SBimServerInfo) SDatabaseInformation(org.bimserver.interfaces.objects.SDatabaseInformation) SVersion(org.bimserver.interfaces.objects.SVersion)

Example 2 with SDatabaseInformation

use of org.bimserver.interfaces.objects.SDatabaseInformation in project BIMserver by opensourceBIM.

the class AdminServiceImpl method getDatabaseInformation.

@Override
public SDatabaseInformation getDatabaseInformation() throws ServerException, UserException {
    requireAdminAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.READ_ONLY);
    try {
        BimDatabaseAction<DatabaseInformation> action = new GetDatabaseInformationAction(session, getInternalAccessMethod());
        return getBimServer().getSConverter().convertToSObject(session.executeAndCommitAction(action));
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : DatabaseInformation(org.bimserver.models.store.DatabaseInformation) SDatabaseInformation(org.bimserver.interfaces.objects.SDatabaseInformation) DatabaseSession(org.bimserver.database.DatabaseSession) GetDatabaseInformationAction(org.bimserver.database.actions.GetDatabaseInformationAction) UserException(org.bimserver.shared.exceptions.UserException) BimBotsException(org.bimserver.bimbots.BimBotsException) IOException(java.io.IOException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException)

Example 3 with SDatabaseInformation

use of org.bimserver.interfaces.objects.SDatabaseInformation in project BIMserver by opensourceBIM.

the class TestBigFilesRemote method start.

private void start(String[] args) {
    String address = args[0];
    String username = args[1];
    String password = args[2];
    String basepath = args[3];
    System.out.println("Address: " + address);
    System.out.println("Username: " + username);
    System.out.println("Password: " + password);
    System.out.println("Basepath: " + basepath);
    try (JsonBimServerClientFactory factory = new JsonBimServerClientFactory(null, address)) {
        BimServerClient client = factory.create(new UsernamePasswordAuthenticationInfo(args[1], args[2]));
        String[] fileNames = new String[] { "4NC Whole Model.ifc", "1006 General withIFC_exportLayerCombos.ifc", "12001_17 MOS_AC17SpecialBigVersion.ifc", "12510_MASTER_Drofus_Test.ifc", "BondBryan10-134 (06) Proposed Site-1.ifc", "HLM_39090_12259 University of Sheffield NEB  [PR-BIM-01-bhelberg].ifc" };
        DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss");
        for (String fileName : fileNames) {
            String projectName = fileName.substring(0, fileName.lastIndexOf(".ifc"));
            List<SProject> projectsByName = client.getServiceInterface().getProjectsByName(projectName);
            SProject project = null;
            if (projectsByName.size() == 1) {
                project = projectsByName.get(0);
            } else {
                System.out.println("Creating project " + fileName);
                project = client.getServiceInterface().addProject(projectName, "ifc2x3tc1");
            }
            SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
            System.out.println(dateFormat.format(new Date()));
            SDatabaseInformation databaseInformation = client.getAdminInterface().getDatabaseInformation();
            System.out.println("Database size: " + Formatters.bytesToString(databaseInformation.getDatabaseSizeInBytes()) + " (" + databaseInformation.getDatabaseSizeInBytes() + ")");
            SJavaInfo javaInfo = client.getAdminInterface().getJavaInfo();
            System.out.println("Used: " + Formatters.bytesToString(javaInfo.getHeapUsed()) + ", Free: " + Formatters.bytesToString(javaInfo.getHeapFree()) + ", Max: " + Formatters.bytesToString(javaInfo.getHeapMax()) + ", Total: " + Formatters.bytesToString(javaInfo.getHeapTotal()));
            String downloadUrl = basepath + UrlEscapers.urlPathSegmentEscaper().escape(fileName);
            System.out.println("Download URL: " + downloadUrl);
            client.getServiceInterface().checkinFromUrlSync(project.getOid(), fileName, deserializer.getOid(), fileName, downloadUrl, false);
            System.out.println("Done checking in " + fileName);
        }
    } catch (ServiceException e) {
        e.printStackTrace();
    } catch (ChannelConnectionException e) {
        e.printStackTrace();
    } catch (PublicInterfaceNotFoundException e) {
        e.printStackTrace();
    } catch (BimServerClientException e) {
        e.printStackTrace();
    } catch (Exception e1) {
        e1.printStackTrace();
    }
}
Also used : SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) ChannelConnectionException(org.bimserver.shared.ChannelConnectionException) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) JsonBimServerClientFactory(org.bimserver.client.json.JsonBimServerClientFactory) SDatabaseInformation(org.bimserver.interfaces.objects.SDatabaseInformation) SProject(org.bimserver.interfaces.objects.SProject) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException) BimServerClient(org.bimserver.client.BimServerClient) Date(java.util.Date) ChannelConnectionException(org.bimserver.shared.ChannelConnectionException) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException) ServiceException(org.bimserver.shared.exceptions.ServiceException) ServiceException(org.bimserver.shared.exceptions.ServiceException) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) SJavaInfo(org.bimserver.interfaces.objects.SJavaInfo) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

SDatabaseInformation (org.bimserver.interfaces.objects.SDatabaseInformation)3 IOException (java.io.IOException)1 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)1 BimBotsException (org.bimserver.bimbots.BimBotsException)1 BimServerClient (org.bimserver.client.BimServerClient)1 JsonBimServerClientFactory (org.bimserver.client.json.JsonBimServerClientFactory)1 DatabaseSession (org.bimserver.database.DatabaseSession)1 GetDatabaseInformationAction (org.bimserver.database.actions.GetDatabaseInformationAction)1 SBimServerInfo (org.bimserver.interfaces.objects.SBimServerInfo)1 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)1 SJavaInfo (org.bimserver.interfaces.objects.SJavaInfo)1 SProject (org.bimserver.interfaces.objects.SProject)1 SVersion (org.bimserver.interfaces.objects.SVersion)1 DatabaseInformation (org.bimserver.models.store.DatabaseInformation)1 ChannelConnectionException (org.bimserver.shared.ChannelConnectionException)1 UsernamePasswordAuthenticationInfo (org.bimserver.shared.UsernamePasswordAuthenticationInfo)1 BimServerClientException (org.bimserver.shared.exceptions.BimServerClientException)1