private void copyToRollerEntry()

in app/src/main/java/org/apache/roller/weblogger/webservices/atomprotocol/EntryCollection.java [390:461]


    private void copyToRollerEntry(Entry entry, WeblogEntry rollerEntry) throws WebloggerException {
        
        Timestamp current = new Timestamp(System.currentTimeMillis());
        Timestamp pubTime = current;
        Timestamp updateTime = current;
        if (entry.getPublished() != null) {
            pubTime = new Timestamp( entry.getPublished().getTime() );
        }
        if (entry.getUpdated() != null) {
            updateTime = new Timestamp( entry.getUpdated().getTime() );
        }
        rollerEntry.setTitle(entry.getTitle());
        if (entry.getContents() != null && !entry.getContents().isEmpty()) {
            Content content = entry.getContents().get(0);
            rollerEntry.setText(content.getValue());
        }
        if (entry.getSummary() != null) {
            rollerEntry.setSummary(entry.getSummary().getValue());
        }
        rollerEntry.setPubTime(pubTime);
        rollerEntry.setUpdateTime(updateTime);
        
        AppModule control =
                (AppModule)entry.getModule(AppModule.URI);
        if (control!=null && control.getDraft()) {
            rollerEntry.setStatus(PubStatus.DRAFT);
        } else {
            rollerEntry.setStatus(PubStatus.PUBLISHED);
        }
                
        // Process incoming categories:
        // Atom categories with weblog-level scheme are Weblogger categories.
        // Atom supports multiple cats, but Weblogger supports one/entry
        // so here we take accept the first category that exists.
        List<Category> categories = entry.getCategories();
        if (categories != null && !categories.isEmpty()) {
            for (Category cat : categories) {
                if (cat.getScheme() != null && cat.getScheme().equals(
                        RollerAtomService.getWeblogCategoryScheme(rollerEntry.getWebsite()))) {
                    String catString = cat.getTerm();
                    if (catString != null) {
                        WeblogCategory rollerCat =
                                roller.getWeblogEntryManager().getWeblogCategoryByName(
                                rollerEntry.getWebsite(), catString);
                        if (rollerCat != null) {
                            // Found a valid category, so break out
                            rollerEntry.setCategory(rollerCat);
                            break;
                        }
                    }
                }
            }
        }
        if (rollerEntry.getCategory() == null) {
            // Didn't find a category? Fall back to the default Blogger API category.
            rollerEntry.setCategory(rollerEntry.getWebsite().getBloggerCategory());
        }
        
        // Now process incoming categories that are tags:
        // Atom categories with no scheme are considered tags.
        String tags = "";
        StringBuilder buff = new StringBuilder();
        if (categories != null && !categories.isEmpty()) {
            for (Category cat : categories) {
                if (cat.getScheme() == null) {
                    buff.append(" ").append(cat.getTerm());
                }                
            }
            tags = buff.toString();
        }
        rollerEntry.setTagsAsString(tags);        
    }