Search in sources :

Example 1 with SModelCheckerInstance

use of org.bimserver.interfaces.objects.SModelCheckerInstance 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)

Example 2 with SModelCheckerInstance

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

the class ServiceImpl method addModelChecker.

@Override
public Long addModelChecker(SModelCheckerInstance modelCheckerInstance) throws UserException, ServerException {
    requireAdminAuthenticationAndRunningServer();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        ModelCheckerInstance convert = getBimServer().getSConverter().convertFromSObject(modelCheckerInstance, session);
        return session.executeAndCommitAction(new AddModelCheckerDatabaseAction(session, getInternalAccessMethod(), convert));
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : AddModelCheckerDatabaseAction(org.bimserver.database.actions.AddModelCheckerDatabaseAction) 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) ModelCheckerInstance(org.bimserver.models.store.ModelCheckerInstance) SModelCheckerInstance(org.bimserver.interfaces.objects.SModelCheckerInstance)

Aggregations

IOException (java.io.IOException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 MalformedURLException (java.net.MalformedURLException)2 MessagingException (javax.mail.MessagingException)2 AddressException (javax.mail.internet.AddressException)2 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)2 SModelCheckerInstance (org.bimserver.interfaces.objects.SModelCheckerInstance)2 CannotBeScheduledException (org.bimserver.longaction.CannotBeScheduledException)2 DeserializeException (org.bimserver.plugins.deserializers.DeserializeException)2 SerializerException (org.bimserver.plugins.serializers.SerializerException)2 ServerException (org.bimserver.shared.exceptions.ServerException)2 UserException (org.bimserver.shared.exceptions.UserException)2 BcfException (org.opensourcebim.bcf.BcfException)2 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 DatabaseSession (org.bimserver.database.DatabaseSession)1 AddModelCheckerDatabaseAction (org.bimserver.database.actions.AddModelCheckerDatabaseAction)1 ModelCheckerInstance (org.bimserver.models.store.ModelCheckerInstance)1 JSONArray (org.codehaus.jettison.json.JSONArray)1 JSONObject (org.codehaus.jettison.json.JSONObject)1