本文整理汇总了Java中org.restlet.data.Form.getNames方法的典型用法代码示例。如果您正苦于以下问题:Java Form.getNames方法的具体用法?Java Form.getNames怎么用?Java Form.getNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.restlet.data.Form
的用法示例。
在下文中一共展示了Form.getNames方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: logFormRequest
import org.restlet.data.Form; //导入方法依赖的package包/类
/**
* Log the form request.
*
* @param form the form
*/
private void logFormRequest(final Form form) {
if (LOGGER.isDebugEnabled()) {
final Set<String> pairs = new HashSet<>();
for (final String name : form.getNames()) {
final StringBuilder builder = new StringBuilder();
builder.append(name);
builder.append(": ");
if (!"password".equalsIgnoreCase(name)) {
builder.append(form.getValues(name));
} else {
builder.append("*****");
}
pairs.add(builder.toString());
}
LOGGER.debug(StringUtils.join(pairs, ", "));
}
}
示例2: logFormRequest
import org.restlet.data.Form; //导入方法依赖的package包/类
private void logFormRequest(final Form form) {
if (LOGGER.isDebugEnabled()) {
final Set<String> pairs = new HashSet<String>();
for (final String name : form.getNames()) {
final StringBuilder builder = new StringBuilder();
builder.append(name);
builder.append(": ");
if (!"password".equalsIgnoreCase(name)) {
builder.append(form.getValues(name));
} else {
builder.append("*****");
}
pairs.add(builder.toString());
}
LOGGER.debug(StringUtils.join(pairs, ", "));
}
}
示例3: initPage
import org.restlet.data.Form; //导入方法依赖的package包/类
/**
* 初始化分页处理
*/
protected void initPage() {
Form queryForm = getQuery();
Set<String> queryNames = queryForm.getNames();
if (queryNames.contains(RestConstants.PAGE_START)) {
if (queryNames.contains(RestConstants.PAGE_LENGTH)) {
pageSize = StringUtil.getInt(getQueryParameter(RestConstants.PAGE_LENGTH, queryForm));
}
pageIndex = StringUtil.getInt(getQueryParameter(RestConstants.PAGE_START, queryForm)) / pageSize + 1;
}
if (queryNames.contains(RestConstants.PAGE_INDEX)) {
pageIndex = StringUtil.getInt(getQueryParameter(RestConstants.PAGE_INDEX, queryForm));
}
if (queryNames.contains(RestConstants.PAGE_SIZE)) {
pageSize = StringUtil.getInt(getQueryParameter(RestConstants.PAGE_SIZE, queryForm));
}
}
示例4: getNumberOfInstancesToAdd
import org.restlet.data.Form; //导入方法依赖的package包/类
protected static int getNumberOfInstancesToAdd(Form form) {
Set<String> formParams = form.getNames();
try {
if (formParams.contains(NUMBER_INSTANCES_ADD_FORM_PARAM)) {
return Integer.parseInt(form.getFirstValue(NUMBER_INSTANCES_ADD_FORM_PARAM));
} else if (formParams.isEmpty()) {
return Integer.parseInt(NUMBER_INSTANCES_ADD_DEFAULT);
} else {
throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST,
"No form parameter " + NUMBER_INSTANCES_ADD_FORM_PARAM +
"=# found in the scale-up request.");
}
} catch (NumberFormatException e) {
throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST,
"Number of instances to add should be an integer.");
}
}
示例5: request
import org.restlet.data.Form; //导入方法依赖的package包/类
@Get("json")
public String request(final String entity) {
int verboseLevel = 0;
addAllowOrigin();
//routing should be in a way in which open_test_uuid is always set
String openUUID = getRequest().getAttributes().get("open_test_uuid").toString();
final Form getParameters = getRequest().getResourceRef().getQueryAsForm();
//allow sender + verbose
for (String name : getParameters.getNames()) {
if (name.equals("verbose")) {
try {
verboseLevel = Integer.parseInt(getParameters.getFirstValue("verbose"));
} catch (NumberFormatException ex) {
Logger.getGlobal().info("invalid non-numberic verbosity level");
}
} else if (name.equals("sender") || name.equals("?sender")) { //allow for ?sender; used by some users due to error in old documentation
//ignore for now
final String sender_id;
if (name.equals("sender"))
sender_id = "sender " + getParameters.getFirstValue("sender");
else
sender_id = "sender " + getParameters.getFirstValue("?sender");
}
}
return getSingleOpenTest(openUUID, verboseLevel);
}
示例6: getDefinitions
import org.restlet.data.Form; //导入方法依赖的package包/类
@Get
public DataResult getDefinitions() {
ProcessEngine engine = ProcessEngineManagement.getDefaultProcessEngine();
ProcessDefinitionQuery processDefinitionQuery = engine.getModelService().createProcessDefinitionQuery();
Form query = getQuery();
Set<String> names = query.getNames();
if (names.contains(RestConstants.CATEGORY)) {
processDefinitionQuery.processDefinitionCategory(getQueryParameter(RestConstants.CATEGORY, query));
}
if (names.contains(RestConstants.PROCESS_KEY)) {
processDefinitionQuery.processDefinitionKey(getQueryParameter(RestConstants.PROCESS_KEY, query));
}
if (names.contains(RestConstants.NAME)) {
processDefinitionQuery.processDefinitionName(getQueryParameter(RestConstants.NAME, query));
}
if (names.contains(RestConstants.NAME_LIKE)) {
processDefinitionQuery.processDefinitionNameLike(parseLikeValue(getQueryParameter(RestConstants.NAME_LIKE, query)));
}
List<ProcessDefinition> processDefinitions = processDefinitionQuery.list();
List<Map<String,Object>> results = new ArrayList<Map<String,Object>>();
for (ProcessDefinition process : processDefinitions) {
Map<String,Object> processAttrMap = process.getPersistentState();
processAttrMap.put("description", process.getDescription());
results.add(processAttrMap);
}
DataResult result = new DataResult();
result.setData(results);
result.setTotal(processDefinitions.size());
return result;
}
示例7: getAllUsers
import org.restlet.data.Form; //导入方法依赖的package包/类
@Get
public DataResult getAllUsers() {
Form query = getQuery();
Set<String> names = query.getNames();
String userName = null;
String userId = null;
if (names.contains("userName")) {
String tmpUserName = getQueryParameter("userName", query);
if(StringUtil.isNotEmpty(tmpUserName))
userName = "%"+tmpUserName+"%";
}
if (names.contains("userId")) {
String tmpUserId = getQueryParameter("userId", query);
if(StringUtil.isNotEmpty(tmpUserId))
userId = "%"+tmpUserId+"%";
}
List<UserEntity> users = FoxBpmUtil.getProcessEngine().getIdentityService().getUsers(userId, userName);
// 数据转换
List<Map<String, Object>> resultDatas = new ArrayList<Map<String, Object>>();
for (UserEntity user : users) {
resultDatas.add(user.getPersistentState());
}
// 数据响应体构造
DataResult result = new DataResult();
result.setData(resultDatas);
result.setTotal(users.size());
return result;
}
示例8: getCalendarParts
import org.restlet.data.Form; //导入方法依赖的package包/类
@Get
public DataResult getCalendarParts(){
Form queryForm = getQuery();
Set<String> queryNames = queryForm.getNames();
String id = StringUtil.getString(getQueryParameter("id", queryForm));
String idLike = null;
if (StringUtil.isNotEmpty(id)) {
idLike = "%" + id + "%";
}
if (queryNames.contains(RestConstants.PAGE_START)) {
if (queryNames.contains(RestConstants.PAGE_LENGTH)) {
pageSize = StringUtil.getInt(getQueryParameter(RestConstants.PAGE_LENGTH, queryForm));
}
pageIndex = StringUtil.getInt(getQueryParameter(RestConstants.PAGE_START, queryForm)) / pageSize + 1;
}
if (queryNames.contains(RestConstants.PAGE_INDEX)) {
pageIndex = StringUtil.getInt(getQueryParameter(RestConstants.PAGE_INDEX, queryForm));
}
if (queryNames.contains(RestConstants.PAGE_SIZE)) {
pageSize = StringUtil.getInt(getQueryParameter(RestConstants.PAGE_SIZE, queryForm));
}
WorkCalendarService workCalendarService = ProcessEngineManagement.getDefaultProcessEngine().getService(WorkCalendarService.class);
DataResult result = new DataResult();
result.setData(workCalendarService.getCalendarPart(pageIndex, pageSize, idLike));
result.setPageIndex(pageIndex);
result.setPageSize(pageSize);
result.setRecordsTotal(workCalendarService.getCalendarPartCount(idLike));
result.setRecordsFiltered(workCalendarService.getCalendarPartCount(idLike));
return result;
}
示例9: paginateList
import org.restlet.data.Form; //导入方法依赖的package包/类
/**
* foxbpm rest接口的分页机制 接收参数: start:起始行数 lenth:每页条数 pageIndex:当前页
* pageSize:每页条数 冲突解决:优先处理pageIndex、pageSize
*
* @param query
* @return
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public DataResult paginateList(Query query) {
Form queryForm = getQuery();
Set<String> queryNames = queryForm.getNames();
if (queryNames.contains(RestConstants.PAGE_START)) {
if (queryNames.contains(RestConstants.PAGE_LENGTH)) {
pageSize = StringUtil.getInt(getQueryParameter(RestConstants.PAGE_LENGTH, queryForm));
}
pageIndex = StringUtil.getInt(getQueryParameter(RestConstants.PAGE_START, queryForm)) / pageSize + 1;
}
if (queryNames.contains(RestConstants.PAGE_INDEX)) {
pageIndex = StringUtil.getInt(getQueryParameter(RestConstants.PAGE_INDEX, queryForm));
}
if (queryNames.contains(RestConstants.PAGE_SIZE)) {
pageSize = StringUtil.getInt(getQueryParameter(RestConstants.PAGE_SIZE, queryForm));
}
List<PersistentObject> resultObjects = query.listPagination(pageIndex, pageSize);
List<Map<String, Object>> dataMap = new ArrayList<Map<String, Object>>();
if (resultObjects != null) {
Iterator<PersistentObject> iterator = resultObjects.iterator();
while (iterator.hasNext()) {
dataMap.add(iterator.next().getPersistentState());
}
}
long resultCount = query.count();
DataResult result = new DataResult();
result.setData(dataMap);
result.setPageIndex(pageIndex);
result.setPageSize(pageSize);
result.setRecordsTotal(resultCount);
result.setRecordsFiltered(resultCount);
return result;
}
示例10: adaptParameterMapToUserPrefValues
import org.restlet.data.Form; //导入方法依赖的package包/类
private Map<String, String> adaptParameterMapToUserPrefValues(Form params) {
Map<String, String> values = new HashMap<String, String>();
for (String param : params.getNames()) {
if (param.startsWith(USER_PREF_PREFIX) && params.getFirst(param) != null) {
values.put(param.substring(USER_PREF_PREFIX.length()), params.getFirstValue(param));
}
}
return values;
}
示例11: parsePackages
import org.restlet.data.Form; //导入方法依赖的package包/类
private void parsePackages(Form form) throws ValidationException {
// items should be encoded as: package--[index]--[value]
Set<String> formitems = form.getNames();
ImageModule image = castToModule();
image.getPackages().clear();
for (String inputName : formitems.toArray(new String[0])) {
if (inputName.startsWith("package--")
&& inputName.endsWith("--name")) {
String[] parts = inputName.split("--");
String genericPart = parts[0] + "--" + parts[1] + "--";
String name = form.getFirstValue(inputName);
String repository = form.getFirstValue(genericPart
+ "repository");
String key = form.getFirstValue(genericPart + "key");
Package package_ = new Package(name, repository, key);
if (image.getPackages().contains(package_)) {
throw (new ValidationException(
"Cannot specify the same package multiply times: "
+ package_.getName()));
}
image.setPackage(package_);
}
}
if (havePackagesChanged(image.getPackages())) {
needsRebuild = true;
}
}
示例12: request
import org.restlet.data.Form; //导入方法依赖的package包/类
@Get("json")
public String request(final String entity)
{
int verboseLevel = 0;
addAllowOrigin();
//routing should be in a way in which open_test_uuid is always set
String openUUID = getRequest().getAttributes().get("open_test_uuid").toString();
final Form getParameters = getRequest().getResourceRef().getQueryAsForm();
//allow sender + verbose
for (String name : getParameters.getNames()) {
if (name.equals("verbose")) {
try {
verboseLevel = Integer.parseInt(getParameters.getFirstValue("verbose"));
}
catch (NumberFormatException ex) {
Logger.getGlobal().info("invalid non-numberic verbosity level");
}
}
else if (name.equals("sender") || name.equals("?sender")) { //allow for ?sender; used by some users due to error in old documentation
//ignore for now
final String sender_id;
if (name.equals("sender"))
sender_id = "sender " + getParameters.getFirstValue("sender");
else
sender_id = "sender " + getParameters.getFirstValue("?sender");
// System.out.println(sender_id);
//the logging block would require write access to the database
/*
final String sql = "UPDATE json_sender SET count = count + 1 WHERE sender_id = ?";
PreparedStatement ps = null;
try
{
ps = conn.prepareStatement(sql);
ps.setString(1, sender_id);
ps.executeUpdate();
} catch (final SQLException e)
{
Logger.getLogger(OpenTestResource.class.getName()).log(Level.SEVERE, null, e);
}
*/
}
}
return getSingleOpenTest(openUUID, verboseLevel);
}
示例13: getProcessInstance
import org.restlet.data.Form; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Get
public DataResult getProcessInstance(){
if(!validationUser())
return null;
Form queryForm = getQuery();
Set<String> queryNames = queryForm.getNames();
RuntimeService runtimeService = FoxBpmUtil.getProcessEngine().getRuntimeService();
ProcessInstanceQuery processIntanceQuery = runtimeService.createProcessInstanceQuery();
if(queryNames.contains(RestConstants.PARTICIPATE)){
String participate = StringUtil.getString(getQueryParameter(RestConstants.PARTICIPATE, queryForm));
processIntanceQuery.taskParticipants(participate);
}
if(queryNames.contains(RestConstants.INITIATOR)){
String initotor = StringUtil.getString(getQueryParameter(RestConstants.INITIATOR, queryForm));
processIntanceQuery.initiator(initotor);
}
if(queryNames.contains(RestConstants.PROCESS_KEY)){
processIntanceQuery.processDefinitionKey(getQueryParameter(RestConstants.PROCESS_KEY, queryForm));
}
if(queryNames.contains(RestConstants.NAME_LIKE)){
processIntanceQuery.processDefinitionNameLike(parseLikeValue(getQueryParameter(RestConstants.NAME_LIKE, queryForm)));
}
if(queryNames.contains(RestConstants.PROCESSINSTANCE_ID)){
processIntanceQuery.processInstanceId(getQueryParameter(RestConstants.PROCESSINSTANCE_ID, queryForm));
}
if(queryNames.contains(RestConstants.PROCESS_ID)){
processIntanceQuery.processDefinitionId(getQueryParameter(RestConstants.PROCESS_ID, queryForm));
}
if(queryNames.contains(RestConstants.BIZKEY_LIKE)){
processIntanceQuery.processInstanceBusinessKeyLike(parseLikeValue(getQueryParameter(RestConstants.BIZKEY_LIKE, queryForm)));
}
if(queryNames.contains("subjectLike")){
processIntanceQuery.subjectLike(parseLikeValue(getQueryParameter("subjectLike", queryForm)));
}
processIntanceQuery.subjectUnionInitiator();
if(queryNames.contains("ended")){
boolean ended = StringUtil.getBoolean(getQueryParameter("ended", queryForm));
if(ended){
processIntanceQuery.isEnd();
}else{
processIntanceQuery.notEnd();
}
}
if(queryNames.contains("status")){
processIntanceQuery.processInstanceStatus(getQueryParameter("status", queryForm));
}
processIntanceQuery.orderByUpdateTime().desc();
DataResult result = paginateList(processIntanceQuery);
List<Map<String,Object>> mapList = (List<Map<String,Object>>)result.getData();
if(mapList != null && mapList.size()>0){
for(Map<String,Object> tmp : mapList){
String initator = StringUtil.getString(tmp.get("initiator"));
String initatorName = getUserName(initator);
tmp.put("initatorName", initatorName);
String processLocation = StringUtil.getString(tmp.get("processLocation"));
String processLocationString = LocationUtil.parseProcessLocation(processLocation);
tmp.put("processLocationString", processLocationString);
}
}
return result;
}
示例14: paginateList
import org.restlet.data.Form; //导入方法依赖的package包/类
/**
* foxbpm rest接口的分页机制 接收参数: start:起始行数 lenth:每页条数 pageIndex:当前页
* pageSize:每页条数 冲突解决:优先处理pageIndex、pageSize 默认降序排列
*
* @param query
* @param properties
* 支持的排序字段
* @param defaultOrderBy
* 默认排序字段
* @return
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public DataResult paginateList(Query query, Map<String, QueryProperty> properties, String defaultOrderBy) {
Form queryForm = getQuery();
Set<String> queryNames = queryForm.getNames();
if (properties != null) {
String orderby = StringUtil.getString(getQueryParameter(RestConstants.ORDERBY, queryForm));
if (StringUtil.isEmpty(orderby)) {
orderby = defaultOrderBy;
}
QueryProperty orderByProPerty = properties.get(orderby);
if (orderByProPerty == null) {
throw new FoxbpmPluginException("不支持的排序字段:" + orderby,"Rest服务");
}
((AbstractQuery) query).orderBy(orderByProPerty);
String sort = StringUtil.getString(getQueryParameter(RestConstants.SORT, queryForm));
if (StringUtil.isEmpty(sort)) {
sort = "desc";
}
if ("asc".equals(sort)) {
((AbstractQuery) query).asc();
} else {
((AbstractQuery) query).desc();
}
}
if (queryNames.contains(RestConstants.PAGE_START)) {
if (queryNames.contains(RestConstants.PAGE_LENGTH)) {
pageSize = StringUtil.getInt(getQueryParameter(RestConstants.PAGE_LENGTH, queryForm));
}
pageIndex = StringUtil.getInt(getQueryParameter(RestConstants.PAGE_START, queryForm)) / pageSize + 1;
}
if (queryNames.contains(RestConstants.PAGE_INDEX)) {
pageIndex = StringUtil.getInt(getQueryParameter(RestConstants.PAGE_INDEX, queryForm));
}
if (queryNames.contains(RestConstants.PAGE_SIZE)) {
pageSize = StringUtil.getInt(getQueryParameter(RestConstants.PAGE_SIZE, queryForm));
}
List<PersistentObject> resultObjects = null;
if (pageIndex == -1) {
resultObjects = query.list();
} else {
resultObjects = query.listPagination(pageIndex, pageSize);
}
List<Map<String, Object>> dataMap = new ArrayList<Map<String, Object>>();
if (resultObjects != null) {
Iterator<PersistentObject> iterator = resultObjects.iterator();
while (iterator.hasNext()) {
dataMap.add(iterator.next().getPersistentState());
}
}
long resultCount = query.count();
DataResult result = new DataResult();
result.setData(dataMap);
result.setPageIndex(pageIndex);
result.setPageSize(pageSize);
result.setRecordsTotal(resultCount);
result.setRecordsFiltered(resultCount);
return result;
}
示例15: getCalendarRules
import org.restlet.data.Form; //导入方法依赖的package包/类
@Get
public DataResult getCalendarRules(){
Form queryForm = getQuery();
Set<String> queryNames = queryForm.getNames();
String id = StringUtil.getString(getQueryParameter("id", queryForm));
String name = StringUtil.getString(getQueryParameter("name", queryForm));
String idLike = null;
String nameLike = null;
if (StringUtil.isNotEmpty(id)) {
idLike = "%" + id + "%";
}
if (StringUtil.isNotEmpty(name)) {
nameLike = "%" + name + "%";
}
if (queryNames.contains(RestConstants.PAGE_START)) {
if (queryNames.contains(RestConstants.PAGE_LENGTH)) {
pageSize = StringUtil.getInt(getQueryParameter(RestConstants.PAGE_LENGTH, queryForm));
}
pageIndex = StringUtil.getInt(getQueryParameter(RestConstants.PAGE_START, queryForm)) / pageSize + 1;
}
if (queryNames.contains(RestConstants.PAGE_INDEX)) {
pageIndex = StringUtil.getInt(getQueryParameter(RestConstants.PAGE_INDEX, queryForm));
}
if (queryNames.contains(RestConstants.PAGE_SIZE)) {
pageSize = StringUtil.getInt(getQueryParameter(RestConstants.PAGE_SIZE, queryForm));
}
WorkCalendarService workCalendarService = ProcessEngineManagement.getDefaultProcessEngine().getService(WorkCalendarService.class);
DataResult result = new DataResult();
result.setData(workCalendarService.getCalendarRule(pageIndex, pageSize, idLike, nameLike));
result.setPageIndex(pageIndex);
result.setPageSize(pageSize);
result.setRecordsTotal(workCalendarService.getCalendarRuleCount(idLike, nameLike));
result.setRecordsFiltered(workCalendarService.getCalendarRuleCount(idLike, nameLike));
return result;
}