// Change the component section and save it to disk private void setSection(final String section, ODocument sectionDoc) { ODocument oldSection = getSection(section); try { if (configDoc != null) { configDoc.field(section, sectionDoc); String configFile = OSystemVariableResolver.resolveSystemVariables("${ORIENTDB_HOME}/config/security.json"); // The default "security.json" file can be overridden in the server config file. String securityFile = getConfigProperty("server.security.file"); if (securityFile != null) configFile = securityFile; String ssf = OGlobalConfiguration.SERVER_SECURITY_FILE.getValueAsString(); if (ssf != null) configFile = ssf; File f = new File(configFile); OIOUtils.writeFile(f, configDoc.toJSON("prettyPrint")); } } catch (Exception ex) { configDoc.field(section, oldSection); OLogManager.instance() .error( this, "ODefaultServerSecurity.setSection(%s) Exception: %s", section, ex.getMessage()); } }
@Test public void test() { final List<String> stringItems = new ArrayList<String>(); final String text = "['f\\\'oo', 'don\\\'t can\\\'t', \"\\\"bar\\\"\", 'b\\\"a\\\'z', \"q\\\"u\\'x\"]"; final int startPos = 0; OStringSerializerHelper.getCollection( text, startPos, stringItems, OStringSerializerHelper.LIST_BEGIN, OStringSerializerHelper.LIST_END, OStringSerializerHelper.COLLECTION_SEPARATOR); Assert.assertEquals(OIOUtils.getStringContent(stringItems.get(0)), "f'oo"); Assert.assertEquals(OIOUtils.getStringContent(stringItems.get(1)), "don't can't"); Assert.assertEquals(OIOUtils.getStringContent(stringItems.get(2)), "\"bar\""); Assert.assertEquals(OIOUtils.getStringContent(stringItems.get(3)), "b\"a\'z"); Assert.assertEquals(OIOUtils.getStringContent(stringItems.get(4)), "q\"u\'x"); }
public DB acquire( final String iURL, final String iUserName, final String iUserPassword, final Map<String, Object> iOptionalParams) throws OLockException { final String dbPooledName = OIOUtils.getUnixFileName(iUserName + "@" + iURL); synchronized (pools) { OResourcePool<String, DB> pool = pools.get(dbPooledName); if (pool == null) // CREATE A NEW ONE pool = new OResourcePool<String, DB>(maxSize, this); final DB db = pool.getResource(iURL, timeout, iUserName, iUserPassword, iOptionalParams); // PUT IN THE POOL MAP ONLY IF AUTHENTICATION SUCCEED pools.put(dbPooledName, pool); return db; } }
public static Object encode(final Object iValue) { return OIOUtils.encode(iValue); }