Search in sources :

Example 96 with LinkedList

use of java.util.LinkedList in project jersey by jersey.

the class IntrospectionModeller method doCreateResourceBuilder.

private Resource.Builder doCreateResourceBuilder() {
    if (!disableValidation) {
        checkForNonPublicMethodIssues();
    }
    final Class<?> annotatedResourceClass = ModelHelper.getAnnotatedResourceClass(handlerClass);
    final Path rPathAnnotation = annotatedResourceClass.getAnnotation(Path.class);
    final boolean keepEncodedParams = (null != annotatedResourceClass.getAnnotation(Encoded.class));
    final List<MediaType> defaultConsumedTypes = extractMediaTypes(annotatedResourceClass.getAnnotation(Consumes.class));
    final List<MediaType> defaultProducedTypes = extractMediaTypes(annotatedResourceClass.getAnnotation(Produces.class));
    final Collection<Class<? extends Annotation>> defaultNameBindings = ReflectionHelper.getAnnotationTypes(annotatedResourceClass, NameBinding.class);
    final MethodList methodList = new MethodList(handlerClass);
    final List<Parameter> resourceClassParameters = new LinkedList<>();
    checkResourceClassSetters(methodList, keepEncodedParams, resourceClassParameters);
    checkResourceClassFields(keepEncodedParams, InvocableValidator.isSingleton(handlerClass), resourceClassParameters);
    Resource.Builder resourceBuilder;
    if (null != rPathAnnotation) {
        resourceBuilder = Resource.builder(rPathAnnotation.value());
    } else {
        resourceBuilder = Resource.builder();
    }
    boolean extended = false;
    if (handlerClass.isAnnotationPresent(ExtendedResource.class)) {
        resourceBuilder.extended(true);
        extended = true;
    }
    resourceBuilder.name(handlerClass.getName());
    addResourceMethods(resourceBuilder, methodList, resourceClassParameters, keepEncodedParams, defaultConsumedTypes, defaultProducedTypes, defaultNameBindings, extended);
    addSubResourceMethods(resourceBuilder, methodList, resourceClassParameters, keepEncodedParams, defaultConsumedTypes, defaultProducedTypes, defaultNameBindings, extended);
    addSubResourceLocators(resourceBuilder, methodList, resourceClassParameters, keepEncodedParams, extended);
    if (LOGGER.isLoggable(Level.FINEST)) {
        LOGGER.finest(LocalizationMessages.NEW_AR_CREATED_BY_INTROSPECTION_MODELER(resourceBuilder.toString()));
    }
    return resourceBuilder;
}
Also used : Path(javax.ws.rs.Path) Annotation(java.lang.annotation.Annotation) LinkedList(java.util.LinkedList) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) MediaType(javax.ws.rs.core.MediaType)

Example 97 with LinkedList

use of java.util.LinkedList in project k-9 by k9mail.

the class MessagingController method refreshLocalMessageFlags.

private void refreshLocalMessageFlags(final Account account, final Folder remoteFolder, final LocalFolder localFolder, List<Message> syncFlagMessages, final AtomicInteger progress, final int todo) throws MessagingException {
    final String folder = remoteFolder.getName();
    if (remoteFolder.supportsFetchingFlags()) {
        Timber.d("SYNC: About to sync flags for %d remote messages for folder %s", syncFlagMessages.size(), folder);
        FetchProfile fp = new FetchProfile();
        fp.add(FetchProfile.Item.FLAGS);
        List<Message> undeletedMessages = new LinkedList<>();
        for (Message message : syncFlagMessages) {
            if (!message.isSet(Flag.DELETED)) {
                undeletedMessages.add(message);
            }
        }
        remoteFolder.fetch(undeletedMessages, fp, null);
        for (Message remoteMessage : syncFlagMessages) {
            LocalMessage localMessage = localFolder.getMessage(remoteMessage.getUid());
            boolean messageChanged = syncFlags(localMessage, remoteMessage);
            if (messageChanged) {
                boolean shouldBeNotifiedOf = false;
                if (localMessage.isSet(Flag.DELETED) || isMessageSuppressed(localMessage)) {
                    for (MessagingListener l : getListeners()) {
                        l.synchronizeMailboxRemovedMessage(account, folder, localMessage);
                    }
                } else {
                    if (shouldNotifyForMessage(account, localFolder, localMessage)) {
                        shouldBeNotifiedOf = true;
                    }
                }
                // we're only interested in messages that need removing
                if (!shouldBeNotifiedOf) {
                    MessageReference messageReference = localMessage.makeMessageReference();
                    notificationController.removeNewMailNotification(account, messageReference);
                }
            }
            progress.incrementAndGet();
            for (MessagingListener l : getListeners()) {
                l.synchronizeMailboxProgress(account, folder, progress.get(), todo);
            }
        }
    }
}
Also used : LocalMessage(com.fsck.k9.mailstore.LocalMessage) FetchProfile(com.fsck.k9.mail.FetchProfile) LocalMessage(com.fsck.k9.mailstore.LocalMessage) MimeMessage(com.fsck.k9.mail.internet.MimeMessage) Message(com.fsck.k9.mail.Message) MessageReference(com.fsck.k9.activity.MessageReference) LinkedList(java.util.LinkedList)

