List of usage examples for org.apache.commons.lang3 EnumUtils getEnum
public static <E extends Enum<E>> E getEnum(final Class<E> enumClass, final String enumName)
Gets the enum for the class, returning null if not found.
This method differs from Enum#valueOf in that it does not throw an exception for an invalid enum name.
From source file:com.netflix.metacat.server.jersey.MetacatRestFilter.java
@Override public void filter(final ContainerRequestContext requestContext) throws IOException { String userName = requestContext.getHeaderString(MetacatRequestContext.HEADER_KEY_USER_NAME); if (userName == null) { userName = "metacat"; }//ww w .j ava2 s .c om final String clientAppName = requestContext .getHeaderString(MetacatRequestContext.HEADER_KEY_CLIENT_APP_NAME); final String clientHost = requestContext.getHeaderString("X-Forwarded-For"); final String jobId = requestContext.getHeaderString(MetacatRequestContext.HEADER_KEY_JOB_ID); final MetacatRequestContext.DataTypeContext dataTypeContext = EnumUtils.getEnum( MetacatRequestContext.DataTypeContext.class, requestContext.getHeaderString(MetacatRequestContext.HEADER_KEY_DATA_TYPE_CONTEXT)); final MetacatRequestContext context = new MetacatRequestContext(userName, clientAppName, clientHost, jobId, dataTypeContext); MetacatContextManager.setContext(context); log.info(context.toString()); }
From source file:eu.europa.ec.fisheries.uvms.rules.service.bean.ExchangeRuleServiceBean.java
@Override public boolean identificationRefExists(String refGuid, String... typeRefType) { Boolean faQueryIdentificationExists = false; try {//from w w w . jav a 2 s . c o m LogRefIdByTypeExistsRequest existsRequest = new LogRefIdByTypeExistsRequest(); for (String refType : typeRefType) { existsRequest.getRefTypes().add(EnumUtils.getEnum(TypeRefType.class, refType)); } existsRequest.getRefTypes().removeAll(Collections.singleton(null)); existsRequest.setRefGuid(refGuid); existsRequest.setMethod(ExchangeModuleMethod.LOG_REF_ID_BY_TYPE_EXISTS); String jaxBObjectToString = marshallJaxBObjectToString(existsRequest); String jmsMessageID = producer.sendDataSourceMessage(jaxBObjectToString, EXCHANGE); TextMessage message = consumer.getMessage(jmsMessageID, TextMessage.class); String text = message.getText(); LogRefIdByTypeExistsResponse response = unMarshallMessage(text, LogRefIdByTypeExistsResponse.class); faQueryIdentificationExists = response.getRefGuid() != null; } catch (JAXBException | MessageException | JMSException e) { log.error(e.getMessage(), e); } return faQueryIdentificationExists; }
From source file:com.adobe.acs.commons.workflow.bulk.execution.model.Payload.java
public Status getStatus() { return EnumUtils.getEnum(Status.class, status); }
From source file:eu.europa.ec.fisheries.uvms.rules.service.bean.MDRCacheServiceBean.java
/** * Check if value passed is present in the MDR list speified * * @param listName - MDR list name to be ckecked against * @param codeValue - This value will be checked in MDR list * @return True-> if value is present in MDR list False-> if value is not present in MDR list *//* w w w . j av a2s . c o m*/ public boolean isPresentInMDRList(String listName, String codeValue) { MDRAcronymType mdrAcronymType = EnumUtils.getEnum(MDRAcronymType.class, listName); if (mdrAcronymType == null) { return false; } List<String> values = getValues(mdrAcronymType); return CollectionUtils.isNotEmpty(values) && values.contains(codeValue); }
From source file:eu.europa.ec.fisheries.uvms.rules.service.bean.ExchangeRuleServiceBean.java
@Override public boolean identificationExists(String messageGuid, String typeRefType) { Boolean messageGuidIdentificationExists = false; try {/* w w w .jav a 2 s . c o m*/ LogIdByTypeExistsRequest existsRequest = new LogIdByTypeExistsRequest(); existsRequest.setRefType(EnumUtils.getEnum(TypeRefType.class, typeRefType)); existsRequest.setMessageGuid(messageGuid); existsRequest.setMethod(ExchangeModuleMethod.LOG_ID_BY_TYPE_EXISTS); String jaxBObjectToString = marshallJaxBObjectToString(existsRequest); String jmsMessageID = producer.sendDataSourceMessage(jaxBObjectToString, EXCHANGE); TextMessage message = consumer.getMessage(jmsMessageID, TextMessage.class); String text = message.getText(); LogIdByTypeExistsResponse response = unMarshallMessage(text, LogIdByTypeExistsResponse.class); messageGuidIdentificationExists = response.getMessageGuid() != null; } catch (JAXBException | MessageException | JMSException e) { log.error(e.getMessage(), e); } return messageGuidIdentificationExists; }
From source file:mobile.service.MessageService.java
/** * ???Page//from ww w . java 2 s . c o m * * @param pageIndex ?1 * @param pageSize ? * @param autoRead ???????? * @param msgTypeList ??nullempty??{@literal ext.msg.model.Message.MsgType} * @param unReadFirst ??? * @return */ public static MobilePage<SystemMessageItem> getSystemMessagePage(Integer pageIndex, Integer pageSize, Boolean autoRead, List<String> msgTypeList, boolean unReadFirst) { Set<MsgType> msgTypeSet = new HashSet<>(); if (!CollectionUtils.isEmpty(msgTypeList)) { for (String msgTypeStr : msgTypeList) { MsgType msgType = EnumUtils.getEnum(MsgType.class, msgTypeStr); if (msgType != null) { msgTypeSet.add(msgType); } } } User user = User.getFromSession(Context.current().session()); Page<Message> pageMsg = Message.queryMessageByRead(pageIndex - 1, pageSize, String.valueOf(user.id), msgTypeSet, unReadFirst); List<SystemMessageItem> sysMsgList = SystemMessageItem.createList(pageMsg.getList()); List<Long> systemMsgIdList = new ArrayList<>(); for (Message message : pageMsg.getList()) { systemMsgIdList.add(message.id); } if (autoRead) { Message.markReaded(String.valueOf(user.id), systemMsgIdList); } return new MobilePage<>(pageMsg.getTotalRowCount(), sysMsgList); }
From source file:eu.europa.ec.fisheries.uvms.exchange.service.bean.ExchangeToRulesSyncMsgBean.java
private LogValidationResult mapToLogValidationResult(ValidationMessageType validMsgFromRules) { LogValidationResult logResult = new LogValidationResult(); logResult.setId(validMsgFromRules.getBrId()); try {/* www.j av a 2 s . co m*/ logResult.setLevel(RuleValidationLevel.fromValue(validMsgFromRules.getLevel())); } catch (IllegalArgumentException ex) { log.error("[ERROR] The validation level " + validMsgFromRules.getLevel() + " doesn't exist in RuleValidationLevel class.."); } logResult.setStatus( EnumUtils.getEnum(RuleValidationStatus.class, validMsgFromRules.getErrorType().toString())); logResult.setXpaths(StringUtils.join(validMsgFromRules.getXpaths(), ',')); return logResult; }
From source file:eu.europa.ec.fisheries.uvms.rules.service.bean.MDRCacheServiceBean.java
/** * This function checks that all the CodeType values passed to the function exist in MDR code list defined by its listId * * @param valuesToMatch - CodeType list--Values from each instance will be checked agaist ListName * @return true -> if all values are found in MDR list specified. false -> if even one value is not matching with MDR list *//*from w w w. j av a 2 s . com*/ public boolean isCodeTypePresentInMDRList(List<CodeType> valuesToMatch) { if (CollectionUtils.isEmpty(valuesToMatch)) { return false; } for (CodeType codeType : valuesToMatch) { if (codeType == null || codeType.getValue() == null || codeType.getListId() == null) { return false; } MDRAcronymType anEnum = EnumUtils.getEnum(MDRAcronymType.class, codeType.getListId()); if (anEnum == null) { return false; } List<String> codeListValues = getValues(anEnum); if (!codeListValues.contains(codeType.getValue())) { return false; } } return true; }
From source file:com.adobe.acs.commons.workflow.bulk.execution.model.Payload.java
public void updateWith(Workflow workflow) throws PersistenceException { if (StringUtils.isBlank(getWorkflowInstanceId())) { workflowInstanceId = workflow.getId(); properties.put(PN_WORKFLOW_INSTANCE_ID, dereference(workflowInstanceId)); } else if (!StringUtils.equals(getWorkflowInstanceId(), workflow.getId())) { throw new PersistenceException("Batch Entry workflow instance does not match. [ " + workflowInstanceId + " ] vs [ " + workflow.getId() + " ]"); }// www . j a va2 s .c om if (!StringUtils.equals(status, workflow.getState())) { // Status is different, so update setStatus(EnumUtils.getEnum(Status.class, workflow.getState())); } }
From source file:com.norconex.collector.core.spoil.impl.GenericSpoiledReferenceStrategizer.java
private SpoiledReferenceStrategy toStrategy(String strategy) { return EnumUtils.getEnum(SpoiledReferenceStrategy.class, StringUtils.upperCase(strategy)); }