Java Code Examples for org.apache.wicket.util.string.Strings#isEmpty()
The following examples show how to use
org.apache.wicket.util.string.Strings#isEmpty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JobEntityHandler.java From Orienteer with Apache License 2.0 | 6 votes |
@Statement public List<JobEntity> selectJobsByConfiguration(OPersistenceSession session, ListQueryParameterObject query) { Map<String, Object> params = (Map<String, Object>) query.getParameter(); String config = (String) params.get("handlerConfiguration"); String followUpConfig = (String) params.get("handlerConfigurationWithFollowUpJobCreatedProperty"); String type = (String) params.get("handlerType"); List<String> args = new ArrayList<>(); Query q = new Query().from(getSchemaClass()); q.where(Clause.clause("jobHandlerType", Operator.EQ, Parameter.PARAMETER)); args.add(type); Clause eqConfig = Clause.clause("JobHandlerConfigurationRaw", Operator.EQ, Parameter.PARAMETER); if(Strings.isEmpty(followUpConfig)) { q.where(eqConfig); args.add(config); } else { q.where(Clause.or(eqConfig, eqConfig)); args.add(config); args.add(followUpConfig); } return queryList(session, q.toString(), args.toArray()); }
Example 2
Source File: UrlImporter.java From webanno with Apache License 2.0 | 6 votes |
private Optional<Import> resolvePackageDependency(String url) { if (Strings.isEmpty(scopeClass)) { throw new IllegalStateException( "Cannot resolve dependency '" + url + "' without a scope class!"); } LOG.debug("Going to resolve an import from the package: {}", url); String resourceName = url.startsWith(PACKAGE_SCHEME) ? url.substring(PACKAGE_SCHEME.length()) : url; if (resourceName.indexOf(0) == '/') { resourceName = resourceName.substring(1); } Class<?> scope = WicketObjects.resolveClass(scopeClass); URL importUrl = scope.getResource(resourceName); return Optional.ofNullable(importUrl).map(this::buildImport); }
Example 3
Source File: ChangePasswordDialog.java From openmeetings with Apache License 2.0 | 6 votes |
@Override protected void onValidate() { String p = current.getConvertedInput(); if (!Strings.isEmpty(p) && !userDao.verifyPassword(getUserId(), p)) { error(getString("231")); // add random timeout try { Thread.sleep(6 + (long)(10 * Math.random() * 1000)); } catch (InterruptedException e) { log.error("Unexpected exception while sleeping", e); Thread.currentThread().interrupt(); } } String p1 = pass.getConvertedInput(); if (!Strings.isEmpty(p1) && !p1.equals(pass2.getConvertedInput())) { error(getString("232")); } super.onValidate(); }
Example 4
Source File: DocumentConverter.java From openmeetings with Apache License 2.0 | 6 votes |
public static void createOfficeManager(String officePath, Function<OfficeManager, ConversionJob> job) throws OfficeException { OfficeManager manager = null; try { LocalOfficeManager.Builder builder = LocalOfficeManager.builder(); if (!Strings.isEmpty(officePath)) { builder.officeHome(officePath); } manager = builder.build(); manager.start(); if (job != null) { job.apply(manager).execute(); } } finally { if (manager != null) { manager.stop(); } } }
Example 5
Source File: HexConverter.java From wicket-orientdb with Apache License 2.0 | 5 votes |
@Override public String convertToString(byte[] array, Locale locale) { if(array==null || array.length==0) return null; if(maxLength>0 && maxLength<array.length) { byte[] newArray = new byte[maxLength]; System.arraycopy(array, 0, newArray, 0, newArray.length); array = newArray; } String data = DatatypeConverter.printHexBinary(array); if(!Strings.isEmpty(prefix))data = prefix+data; if(cols>0) data = data.replaceAll("(.{"+cols+"})", "$1\n"); return data; }
Example 6
Source File: FileTypeAdapter.java From openmeetings with Apache License 2.0 | 5 votes |
@Override public BaseFileItem.Type unmarshal(String v) throws Exception { if ("PollChart".equalsIgnoreCase(v)) { return BaseFileItem.Type.POLL_CHART; } if ("WmlFile".equalsIgnoreCase(v)) { return BaseFileItem.Type.WML_FILE; } return Strings.isEmpty(v) ? null : BaseFileItem.Type.valueOf(v.toUpperCase(Locale.ROOT)); }
Example 7
Source File: ConfigurationDao.java From openmeetings with Apache License 2.0 | 5 votes |
private void addCspRule(CSPHeaderConfiguration cspConfig, CSPDirective key, String val, boolean remove) { if (!Strings.isEmpty(val)) { for(String str : val.split(",")) { if (!Strings.isEmpty(str)) { try { cspConfig.add(key, str.trim()); } catch (Exception e) { log.error("Enexpected error while adding CSP rule: key '{}', value '{}', part '{}'", key, val, str, e); } } } } else if (remove) { cspConfig.remove(key); } }
Example 8
Source File: AbstractWidgetPage.java From Orienteer with Apache License 2.0 | 5 votes |
public boolean addTab(String name) { if(Strings.isEmpty(name)) return false; List<DashboardTab> tabs = tabbedPanel.getTabs(); for(DashboardTab tab:tabs) { if(name.equals(tab.tab)) return false; } tabbedPanel.getTabs().add(new DashboardTab(name)); return false; }
Example 9
Source File: RecordingStatusAdapter.java From openmeetings with Apache License 2.0 | 5 votes |
@Override public Recording.Status unmarshal(String v) throws Exception { if ("PROCESSING".equalsIgnoreCase(v)) { return Recording.Status.CONVERTING; } Recording.Status result = Status.NONE; if (!Strings.isEmpty(v)) { try { result = Recording.Status.valueOf(v); } catch (Exception e) { //no-op } } return result; }
Example 10
Source File: WbPanel.java From openmeetings with Apache License 2.0 | 5 votes |
@Override protected void onSubmit(AjaxRequestTarget target) { String res = saveWb(roomId, wb2save, getModelObject()); if (!Strings.isEmpty(res)) { error("Unexpected error while saving WB: " + res); target.add(feedback); } else { super.onSubmit(target); } }
Example 11
Source File: ODocumentPage.java From Orienteer with Apache License 2.0 | 5 votes |
@Override protected IModel<ODocument> resolveByPageParameters(PageParameters parameters) { String rid = parameters.get("rid").toOptionalString(); if (rid != null) { try { return new ODocumentModel(new ORecordId(rid)); } catch (IllegalArgumentException e) { //NOP Support of case with wrong rid } } String className = parameters.get("class").toOptionalString(); return new ODocumentModel(!Strings.isEmpty(className) ? new ODocument(className) : null); }
Example 12
Source File: PageDelegate.java From Orienteer with Apache License 2.0 | 5 votes |
public PageDelegate(WebPage page, ORID pageOrid, ORID docOrid) { this.page = page; this.pageDocumentModel = new ODocumentModel(pageOrid); ODocument doc = (ODocument)(docOrid!=null?docOrid.getRecord():pageDocumentModel.getObject().field(PagesModule.OPROPERTY_DOCUMENT)); if(doc!=null) page.setDefaultModel(new ODocumentModel(doc)); String script = pageDocumentModel.getObject().field(PagesModule.OPROPERTY_SCRIPT); if(!Strings.isEmpty(script)) { OScriptManager scriptManager = Orient.instance().getScriptManager(); ODatabaseDocument db = OrienteerWebSession.get().getDatabase(); final OPartitionedObjectPool.PoolEntry<ScriptEngine> entry = scriptManager.acquireDatabaseEngine(db.getName(), "javascript"); final ScriptEngine scriptEngine = entry.object; Bindings binding = null; try { binding = scriptManager.bind(scriptEngine.getBindings(ScriptContext.ENGINE_SCOPE), (ODatabaseDocumentTx) db, null, null); binding.put("page", page); binding.put("pageDoc", pageDocumentModel.getObject()); binding.put("doc", doc); try { scriptEngine.eval(script); } catch (ScriptException e) { scriptManager.throwErrorMessage(e, script); } } finally { if (scriptManager != null && binding != null) { scriptManager.unbind(binding, null, null); scriptManager.releaseDatabaseEngine("javascript", db.getName(), entry); } } } }
Example 13
Source File: BackupImport.java From openmeetings with Apache License 2.0 | 5 votes |
private void checkHash(BaseFileItem file, BaseFileItemDao dao, BiConsumer<String, String> consumer) { String oldHash = file.getHash(); if (Strings.isEmpty(oldHash) || !UUID_PATTERN.matcher(oldHash).matches() || dao.get(oldHash) != null) { file.setHash(randomUUID().toString()); hashMap.put(oldHash, file.getHash()); if (consumer != null) { consumer.accept(oldHash, file.getHash()); } } else { hashMap.put(file.getHash(), file.getHash()); } }
Example 14
Source File: AbstractWebSocketProcessor.java From onedev with MIT License | 5 votes |
protected IKey getRegistryKey() { IKey key; if (Strings.isEmpty(resourceName)) { key = new PageIdKey(pageId); } else { key = new ResourceNameKey(resourceName); } return key; }
Example 15
Source File: AbstractWebSocketProcessor.java From onedev with MIT License | 4 votes |
/** * Constructor. * * @param request * the http request that was used to create the TomcatWebSocketProcessor * @param application * the current Wicket Application */ public AbstractWebSocketProcessor(final HttpServletRequest request, final WebApplication application) { final HttpSession httpSession = request.getSession(true); if (httpSession == null) { throw new IllegalStateException("There is no HTTP Session bound. Without a session Wicket won't be " + "able to find the stored page to update its components"); } this.sessionId = httpSession.getId(); String pageId = request.getParameter("pageId"); resourceName = request.getParameter("resourceName"); if (Strings.isEmpty(pageId) && Strings.isEmpty(resourceName)) { throw new IllegalArgumentException("The request should have either 'pageId' or 'resourceName' parameter!"); } if (Strings.isEmpty(pageId) == false) { this.pageId = Integer.parseInt(pageId, 10); } else { this.pageId = NO_PAGE_ID; } String baseUrl = request.getParameter(WebRequest.PARAM_AJAX_BASE_URL); Checks.notNull(baseUrl, String.format("Request parameter '%s' is required!", WebRequest.PARAM_AJAX_BASE_URL)); this.baseUrl = Url.parse(baseUrl); WicketFilter wicketFilter = application.getWicketFilter(); this.servletRequest = new ServletRequestCopy(request); this.application = Args.notNull(application, "application"); this.webSocketSettings = WebSocketSettings.Holder.get(application); this.webRequest = webSocketSettings.newWebSocketRequest(request, wicketFilter.getFilterPath()); this.connectionRegistry = webSocketSettings.getConnectionRegistry(); this.connectionFilter = webSocketSettings.getConnectionFilter(); }
Example 16
Source File: PageDelegate.java From Orienteer with Apache License 2.0 | 4 votes |
public PageDelegate(WebPage page, String pageOrid, String docOrid) { this(page, new ORecordId(pageOrid), Strings.isEmpty(docOrid)?null:new ORecordId(docOrid)); }
Example 17
Source File: OClusterPage.java From Orienteer with Apache License 2.0 | 4 votes |
@Override protected IModel<OCluster> resolveByPageParameters( PageParameters pageParameters) { String name = pageParameters.get("clusterName").toOptionalString(); return Strings.isEmpty(name)? null:new OClusterModel(name); }
Example 18
Source File: BirtReportODocumentConfig.java From Orienteer with Apache License 2.0 | 4 votes |
@Override public String getOutName() { ODocument modelObject = configDocModel.getObject(); String filename = modelObject.field(AbstractBirtWidget.REPORT_FIELD_NAME+BinaryEditPanel.FILENAME_SUFFIX); return Strings.isEmpty(filename)?"report":filename.replaceFirst("\\.[^\\.]*$", ""); }
Example 19
Source File: InitUtils.java From Orienteer with Apache License 2.0 | 4 votes |
/** * @return current Orienteer version */ public String getOrienteerVersion() { String version = PROPERTIES.getProperty(ORIENTEER_VERSION); return Strings.isEmpty(version)?OrienteerWebApplication.class.getPackage().getImplementationVersion():version; }
Example 20
Source File: WebSession.java From openmeetings with Apache License 2.0 | 4 votes |
public boolean signIn(String secureHash, boolean markUsed) { SOAPLogin soapLogin = soapDao.get(secureHash); if (soapLogin == null) { log.warn("Secure hash not found in DB"); return false; } log.debug("Secure hash found, is used ? {}", soapLogin.isUsed()); if (!soapLogin.isUsed() || soapLogin.getAllowSameURLMultipleTimes()) { Sessiondata sd = sessionDao.check(soapLogin.getSessionHash()); log.debug("Do we have data for hash ? {}", (sd.getXml() != null)); if (sd.getXml() != null) { RemoteSessionObject remoteUser = RemoteSessionObject.fromString(sd.getXml()); log.debug("Hash data was parsed successfuly ? {}, containg exterlaId ? {}", (remoteUser != null), !Strings.isEmpty(remoteUser.getExternalId())); if (remoteUser != null && !Strings.isEmpty(remoteUser.getExternalId())) { Room r = roomDao.get(soapLogin.getRoomId()); if (r == null) { log.warn("Room was not found"); } else { redirectHash(r, () -> {}); } User user = userDao.getExternalUser(remoteUser.getExternalId(), remoteUser.getExternalType()); if (user == null) { user = getNewUserInstance(null); user.setFirstname(remoteUser.getFirstname()); user.setLastname(remoteUser.getLastname()); user.setLogin(remoteUser.getUsername()); user.setType(Type.EXTERNAL); user.setExternalId(remoteUser.getExternalId()); user.addGroup(groupDao.getExternal(remoteUser.getExternalType())); user.getRights().clear(); user.getRights().add(Right.ROOM); user.getAddress().setEmail(remoteUser.getEmail()); user.setPictureUri(remoteUser.getPictureUrl()); } else { user.setFirstname(remoteUser.getFirstname()); user.setLastname(remoteUser.getLastname()); user.setPictureUri(remoteUser.getPictureUrl()); } user = userDao.update(user, null); if (markUsed) { soapLogin.setUsed(true); soapLogin.setUseDate(new Date()); soapDao.update(soapLogin); } roomId = soapLogin.getRoomId(); sd.setUserId(user.getId()); sd.setRoomId(roomId); sessionDao.update(sd); setUser(user, null); recordingId = soapLogin.getRecordingId(); soap = soapLogin; log.info("Hash was authorized"); return true; } } } log.warn("Hash was NOT authorized"); return false; }