Example 98 with LinkedList

use of java.util.LinkedList in project k-9 by k9mail.

the class MessagingController method refreshRemoteSynchronous.

@VisibleForTesting
void refreshRemoteSynchronous(final Account account, final MessagingListener listener) {
    List<LocalFolder> localFolders = null;
    try {
        Store store = account.getRemoteStore();
        List<? extends Folder> remoteFolders = store.getPersonalNamespaces(false);
        LocalStore localStore = account.getLocalStore();
        Set<String> remoteFolderNames = new HashSet<>();
        List<LocalFolder> foldersToCreate = new LinkedList<>();
        localFolders = localStore.getPersonalNamespaces(false);
        Set<String> localFolderNames = new HashSet<>();
        for (Folder localFolder : localFolders) {
            localFolderNames.add(localFolder.getName());
        }
        for (Folder remoteFolder : remoteFolders) {
            if (!localFolderNames.contains(remoteFolder.getName())) {
                LocalFolder localFolder = localStore.getFolder(remoteFolder.getName());
                foldersToCreate.add(localFolder);
            }
            remoteFolderNames.add(remoteFolder.getName());
        }
        localStore.createFolders(foldersToCreate, account.getDisplayCount());
        localFolders = localStore.getPersonalNamespaces(false);
        /*
             * Clear out any folders that are no longer on the remote store.
             */
        for (Folder localFolder : localFolders) {
            String localFolderName = localFolder.getName();
            //        special placeholder folder "-NONE-".
            if (K9.FOLDER_NONE.equals(localFolderName)) {
                localFolder.delete(false);
            }
            if (!account.isSpecialFolder(localFolderName) && !remoteFolderNames.contains(localFolderName)) {
                localFolder.delete(false);
            }
        }
        localFolders = localStore.getPersonalNamespaces(false);
        for (MessagingListener l : getListeners(listener)) {
            l.listFolders(account, localFolders);
        }
        for (MessagingListener l : getListeners(listener)) {
            l.listFoldersFinished(account);
        }
    } catch (Exception e) {
        for (MessagingListener l : getListeners(listener)) {
            l.listFoldersFailed(account, "");
        }
        addErrorMessage(account, null, e);
    } finally {
        if (localFolders != null) {
            for (Folder localFolder : localFolders) {
                closeFolder(localFolder);
            }
        }
    }
}
Also used : LocalFolder(com.fsck.k9.mailstore.LocalFolder) LocalStore(com.fsck.k9.mailstore.LocalStore) Store(com.fsck.k9.mail.Store) Pop3Store(com.fsck.k9.mail.store.pop3.Pop3Store) LocalStore(com.fsck.k9.mailstore.LocalStore) Folder(com.fsck.k9.mail.Folder) LocalFolder(com.fsck.k9.mailstore.LocalFolder) LinkedList(java.util.LinkedList) CertificateValidationException(com.fsck.k9.mail.CertificateValidationException) UnavailableStorageException(com.fsck.k9.mailstore.UnavailableStorageException) IOException(java.io.IOException) MessagingException(com.fsck.k9.mail.MessagingException) AuthenticationFailedException(com.fsck.k9.mail.AuthenticationFailedException) HashSet(java.util.HashSet) VisibleForTesting(android.support.annotation.VisibleForTesting)

