Search in sources :

Example 46 with AssertException

use of org.olat.core.logging.AssertException in project openolat by klemens.

the class CollaborationTools method getForum.

public Forum getForum() {
    final ForumManager fom = ForumManager.getInstance();
    final NarrowedPropertyManager npm = NarrowedPropertyManager.getInstance(ores);
    Property forumProperty = npm.findProperty(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_FORUM);
    Forum forum;
    if (forumProperty != null) {
        forum = fom.loadForum(forumProperty.getLongValue());
    } else {
        forum = coordinatorManager.getCoordinator().getSyncer().doInSync(ores, new SyncerCallback<Forum>() {

            @Override
            public Forum execute() {
                Forum aforum;
                Long forumKey;
                Property forumKeyProperty = npm.findProperty(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_FORUM);
                if (forumKeyProperty == null) {
                    // First call of forum, create new forum and save
                    aforum = fom.addAForum();
                    forumKey = aforum.getKey();
                    if (log.isDebug()) {
                        log.debug("created new forum in collab tools: foid::" + forumKey.longValue() + " for ores::" + ores.getResourceableTypeName() + "/" + ores.getResourceableId());
                    }
                    forumKeyProperty = npm.createPropertyInstance(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_FORUM, null, forumKey, null, null);
                    npm.saveProperty(forumKeyProperty);
                } else {
                    // Forum does already exist, load forum with key from properties
                    forumKey = forumKeyProperty.getLongValue();
                    aforum = fom.loadForum(forumKey);
                    if (aforum == null) {
                        throw new AssertException("Unable to load forum with key " + forumKey.longValue() + " for ores " + ores.getResourceableTypeName() + " with key " + ores.getResourceableId());
                    }
                    if (log.isDebug()) {
                        log.debug("loading forum in collab tools from properties: foid::" + forumKey.longValue() + " for ores::" + ores.getResourceableTypeName() + "/" + ores.getResourceableId());
                    }
                }
                return aforum;
            }
        });
    }
    return forum;
}
Also used : AssertException(org.olat.core.logging.AssertException) ForumManager(org.olat.modules.fo.manager.ForumManager) NarrowedPropertyManager(org.olat.properties.NarrowedPropertyManager) SyncerCallback(org.olat.core.util.coordinate.SyncerCallback) Property(org.olat.properties.Property) Forum(org.olat.modules.fo.Forum)

Example 47 with AssertException

use of org.olat.core.logging.AssertException in project openolat by klemens.

the class BaseSecurityManager method findSecurityGroupByName.

/**
 * @see org.olat.basesecurity.Manager#findSecurityGroupByName(java.lang.String)
 */
@Override
public SecurityGroup findSecurityGroupByName(String securityGroupName) {
    StringBuilder sb = new StringBuilder();
    sb.append("select sgi from ").append(NamedGroupImpl.class.getName()).append(" as ngroup ").append(" inner join ngroup.securityGroup sgi").append(" where ngroup.groupName=:groupName");
    List<SecurityGroup> group = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), SecurityGroup.class).setParameter("groupName", securityGroupName).setHint("org.hibernate.cacheable", Boolean.TRUE).getResultList();
    int size = group.size();
    if (size == 0)
        return null;
    if (size != 1)
        throw new AssertException("non unique name in namedgroup: " + securityGroupName);
    SecurityGroup sg = group.get(0);
    return sg;
}
Also used : AssertException(org.olat.core.logging.AssertException)

Example 48 with AssertException

use of org.olat.core.logging.AssertException in project openolat by klemens.

the class WimbaClassroomProvider method removeClassroom.

@Override
public boolean removeClassroom(String roomId, VCConfiguration config) {
    if (!existsClassroom(roomId, config))
        return true;
    if (!loginAdmin())
        throw new AssertException("Cannot login to Wimba Classroom. Please check module configuration and Wimba Classroom connectivity");
    // first delete recordings
    Map<String, String> mapRecordings = listRecordings(roomId);
    for (String key : mapRecordings.keySet()) {
        removeClassroomRecording(key);
    }
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("function", "deleteClass");
    parameters.put("target", PREFIX + roomId);
    String raw = sendRequest(parameters);
    WimbaResponse response = getResponseDocument(raw);
    boolean success = evaluateOk(response);
    if (!success)
        handleError(response.getStatus(), null);
    return success;
}
Also used : AssertException(org.olat.core.logging.AssertException) HashMap(java.util.HashMap)

Example 49 with AssertException

use of org.olat.core.logging.AssertException in project openolat by klemens.

the class WimbaClassroomProvider method setPreviewMode.

public boolean setPreviewMode(String roomId, boolean enabled, boolean isRecording) {
    if (!loginAdmin())
        throw new AssertException("Cannot login to Wimba Classroom. Please check module configuration and Wimba Classroom connectivity");
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("function", "modifyClass");
    parameters.put("target", isRecording ? roomId : PREFIX + roomId);
    parameters.put("preview", param(enabled));
    String raw = sendRequest(parameters);
    WimbaResponse response = getResponseDocument(raw);
    boolean success = evaluateOk(response);
    if (!success)
        handleError(response.getStatus(), null);
    return success;
}
Also used : AssertException(org.olat.core.logging.AssertException) HashMap(java.util.HashMap)

Example 50 with AssertException

use of org.olat.core.logging.AssertException in project openolat by klemens.

the class AdobeConnectProvider method removeClassroom.

@Override
public boolean removeClassroom(String roomId, VCConfiguration config) {
    if (!existsClassroom(roomId, config))
        return true;
    if (!loginAdmin())
        throw new AssertException("Cannot login to Adobe Connect. Please check module configuration and that Adobe Connect is available.");
    String scoId = getScoIdFor(roomId);
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("action", "sco-delete");
    parameters.put("sco-id", scoId);
    Document responseDoc = getResponseDocument(sendRequest(parameters));
    if (!evaluateOk(responseDoc))
        return false;
    logout();
    return true;
}
Also used : AssertException(org.olat.core.logging.AssertException) HashMap(java.util.HashMap) Document(org.w3c.dom.Document)

Aggregations

AssertException (org.olat.core.logging.AssertException)364 IOException (java.io.IOException)38 File (java.io.File)28 Identity (org.olat.core.id.Identity)28 ArrayList (java.util.ArrayList)26 HashMap (java.util.HashMap)24 Controller (org.olat.core.gui.control.Controller)22 OLATResourceable (org.olat.core.id.OLATResourceable)22 RepositoryEntry (org.olat.repository.RepositoryEntry)22 WindowControl (org.olat.core.gui.control.WindowControl)20 UnsupportedEncodingException (java.io.UnsupportedEncodingException)18 JSONException (org.json.JSONException)18 BusinessGroup (org.olat.group.BusinessGroup)18 JSONObject (org.json.JSONObject)16 UserRequest (org.olat.core.gui.UserRequest)16 VFSContainer (org.olat.core.util.vfs.VFSContainer)16 VFSItem (org.olat.core.util.vfs.VFSItem)16 Date (java.util.Date)14 Properties (java.util.Properties)14 Property (org.olat.properties.Property)14