Search in sources :

Example 91 with ServerException

use of org.bimserver.shared.exceptions.ServerException in project BIMserver by opensourceBIM.

the class ServiceImpl method getTopLevelProjectByName.

@Override
public SProject getTopLevelProjectByName(String name) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.READ_ONLY);
    try {
        GetTopLevelProjectByNameDatabaseAction action = new GetTopLevelProjectByNameDatabaseAction(session, getInternalAccessMethod(), name, getAuthorization());
        return getBimServer().getSConverter().convertToSObject(session.executeAndCommitAction(action));
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : DatabaseSession(org.bimserver.database.DatabaseSession) GetTopLevelProjectByNameDatabaseAction(org.bimserver.database.actions.GetTopLevelProjectByNameDatabaseAction) ServiceException(org.bimserver.shared.exceptions.ServiceException) IOException(java.io.IOException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) SerializerException(org.bimserver.plugins.serializers.SerializerException) BcfException(org.opensourcebim.bcf.BcfException) UserException(org.bimserver.shared.exceptions.UserException) CannotBeScheduledException(org.bimserver.longaction.CannotBeScheduledException) DeserializeException(org.bimserver.plugins.deserializers.DeserializeException) ServerException(org.bimserver.shared.exceptions.ServerException) PluginException(org.bimserver.shared.exceptions.PluginException) MessagingException(javax.mail.MessagingException) AddressException(javax.mail.internet.AddressException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException) FileAlreadyExistsException(java.nio.file.FileAlreadyExistsException)

Example 92 with ServerException

use of org.bimserver.shared.exceptions.ServerException in project BIMserver by opensourceBIM.

the class ServiceImpl method getAllRepositoryModelCheckers.

@Override
public List<SModelCheckerInstance> getAllRepositoryModelCheckers() throws ServerException, UserException {
    requireRealUserAuthentication();
    try {
        List<SModelCheckerInstance> modelCheckers = new ArrayList<SModelCheckerInstance>();
        String content = NetUtils.getContent(new URL(getServiceMap().get(SettingsInterface.class).getServiceRepositoryUrl() + "/modelcheckers"), 5000);
        JSONObject root = new JSONObject(new JSONTokener(content));
        JSONArray modelCheckersJson = root.getJSONArray("modelcheckers");
        for (int i = 0; i < modelCheckersJson.length(); i++) {
            JSONObject modelCheckerJson = modelCheckersJson.getJSONObject(i);
            SModelCheckerInstance sModelChecker = new SModelCheckerInstance();
            sModelChecker.setName(modelCheckerJson.getString("name"));
            sModelChecker.setCode(modelCheckerJson.getString("code"));
            sModelChecker.setDescription(modelCheckerJson.getString("description"));
            sModelChecker.setModelCheckerPluginClassName(modelCheckerJson.getString("modelCheckerPluginClassName"));
            modelCheckers.add(sModelChecker);
        }
        return modelCheckers;
    } catch (Exception e) {
        return handleException(e);
    }
}
Also used : JSONTokener(org.codehaus.jettison.json.JSONTokener) SModelCheckerInstance(org.bimserver.interfaces.objects.SModelCheckerInstance) JSONObject(org.codehaus.jettison.json.JSONObject) ArrayList(java.util.ArrayList) JSONArray(org.codehaus.jettison.json.JSONArray) URL(java.net.URL) ServiceException(org.bimserver.shared.exceptions.ServiceException) IOException(java.io.IOException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) SerializerException(org.bimserver.plugins.serializers.SerializerException) BcfException(org.opensourcebim.bcf.BcfException) UserException(org.bimserver.shared.exceptions.UserException) CannotBeScheduledException(org.bimserver.longaction.CannotBeScheduledException) DeserializeException(org.bimserver.plugins.deserializers.DeserializeException) ServerException(org.bimserver.shared.exceptions.ServerException) PluginException(org.bimserver.shared.exceptions.PluginException) MessagingException(javax.mail.MessagingException) AddressException(javax.mail.internet.AddressException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException) FileAlreadyExistsException(java.nio.file.FileAlreadyExistsException)

Example 93 with ServerException

use of org.bimserver.shared.exceptions.ServerException in project BIMserver by opensourceBIM.

the class ServiceImpl method removeNewServiceFromProject.

@Override
public void removeNewServiceFromProject(Long poid, Long serviceOid) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.POSSIBLY_WRITE);
    try {
        BimDatabaseAction<Boolean> action = new RemoveNewServiceFromProjectDatabaseAction(getBimServer(), session, getInternalAccessMethod(), serviceOid, poid, getAuthorization());
        session.executeAndCommitAction(action);
    } catch (Exception e) {
        handleException(e);
    } finally {
        session.close();
    }
}
Also used : DatabaseSession(org.bimserver.database.DatabaseSession) RemoveNewServiceFromProjectDatabaseAction(org.bimserver.database.actions.RemoveNewServiceFromProjectDatabaseAction) ServiceException(org.bimserver.shared.exceptions.ServiceException) IOException(java.io.IOException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) SerializerException(org.bimserver.plugins.serializers.SerializerException) BcfException(org.opensourcebim.bcf.BcfException) UserException(org.bimserver.shared.exceptions.UserException) CannotBeScheduledException(org.bimserver.longaction.CannotBeScheduledException) DeserializeException(org.bimserver.plugins.deserializers.DeserializeException) ServerException(org.bimserver.shared.exceptions.ServerException) PluginException(org.bimserver.shared.exceptions.PluginException) MessagingException(javax.mail.MessagingException) AddressException(javax.mail.internet.AddressException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException) FileAlreadyExistsException(java.nio.file.FileAlreadyExistsException)

