/** * Returns the process id of the current application. * * @return the current process id */ public static String getPid() { RuntimeMXBean rt = ManagementFactory.getRuntimeMXBean(); String name = rt.getName(); return MString.beforeIndex(name, '@'); }
/** * <p>getPack.</p> * * @param name a {@link java.lang.String} object. * @return a {@link de.mhus.lib.form.DataSource} object. */ protected DataSource getPack(String name) { if (name == null) return defaultSource; String packName = MString.beforeIndex(name, '.'); if (packName.length() == 0) return defaultSource; DataSource pack = packages.get(packName); return pack == null ? defaultSource : pack; }
public String getActiveProcessVersion(String processName) { if (processName.indexOf(':') >= 0) processName = MString.beforeIndex(processName, ':'); return String.valueOf(getParameters().get("process:" + processName + ":active")); } public boolean isProcessActive(String deployedName) {
/** * @param tag * @return */ private String getTagName(String tag) { if (MString.isIndex(tag, MString.WHITESPACE)) { return MString.beforeIndex(tag, MString.WHITESPACE); } return tag; }
public boolean isProcessActive(String deployedName) { String v = MString.afterIndex(deployedName, ':'); String n = MString.beforeIndex(deployedName, ':'); return v.equals(String.valueOf(getParameters().get("process:" + n + ":active"))); }
public FilterRequest(String text) { LinkedList<String> lText = new LinkedList<String>(); facets = new HashMap<String, String>(); for (String part : text.split(" ")) { part = part.trim(); if (MString.isSet(part)) { if (part.indexOf(':') > 0) { facets.put(MString.beforeIndex(part, ':'), MString.afterIndex(part, ':')); } else { lText.add(part); } } } this.text = lText.toArray(new String[lText.size()]); }
/** * Enabled means the version can be instantiated. * @param name * @return true if it's allowed */ public boolean isProcessEnabled(String name) { String v = MString.afterIndex(name, ':'); String n = MString.beforeIndex(name, ':'); String[] versions = String.valueOf(getParameters().getOrDefault("process:" + n + ":versions","")).split(","); return MCollection.contains(versions, v); }
/** * Active means this is the default version for a new process instance * @param deployedName */ public void activateProcessVersion(String deployedName) { String v = MString.afterIndex(deployedName, ':'); String n = MString.beforeIndex(deployedName, ':'); getParameters().put("process:" + n + ":active", v); } public String getActiveProcessVersion(String processName) {
void doUpdate(Element xml) { id = xml.getAttribute("id"); name = xml.getAttribute("name"); incoming.clear(); for (Element eIn : MXml.getLocalElementIterator(xml, "bpmn2:incoming")) { String ref = MXml.getValue(eIn, false); if (ref.startsWith(XElement.SEQUENCE_FLOW)) { ref = ref.substring(XElement.SEQUENCE_FLOW.length()); ref = MString.beforeIndex(ref, '_'); } incoming.add(ref); } outgoing.clear(); for (Element eOut : MXml.getLocalElementIterator(xml, "bpmn2:outgoing")) { String ref = MXml.getValue(eOut, false); if (ref.startsWith(XElement.SEQUENCE_FLOW)) { ref = ref.substring(XElement.SEQUENCE_FLOW.length()); ref = MString.afterIndex(ref, '_'); } outgoing.add(ref); } }
public void enableProcessVersion(String deployedName) { // add version String v = MString.afterIndex(deployedName, ':'); String n = MString.beforeIndex(deployedName, ':'); String[] versions = String.valueOf(getParameters().getOrDefault("process:" + n + ":versions","")).split(","); if (!MCollection.contains(versions, v)) { versions = MCollection.append(versions, v); getParameters().put("process:" + n + ":versions", MString.join(versions,',')); } }
public static SchedulerJob toIntervalJob(String interval, ITimerTask task) { if (interval.indexOf(',') > 0) { long s = 0; String sStr = MString.beforeIndex(interval,','); if (sStr.indexOf('-') > 0 || sStr.indexOf('.') > 0 || sStr.indexOf('/') > 0 ) // it's a date string s = MDate.toDate(sStr, new Date()).getTime(); else // it should be a time interval s = System.currentTimeMillis() + MPeriod.toTime(sStr, -1); // delay is in every case a time interval long l = MPeriod.toTime(MString.afterIndex(interval,','), -1); if (s > 0 && l > 0) return new IntervalWithStartTimeJob(s,l, task); } else { long l = MPeriod.toTime(interval, -1); if (l > 0) return new IntervalJob(l, task); } return null; }
private SchedulerJob toIntervalJob(SchedulerService service, String i) { if (i.indexOf(',') > 0) { long s = 0; String sStr = MString.beforeIndex(i,','); if (sStr.indexOf('-') > 0 || sStr.indexOf('.') > 0 || sStr.indexOf('/') > 0 ) // it's a date string s = MDate.toDate(sStr, new Date()).getTime(); else // it should be a time interval s = System.currentTimeMillis() + MTimeInterval.toTime(sStr, -1); // delay is in every case a time interval long l = MTimeInterval.toTime(MString.afterIndex(i,','), -1); if (s > 0 && l > 0) return new IntervalWithStartTimeJob(s,l, service); } else { long l = MTimeInterval.toTime(i, -1); if (l > 0) return new IntervalJob(l, service); } return null; }
@SuppressWarnings("rawtypes") private ResourceNode getResource(FileResource parent, String target) { if (parent == null || target == null) return null; if (target.length() == 0) return parent; String next = null; if (MString.isIndex(target, '/')) { next = MString.beforeIndex(target, '/'); target = MString.afterIndex(target, '/'); } else { next = target; target = ""; } if (next.length() == 0) return getResource(parent,target); ResourceNode n = parent.getNode(next); if (n == null) return null; return getResource((FileResource) n, target); }
public ParameterDefinition(String line) { if (MString.isIndex(line, ',')) { name = MString.beforeIndex(line, ','); line = MString.afterIndex(line, ','); properties = MProperties.explodeToMProperties(line.split(","), ':', (char)0); } else { name = line; if (name.startsWith("*")) { mandatory = true; name = name.substring(1); } type = "string"; return; } if (name.startsWith("*")) { mandatory = true; name = name.substring(1); } type = properties.getString("type", ""); mandatory = properties.getBoolean("mandatory", mandatory); def = properties.getString("default", null); mapping = properties.getString("mapping",null); format = properties.getString("format", null); }
public void doUpdateHistoryMenu() { int cnt = -2; for (MenuItem c : menuHistory.getChildren()) { if (cnt >= 0) { if (history.size() - cnt - 1 < 0) { c.setText(""); c.setDescription(""); c.setIcon(null); } else { String x = history.get(history.size() - cnt - 1); c.setText(MString.beforeIndex(x, '|')); c.setDescription(x); c.setIcon(VaadinIcons.ARROW_RIGHT); // FontAwesome.ARROW_RIGHT } } cnt++; } }
String msg = ""; if (MString.isIndex(line, ' ')) { date = MString.beforeIndex(line, ' ').trim(); msg = MString.afterIndex(line, ' ').trim(); } else {
public static PemPriv cipherPrivFromString(String str) throws ParseException, NotSupportedException, IOException { if (MValidator.isUUID(str)) { MVault vault = MVaultUtil.loadDefault(); VaultEntry entry = vault.getEntry(UUID.fromString(str)); PemPriv key = MVaultUtil.adaptTo(entry, PemPriv.class); return key; } if (isPemBlock(str)) { PemBlockModel block = new PemBlockModel().parse(str); // return new PemKey(PemBlock.BLOCK_CIPHER).set(PemBlock.METHOD, block.getString(PemBlock.METHOD,"")).setBlock(block.getEncodedBlock()); return new PemKey(block); } String name = MString.beforeIndex(str, ':').toUpperCase().trim(); String key = MString.afterIndex(str, ':').trim(); return new PemKey(PemBlock.BLOCK_CIPHER).set(PemBlock.METHOD, name).setBlock(key); }
public static PemPriv signPrivFromString(String str) throws Exception, NotSupportedException, IOException { if (MValidator.isUUID(str)) { MVault vault = MVaultUtil.loadDefault(); VaultEntry entry = vault.getEntry(UUID.fromString(str)); PemPriv key = MVaultUtil.adaptTo(entry, PemPriv.class); return key; } if (isPemBlock(str)) { PemBlockModel block = new PemBlockModel().parse(str); // return new PemKey(PemBlock.BLOCK_CIPHER).set(PemBlock.METHOD, block.getString(PemBlock.METHOD,"")).setBlock(block.getEncodedBlock()); return new PemKey(block); } String name = MString.beforeIndex(str, ':'); String key = MString.afterIndex(str, ':'); return new PemKey(PemBlock.BLOCK_SIGN).set(PemBlock.METHOD, name).setBlock(key); }
public static PemPub signPubFromString(String str) throws NotSupportedException, IOException, ParseException { if (MValidator.isUUID(str)) { MVault vault = MVaultUtil.loadDefault(); VaultEntry entry = vault.getEntry(UUID.fromString(str)); PemPub key = MVaultUtil.adaptTo(entry, PemPub.class); return key; } if (isPemBlock(str)) { PemBlockModel block = new PemBlockModel().parse(str); // return new PemKey(PemBlock.BLOCK_CIPHER).set(PemBlock.METHOD, block.getString(PemBlock.METHOD,"")).setBlock(block.getEncodedBlock()); return new PemKey(block); } String name = MString.beforeIndex(str, ':'); String key = MString.afterIndex(str, ':'); return new PemKey(PemBlock.BLOCK_SIGN).set(PemBlock.METHOD, name).setBlock(key); }
public static PemPub cipherPubFromString(String str) throws ParseException, NotSupportedException, IOException { if (MValidator.isUUID(str)) { MVault vault = MVaultUtil.loadDefault(); VaultEntry entry = vault.getEntry(UUID.fromString(str)); PemPub key = MVaultUtil.adaptTo(entry, PemPub.class); return key; } if (isPemBlock(str)) { PemBlockModel block = new PemBlockModel().parse(str); // return new PemKey(PemBlock.BLOCK_CIPHER).set(PemBlock.METHOD, block.getString(PemBlock.METHOD,"")).setBlock(block.getEncodedBlock()); return new PemKey(block); } String name = MString.beforeIndex(str, ':'); String key = MString.afterIndex(str, ':'); return new PemKey(PemBlock.BLOCK_CIPHER).set(PemBlock.METHOD, name).setBlock(key); }