Example 99 with LinkedList

use of java.util.LinkedList in project k-9 by k9mail.

the class MessagingController method groupMessagesByAccountAndFolder.

@NonNull
private Map<String, Map<String, List<MessageReference>>> groupMessagesByAccountAndFolder(List<MessageReference> messages) {
    Map<String, Map<String, List<MessageReference>>> accountMap = new HashMap<>();
    for (MessageReference message : messages) {
        if (message == null) {
            continue;
        }
        String accountUuid = message.getAccountUuid();
        String folderName = message.getFolderName();
        Map<String, List<MessageReference>> folderMap = accountMap.get(accountUuid);
        if (folderMap == null) {
            folderMap = new HashMap<>();
            accountMap.put(accountUuid, folderMap);
        }
        List<MessageReference> messageList = folderMap.get(folderName);
        if (messageList == null) {
            messageList = new LinkedList<>();
            folderMap.put(folderName, messageList);
        }
        messageList.add(message);
    }
    return accountMap;
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) MessageReference(com.fsck.k9.activity.MessageReference) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) NonNull(android.support.annotation.NonNull)

Example 100 with LinkedList

use of java.util.LinkedList in project killbill by killbill.

the class UsageInvoiceItemGenerator method extractPerSubscriptionExistingInArrearUsageItems.

private Map<UUID, List<InvoiceItem>> extractPerSubscriptionExistingInArrearUsageItems(final Map<String, Usage> knownUsage, @Nullable final List<Invoice> existingInvoices) {
    if (existingInvoices == null || existingInvoices.isEmpty()) {
        return ImmutableMap.of();
    }
    final Map<UUID, List<InvoiceItem>> result = new HashMap<UUID, List<InvoiceItem>>();
    final Iterable<InvoiceItem> usageInArrearItems = Iterables.concat(Iterables.transform(existingInvoices, new Function<Invoice, Iterable<InvoiceItem>>() {

        @Override
        public Iterable<InvoiceItem> apply(final Invoice input) {
            return Iterables.filter(input.getInvoiceItems(), new Predicate<InvoiceItem>() {

                @Override
                public boolean apply(final InvoiceItem input) {
                    if (input.getInvoiceItemType() == InvoiceItemType.USAGE) {
                        final Usage usage = knownUsage.get(input.getUsageName());
                        return usage.getBillingMode() == BillingMode.IN_ARREAR;
                    }
                    return false;
                }
            });
        }
    }));
    for (final InvoiceItem cur : usageInArrearItems) {
        List<InvoiceItem> perSubscriptionUsageItems = result.get(cur.getSubscriptionId());
        if (perSubscriptionUsageItems == null) {
            perSubscriptionUsageItems = new LinkedList<InvoiceItem>();
            result.put(cur.getSubscriptionId(), perSubscriptionUsageItems);
        }
        perSubscriptionUsageItems.add(cur);
    }
    return result;
}
Also used : Usage(org.killbill.billing.catalog.api.Usage) InvoiceItem(org.killbill.billing.invoice.api.InvoiceItem) Invoice(org.killbill.billing.invoice.api.Invoice) HashMap(java.util.HashMap) Function(com.google.common.base.Function) ImmutableList(com.google.common.collect.ImmutableList) LinkedList(java.util.LinkedList) List(java.util.List) UUID(java.util.UUID)

Aggregations

LinkedList (java.util.LinkedList)10512 Test (org.junit.Test)1487 List (java.util.List)1463 HashMap (java.util.HashMap)1371 ArrayList (java.util.ArrayList)1313 Map (java.util.Map)871 IOException (java.io.IOException)800 File (java.io.File)695 HashSet (java.util.HashSet)605 LinkedHashMap (java.util.LinkedHashMap)382 GenericValue (org.apache.ofbiz.entity.GenericValue)296 Iterator (java.util.Iterator)277 Set (java.util.Set)255 GenericEntityException (org.apache.ofbiz.entity.GenericEntityException)232 Date (java.util.Date)222 Collection (java.util.Collection)201 Delegator (org.apache.ofbiz.entity.Delegator)162 Locale (java.util.Locale)158 URL (java.net.URL)154 BufferedReader (java.io.BufferedReader)146