code
stringlengths
73
34.1k
label
stringclasses
1 value
public IGoal[] getAgentGoals(final String agent_name, Connector connector) { ((IExternalAccess) connector.getAgentsExternalAccess(agent_name)) .scheduleStep(new IComponentStep<Plan>() { public IFuture<Plan> execute(IInternalAccess ia) { IBDIInternalAc...
java
public void localBegin() { if (this.isInLocalTransaction) { throw new TransactionInProgressException("Connection is already in transaction"); } Connection connection = null; try { connection = this.getConnection(); } ...
java
public void localCommit() { if (log.isDebugEnabled()) log.debug("commit was called"); if (!this.isInLocalTransaction) { throw new TransactionNotInProgressException("Not in transaction, call begin() before commit()"); } try { if(!broker...
java
public void localRollback() { log.info("Rollback was called, do rollback on current connection " + con); if (!this.isInLocalTransaction) { throw new PersistenceBrokerException("Not in transaction, cannot abort"); } try { //truncate the...
java
protected void restoreAutoCommitState() { try { if(!broker.isManaged()) { if (jcd.getUseAutoCommit() == JdbcConnectionDescriptor.AUTO_COMMIT_SET_TRUE_AND_TEMPORARY_FALSE && originalAutoCommitState == true && con != null && !con.i...
java
public boolean isAlive(Connection conn) { try { return con != null ? !con.isClosed() : false; } catch (SQLException e) { log.error("IsAlive check failed, running connection was invalid!!", e); return false; } }
java
public static void registerAgent(Agent agent, String serviceName, String serviceType) throws FIPAException{ DFAgentDescription dfd = new DFAgentDescription(); ServiceDescription sd = new ServiceDescription(); sd.setType(serviceType); sd.setName(serviceName); //N...
java
public static InterceptorFactory getInstance() { if (instance == null) { instance = new InterceptorFactory(); OjbConfigurator.getInstance().configure(instance); } return instance; }
java
public void registerDropPasteWorker(DropPasteWorkerInterface worker) { this.dropPasteWorkerSet.add(worker); defaultDropTarget.setDefaultActions( defaultDropTarget.getDefaultActions() | worker.getAcceptableActions(defaultDropTarget.getComponent()) ...
java
public void removeDropPasteWorker(DropPasteWorkerInterface worker) { this.dropPasteWorkerSet.remove(worker); java.util.Iterator it = this.dropPasteWorkerSet.iterator(); int newDefaultActions = 0; while (it.hasNext()) newDefaultActions |= ((DropPasteWorkerInterface)i...
java
public static String serialize(final Object obj) throws IOException { final ObjectMapper mapper = new ObjectMapper(); mapper.disable(MapperFeature.USE_GETTERS_AS_SETTERS); return mapper.writeValueAsString(obj); }
java
public static Organization unserializeOrganization(final String organization) throws IOException { final ObjectMapper mapper = new ObjectMapper(); mapper.disable(MapperFeature.USE_GETTERS_AS_SETTERS); return mapper.readValue(organization, Organization.class); }
java
public static Module unserializeModule(final String module) throws IOException { final ObjectMapper mapper = new ObjectMapper(); mapper.disable(MapperFeature.USE_GETTERS_AS_SETTERS); return mapper.readValue(module, Module.class); }
java
public static Map<String,String> unserializeBuildInfo(final String buildInfo) throws IOException { final ObjectMapper mapper = new ObjectMapper(); mapper.disable(MapperFeature.USE_GETTERS_AS_SETTERS); return mapper.readValue(buildInfo, new TypeReference<Map<String, Object>>(){}); }
java
public Object get(String name, ObjectFactory<?> factory) { ThreadScopeContext context = ThreadScopeContextHolder.getContext(); Object result = context.getBean(name); if (null == result) { result = factory.getObject(); context.setBean(name, result); } return result; }
java
public Object remove(String name) { ThreadScopeContext context = ThreadScopeContextHolder.getContext(); return context.remove(name); }
java
public static void addItemsHandled(String handledItemsType, int handledItemsNumber) { JobLogger jobLogger = (JobLogger) getInstance(); if (jobLogger == null) { return; } jobLogger.addItemsHandledInstance(handledItemsType, handledItemsNumber); }
java
protected DataSource getDataSource(JdbcConnectionDescriptor jcd) throws LookupException { final PBKey key = jcd.getPBKey(); DataSource ds = (DataSource) dsMap.get(key); if (ds == null) { // Found no pool for PBKey try { ...
java
protected ObjectPool setupPool(JdbcConnectionDescriptor jcd) { log.info("Create new ObjectPool for DBCP connections:" + jcd); try { ClassHelper.newInstance(jcd.getDriver()); } catch (InstantiationException e) { log.fatal("Unable to i...
java
protected DataSource wrapAsDataSource(JdbcConnectionDescriptor jcd, ObjectPool connectionPool) { final boolean allowConnectionUnwrap; if (jcd == null) { allowConnectionUnwrap = false; } else { ...
java
public void setAlias(String alias) { m_alias = alias; String attributePath = (String)getAttribute(); boolean allPathsAliased = true; m_userAlias = new UserAlias(alias, attributePath, allPathsAliased); }
java
final void begin() { if (this.properties.isDateRollEnforced()) { final Thread thread = new Thread(this, "Log4J Time-based File-roll Enforcer"); thread.setDaemon(true); thread.start(); this.threadRef = thread; } }
java
public Map<String, ClientWidgetInfo> securityClone(Map<String, ClientWidgetInfo> widgetInfo) { Map<String, ClientWidgetInfo> res = new HashMap<String, ClientWidgetInfo>(); for (Map.Entry<String, ClientWidgetInfo> entry : widgetInfo.entrySet()) { ClientWidgetInfo value = entry.getValue(); if (!(value instanceo...
java
public ClientLayerInfo securityClone(ClientLayerInfo original) { // the data is explicitly copied as this assures the security is considered when copying. if (null == original) { return null; } ClientLayerInfo client = null; String layerId = original.getServerLayerId(); if (securityContext.isLayerVisible...
java
public String getKeyValue(String key){ String keyName = keysMap.get(key); if (keyName != null){ return keyName; } return ""; //key wasn't defined in keys properties file }
java
public static void serialize(final File folder, final String content, final String fileName) throws IOException { if (!folder.exists()) { folder.mkdirs(); } final File output = new File(folder, fileName); try ( final FileWriter writer = new FileWriter(output...
java
public static String read(final File file) throws IOException { final StringBuilder sb = new StringBuilder(); try ( final FileReader fr = new FileReader(file); final BufferedReader br = new BufferedReader(fr); ) { String sCurrentLine; wh...
java
public static Long getSize(final File file){ if ( file!=null && file.exists() ){ return file.length(); } return null; }
java
public static void touch(final File folder , final String fileName) throws IOException { if(!folder.exists()){ folder.mkdirs(); } final File touchedFile = new File(folder, fileName); // The JVM will only 'touch' the file if you instantiate a // FileOutputStream inst...
java
private void init(final List<DbLicense> licenses) { licensesRegexp.clear(); for (final DbLicense license : licenses) { if (license.getRegexp() == null || license.getRegexp().isEmpty()) { licensesRegexp.put(license.getName(), license); } else {...
java
public DbLicense getLicense(final String name) { final DbLicense license = repoHandler.getLicense(name); if (license == null) { throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND) .entity("License " + name + " does not exist.").build()); ...
java
public void deleteLicense(final String licName) { final DbLicense dbLicense = getLicense(licName); repoHandler.deleteLicense(dbLicense.getName()); final FiltersHolder filters = new FiltersHolder(); final LicenseIdFilter licenseIdFilter = new LicenseIdFilter(licName); filters.ad...
java
public DbLicense resolve(final String licenseId) { for (final Entry<String, DbLicense> regexp : licensesRegexp.entrySet()) { try { if (licenseId.matches(regexp.getKey())) { return regexp.getValue(); } } catch (PatternSyntaxException e)...
java
public Set<DbLicense> resolveLicenses(List<String> licStrings) { Set<DbLicense> result = new HashSet<>(); licStrings .stream() .map(this::getMatchingLicenses) .forEach(result::addAll); return result; }
java
private void verityLicenseIsConflictFree(final DbLicense newComer) { if(newComer.getRegexp() == null || newComer.getRegexp().isEmpty()) { return; } final DbLicense existing = repoHandler.getLicense(newComer.getName()); final List<DbLicense> licenses = repoHandler.getAllLicen...
java
public List<Dependency> getModuleDependencies(final String moduleId, final FiltersHolder filters){ final DbModule module = moduleHandler.getModule(moduleId); final DbOrganization organization = moduleHandler.getOrganization(module); filters.setCorporateFilter(new CorporateFilter(organization)); ...
java
public DependencyReport getDependencyReport(final String moduleId, final FiltersHolder filters) { final DbModule module = moduleHandler.getModule(moduleId); final DbOrganization organization = moduleHandler.getOrganization(module); filters.setCorporateFilter(new CorporateFilter(organization)); ...
java
public final boolean roll(final LoggingEvent loggingEvent) { for (int i = 0; i < this.fileRollables.length; i++) { if (this.fileRollables[i].roll(loggingEvent)) { return true; } } return false; }
java
public boolean isPartOf(GetVectorTileRequest request) { if (Math.abs(request.scale - scale) > EQUALS_DELTA) { return false; } if (code != null ? !code.equals(request.code) : request.code != null) { return false; } if (crs != null ? !crs.equals(request.crs) : request.crs != null) { return false; } if (filter != ...
java
@PostConstruct protected void checkPluginDependencies() throws GeomajasException { if ("true".equals(System.getProperty("skipPluginDependencyCheck"))) { return; } if (null == declaredPlugins) { return; } // start by going through all plug-ins to build a map of versions for plug-in keys // includes ...
java
String checkVersion(String pluginName, String dependency, String requestedVersion, String availableVersion) { if (null == availableVersion) { return "Dependency " + dependency + " not found for " + pluginName + ", version " + requestedVersion + " or higher needed.\n"; } if (requestedVersion.startsWith(EXP...
java
public void check(ClassDescriptorDef classDef, String checkLevel) throws ConstraintException { ensureNoTableInfoIfNoRepositoryInfo(classDef, checkLevel); checkModifications(classDef, checkLevel); checkExtents(classDef, checkLevel); ensureTableIfNecessary(classDef, checkLevel); ...
java
private void ensureNoTableInfoIfNoRepositoryInfo(ClassDescriptorDef classDef, String checkLevel) { if (!classDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_GENERATE_REPOSITORY_INFO, true)) { classDef.setProperty(PropertyHelper.OJB_PROPERTY_GENERATE_TABLE_INFO, "false"); ...
java
private void checkModifications(ClassDescriptorDef classDef, String checkLevel) throws ConstraintException { if (CHECKLEVEL_NONE.equals(checkLevel)) { return; } HashMap features = new HashMap(); FeatureDescriptorDef def; for (Itera...
java
private void checkExtents(ClassDescriptorDef classDef, String checkLevel) throws ConstraintException { if (CHECKLEVEL_NONE.equals(checkLevel)) { return; } HashMap processedClasses = new HashMap(); InheritanceHelper helper = new Inher...
java
private void checkInitializationMethod(ClassDescriptorDef classDef, String checkLevel) throws ConstraintException { if (!CHECKLEVEL_STRICT.equals(checkLevel)) { return; } String initMethodName = classDef.getProperty(PropertyHelper.OJB_PROPERTY_INITIALIZATI...
java
private void checkPrimaryKey(ClassDescriptorDef classDef, String checkLevel) throws ConstraintException { if (CHECKLEVEL_NONE.equals(checkLevel)) { return; } if (classDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_GENERATE_TABLE_INFO, true) && cla...
java
private void checkRowReader(ClassDescriptorDef classDef, String checkLevel) throws ConstraintException { if (!CHECKLEVEL_STRICT.equals(checkLevel)) { return; } String rowReaderName = classDef.getProperty(PropertyHelper.OJB_PROPERTY_ROW_READER); ...
java
private void checkObjectCache(ClassDescriptorDef classDef, String checkLevel) throws ConstraintException { if (!CHECKLEVEL_STRICT.equals(checkLevel)) { return; } ObjectCacheDef objCacheDef = classDef.getObjectCache(); if (objCacheDef == null) ...
java
private void checkProcedures(ClassDescriptorDef classDef, String checkLevel) throws ConstraintException { if (CHECKLEVEL_NONE.equals(checkLevel)) { return; } ProcedureDef procDef; String type; String name; String fieldN...
java
OTMConnection getConnection() { if (m_connection == null) { OTMConnectionRuntimeException ex = new OTMConnectionRuntimeException("Connection is null."); sendEvents(ConnectionEvent.CONNECTION_ERROR_OCCURRED, ex, null); } return m_connection; }
java
private Integer getReleaseId() { final String[] versionParts = stringVersion.split("-"); if(isBranch() && versionParts.length >= 3){ return Integer.valueOf(versionParts[2]); } else if(versionParts.length >= 2){ return Integer.valueOf(versionParts[1]); } return 0; }
java
public int compare(final Version other) throws IncomparableException{ // Cannot compare branch versions and others if(!isBranch().equals(other.isBranch())){ throw new IncomparableException(); } // Compare digits final int minDigitSize = getDigitsSize() < other.getDigitsSize()? getDigitsSize(): other.ge...
java
public void calculateSize(PdfContext context) { float width = 0; float height = 0; for (PrintComponent<?> child : children) { child.calculateSize(context); float cw = child.getBounds().getWidth() + 2 * child.getConstraint().getMarginX(); float ch = child.getBounds().getHeight() + 2 * child.getConstraint(...
java
public void setChildren(List<PrintComponent<?>> children) { this.children = children; // needed for Json unmarshall !!!! for (PrintComponent<?> child : children) { child.setParent(this); } }
java
public void remove(Identity oid) { //processQueue(); if(oid != null) { removeTracedIdentity(oid); objectTable.remove(buildKey(oid)); if(log.isDebugEnabled()) log.debug("Remove object " + oid); } }
java
public List<DbComment> getComments(String entityId, String entityType) { return repositoryHandler.getComments(entityId, entityType); }
java
public void store(String gavc, String action, String commentText, DbCredential credential, String entityType) { DbComment comment = new DbComment(); comment.setEntityId(gavc); comment.setEntityType(entityType...
java
private boolean relevant(File currentLogFile, GregorianCalendar lastRelevantDate) { String fileName=currentLogFile.getName(); Pattern p = Pattern.compile(APPENER_DATE_DEFAULT_PATTERN); Matcher m = p.matcher(fileName); if(m.find()){ int year=Integer.parseInt(m.group(1)); int month=Integer.parseInt(m.group(...
java
private GregorianCalendar getLastReleventDate(GregorianCalendar currentDate) { int age=this.getProperties().getMaxFileAge(); GregorianCalendar result=new GregorianCalendar(currentDate.get(Calendar.YEAR),currentDate.get(Calendar.MONTH),currentDate.get(Calendar.DAY_OF_MONTH)); result.add(Calendar.DAY_OF_MONTH, -age...
java
private ColumnDef addColumnFor(FieldDescriptorDef fieldDef, TableDef tableDef) { String name = fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_COLUMN); ColumnDef columnDef = tableDef.getColumn(name); if (columnDef == null) { columnDef = new ColumnDef(name...
java
private List getColumns(List fields) { ArrayList columns = new ArrayList(); for (Iterator it = fields.iterator(); it.hasNext();) { FieldDescriptorDef fieldDef = (FieldDescriptorDef)it.next(); columns.add(fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_COLUM...
java
private boolean containsCollectionAndMapsToDifferentTable(CollectionDescriptorDef origCollDef, TableDef origTableDef, ClassDescriptorDef classDef) { if (classDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_GENERATE_TABLE_INFO, true) && !origTableDef.getName().equals(classDef.getProperty(Pr...
java
private String getHierarchyTable(ClassDescriptorDef classDef) { ArrayList queue = new ArrayList(); String tableName = null; queue.add(classDef); while (!queue.isEmpty()) { ClassDescriptorDef curClassDef = (ClassDescriptorDef)queue.get(0); ...
java
private void addIndex(IndexDescriptorDef indexDescDef, TableDef tableDef) { IndexDef indexDef = tableDef.getIndex(indexDescDef.getName()); if (indexDef == null) { indexDef = new IndexDef(indexDescDef.getName(), indexDescDef.getBooleanPr...
java
private void addTable(TableDef table) { table.setOwner(this); _tableDefs.put(table.getName(), table); }
java
public static Class getClass(String name) throws ClassNotFoundException { try { return Class.forName(name); } catch (ClassNotFoundException ex) { throw new ClassNotFoundException(name); } }
java
public void cache(Identity oid, Object obj) { if (oid != null && obj != null) { ObjectCache cache = getCache(oid, obj, METHOD_CACHE); if (cache != null) { cache.cache(oid, obj); } } }
java
public Object lookup(Identity oid) { Object ret = null; if (oid != null) { ObjectCache cache = getCache(oid, null, METHOD_LOOKUP); if (cache != null) { ret = cache.lookup(oid); } } return ret; }
java
public void remove(Identity oid) { if (oid == null) return; ObjectCache cache = getCache(oid, null, METHOD_REMOVE); if (cache != null) { cache.remove(oid); } }
java
public static ResourceBundle getCurrentResourceBundle(String locale) { try { if (null != locale && !locale.isEmpty()) { return getCurrentResourceBundle(LocaleUtils.toLocale(locale)); } } catch (IllegalArgumentException ex) { // do nothing } return getCurrentResourceBundle((Locale) null); }
java
private String getPropertyName(Expression expression) { if (!(expression instanceof PropertyName)) { throw new IllegalArgumentException("Expression " + expression + " is not a PropertyName."); } String name = ((PropertyName) expression).getPropertyName(); if (name.endsWith(FilterService.ATTRIBUTE_ID)) { /...
java
private Object getLiteralValue(Expression expression) { if (!(expression instanceof Literal)) { throw new IllegalArgumentException("Expression " + expression + " is not a Literal."); } return ((Literal) expression).getValue(); }
java
private String parsePropertyName(String orgPropertyName, Object userData) { // try to assure the correct separator is used String propertyName = orgPropertyName.replace(HibernateLayerUtil.XPATH_SEPARATOR, HibernateLayerUtil.SEPARATOR); // split the path (separator is defined in the HibernateLayerUtil) String[]...
java
public void afterCompletion(int status) { if(afterCompletionCall) return; log.info("Method afterCompletion was called"); try { switch(status) { case Status.STATUS_COMMITTED: if(log.isDebugEnabled()) ...
java
public void beforeCompletion() { // avoid redundant calls if(beforeCompletionCall) return; log.info("Method beforeCompletion was called"); int status = Status.STATUS_UNKNOWN; try { JTATxManager mgr = (JTATxManager) getImplementation().getTxManage...
java
private void internalCleanup() { if(hasBroker()) { PersistenceBroker broker = getBroker(); if(log.isDebugEnabled()) { log.debug("Do internal cleanup and close the internal used connection without" + " closing the use...
java
public void checkpoint(ObjectEnvelope mod) throws org.apache.ojb.broker.PersistenceBrokerException { mod.doUpdate(); }
java
@Api public void setUrl(String url) throws LayerException { try { this.url = url; Map<String, Object> params = new HashMap<String, Object>(); params.put("url", url); DataStore store = DataStoreFactory.create(params); setDataStore(store); } catch (IOException ioe) { throw new LayerException(ioe, E...
java
private void beginInternTransaction() { if (log.isDebugEnabled()) log.debug("beginInternTransaction was called"); J2EETransactionImpl tx = (J2EETransactionImpl) super.currentTransaction(); if (tx == null) tx = newInternTransaction(); if (!tx.isOpen()) { // ...
java
private J2EETransactionImpl newInternTransaction() { if (log.isDebugEnabled()) log.debug("obtain new intern odmg-transaction"); J2EETransactionImpl tx = new J2EETransactionImpl(this); try { getConfigurator().configure(tx); } catch (ConfigurationExc...
java
protected void associateBatched(Collection owners, Collection children) { ObjectReferenceDescriptor ord = getObjectReferenceDescriptor(); ClassDescriptor cld = getOwnerClassDescriptor(); Object owner; Object relatedObject; Object fkValues[]; Identity id; ...
java
public boolean existsElement(String predicate) throws org.odmg.QueryInvalidException { DList results = (DList) this.query(predicate); if (results == null || results.size() == 0) return false; else return true; }
java
public Iterator select(String predicate) throws org.odmg.QueryInvalidException { return this.query(predicate).iterator(); }
java
public Object selectElement(String predicate) throws org.odmg.QueryInvalidException { return ((DList) this.query(predicate)).get(0); }
java
public static boolean sameLists(String list1, String list2) { return new CommaListIterator(list1).equals(new CommaListIterator(list2)); }
java
public static void startTimer(final String type) { TransactionLogger instance = getInstance(); if (instance == null) { return; } instance.components.putIfAbsent(type, new Component(type)); instance.components.get(type).startTimer(); }
java
public static void pauseTimer(final String type) { TransactionLogger instance = getInstance(); if (instance == null) { return; } instance.components.get(type).pauseTimer(); }
java
public static ComponentsMultiThread getComponentsMultiThread() { TransactionLogger instance = getInstance(); if (instance == null) { return null; } return instance.componentsMultiThread; }
java
public static Collection<Component> getComponentsList() { TransactionLogger instance = getInstance(); if (instance == null) { return null; } return instance.components.values(); }
java
public static String getFlowContext() { TransactionLogger instance = getInstance(); if (instance == null) { return null; } return instance.flowContext; }
java
protected static boolean createLoggingAction(final Logger logger, final Logger auditor, final TransactionLogger instance) { TransactionLogger oldInstance = getInstance(); if (oldInstance == null || oldInstance.finished) { if(loggingKeys == null) { synchronized (TransactionLogger.class) { ...
java
protected void addPropertiesStart(String type) { putProperty(PropertyKey.Host.name(), IpUtils.getHostName()); putProperty(PropertyKey.Type.name(), type); putProperty(PropertyKey.Status.name(), Status.Start.name()); }
java
protected void writePropertiesToLog(Logger logger, Level level) { writeToLog(logger, level, getMapAsString(this.properties, separator), null); if (this.exception != null) { writeToLog(this.logger, Level.ERROR, "Error:", this.exception); } }
java
private static void initInstance(final TransactionLogger instance, final Logger logger, final Logger auditor) { instance.logger = logger; instance.auditor = auditor; instance.components = new LinkedHashMap<>(); instance.properties = new LinkedHashMap<>(); instance.total = new Component(TOTAL_COMPONE...
java
private static void writeToLog(Logger logger, Level level, String pattern, Exception exception) { if (level == Level.ERROR) { logger.error(pattern, exception); } else if (level == Level.INFO) { logger.info(pattern); } else if (level == Level.DEBUG) { logger.debug(pattern); } }
java
private static void addTimePerComponent(HashMap<String, Long> mapComponentTimes, Component component) { Long currentTimeOfComponent = 0L; String key = component.getComponentType(); if (mapComponentTimes.containsKey(key)) { currentTimeOfComponent = mapComponentTimes.get(key); } //when transacti...
java
public static String convertToSQL92(char escape, char multi, char single, String pattern) throws IllegalArgumentException { if ((escape == '\'') || (multi == '\'') || (single == '\'')) { throw new IllegalArgumentException("do not use single quote (') as special char!"); } StringBuilder result = new Strin...
java
public String getSQL92LikePattern() throws IllegalArgumentException { if (escape.length() != 1) { throw new IllegalArgumentException("Like Pattern --> escape char should be of length exactly 1"); } if (wildcardSingle.length() != 1) { throw new IllegalArgumentException("Like Pattern --> wildcardSingle char s...
java
public boolean evaluate(Object feature) { // Checks to ensure that the attribute has been set if (attribute == null) { return false; } // Note that this converts the attribute to a string // for comparison. Unlike the math or geometry filters, which // require specific types to function correctly, this f...
java