List of usage examples for org.apache.wicket.util.string StringValue toOptionalLong
public final Long toOptionalLong() throws StringValueConversionException
From source file:eu.uqasar.web.pages.qmtree.QMBaseTreePage.java
License:Apache License
private Long getRequestedNodeId() { StringValue id = getPageParameters().get("id"); if (id.isEmpty()) { String key = getPageParameters().get("qmodel-key").toOptionalString(); if (key != null) { IQMTreeNode<String> node = qmtreeNodeService.getTreeNodeByKey(key); if (node != null) { id = StringValue.valueOf(node.getId()); } else { // TODO give translated message for the 404 reason throw new AbortWithHttpErrorCodeException(404); }// www . j a v a2 s . co m } } return id.toOptionalLong(); }
From source file:eu.uqasar.web.pages.tree.BaseTreePage.java
License:Apache License
private Long getRequestedNodeId() { StringValue id = getPageParameters().get("id"); if (id.isEmpty()) { String key = getPageParameters().get("project-key").toOptionalString(); if (key != null) { ITreeNode<String> node = treeNodeService.getTreeNodeByKey(key); if (node != null) { id = StringValue.valueOf(node.getId()); } else { // TODO give translated message for the 404 reason throw new AbortWithHttpErrorCodeException(404); }/* w w w. j a v a 2 s . c o m*/ } } return id.toOptionalLong(); }
From source file:eu.uqasar.web.pages.tree.historic.project.HistoricProjectPage.java
License:Apache License
protected Long getRequestedNodeId() { StringValue id = getPageParameters().get("id"); if (id.isEmpty()) { String key = getPageParameters().get("project-key").toOptionalString(); if (key != null) { ITreeNode<String> node = treeNodeService.getTreeNodeByKey(key); if (node != null) { id = StringValue.valueOf(node.getId()); } else { // TODO give translated message for the 404 reason throw new AbortWithHttpErrorCodeException(404); }/* www. j av a2s . c o m*/ } } return id.toOptionalLong(); }
From source file:org.apache.openmeetings.web.room.RoomResourceReference.java
License:Apache License
@Override protected FileItem getFileItem(Attributes attr) { PageParameters params = attr.getParameters(); StringValue _id = params.get("id"); String uid = params.get("uid").toString(); Long id = null;//from w ww .j a v a2 s . co m try { id = _id.toOptionalLong(); } catch (NumberFormatException e) { //no-op expected } WebSession ws = WebSession.get(); Client c = cm.get(uid); if (id == null || !ws.isSignedIn() || c == null) { return null; } FileItem f = (FileItem) fileDao.getAny(id); if (f == null) { return null; } String ruid = params.get("ruid").toString(); String wuid = params.get("wuid").toString(); if (c.getRoom() != null) { Whiteboards wbs = wbManager.get(c.getRoom().getId()); if (!Strings.isEmpty(wuid) && !Strings.isEmpty(ruid) && ruid.equals(wbs.getUid())) { for (Entry<Long, Whiteboard> e : wbs.getWhiteboards().entrySet()) { JSONObject file = e.getValue().get(wuid); if (file != null && f.getId().equals(file.optLong(ATTR_FILE_ID))) { return f; // item IS on WB } } } } if (f.getGroupId() != null && groupUserDao.isUserInGroup(f.getGroupId(), getUserId())) { return f; } return null; }
From source file:org.apache.openmeetings.web.user.record.RecordingResourceReference.java
License:Apache License
@Override protected Recording getFileItem(Attributes attributes) { PageParameters params = attributes.getParameters(); StringValue _id = params.get("id"); Long id = null;/* ww w .jav a2 s. c o m*/ try { id = _id.toOptionalLong(); } catch (Exception e) { //no-op expected } WebSession ws = WebSession.get(); if (id == null && ws.signIn(_id.toString(), true)) { id = getRecordingId(); } if (id != null && ws.isSignedIn()) { return getRecording(id); } return null; }
From source file:org.apache.openmeetings.web.util.GroupLogoResourceReference.java
License:Apache License
@Override public IResource getResource() { return new FileSystemResource() { private static final long serialVersionUID = 1L; @Override//from w ww . j ava2 s . c o m protected String getMimeType() throws IOException { return PNG_MIME_TYPE; } @Override protected ResourceResponse newResourceResponse(Attributes attrs) { Long id = null; boolean allowed = false; WebSession ws = WebSession.get(); if (ws.isSignedIn()) { PageParameters params = attrs.getParameters(); StringValue _id = params.get("id"); try { id = _id.toOptionalLong(); } catch (Exception e) { //no-op expected } allowed = id == null || hasAdminLevel(getRights()) || null != groupUserDao.getByGroupAndUser(id, getUserId()); if (!allowed && ws.getInvitation() != null) { Room r = ws.getInvitation().getRoom() == null ? null : roomDao.get(ws.getInvitation().getRoom().getId()); if (r != null && r.getGroups() != null) { for (RoomGroup rg : r.getGroups()) { if (id.equals(rg.getGroup().getId())) { allowed = true; break; } } } } } if (allowed) { return createResourceResponse(attrs, getGroupLogo(id, true).toPath()); } else { log.debug("Not authorized"); ResourceResponse rr = new ResourceResponse(); rr.setError(HttpServletResponse.SC_FORBIDDEN); return rr; } } }; }