List of usage examples for org.apache.commons.lang.mutable MutableObject MutableObject
public MutableObject()
null. From source file:com.cognifide.actions.core.internal.ActionEventHandler.java
@Override public boolean process(Event job) { final String path = (String) job.getProperty(SlingConstants.PROPERTY_PATH); Boolean result = true;//from w w w.j ava2 s . com final MutableObject actionNameObject = new MutableObject(); try { executor.execute(new JcrCommand() { @Override public void run(Session session, ResourceResolver resolver) throws Exception { PageManager pm = resolver.adaptTo(PageManager.class); Page page = pm.getPage(path); String actionType = null; if (page != null && page.getContentResource() != null) { actionType = page.getContentResource().getResourceType(); } if (actionType != null) { LOG.debug("Incoming action: " + actionType); Action action = actionRegistry.getAction(actionType); if (action != null) { LOG.debug("Performing action: " + actionType); actionNameObject.setValue(actionType); action.perform(page); LOG.debug("Action " + actionType + " finished"); } else { LOG.info("No action found for: " + actionType); } } } }); } catch (Exception ex) { result = false; LOG.error(ex.getMessage(), ex); } if (actionNameObject.getValue() != null) { LOG.info(String.format("Action %s succeeded", actionNameObject.getValue())); } return result; }
From source file:com.ms.commons.test.assertion.impl.ParameterizedAssertion.java
public void doAssert(String methodName) { if (table == null) { table = database.getTable(0).getName(); }/*from w ww . j ava 2 s .co m*/ Object _instance = (instance instanceof Class<?>) ? null : instance; Class<?> _clazz = (clazz == null) ? ((instance instanceof Class<?>) ? (Class<?>) instance : ((instance == null) ? null : instance.getClass())) : clazz; Method _method = (method == null) ? ReflectUtil.getDeclaredMethod(_clazz, methodName) : method; MemoryTable memoryTable = database.getTable(table); for (MemoryRow memoryRow : memoryTable.getRowList()) { Mutable outParameters = new MutableObject(); Object result = ReflectUtil.invokeMethodByMemoryRow(_instance, _method, memoryRow, outParameters); MemoryField field = memoryRow.getField(0); Object aspect = TypeConvertUtil.convert(_method.getReturnType(), (field.getType() == MemoryFieldType.Null) ? null : field.getValue()); if (!CompareUtil.isObjectEquals(aspect, result)) { throw new AssertException("Call parameterized assertion failed for: " + _clazz + "#" + methodName + " with parameters: " + outParameters.getValue() + " returns: " + result + " but aspects: " + aspect); } } }
From source file:com.ritesh.idea.plugin.state.SettingsPage.java
private void testConnection() { final MutableObject connException = new MutableObject(); if (StringUtils.isEmpty(loginPanel.getUrl()) || StringUtils.isEmpty(loginPanel.getUsername()) || StringUtils.isEmpty(loginPanel.getPassword())) { Messages.showErrorDialog(project, "Connection information provided is invalid.", "Invalid Settings"); return;// www .ja v a2s. co m } TaskUtil.queueTask(project, PluginBundle.message(PluginBundle.CONNECTION_TEST_TITLE), true, new ThrowableFunction<ProgressIndicator, Void>() { @Override public Void throwableCall(ProgressIndicator params) throws Exception { try { params.setIndeterminate(true); ReviewDataProvider.getInstance(project).testConnection(loginPanel.getUrl(), loginPanel.getUsername(), loginPanel.getPassword()); // The task was not cancelled and is successful connException.setValue(Boolean.TRUE); } catch (InvalidConfigurationException a) { } catch (final Exception exception) { connException.setValue(exception); } return null; } }, null, null); if (connException.getValue() == Boolean.TRUE) { Messages.showInfoMessage(project, PluginBundle.message(PluginBundle.LOGIN_SUCCESS_MESSAGE), PluginBundle.message(PluginBundle.CONNECTION_STATUS_TITLE)); } else if (connException.getValue() instanceof Exception) { final ExceptionHandler.Message message = ExceptionHandler .getMessage((Exception) connException.getValue()); Messages.showErrorDialog(message.message, PluginBundle.message(PluginBundle.CONNECTION_STATUS_TITLE)); } }
From source file:mitm.application.djigzo.james.mailets.SenderDKIMSign.java
@Override public PrivateKey getPrivateKey(Mail mail) throws MessagingException { InternetAddress originator = messageOriginatorIdentifier.getOriginator(mail); final MutableObject pemKeyPairHolder = new MutableObject(); MailAddressHandler.HandleUserEventHandler eventHandler = new MailAddressHandler.HandleUserEventHandler() { @Override/*from ww w .j av a2 s . c o m*/ public void handleUser(User user) throws MessagingException { onHandleUserEvent(user, pemKeyPairHolder); } }; MailAddressHandler mailAddressHandler = new MailAddressHandler(sessionManager, userWorkflow, actionExecutor, eventHandler, ACTION_RETRIES); mailAddressHandler.handleMailAddresses(MailAddressUtils.fromAddressArrayToMailAddressList(originator)); return parseKey((String) pemKeyPairHolder.getValue()); }
From source file:mitm.application.djigzo.james.mailets.SenderDKIMVerify.java
@Override public PublicKey getPublicKey(Mail mail) throws MessagingException { InternetAddress originator = messageOriginatorIdentifier.getOriginator(mail); final MutableObject pemKeyPairHolder = new MutableObject(); MailAddressHandler.HandleUserEventHandler eventHandler = new MailAddressHandler.HandleUserEventHandler() { @Override//www . jav a 2 s . c o m public void handleUser(User user) throws MessagingException { onHandleUserEvent(user, pemKeyPairHolder); } }; MailAddressHandler mailAddressHandler = new MailAddressHandler(sessionManager, userWorkflow, actionExecutor, eventHandler, ACTION_RETRIES); mailAddressHandler.handleMailAddresses(MailAddressUtils.fromAddressArrayToMailAddressList(originator)); return parseKey((String) pemKeyPairHolder.getValue()); }
From source file:mitm.application.djigzo.james.mailets.BlackberrySMIMEAdapter.java
private Part findAttachment(MimeMessage containerMessage) throws MessagingException, IOException, PartException { final MutableObject smimePart = new MutableObject(); final MutableObject octetPart = new MutableObject(); PartListener partListener = new PartScanner.PartListener() { @Override//from w ww. j ava 2 s . c o m public boolean onPart(Part parent, Part part, Object context) throws PartException { try { if (ArrayUtils.contains(part.getHeader(DjigzoHeader.MARKER), DjigzoHeader.ATTACHMENT_MARKER_VALUE)) { smimePart.setValue(part); /* * we found the part with the marker so we can stop scanning */ return false; } /* * Fallback scanning for octet-stream in case the template does not contain a DjigzoHeader.MARKER */ if (part.isMimeType("application/octet-stream")) { octetPart.setValue(part); } return true; } catch (MessagingException e) { throw new PartException(e); } } }; PartScanner partScanner = new PartScanner(partListener, MAX_DEPTH); partScanner.scanPart(containerMessage); Part result = (Part) smimePart.getValue(); if (result == null) { result = (Part) octetPart.getValue(); if (result != null) { logger.debug("Marker not found. Using octet-stream instead."); } else { throw new MessagingException("Unable to find the attachment part in the template."); } } return result; }
From source file:com.ms.commons.test.tool.ExportDatabaseData.java
private static MemoryTable querySqlToMemoryTable(JdbcTemplate jdbcTemplate, String sql, Map<String, Integer> tableMap) { System.out.println("Executing: " + sql); List<MemoryRow> rowList = new ArrayList<MemoryRow>(); MutableObject refTableName = new MutableObject(); MemoryTable mt = new MemoryTable(getSqlTableName(sql, tableMap, refTableName)); @SuppressWarnings("unchecked") List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql); for (Map<String, Object> result : resultList) { List<MemoryField> fieldList = new ArrayList<MemoryField>(); for (String field : result.keySet()) { fieldList.add(new MemoryField(field, MemoryFieldType.Unknow, translate(refTableName, field, result.get(field)))); }// ww w . jav a 2 s .c om rowList.add(new MemoryRow(fieldList)); } mt.setRowList(rowList); return mt; }
From source file:mitm.djigzo.web.components.QuarantineManager.java
public Link getViewMIMELink() { final MutableObject mutableLink = new MutableObject(); ComponentEventCallback<Link> callback = new ComponentEventCallback<Link>() { @Override/*from www. ja v a2 s.co m*/ public boolean handleResult(Link link) { mutableLink.setValue(link); return true; } }; resources.triggerEvent(VIEW_MIME_CLICKED_EVENT, new Object[] { mailRepositoryItem.getId() }, callback); return (Link) mutableLink.getValue(); }
From source file:fr.inria.eventcloud.pubsub.PublishSubscribeUtils.java
/** * Rewrites the specified {@code subscription} (written by using a SPARQL * Select query) to a new one where all the result vars have been removed * except for the graph variable.//from ww w . j ava 2s .c o m * * @param subscription * the subscription to rewrite. * * @return new subscription where all the result vars have been removed * except for the graph variable. */ public static final String removeResultVarsExceptGraphVar(String subscription) { Query query = QueryFactory.create(subscription); final MutableObject graphNode = new MutableObject(); ElementWalker.walk(query.getQueryPattern(), new ElementVisitorBase() { @Override public void visit(ElementNamedGraph el) { if (!el.getGraphNameNode().isVariable()) { throw new IllegalArgumentException( "The specified subscription does not have a graph variable: " + el.getGraphNameNode()); } graphNode.setValue(el.getGraphNameNode()); } }); Op op = Transformer.transform(new TransformBase() { @Override public Op transform(OpProject opProject, Op subOp) { return new OpProject(subOp, Lists.newArrayList((Var) graphNode.getValue())); } }, Algebra.compile(query)); return OpAsQuery.asQuery(op).toString(); }
From source file:mitm.application.djigzo.james.mailets.Relay.java
private void handleMessageAction(Session session, Mail sourceMail, MimeMessage relayMessage) throws DatabaseException { final MutableObject userInfoContainer = new MutableObject(); RelayUserInfoProvider infoProvider = new RelayUserInfoProvider() { @Override//from ww w . j ava2s . co m public RelayUserInfo getRelayUserInfo(MimeMessage message) throws MessagingException, RelayException { RelayUserInfo userInfo = null; InternetAddress originator = messageOriginatorIdentifier.getOriginator(message); if (originator != null) { String userEmail = originator.getAddress(); logger.debug("Getting relay info for " + userEmail); userEmail = EmailAddressUtils.canonicalizeAndValidate(userEmail, false); try { User user = userWorkflow.getUser(userEmail, UserWorkflow.GetUserMode.CREATE_IF_NOT_EXIST); userInfo = createRelayUserInfo(user); /* * Save the userInfo because we need it later on */ userInfoContainer.setValue(userInfo); } catch (HierarchicalPropertiesException e) { throw new RelayException(e); } } return userInfo; } }; RelayHandler handler = new RelayHandler(pKISecurityServices, infoProvider); if (preventReplay) { handler.setAdditionalRelayValidator(relayValidator); } try { MimeMessage messageToRelay = handler.handleRelayMessage(relayMessage); if (messageToRelay != null) { sendRelayMessage(sourceMail, messageToRelay, handler.getRecipients()); /* * ghost the source mail if not passThrough */ if (!passThrough) { sourceMail.setState(Mail.GHOST); } } } catch (RelayException e) { handleBlackBerryRelayException(e, (RelayUserInfo) userInfoContainer.getValue(), sourceMail); } catch (MessagingException e) { throw new DatabaseException(e); } catch (IOException e) { throw new DatabaseException(e); } }