Example 94 with ServerException

use of org.bimserver.shared.exceptions.ServerException in project BIMserver by opensourceBIM.

the class ServiceImpl method deleteUser.

@Override
public Boolean deleteUser(Long uoid) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.POSSIBLY_WRITE);
    try {
        BimDatabaseAction<Boolean> action = new DeleteUserDatabaseAction(session, getInternalAccessMethod(), getAuthorization(), uoid);
        return session.executeAndCommitAction(action);
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : DatabaseSession(org.bimserver.database.DatabaseSession) DeleteUserDatabaseAction(org.bimserver.database.actions.DeleteUserDatabaseAction) ServiceException(org.bimserver.shared.exceptions.ServiceException) IOException(java.io.IOException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) SerializerException(org.bimserver.plugins.serializers.SerializerException) BcfException(org.opensourcebim.bcf.BcfException) UserException(org.bimserver.shared.exceptions.UserException) CannotBeScheduledException(org.bimserver.longaction.CannotBeScheduledException) DeserializeException(org.bimserver.plugins.deserializers.DeserializeException) ServerException(org.bimserver.shared.exceptions.ServerException) PluginException(org.bimserver.shared.exceptions.PluginException) MessagingException(javax.mail.MessagingException) AddressException(javax.mail.internet.AddressException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException) FileAlreadyExistsException(java.nio.file.FileAlreadyExistsException)

Example 95 with ServerException

use of org.bimserver.shared.exceptions.ServerException in project BIMserver by opensourceBIM.

the class ServiceImpl method getAllProjects.

@Override
public List<SProject> getAllProjects(Boolean onlyTopLevel, Boolean onlyActive) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.READ_ONLY);
    try {
        BimDatabaseAction<Set<Project>> action = new GetAllProjectsDatabaseAction(session, getInternalAccessMethod(), onlyTopLevel, onlyActive, getAuthorization());
        List<SProject> convertToSListProject = getBimServer().getSConverter().convertToSListProject(session.executeAndCommitAction(action));
        Collections.sort(convertToSListProject, new SProjectComparator());
        return convertToSListProject;
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : SProjectComparator(org.bimserver.webservices.SProjectComparator) HashSet(java.util.HashSet) Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) DatabaseSession(org.bimserver.database.DatabaseSession) GetAllProjectsDatabaseAction(org.bimserver.database.actions.GetAllProjectsDatabaseAction) SProject(org.bimserver.interfaces.objects.SProject) ServiceException(org.bimserver.shared.exceptions.ServiceException) IOException(java.io.IOException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) SerializerException(org.bimserver.plugins.serializers.SerializerException) BcfException(org.opensourcebim.bcf.BcfException) UserException(org.bimserver.shared.exceptions.UserException) CannotBeScheduledException(org.bimserver.longaction.CannotBeScheduledException) DeserializeException(org.bimserver.plugins.deserializers.DeserializeException) ServerException(org.bimserver.shared.exceptions.ServerException) PluginException(org.bimserver.shared.exceptions.PluginException) MessagingException(javax.mail.MessagingException) AddressException(javax.mail.internet.AddressException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException) FileAlreadyExistsException(java.nio.file.FileAlreadyExistsException)

Aggregations

ServerException (org.bimserver.shared.exceptions.ServerException)281 UserException (org.bimserver.shared.exceptions.UserException)277 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)242 IOException (java.io.IOException)234 DatabaseSession (org.bimserver.database.DatabaseSession)234 ServiceException (org.bimserver.shared.exceptions.ServiceException)127 SerializerException (org.bimserver.plugins.serializers.SerializerException)124 PluginException (org.bimserver.shared.exceptions.PluginException)124 DeserializeException (org.bimserver.plugins.deserializers.DeserializeException)122 MalformedURLException (java.net.MalformedURLException)120 BcfException (org.opensourcebim.bcf.BcfException)120 UnsupportedEncodingException (java.io.UnsupportedEncodingException)119 FileAlreadyExistsException (java.nio.file.FileAlreadyExistsException)119 MessagingException (javax.mail.MessagingException)119 AddressException (javax.mail.internet.AddressException)119 CannotBeScheduledException (org.bimserver.longaction.CannotBeScheduledException)119 ArrayList (java.util.ArrayList)30 SProject (org.bimserver.interfaces.objects.SProject)30 User (org.bimserver.models.store.User)27 PublicInterfaceNotFoundException (org.bimserver.shared.exceptions.PublicInterfaceNotFoundException)24