Java Code Examples for org.apache.commons.lang.StringUtils.isNotEmpty()

The following are Jave code examples for showing how to use isNotEmpty() of the org.apache.commons.lang.StringUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: atlas   File: AtlasProxy.java   View Source Code Vote up 7 votes
public static void addAtlasProxyClazz(Document document, Set<String> nonProxyChannels,  Result result) {

        Element root = document.getRootElement();// Get the root node

        List<? extends Node> serviceNodes = root.selectNodes("//@android:process");

        String packageName = root.attribute("package").getStringValue();

        Set<String> processNames = new HashSet<>();
        processNames.add(packageName);

        for (Node node : serviceNodes) {
            if (null != node && StringUtils.isNotEmpty(node.getStringValue())) {
                String value = node.getStringValue();
                processNames.add(value);
            }
        }

        processNames.removeAll(nonProxyChannels);

        List<String> elementNames = Lists.newArrayList("activity", "service", "provider");

        Element applicationElement = root.element("application");

        for (String processName : processNames) {

            boolean isMainPkg = packageName.equals(processName);
            //boolean isMainPkg = true;
            String processClazzName = processName.replace(":", "").replace(".", "_");

            for (String elementName : elementNames) {

                String fullClazzName = "ATLASPROXY_" +  (isMainPkg ? "" : (packageName.replace(".", "_") + "_" )) +  processClazzName + "_" + StringUtils.capitalize(elementName);

                if ("activity".equals(elementName)) {
                    result.proxyActivities.add(fullClazzName);
                } else if ("service".equals(elementName)) {
                    result.proxyServices.add(fullClazzName);
                } else {
                    result.proxyProviders.add(fullClazzName);
                }

                Element newElement = applicationElement.addElement(elementName);
                newElement.addAttribute("android:name", ATLAS_PROXY_PACKAGE + "." + fullClazzName);

                if (!packageName.equals(processName)) {
                    newElement.addAttribute("android:process", processName);
                }

                boolean isProvider = "provider".equals(elementName);
                if (isProvider) {
                    newElement.addAttribute("android:authorities",
                                            ATLAS_PROXY_PACKAGE + "." + fullClazzName);
                }

            }

        }

    }
 
Example 2
Project: sonar-quality-gates-plugin   File: SonarInstanceValidationService.java   View Source Code Vote up 7 votes
GlobalConfigDataForSonarInstance validateData(GlobalConfigDataForSonarInstance globalConfigDataForSonarInstance) {

        if (StringUtils.isNotEmpty(globalConfigDataForSonarInstance.getToken())) {
            return new GlobalConfigDataForSonarInstance(
                    globalConfigDataForSonarInstance.getName(),
                    validateUrl(globalConfigDataForSonarInstance),
                    globalConfigDataForSonarInstance.getToken(),
                    globalConfigDataForSonarInstance.getTimeToWait());
        } else {
            return new GlobalConfigDataForSonarInstance(
                    globalConfigDataForSonarInstance.getName(),
                    validateUrl(globalConfigDataForSonarInstance),
                    validateUsername(globalConfigDataForSonarInstance),
                    validatePassword(globalConfigDataForSonarInstance),
                    globalConfigDataForSonarInstance.getTimeToWait());
        }
    }
 
Example 3
Project: bdf2   File: LabelBuilder.java   View Source Code Vote up 7 votes
public void build(Object control, ViewComponent parentViewComponent) {
	Label label = (Label) control;
	String id = label.getId();
	ViewComponent component = null;
	if (StringUtils.isNotEmpty(id)) {
		component = this.generateViewComponent(id,  Label.class);
		if (StringUtils.isEmpty(label.getText())) {
			component.setDesc(label.getText());
		}
	}else if (StringUtils.isEmpty(label.getText())) {
		component = this.generateViewComponent(label.getText(),Label.class);
	}
	if(component!=null){
		if(StringUtils.isEmpty(component.getId())){
			component.setEnabled(false);
		}
		parentViewComponent.addChildren(component);			
	}
}
 
