List of usage examples for org.apache.commons.lang StringUtils substringAfter
public static String substringAfter(String str, String separator)
Gets the substring after the first occurrence of a separator.
From source file:cn.newtouch.util.orm.hibernate.HibernateDao.java
private String prepareCountHql(String orgHql) { String fromHql = orgHql;/* w w w . j a v a 2 s . c o m*/ //select??order by???count,?. fromHql = "from " + StringUtils.substringAfter(fromHql, "from"); fromHql = StringUtils.substringBefore(fromHql, "order by"); String countHql = "select count(*) " + fromHql; return countHql; }
From source file:com.homeadvisor.kafdrop.service.CuratorKafkaMonitor.java
private int brokerId(ChildData input) { return Integer.parseInt(StringUtils.substringAfter(input.getPath(), ZkUtils.BrokerIdsPath() + "/")); }
From source file:cn.newtouch.util.hibernate.HibernateDao.java
private String prepareCountHql(String orgHql) { String fromHql = orgHql;/* w w w . ja va 2s .c om*/ // select??order by???count,?. fromHql = "from " + StringUtils.substringAfter(fromHql, "from"); fromHql = StringUtils.substringBefore(fromHql, "order by"); String countHql = "select count(*) " + fromHql; return countHql; }
From source file:gobblin.data.management.conversion.hive.converter.HiveAvroToOrcConverterTest.java
/*** * Test nested DDL and DML generation/*ww w .jav a 2 s . c om*/ * @throws IOException */ @Test public void testNestedSchemaDDLandDML() throws Exception { String dbName = "testdb"; String tableName = "testtable"; String tableSdLoc = "/tmp/testtable"; this.hiveMetastoreTestUtils.getLocalMetastoreClient().dropDatabase(dbName, false, true, true); Table table = this.hiveMetastoreTestUtils.createTestTable(dbName, tableName, tableSdLoc, Optional.<String>absent()); Schema schema = ConversionHiveTestUtils.readSchemaFromJsonFile(resourceDir, "recordWithinRecordWithinRecord_nested.json"); WorkUnitState wus = ConversionHiveTestUtils.createWus(dbName, tableName, 0); wus.getJobState().setProp("orc.table.flatten.schema", "false"); try (HiveAvroToNestedOrcConverter converter = new HiveAvroToNestedOrcConverter();) { Config config = ConfigFactory .parseMap(ImmutableMap.<String, String>builder().put("destinationFormats", "nestedOrc") .put("nestedOrc.destination.tableName", "testtable_orc_nested") .put("nestedOrc.destination.dbName", dbName) .put("nestedOrc.destination.dataPath", "file:/tmp/testtable_orc_nested").build()); ConvertibleHiveDataset cd = ConvertibleHiveDatasetTest.createTestConvertibleDataset(config); List<QueryBasedHiveConversionEntity> conversionEntities = Lists .newArrayList(converter.convertRecord(converter.convertSchema(schema, wus), new QueryBasedHiveConversionEntity(cd, new SchemaAwareHiveTable(table, schema)), wus)); Assert.assertEquals(conversionEntities.size(), 1, "Only one query entity should be returned"); QueryBasedHiveConversionEntity queryBasedHiveConversionEntity = conversionEntities.get(0); List<String> queries = queryBasedHiveConversionEntity.getQueries(); Assert.assertEquals(queries.size(), 4, "4 DDL and one DML query should be returned"); // Ignoring part before first bracket in DDL and 'select' clause in DML because staging table has // .. a random name component String actualDDLQuery = StringUtils.substringAfter("(", queries.get(0).trim()); String actualDMLQuery = StringUtils.substringAfter("SELECT", queries.get(0).trim()); String expectedDDLQuery = StringUtils.substringAfter("(", ConversionHiveTestUtils .readQueryFromFile(resourceDir, "recordWithinRecordWithinRecord_nested.ddl")); String expectedDMLQuery = StringUtils.substringAfter("SELECT", ConversionHiveTestUtils .readQueryFromFile(resourceDir, "recordWithinRecordWithinRecord_nested.dml")); Assert.assertEquals(actualDDLQuery, expectedDDLQuery); Assert.assertEquals(actualDMLQuery, expectedDMLQuery); } }
From source file:info.magnolia.jaas.sp.jcr.JCRAuthorizationModule.java
/** * set access control list from a list of roles under the provided content object * @param role under which roles and ACL are defined *//*w ww . j a v a2 s .c om*/ private void setACL(Content role, PrincipalCollection principalList) { try { Iterator it = role.getChildren(ItemType.CONTENTNODE.getSystemName(), "acl*").iterator(); while (it.hasNext()) { Content aclEntry = (Content) it.next(); String name = StringUtils.substringAfter(aclEntry.getName(), "acl_"); ACL acl; String repositoryName; String workspaceName; if (!StringUtils.contains(name, "_")) { workspaceName = ContentRepository.getDefaultWorkspace(StringUtils.substringBefore(name, "_")); repositoryName = name; name += ("_" + workspaceName); // default workspace // must be added to the // name } else { String[] tokens = StringUtils.split(name, "_"); repositoryName = tokens[0]; workspaceName = tokens[1]; } // get the existing acl object if created before with some // other role if (!principalList.contains(name)) { acl = new ACLImpl(); principalList.add(acl); } else { acl = (ACL) principalList.get(name); } acl.setName(name); acl.setRepository(repositoryName); acl.setWorkspace(workspaceName); // add acl Iterator permissionIterator = aclEntry.getChildren().iterator(); while (permissionIterator.hasNext()) { Content map = (Content) permissionIterator.next(); String path = map.getNodeData("path").getString(); UrlPattern p = new SimpleUrlPattern(path); Permission permission = new PermissionImpl(); permission.setPattern(p); permission.setPermissions(map.getNodeData("permissions").getLong()); acl.addPermission(permission); } } } catch (Exception e) { log.error(e.getMessage(), e); } }
From source file:com.dgq.utils.Struts2Utils.java
private static HttpServletResponse initResponseHeaderServlet(final String contentType, HttpServletResponse response, final String... headers) { // ?headers?//from w w w. ja v a 2 s . c o m String encoding = DEFAULT_ENCODING; boolean noCache = DEFAULT_NOCACHE; for (String header : headers) { String headerName = StringUtils.substringBefore(header, ":"); String headerValue = StringUtils.substringAfter(header, ":"); if (StringUtils.equalsIgnoreCase(headerName, HEADER_ENCODING)) { encoding = headerValue; } else if (StringUtils.equalsIgnoreCase(headerName, HEADER_NOCACHE)) { noCache = Boolean.parseBoolean(headerValue); } else { throw new IllegalArgumentException(headerName + "??header"); } } // headers? String fullContentType = contentType + ";charset=" + encoding; response.setContentType(fullContentType); if (noCache) { ServletUtils.setNoCacheHeader(response); } return response; }
From source file:com.opengamma.component.factory.engine.EngineConfigurationComponentFactory.java
/** * Builds the map, handling dot separate keys. * /*from ww w . ja va 2 s .c o m*/ * @param map the map, not null * @param key the key, not null * @param targetValue the target value,not null */ protected void buildMap(final Map<String, Object> map, final String key, final Object targetValue) { if (key.contains(".")) { final String key1 = StringUtils.substringBefore(key, "."); final String key2 = StringUtils.substringAfter(key, "."); @SuppressWarnings("unchecked") Map<String, Object> subMap = (Map<String, Object>) map.get(key1); if (subMap == null) { subMap = new LinkedHashMap<String, Object>(); map.put(key1, subMap); } buildMap(subMap, key2, targetValue); } else { map.put(key, targetValue); } }
From source file:com.edmunds.autotest.AutoTestGetterSetter.java
private String getBaseName(String name, String[] prefixes) { for (String prefix : prefixes) { if (name.startsWith(prefix)) { return StringUtils.substringAfter(name, prefix); }/*from w w w . j a v a 2 s . c o m*/ } return null; }
From source file:com.hangum.tadpole.rdb.core.viewers.object.sub.utils.TadpoleObjectQuery.java
/** * ?? Table? .// w w w . j a va2 s . c om * * @param userDB * @param tableDao * @throws Exception */ public static List<TableColumnDAO> getTableColumns(UserDBDAO userDB, TableDAO tableDao) throws Exception { List<TableColumnDAO> returnColumns = new ArrayList<TableColumnDAO>(); Map<String, String> mapParam = new HashMap<String, String>(); mapParam.put("db", userDB.getDb()); String strTableName = ""; if (userDB.getDBDefine() == DBDefine.SQLite_DEFAULT) strTableName = tableDao.getSysName(); else strTableName = tableDao.getName(); if (userDB.getDBDefine() == DBDefine.ALTIBASE_DEFAULT) { mapParam.put("user", StringUtils.substringBefore(strTableName, ".")); mapParam.put("table", StringUtils.substringAfter(strTableName, ".")); } else { mapParam.put("schema", tableDao.getSchema_name()); mapParam.put("table", strTableName); } if (userDB.getDBDefine() == DBDefine.TAJO_DEFAULT) { returnColumns = new TajoConnectionManager().tableColumnList(userDB, mapParam); } else if (userDB.getDBDefine() == DBDefine.POSTGRE_DEFAULT) { if ("".equals(mapParam.get("schema")) || null == mapParam.get("schema")) { mapParam.put("schema", "public"); } SqlMapClient sqlClient = TadpoleSQLManager.getInstance(userDB); returnColumns = sqlClient.queryForList("tableColumnList", mapParam); //$NON-NLS-1$ } else { SqlMapClient sqlClient = TadpoleSQLManager.getInstance(userDB); returnColumns = sqlClient.queryForList("tableColumnList", mapParam); //$NON-NLS-1$ } if (DBDefine.SQLite_DEFAULT == userDB.getDBDefine()) { try { SqlMapClient sqlClient = TadpoleSQLManager.getInstance(userDB); List<SQLiteForeignKeyListDAO> foreignKeyList = sqlClient.queryForList("tableForeignKeyList", //$NON-NLS-1$ mapParam); for (SQLiteForeignKeyListDAO fkeydao : foreignKeyList) { for (TableColumnDAO dao : returnColumns) { if (dao.getName().equals(fkeydao.getFrom())) { if (PublicTadpoleDefine.isPK(dao.getKey())) { dao.setKey("MUL"); } else { dao.setKey("FK"); } } } } } catch (Exception e) { logger.error("not found foreignkey for " + tableDao.getName()); } } // if find the keyword is add system quote. for (TableColumnDAO td : returnColumns) { td.setTableDao(tableDao); td.setSysName(SQLUtil.makeIdentifierName(userDB, td.getField())); } returnColumns = DBAccessCtlManager.getInstance().getColumnFilter(tableDao, returnColumns, userDB); return returnColumns; }
From source file:net.sourceforge.fenixedu.domain.SchoolClass.java
public Object getEditablePartOfName() { final DegreeCurricularPlan degreeCurricularPlan = getExecutionDegree().getDegreeCurricularPlan(); final Degree degree = degreeCurricularPlan.getDegree(); return StringUtils.substringAfter(getNome(), degree.constructSchoolClassPrefix(getAnoCurricular())); }