List of usage examples for org.apache.commons.lang.mutable MutableObject getValue
public Object getValue()
From source file:com.ms.commons.test.tool.ExportDatabaseData.java
private static Object translate(MutableObject refTableName, String field, Object object) { if ((refTableName == null) || (refTableName.getValue() == null)) { return object; }/* ww w . ja v a 2 s .c o m*/ if (object == null) { return object; } String tb = refTableName.getValue().toString().toLowerCase().trim(); String fi = field.toLowerCase().trim(); { TableFields tf = encodeMapping.getGbkMap().get(tb); if ((tf != null) && (tf.getFields().contains(fi))) { return new UnCnStringTypeConverter().convert(object.toString()); } } { TableFields tf = encodeMapping.getUtf8Map().get(tb); if ((tf != null) && (tf.getFields().contains(fi))) { return new UnUTF8StringTypeConverter().convert(object.toString()); } } return object; }
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 w w w . j a v 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.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/*from w ww . ja va 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: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 a v a 2s. c om*/ * * @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.djigzo.web.components.QuarantineManager.java
public Link getViewMIMELink() { final MutableObject mutableLink = new MutableObject(); ComponentEventCallback<Link> callback = new ComponentEventCallback<Link>() { @Override/* ww w . j a va2 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: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 a v a2 s.c o m 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.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 . j a v a2 s. 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.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 w w. j a va2s . co 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 String getSqlTableName(String sql, final Map<String, Integer> tableMap, final MutableObject refTableName) { CCJSqlParserManager sqlPaerserManager = new CCJSqlParserManager(); try {//w w w. j ava 2 s.co m Statement statement = sqlPaerserManager.parse(new StringReader(sql)); final MutableObject refTable = new MutableObject(null); statement.accept(new StatementVisitor() { public void visit(CreateTable createTable) { throw new MessageException("Cannot parser sql for: " + createTable.getClass().getSimpleName()); } public void visit(Truncate truncate) { throw new MessageException("Cannot parser sql for: " + truncate.getClass().getSimpleName()); } public void visit(Drop drop) { throw new MessageException("Cannot parser sql for: " + drop.getClass().getSimpleName()); } public void visit(Replace replace) { throw new MessageException("Cannot parser sql for: " + replace.getClass().getSimpleName()); } public void visit(Insert insert) { throw new MessageException("Cannot parser sql for: " + insert.getClass().getSimpleName()); } public void visit(Update update) { throw new MessageException("Cannot parser sql for: " + update.getClass().getSimpleName()); } public void visit(Delete delete) { throw new MessageException("Cannot parser sql for: " + delete.getClass().getSimpleName()); } public void visit(Select select) { select.getSelectBody().accept(new SelectVisitor() { public void visit(Union union) { refTable.setValue("table_" + GLOBAL_COUNT.getAndIncrement()); } public void visit(PlainSelect plainSelect) { plainSelect.getFromItem().accept(new FromItemVisitor() { public void visit(SubJoin subjoin) { refTable.setValue("table_" + GLOBAL_COUNT.getAndIncrement()); } public void visit(SubSelect subSelect) { refTable.setValue("table_" + GLOBAL_COUNT.getAndIncrement()); } public void visit(Table tableName) { String tn = tableName.getName().trim().toLowerCase(); refTableName.setValue(tn); Integer tnCount = tableMap.get(tn); if (tnCount == null) { tableMap.put(tn, Integer.valueOf(1)); refTable.setValue(tn); } else { tnCount = Integer.valueOf(tnCount.intValue() + 1); tableMap.put(tn, tnCount); refTable.setValue(tn + "_" + tnCount.intValue()); } } }); } }); } }); if (refTable.getValue() == null) { throw new MessageException("Canot parser sql and get table name."); } return (String) refTable.getValue(); } catch (Exception e) { throw ExceptionUtil.wrapToRuntimeException(e); } }
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 w ww. j ava 2s. c o 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); } }