Example 4
Project: bdf2   File: TabControlFilter.java   View Source Code Vote up 7 votes
public void filter(String processDefinitionId, String taskName, Component component) throws Exception {
	TabControl tabControl = (TabControl) component;

	Set<String> componentSignature = new HashSet<String>();
	for (Tab tab : tabControl.getTabs()) {
		String tags = tab.getTags();
		if (StringUtils.isNotEmpty(tags)) {
			componentSignature.addAll(Arrays.asList(tags.split(",")));
		}
		for (String token : new String[] { tab.getName(), tab.getName() }) {
			if (StringUtils.isNotEmpty(token)) {
				componentSignature.add(token);
			}
		}
		int authority = securityCheck.checkComponent(processDefinitionId, taskName, componentSignature);
		if (authority == ComponentFilter.INVISIBLE) {
			tab.setIgnored(true);
		} else if (authority > 0) {
			tab.setDisabled(authority == ComponentFilter.READONLY);
		}
	}
}
 
Example 5
Project: keti   File: GraphConfig.java   View Source Code Vote up 7 votes
public Graph createGraph() throws InterruptedException {
    Graph newGraph;
    if (this.cassandraEnabled) {
        Builder titanBuilder = TitanFactory.build().set("storage.backend", "cassandra")
                .set("storage.cassandra.keyspace", this.cassandraKeyspace)
                .set("storage.hostname", Arrays.asList(hostname.split(","))).set("storage.port", this.port)
                .set("cache.db-cache", this.cacheEnabled).set("cache.db-cache-clean-wait", this.titanCacheCleanWait)
                .set("cache.db-cache-time", this.titanCacheTime).set("cache.db-cache-size", this.titanCacheSize);
        if (StringUtils.isNotEmpty(this.username)) {
            titanBuilder = titanBuilder.set("storage.username", this.username);
        }
        if (StringUtils.isNotEmpty(this.password)) {
            titanBuilder = titanBuilder.set("storage.password", this.password);
        }
        newGraph = titanBuilder.open();
    } else {
        newGraph = TitanFactory.build().set("storage.backend", "inmemory").open();
    }
    createSchemaElements(newGraph);
    LOGGER.info("Initialized titan db.");
    return newGraph;
}
 
Example 6
Project: Hydrograph   File: WatchRecordAction.java   View Source Code Vote up 7 votes
private JobDetails getSelectedJobDetails(String consoleName, Map<String, List<JobDetails>> jobDetails,
		String selectedUniqueJobId) {
	JobDetails selectedJob = null;
	for (Map.Entry<String, List<JobDetails>> entry : jobDetails.entrySet()) {
		if (consoleName.equalsIgnoreCase(entry.getKey())) {
			List<JobDetails> jobList = entry.getValue();
			for (JobDetails jobDetail : jobList) {
				if (StringUtils.isNotEmpty(selectedUniqueJobId)
						&& jobDetail.getUniqueJobID().equalsIgnoreCase(selectedUniqueJobId)) {
					selectedJob = jobDetail;
					break;
				}
			}
		}
	}
	return selectedJob;
}
 
Example 7
Project: logistimo-web-service   File: EntitiesServiceImpl.java   View Source Code Vote up 7 votes
private String getLocFilterSubQuery(LocationSuggestionModel parentLocation) {
  StringBuilder filterQuery = new StringBuilder();
  if (parentLocation != null) {
      if (StringUtils.isNotEmpty(parentLocation.state)) {
          filterQuery.append(" AND STATE ")
              .append(CharacterConstants.EQUALS).append(CharacterConstants.S_QUOTE)
              .append(parentLocation.state).append(CharacterConstants.S_QUOTE).append(CharacterConstants.SPACE);
      }
      if (StringUtils.isNotEmpty(parentLocation.district)) {
          filterQuery.append(" AND DISTRICT ")
              .append(CharacterConstants.EQUALS).append(CharacterConstants.S_QUOTE)
              .append(parentLocation.district).append(CharacterConstants.S_QUOTE).append(CharacterConstants.SPACE);
      }
  }
  return filterQuery.toString();
}
 
Example 8
Project: bdf2   File: DataGridProfileFilter.java   View Source Code Vote up 6 votes
/**
 * 获取系统默认DataGrid的所有列,包括ColumnGroup中的多有列到Map对象中
 * 
 * @param topColumns
 * @param groupColumns
 */
