Search in sources :

Example 11 with ServerException

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

the class LowLevelServiceImpl method getDataObjectByOid.

@Override
public SDataObject getDataObjectByOid(Long roid, Long oid) throws ServerException, UserException {
    requireAuthenticationAndRunningServer();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        BimDatabaseAction<DataObject> action = new GetDataObjectByOidDatabaseAction(getBimServer(), session, getInternalAccessMethod(), roid, oid, getAuthorization());
        SDataObject dataObject = getBimServer().getSConverter().convertToSObject(session.executeAndCommitAction(action));
        return dataObject;
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : GetDataObjectByOidDatabaseAction(org.bimserver.database.actions.GetDataObjectByOidDatabaseAction) SDataObject(org.bimserver.interfaces.objects.SDataObject) DataObject(org.bimserver.models.store.DataObject) DatabaseSession(org.bimserver.database.DatabaseSession) SDataObject(org.bimserver.interfaces.objects.SDataObject) UserException(org.bimserver.shared.exceptions.UserException) NoTransactionException(org.bimserver.webservices.NoTransactionException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException)

Example 12 with ServerException

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

the class LowLevelServiceImpl method getReferences.

@SuppressWarnings("unchecked")
@Override
public List<Long> getReferences(Long tid, Long oid, String referenceName) throws ServerException, UserException {
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        LongTransaction transaction = getBimServer().getLongTransactionManager().get(tid);
        EClass eClass = session.getEClassForOid(oid);
        IdEObject object = session.get(eClass, oid, new OldQuery(transaction.getPackageMetaData(), transaction.getPid(), transaction.getRid(), transaction.getRoid(), null, Deep.NO));
        if (object == null) {
            throw new UserException("No object of type " + eClass.getName() + " with oid " + oid + " found");
        }
        List<IdEObject> list = (List<IdEObject>) object.eGet(object.eClass().getEStructuralFeature(referenceName));
        List<Long> oidList = new ArrayList<Long>();
        for (IdEObject idEObject : list) {
            oidList.add(idEObject.getOid());
        }
        return oidList;
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : EClass(org.eclipse.emf.ecore.EClass) DatabaseSession(org.bimserver.database.DatabaseSession) IdEObject(org.bimserver.emf.IdEObject) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) UserException(org.bimserver.shared.exceptions.UserException) LongTransaction(org.bimserver.webservices.LongTransaction) UserException(org.bimserver.shared.exceptions.UserException) NoTransactionException(org.bimserver.webservices.NoTransactionException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) OldQuery(org.bimserver.database.OldQuery)

Example 13 with ServerException

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

the class ServiceImpl method getAllNonAuthorizedProjectsOfUser.

@Override
public List<SProject> getAllNonAuthorizedProjectsOfUser(Long uoid) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        BimDatabaseAction<Set<Project>> action = new GetAllNonAuthorizedProjectsOfUserDatabaseAction(session, getInternalAccessMethod(), uoid);
        return getBimServer().getSConverter().convertToSListProject(session.executeAndCommitAction(action));
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) GetAllNonAuthorizedProjectsOfUserDatabaseAction(org.bimserver.database.actions.GetAllNonAuthorizedProjectsOfUserDatabaseAction) DatabaseSession(org.bimserver.database.DatabaseSession) 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) MessagingException(javax.mail.MessagingException) AddressException(javax.mail.internet.AddressException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException)

Example 14 with ServerException

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

the class ServiceImpl method getAllModelCheckers.

@Override
public List<SModelCheckerInstance> getAllModelCheckers() throws UserException, ServerException {
    requireAuthenticationAndRunningServer();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        return getBimServer().getSConverter().convertToSListModelCheckerInstance(session.executeAndCommitAction(new GetAllModelCheckersDatabaseAction(session, getInternalAccessMethod())));
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : GetAllModelCheckersDatabaseAction(org.bimserver.database.actions.GetAllModelCheckersDatabaseAction) DatabaseSession(org.bimserver.database.DatabaseSession) 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) MessagingException(javax.mail.MessagingException) AddressException(javax.mail.internet.AddressException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException)

Example 15 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) 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) MessagingException(javax.mail.MessagingException) AddressException(javax.mail.internet.AddressException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException)

Aggregations

ServerException (org.bimserver.shared.exceptions.ServerException)253 UserException (org.bimserver.shared.exceptions.UserException)250 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)224 DatabaseSession (org.bimserver.database.DatabaseSession)215 IOException (java.io.IOException)212 SerializerException (org.bimserver.plugins.serializers.SerializerException)111 DeserializeException (org.bimserver.plugins.deserializers.DeserializeException)110 MalformedURLException (java.net.MalformedURLException)109 BcfException (org.opensourcebim.bcf.BcfException)109 UnsupportedEncodingException (java.io.UnsupportedEncodingException)108 MessagingException (javax.mail.MessagingException)108 AddressException (javax.mail.internet.AddressException)108 CannotBeScheduledException (org.bimserver.longaction.CannotBeScheduledException)108 ArrayList (java.util.ArrayList)29 SProject (org.bimserver.interfaces.objects.SProject)26 User (org.bimserver.models.store.User)23 Project (org.bimserver.models.store.Project)20 SUser (org.bimserver.interfaces.objects.SUser)19 UserSettings (org.bimserver.models.store.UserSettings)18 PublicInterfaceNotFoundException (org.bimserver.shared.exceptions.PublicInterfaceNotFoundException)18