@Override public String getString(String name, String def) { return parent.getString(name, def); }
@Override public Set<java.util.Map.Entry<String, Object>> entrySet() { return parent.entrySet(); }
Class<?> type = attr.getType(); try { if (!from.isProperty(name) || !attr.canWrite() ) { attr.set(to, from.getBoolean(name, false)); else if (type == Integer.class || type == int.class) attr.set(to, from.getInt(name, 0)); else if (type == String.class) attr.set(to, from.getString(name, null)); else if (type == UUID.class) try { attr.set(to, UUID.fromString(from.getString(name))); } catch (IllegalArgumentException e) { attr.set(to, null); if (type.isEnum()) { Object[] cons=type.getEnumConstants(); int ord = from.getInt(name, 0); Object c = cons.length > 0 ? cons[0] : null; if (ord >=0 && ord < cons.length) c = cons[ord]; attr.set(to, unknownHadler == null ? from.getString(name) : unknownHadler.cast(from.get(name), null) ); } catch (Throwable t) { log.d(MSystem.getClassName(to), name, t);
@Override public OperationResult doExecuteInternal(CaoConfiguration configuration, Monitor monitor) throws CaoException { if (!canExecute(configuration)) return new NotSuccessful(getName(), "can't execute", -1); try { FsNode parent = (FsNode)configuration.getList().get(0); File nextFile = new File(parent.getFile(), configuration.getProperties().getString(CreateConfiguration.NAME) ); nextFile.mkdir(); CaoNode nextNode = parent.getNode(nextFile.getName()); CaoWritableElement nextWrite = nextNode.getWritableNode(); for (Entry<String, Object> entry : configuration.getProperties().entrySet()) { if (!entry.getKey().startsWith("_")) nextWrite.put(entry.getKey(), entry.getValue()); } nextWrite.getUpdateAction().doExecute(monitor); nextNode.reload(); return new Successful(getName(),"ok",0,nextNode); } catch (Throwable t) { log().d(t); return new NotSuccessful(getName(),t.toString(),-1); } }
String methodName = p.getString(METHOD); Method method = null; for (int i = 0; i < mp.length; i++) { String mpType = mp[i].getType().getCanonicalName(); String reqType = p.getString(PARAMETERTYPE + i, null); if (reqType != null && reqType.equals("null")) { reqType = p.getString(TYPE + i, null); if (p.containsKey(PARAMETERTYPE + mp.length)) continue; Object[] params = new Object[pcount]; for (int i = 0; i < pcount; i++) { params[i] = toObject(p.get(PARAMETER + i), p.getString(TYPE + i), cl);
/** * Encode a list of attributes in a single string * @param _in * @return encoded string */ public static String implode(IProperties _in) { if (_in == null) return ""; StringBuilder sb = new StringBuilder(); boolean first = true; for (Iterator<String> e = _in.keys().iterator(); e.hasNext();) { String key = e.next(); String value = _in.getString(key, null); if (value != null) { if (!first) sb.append('&'); sb.append(encode(key)); sb.append('='); sb.append(encode(value)); first = false; } } return sb.toString(); }
@Override public int getInt(String name, int def) { return parent.getInt(name, def); }
AdbNode to = (AdbNode) configuration.getProperties().getProperty(CopyConfiguration.NEW_PARENT); @SuppressWarnings("unused") final boolean recursive = configuration.getProperties().getBoolean(CopyConfiguration.RECURSIVE, false);
@Override public boolean getBoolean(String name, boolean def) { return parent.getBoolean(name,def); }
@Override public void fillOperationParameters(IProperties param) { param.putAll(dataSource.getProperties()); }
@Override public OperationResult doExecuteInternal(CaoConfiguration configuration, Monitor monitor) throws CaoException { if (!canExecute(configuration)) return new NotSuccessful(getName(), "can't execute", -1); try { FdbNode parent = (FdbNode)configuration.getList().get(0); File nextFile = new File(parent.getFile(), configuration.getProperties().getString(CreateConfiguration.NAME) ); nextFile.mkdir(); ((FdbCore)core).indexFile(nextFile); CaoNode nextNode = parent.getNode(nextFile.getName()); CaoWritableElement nextWrite = nextNode.getWritableNode(); for (Entry<String, Object> entry : configuration.getProperties().entrySet()) { if (!entry.getKey().startsWith("_")) nextWrite.put(entry.getKey(), entry.getValue()); } nextWrite.getUpdateAction().doExecute(monitor); nextNode.reload(); Changes change = nextNode.adaptTo(Changes.class); if (change != null) change.created(); return new Successful(getName(),"ok",0,nextNode); } catch (Throwable t) { log().d(t); return new NotSuccessful(getName(),t.toString(),-1); } }
@Override public PemPair createKeys(IProperties properties) throws MException { int length = properties.getInt(CryptApi.LENGTH, 256); length = length / 8 * 8; byte[] key = new byte[length/8]; MRandom random = MApi.lookup(MRandom.class); for (int i = 0; i < key.length; i++) key[i] = random.getByte(); UUID privId = UUID.randomUUID(); PemKey xpriv = new PemKey(PemBlock.BLOCK_PRIV, key, true ) .set(PemBlock.METHOD, getName()) .set(PemBlock.LENGTH, length) .set(PemBlock.IDENT, privId); return new PemKeyPair(xpriv, xpriv); }
FdbNode to = (FdbNode) configuration.getProperties().getProperty(CopyConfiguration.NEW_PARENT); final boolean recursive = configuration.getProperties().getBoolean(CopyConfiguration.RECURSIVE, false); CaoNode createdNode = null; monitor.setSteps(configuration.getList().size());
@Override public boolean getBoolean(String name) throws MException { return parent.getBoolean(name); }
@Override public CaoNode createChildNode(String name, IProperties properties) { try { CaoAction action = node.getConnection().getAction(CaoAction.CREATE); if (action == null) return null; CreateConfiguration configuration = (CreateConfiguration) action.createConfiguration(node, null); configuration.setName(name); configuration.getProperties().putAll(properties); OperationResult ret = action.doExecute(configuration, null); if (ret != null && ret.isSuccessful()) return ret.getResultAs(); } catch (Exception e) { log().e("createChildNode",node,name,e); } return null; }
@Override public String getString(String name) throws MException { return parent.getString(name); }
try { if (properties == null) properties = new MProperties(); int len = properties.getInt(CryptApi.LENGTH, 1024); // 8192 KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA"); MRandom random = MApi.lookup(MRandom.class); String passphrase = properties.getString(CryptApi.PASSPHRASE, null); if (MString.isSet(passphrase)) privBytes = Blowfish.encrypt(privBytes, passphrase);
@Override public Collection<Object> values() { HashSet<Object> out = new HashSet<>(); for (java.util.Map.Entry<String, Object> entry : parent.entrySet()) { if (entry.getKey().startsWith(prefix)) out.add(entry.getValue()); } return out; }