private void getDataGridColumns(List<Column> topColumns, Map<String, Column> groupColumns) {

	for (Column column : topColumns) {
		if (column instanceof ColumnGroup) {
			this.getDataGridColumns(((ColumnGroup) column).getColumns(), groupColumns);
		}
		String name = column.getName();
		if (StringUtils.isNotEmpty(name)) {
			groupColumns.put(column.getName(), column);
		}
	}
}
 
Example 9
Project: ThriftJ   File: ClientSelector.java   View Source Code Vote up 6 votes
@SuppressWarnings({ "rawtypes", "unchecked" })
public ClientSelector(String servers, int loadBalance, ConnectionValidator validator, GenericKeyedObjectPoolConfig poolConfig, FailoverStrategy strategy, int connTimeout, String backupServers, int serviceLevel) {
   	this.failoverChecker = new FailoverChecker(validator, strategy, serviceLevel);
   	this.poolProvider = new DefaultThriftConnectionPool(new ThriftConnectionFactory(failoverChecker, connTimeout), poolConfig);
   	failoverChecker.setConnectionPool(poolProvider);
   	failoverChecker.setServerList(ThriftServer.parse(servers));
       if (StringUtils.isNotEmpty(backupServers)) {
       	failoverChecker.setBackupServerList(ThriftServer.parse(backupServers));
       } else{
       	failoverChecker.setBackupServerList(new ArrayList<ThriftServer>());
       }
       failoverChecker.startChecking();
   }
 
Example 10
Project: logistimo-web-service   File: ReportPluginService.java   View Source Code Vote up 6 votes
private void prepareFiltersByRegion(Long domainId, QueryRequestModel model) {
  try {
    DomainConfig dc = DomainConfig.getInstance(domainId);
    if (StringUtils.isNotEmpty(dc.getCountry())) {
      if (StringUtils.isNotEmpty(dc.getState())) {
        if (StringUtils.isNotEmpty(dc.getDistrict())) {
          model.filters.put(QueryHelper.TOKEN_LOCATION, QueryHelper.LOCATION_TALUK);
          model.filters.put(QueryHelper.TOKEN + QueryHelper.QUERY_TALUK, null);
          model.filters.put(QueryHelper.TOKEN + QueryHelper.QUERY_DISTRICT, null);
          model.filters.put(QueryHelper.TOKEN + QueryHelper.QUERY_STATE, null);
          model.filters.put(QueryHelper.TOKEN + QueryHelper.QUERY_COUNTRY, null);
        } else {
          model.filters.put(QueryHelper.TOKEN_LOCATION, QueryHelper.LOCATION_DISTRICT);
          model.filters.put(QueryHelper.TOKEN + QueryHelper.QUERY_DISTRICT, null);
          model.filters.put(QueryHelper.TOKEN + QueryHelper.QUERY_STATE, null);
          model.filters.put(QueryHelper.TOKEN + QueryHelper.QUERY_COUNTRY, null);
        }
      } else {
        model.filters.put(QueryHelper.TOKEN_LOCATION, QueryHelper.LOCATION_STATE);
        model.filters.put(QueryHelper.TOKEN + QueryHelper.QUERY_STATE, null);
        model.filters.put(QueryHelper.TOKEN + QueryHelper.QUERY_COUNTRY, null);
      }
    } else {
      model.filters.put(QueryHelper.TOKEN_LOCATION, QueryHelper.LOCATION_COUNTRY);
      model.filters.put(QueryHelper.TOKEN + QueryHelper.QUERY_COUNTRY, null);
    }
  } catch (Exception e) {
    xLogger.warn("Exception in replacing location token", e);
  }
}
 
Example 11
Project: kaltura-ce-sakai-extension   File: KalturaAPIService.java   View Source Code Vote up 6 votes
/**
 * Finds the correct JS player to use
 * @param playerId [OPTIONAL] the numeric id of the kaltura player
 * @return the HTML5 JS player for a given player or null if the player is not enabled. If for some reason the player id is
 * also null, then we return null.
 */
