use of org.olat.core.logging.AssertException in project openolat by klemens.
the class AdobeConnectProvider method getScoIdFor.
private String getScoIdFor(String roomId) {
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("action", "sco-search-by-field");
parameters.put("query", PREFIX + roomId);
parameters.put("filter-type", "meeting");
Document responseDoc = getResponseDocument(sendRequest(parameters));
if (!evaluateOk(responseDoc))
return null;
Object result = evaluate(responseDoc, "//sco/url-path[text()='/" + PREFIX + roomId + "/']", XPathConstants.NODESET);
if (result == null)
return null;
NodeList nodes = (NodeList) result;
if (nodes.getLength() == 1) {
String scoId = evaluate(responseDoc, "//sco[1]/attribute::sco-id");
return scoId;
} else if (nodes.getLength() > 1)
throw new AssertException("More than one Adobe Connect room found for one course node!");
else
return null;
}
use of org.olat.core.logging.AssertException in project openolat by klemens.
the class AdobeConnectProvider method existsClassroom.
@Override
public boolean existsClassroom(String roomId, VCConfiguration config) {
if (!loginAdmin())
return false;
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("action", "sco-search-by-field");
parameters.put("query", PREFIX + roomId);
parameters.put("filter-type", "meeting");
Document responseDoc = getResponseDocument(sendRequest(parameters));
if (!evaluateOk(responseDoc))
return false;
Object result = evaluate(responseDoc, "//sco/url-path[text()='/" + PREFIX + roomId + "/']", XPathConstants.NODESET);
logout();
if (result == null)
return false;
NodeList nodes = (NodeList) result;
if (nodes.getLength() == 1)
return true;
else if (nodes.getLength() > 1)
throw new AssertException("More than one Adobe Connect room found for one course node!");
else
return false;
}
use of org.olat.core.logging.AssertException in project OpenOLAT by OpenOLAT.
the class CmdUnzip method execute.
public Controller execute(FolderComponent folderComponent, UserRequest ureq, WindowControl wContr, Translator trans) {
this.translator = trans;
FileSelection selection = new FileSelection(ureq, folderComponent.getCurrentContainerPath());
VFSContainer currentContainer = folderComponent.getCurrentContainer();
if (!(currentContainer.canWrite() == VFSConstants.YES))
throw new AssertException("Cannot unzip to folder. Writing denied.");
// check if command is executed on a file containing invalid filenames or paths - checks if the resulting folder has a valid name
if (selection.getInvalidFileNames().size() > 0) {
status = FolderCommandStatus.STATUS_INVALID_NAME;
return null;
}
List<String> lockedFiles = new ArrayList<String>();
for (String sItem : selection.getFiles()) {
VFSItem vfsItem = currentContainer.resolve(sItem);
if (vfsItem instanceof VFSLeaf) {
try {
Roles roles = ureq.getUserSession().getRoles();
lockedFiles.addAll(checkLockedFiles((VFSLeaf) vfsItem, currentContainer, ureq.getIdentity(), roles));
} catch (Exception e) {
String name = vfsItem == null ? "NULL" : vfsItem.getName();
getWindowControl().setError(translator.translate("FileUnzipFailed", new String[] { name }));
}
}
}
if (!lockedFiles.isEmpty()) {
String msg = FolderCommandHelper.renderLockedMessageAsHtml(trans, lockedFiles);
List<String> buttonLabels = Collections.singletonList(trans.translate("ok"));
lockedFiledCtr = activateGenericDialog(ureq, trans.translate("lock.title"), msg, buttonLabels, lockedFiledCtr);
return null;
}
VFSItem currentVfsItem = null;
try {
boolean fileNotExist = false;
for (String sItem : selection.getFiles()) {
currentVfsItem = currentContainer.resolve(sItem);
if (currentVfsItem != null && (currentVfsItem instanceof VFSLeaf)) {
if (!doUnzip((VFSLeaf) currentVfsItem, currentContainer, ureq, wContr)) {
status = FolderCommandStatus.STATUS_FAILED;
break;
}
} else {
fileNotExist = true;
break;
}
}
if (fileNotExist) {
status = FolderCommandStatus.STATUS_FAILED;
getWindowControl().setError(translator.translate("FileDoesNotExist"));
}
VFSContainer inheritingCont = VFSManager.findInheritingSecurityCallbackContainer(folderComponent.getRootContainer());
if (inheritingCont != null) {
VFSSecurityCallback secCallback = inheritingCont.getLocalSecurityCallback();
if (secCallback != null) {
SubscriptionContext subsContext = secCallback.getSubscriptionContext();
if (subsContext != null) {
NotificationsManager.getInstance().markPublisherNews(subsContext, ureq.getIdentity(), true);
}
}
}
} catch (IllegalArgumentException e) {
logError("Corrupted ZIP", e);
String name = currentVfsItem == null ? "NULL" : currentVfsItem.getName();
getWindowControl().setError(translator.translate("FileUnzipFailed", new String[] { name }));
}
return null;
}
use of org.olat.core.logging.AssertException in project OpenOLAT by OpenOLAT.
the class DBImpl method loadObject.
/**
* loads an object if needed. this makes sense if you have an object which had
* been generated in a previous hibernate session AND you need to access a Set
* or a attribute which was defined as a proxy.
*
* @param persistable the object which needs to be reloaded
* @param forceReloadFromDB if true, force a reload from the db (e.g. to catch
* up to an object commited by another thread which is still in this
* thread's session cache
* @return the loaded Object
*/
@Override
public Persistable loadObject(Persistable persistable, boolean forceReloadFromDB) {
if (persistable == null)
throw new AssertException("persistable must not be null");
EntityManager em = getCurrentEntityManager();
Class<? extends Persistable> theClass = persistable.getClass();
if (forceReloadFromDB) {
if (contains(persistable)) {
// case b - then we can use evict and load
evict(em, persistable, getData());
return em.find(theClass, persistable.getKey());
} else {
// case a or c - unfortunatelly we can't distinguish these two cases
// and session.refresh(Object) doesn't work.
// the only scenario that works is load/evict/load
Persistable attachedObj = em.find(theClass, persistable.getKey());
evict(em, attachedObj, getData());
return em.find(theClass, persistable.getKey());
}
} else if (!contains(persistable)) {
// therefore the following loadObject can either return it from the cache or load it from the DB
return em.find(theClass, persistable.getKey());
} else {
// nothing to do, return the same object
return persistable;
}
}
use of org.olat.core.logging.AssertException in project OpenOLAT by OpenOLAT.
the class NotificationsManagerImpl method getSubscriber.
/**
* @param identity
* @param publisher
* @return a Subscriber object belonging to the identity and listening to the
* given publisher
*/
@Override
public Subscriber getSubscriber(Identity identity, Publisher publisher) {
List<Subscriber> res = dbInstance.getCurrentEntityManager().createNamedQuery("subscribersByPublisherAndIdentity", Subscriber.class).setParameter("publisherKey", publisher.getKey()).setParameter("identityKey", identity.getKey()).getResultList();
if (res.size() == 0)
return null;
if (res.size() != 1)
throw new AssertException("only one subscriber per person and publisher!!");
Subscriber s = res.get(0);
return s;
}
Aggregations