protected String findKalturaPlayerJSURL(String playerId) {
    String playerJSURL = null; // should be null if not enabled or the player id is null.
    if (this.kalturaHtml5PlayerEnabled && StringUtils.isNotEmpty(playerId)) {
        int partnerId = this.getKalturaConfig().getPartnerId();
        // Use the URL provided if there was a property override set
        if (StringUtils.isNotEmpty(this.kalturaHtml5PlayerJS)) {
            playerJSURL = this.kalturaHtml5PlayerJS;
        } else {
            // build custom JS url: {KALTURA HOST}/p/{PARTNER_ID}/sp/{PARTNER_ID}00/embedIframeJs/uiconf_id/{PLAYER_ID}/partner_id/{PARTNER_ID}
            playerJSURL = this.getKalturaConfig().getEndpoint()+"/p/"+partnerId+"/sp/"+partnerId+"00/embedIframeJs/uiconf_id/"+playerId+"/partner_id/"+partnerId;
        }
    }
    return playerJSURL;
}
 
Example 12
Project: jsf-core   File: ScanNodeStatusHelper.java   View Source Code Vote up 6 votes
/**
 * 验证接口和ip是否符合上下线报警规则
 * @param interfaceName
 * @param ip
 * @return
 */
public boolean needAlarm(String interfaceName, String ip) {
    List<IfaceAlarm> list = ifaceAlarmRuleMap.get(interfaceName);
    if (list != null) {
        for (IfaceAlarm alarm : list) {
            if (StringUtils.isNotEmpty(alarm.getAlarmIp()) && isIpMatch(GenerateRegular.getIpRegularList(alarm.getAlarmIp()), ip)) {
                return true;
            }
        }
    }
    return false;
}
 
Example 13
Project: bdf2   File: FormElementBuilder.java   View Source Code Vote up 6 votes
private String getFormElementLabel(FormElement element, Map<String, PropertyDef> dataTypePropertyDefs) {
	String property = element.getProperty();
	if (StringUtils.isNotEmpty(property) && dataTypePropertyDefs != null) {
		PropertyDef pd = dataTypePropertyDefs.get(property);
		if (pd != null && StringUtils.isNotEmpty(pd.getLabel())) {
			return pd.getLabel();
		}
	}
	return property;
}
 
Example 14
Project: rapidminer   File: OperatorDocLoader.java   View Source Code Vote up 6 votes
/**
	 * This is the method for loading an operator's documentation within the program.
	 */
	public static String loadOperatorDocumentation(final boolean online, final boolean activateCache,
			final OperatorDescription dirtyOpDesc) {
		String toShowText;
		OperatorDescription opDesc = dirtyOpDesc;
		if (opDesc == null) {
			// TODO: Eliminate this case
			toShowText = ERROR_TEXT_FOR_WIKI;
		} else {
			if (activateCache && OPERATOR_CACHE_MAP.containsKey(opDesc)) {
				return OPERATOR_CACHE_MAP.get(opDesc);
			} else {
				try {
//					if (online) {
//						toShowText = loadSelectedOperatorDocuFromWiki(opDesc);
//					} else {
//						toShowText = loadSelectedOperatorDocuLocally(opDesc);
//					}
                    toShowText = loadSelectedOperatorDocuLocally(opDesc);
				} catch (Exception e) {
					SwingTools.showFinalErrorMessage("rapid_doc_bot_importer_showInBrowser", e, true,
							new Object[] { e.getMessage() });
					toShowText = ERROR_TEXT_FOR_WIKI;
				}
				if (activateCache && StringUtils.isNotBlank(toShowText) && StringUtils.isNotEmpty(toShowText)) {
					OPERATOR_CACHE_MAP.put(opDesc, toShowText);
				}
			}
		}
		return toShowText;
	}
 
Example 15
Project: Hydrograph   File: InputAdditionalParametersDialog.java   View Source Code Vote up 6 votes
private void addAdditionalParameterMapValues() {

		if (additionalParameterValue != null && !additionalParameterValue.isEmpty()) {
			if (additionalParameterValue.get(Constants.NUMBER_OF_PARTITIONS) != null 
					&& StringUtils.isNotEmpty((String)additionalParameterValue.get(Constants.NUMBER_OF_PARTITIONS))) {
				noOfPartitionsTextBox.setText(additionalParameterValue.get(Constants.NUMBER_OF_PARTITIONS).toString());
				Utils.INSTANCE.addMouseMoveListener(noOfPartitionsTextBox, cursor);	
				if (additionalParameterValue.get(Constants.NOP_LOWER_BOUND) != null 
						&& StringUtils.isNotEmpty((String) additionalParameterValue.get(Constants.NOP_LOWER_BOUND))) {
					partitionKeyLowerBoundTextBox.setText(additionalParameterValue.get(Constants.NOP_LOWER_BOUND).toString());
					Utils.INSTANCE.addMouseMoveListener(partitionKeyLowerBoundTextBox, cursor);
					partitionKeyLowerBoundControlDecoration.hide();
				} else {
					partitionKeyLowerBoundControlDecoration.show();
				}
				if (additionalParameterValue.get(Constants.NOP_UPPER_BOUND) != null 
						&& StringUtils.isNotEmpty((String) additionalParameterValue.get(Constants.NOP_UPPER_BOUND))) {
					partitionKeyUpperBoundTextBox
							.setText(additionalParameterValue.get(Constants.NOP_UPPER_BOUND).toString());
					Utils.INSTANCE.addMouseMoveListener(partitionKeyUpperBoundTextBox, cursor);
					partitionKeyUpperBoundControlDecoration.hide();
				} else {
					partitionKeyUpperBoundControlDecoration.show();
				}
			}else{
				partitionKeyLowerBoundControlDecoration.hide();
				partitionKeyUpperBoundControlDecoration.hide();
			}
			fetchSizeTextBox.setText((String) additionalParameterValue.get(Constants.ADDITIONAL_DB_FETCH_SIZE));
			Utils.INSTANCE.addMouseMoveListener(fetchSizeTextBox, cursor);

			if (StringUtils.isNotBlank((String) additionalParameterValue.get(Constants.ADDITIONAL_PARAMETERS_FOR_DB))) {
				additionalParameterTextBox
						.setText((String) additionalParameterValue.get(Constants.ADDITIONAL_PARAMETERS_FOR_DB));
				Utils.INSTANCE.addMouseMoveListener(additionalParameterTextBox, cursor);
			}
		}

	}
 
Example 16
Project: logistimo-web-service   File: ApprovalsDao.java   View Source Code Vote up 6 votes
public void updateOrderApprovalStatus(Long orderId, String approvalId, String status) {
  if (orderId != null && StringUtils.isNotEmpty(approvalId)) {
    PersistenceManager pm = null;
    Query query = null;
    try {
      pm = PMF.get().getPersistenceManager();
      Map<String, Object> params = new HashMap<>();
      query = pm.newQuery(JDOUtils.getImplClass(IOrderApprovalMapping.class));
      query.setFilter("orderId == orderIdParam && approvalId == approvalIdParam ");
      query.declareParameters("Long orderIdParam, String approvalIdParam");
      params.put("orderIdParam", orderId);
      params.put(APPROVAL_ID_PARAM, approvalId);
      query.setUnique(true);
      IOrderApprovalMapping orderApprovalMapping = (IOrderApprovalMapping) query
          .executeWithMap(params);
      if (orderApprovalMapping != null) {
        orderApprovalMapping.setStatus(status);
        orderApprovalMapping.setUpdatedAt(new Date());
        pm.makePersistent(orderApprovalMapping);
      }
    } catch (Exception e) {
      xLogger.warn("Failed to get order approval mapping for order: {0} with approval: {1}",
          orderId, approvalId, e);
    } finally {
      if (query != null) {
        try {
          query.closeAll();
        } catch (Exception ignored) {
          xLogger.warn(ignored.getMessage(), ignored);
        }
      }
      if (pm != null) {
        pm.close();
      }
    }
  }
}
 
Example 17
Project: uflo   File: AbstractParser.java   View Source Code Vote up 5 votes
protected void parseNodeCommonInfo(Element element, Node node) {
	node.setName(unescape(element.attributeValue("name")));
	String label=element.attributeValue("label");
	if(StringUtils.isNotEmpty(label)){
		node.setLabel(unescape(label));
	}
	Element desc=element.element("description");
	if(desc!=null){
		node.setDescription(unescape(desc.getTextTrim()));
	}
	node.setEventHandlerBean(unescape(element.attributeValue("event-handler-bean")));
	int x=0,y=0,width=80,height=40;
	String g = element.attributeValue("g");
	if(StringUtils.isNotBlank(g)){
		StringTokenizer tokenizer=new StringTokenizer(g,",");
		if (tokenizer.countTokens() == 4) {
			x=Integer.valueOf(tokenizer.nextToken());
			y=Integer.valueOf(tokenizer.nextToken());
			width=Integer.valueOf(tokenizer.nextToken());
			height=Integer.valueOf(tokenizer.nextToken());
		}
	}
	node.setX(x);
	node.setY(y);
	node.setWidth(width);
	node.setHeight(height);
	String xAttr=element.attributeValue("x");
	String yAttr=element.attributeValue("y");
	String widthAttr=element.attributeValue("width");
	String heightAttr=element.attributeValue("height");
	if(StringUtils.isNotBlank(xAttr)){
		node.setX(Integer.valueOf(xAttr));
	}
	if(StringUtils.isNotBlank(yAttr)){
		node.setY(Integer.valueOf(yAttr));
	}
	if(StringUtils.isNotBlank(widthAttr)){
		node.setWidth(Integer.valueOf(widthAttr));
	}
	if(StringUtils.isNotBlank(heightAttr)){
		node.setHeight(Integer.valueOf(heightAttr));
	}
	
}
 
Example 18
Project: Hydrograph   File: UpdateByKeysWidget.java   View Source Code Vote up 5 votes
@Override
public void attachToPropertySubGroup(AbstractELTContainerWidget subGroup) {
	
	logger.debug("Starting {} button creation");
	ELTDefaultSubgroupComposite selectUpdateKeysComposite = new ELTDefaultSubgroupComposite(subGroup.getContainerControl());
	selectUpdateKeysComposite.createContainerWidget();
	
	ELTDefaultLable defaultLable1 = new ELTDefaultLable(Messages.LABEL_UPDATE_BY_KEYS);
	selectUpdateKeysComposite.attachWidget(defaultLable1);
	setPropertyHelpWidget((Control) defaultLable1.getSWTWidgetControl());
	
	ELTDefaultTextBox defaultUpdateByKeysTextBox = new ELTDefaultTextBox();
	selectUpdateKeysComposite.attachWidget(defaultUpdateByKeysTextBox);
	 updateByKeysTextBox=(Text)defaultUpdateByKeysTextBox.getSWTWidgetControl();
	 updateByKeysTextBox.setEnabled(false);
	setPropertyHelpWidget((Control) defaultUpdateByKeysTextBox.getSWTWidgetControl());
	
	ELTDefaultButton eltDefaultButton = new ELTDefaultButton(Messages.LABEL_SELECT_KEYS);
	selectUpdateKeysComposite.attachWidget(eltDefaultButton);
	selectKeysButton=(Button)eltDefaultButton.getSWTWidgetControl();
	
	updateByKeysTextBoxDecorator = WidgetUtility.addDecorator(updateByKeysTextBox, Messages.bind(Messages.EMPTY_FIELD, "JDBC Driver \n Class"));
	updateByKeysTextBoxDecorator.setMarginWidth(3);

	if(StringUtils.isNotEmpty(propertyValue)){
		updateByKeysTextBox.setText(propertyValue);
		updateByKeysTextBoxDecorator.hide();
	}
	
	attachButtonListner(selectKeysButton);
	
	
	updateByKeysTextBox.addModifyListener(new ModifyListener() {
		
		@Override
		public void modifyText(ModifyEvent event) {
			Text textBox=(Text)event.widget;
			if(StringUtils.isBlank(textBox.getText())){
				updateByKeysTextBoxDecorator.show();
			}else{
				updateByKeysTextBoxDecorator.hide();
			}
		}
	});
	
}
 
Example 19
Project: DBus   File: SqlManager.java   View Source Code Vote up 5 votes
private String getMysqlWriteBackSql(String startTime, String completedTime, String pullStatus, String errorMsg) {
      if(StringUtils.isEmpty(startTime) && StringUtils.isEmpty(completedTime) &&
                StringUtils.isEmpty(pullStatus) && StringUtils.isEmpty(errorMsg)){
            return null;
      }

//      String dbSchema = (String)(options.getConfProperties().get(DBConfiguration.DataSourceInfo.DB_SCHEMA));
//      StringBuilder sqlStr = new StringBuilder("UPDATE "+dbSchema+".db_full_pull_requests SET ");
      StringBuilder sqlStr = new StringBuilder("UPDATE db_full_pull_requests SET ");
      boolean needComma = false;
      if (StringUtils.isNotEmpty(startTime)) {
          needComma = true;
          sqlStr.append("PULL_START_TIME=str_to_date(?,'%Y-%m-%d %H:%i:%s.%f')");
      }
      if (StringUtils.isNotEmpty(completedTime)) {
          if (needComma) {
              sqlStr.append(",PULL_END_TIME=str_to_date(?,'%Y-%m-%d %H:%i:%s.%f')");
          } else {
              sqlStr.append("PULL_END_TIME=str_to_date(?,'%Y-%m-%d %H:%i:%s.%f')");
          }
          needComma = true;
      }
      if (StringUtils.isNotEmpty(pullStatus)) {
          if (needComma) {
              sqlStr.append(",PULL_STATUS=?");
          } else {
              sqlStr.append("PULL_STATUS=?");
          }
          needComma = true;
      }
      if (StringUtils.isNotEmpty(errorMsg)) {
          if (needComma) {
              // sqlStr.append(",PULL_REMARK=concat(PULL_REMARK,'-',?)");
              sqlStr.append(",PULL_REMARK=?");
          } else {
              // sqlStr.append("PULL_REMARK=concat(PULL_REMARK,'-',?)");
              sqlStr.append("PULL_REMARK=?");
          }
          needComma = true;
      }
      sqlStr.append(" WHERE SEQNO=?");
      return sqlStr.toString();
  }
 
Example 20
Project: logistimo-web-service   File: DomainConfigController.java   View Source Code Vote up 5 votes
@RequestMapping(value = "/accesslogs", method = RequestMethod.GET)
public
@ResponseBody
Results getAccessLogs(@RequestParam(required = false) String duration,
                      @RequestParam(defaultValue = "1") int o,
                      @RequestParam(defaultValue = PageParams.DEFAULT_SIZE_STR) int s,
                      HttpServletRequest request) {
  SecureUserDetails sUser = getUserDetails();
  Locale locale = sUser.getLocale();
  ResourceBundle backendMessages = Resources.get().getBundle("BackendMessages", locale);
  if (!GenericAuthoriser.authoriseAdmin(request)) {
    throw new UnauthorizedException(backendMessages.getString("permission.denied"));
  }
  Long domainId = SecurityUtils.getCurrentDomainId();
  if (domainId == null) {
    xLogger.severe("Error in fetching Access log");
    throw new InvalidServiceException(backendMessages.getString("accesslog.fetch.error"));
  }
  Date start = null;
  if (duration != null && !duration.isEmpty()) {
    Calendar cal = LocalDateUtil.getZeroTime(DomainConfig.getInstance(domainId).getTimezone());
    cal.add(Calendar.DATE, -1 * Integer.parseInt(duration));
    start = cal.getTime();
  }
  Navigator
      navigator =
      new Navigator(request.getSession(), "DomainConfigController.getAccessLogs", o, s, "dummy",
          0);
  PageParams pageParams = new PageParams(navigator.getCursor(o), o, s);
  Results results = XLog.getRequestLogs(domainId, IALog.TYPE_BBOARD, start, pageParams);
  navigator.setResultParams(results);
  if (results == null || results.getResults() == null) {
    return null;
  }
  List<IALog> logs = results.getResults();
  List<AccessLogModel> models = new ArrayList<AccessLogModel>();
  for (IALog log : logs) {
    AccessLogModel model = new AccessLogModel();
    if (log != null) {
      if (StringUtils.isNotEmpty(Long.toString(log.getKey()))) {
        model.key = Long.toString(log.getKey());
      }
      if (StringUtils.isNotEmpty(Long.toString(log.getDomainId()))) {
        model.did = Long.toString(log.getDomainId());
      }
      if (StringUtils.isNotEmpty(log.getIPAddress())) {
        model.ip = log.getIPAddress();
      }
      if (StringUtils.isNotEmpty(log.getTimestamp().toString())) {
        model.t = log.getTimestamp().toString();
      }
      if (StringUtils.isNotEmpty(log.getType())) {
        model.type = log.getType();
      }
      if (StringUtils.isNotEmpty(log.getUserAgent())) {
        model.ua = log.getUserAgent();
      }
    }
    models.add(model);
  }
  return new Results(models, "accesslog", -1, o);
}