while (i < 10000 && it.hasNext()) {
@Override protected void processContentFile(String addr, InputStream is, Set<String> tags, boolean closeStream) throws Exception { String ext = contentPathToExtension(addr); String mime = MimeTypeHelper.getTypeForExtension(ext); if (mime == null) { mime = MimeTypeHelper.MIME_UNKNOWN; } String uri = contentPathToArchiveUri(addr); // Object already exists and we don't want to overwrite it if ((overwriteMode == OverwriteMode.NEVER) && (archiveFacade2.queryObjects(uri, false).hasNext())) { return; } archiveTransaction.storeData(uri, mime, is, tags.toArray(new String[tags.size()]), closeStream); archiveObjectsInTransaction++; flushIfNecessary(); }
private void retrieveNext() { while (metaIterator.hasNext()) { CatalogObjectMeta meta = metaIterator.next(); if (meta.getStatus().isDeleted()) continue; try { CatalogObjectPart<String> bwmetaPart = catalogFacade.getPart(meta.getId(), CatalogParamConstants.TYPE_BWMETA1, null); nextObject = bwmetaPart.getData(); } catch (CatalogException e) { throw new RuntimeException("CatalogException while retrieving next bwmeta from catalog", e); } return; } nextObject = null; }
public List<DocId> matchIds(final DocMetadata template) throws ServiceException { List<DocId> ids = template.getIds(); if (ids == null) { ids = Collections.emptyList(); } if (ids.isEmpty()) { return Collections.emptyList(); } final Set<DocId> hits = new HashSet<DocId>(); final BooleanCriterion criterion = new BooleanCriterion(); criterion.setOperator(SearchOperator.OR); for (final DocId id : ids) { criterion.addCriterion( new FieldCriterion(MetadataIndexConstants.F_IDENTIFIER, MetadataIndex.idToString(id)), SearchOperator.OR); } final SearchQuery query = new SearchQuery(); query.addCriterion(criterion); final CountingIterator<SearchResult> ci = searchFacade.query(indexName, query); while (ci.hasNext()) { final SearchResult result = ci.next(); hits.add(new DocId(MetadataIndexConstants.D_EXTID, result.getDocId())); } return new ArrayList<DocId>(hits); }
public void matchMetadata() throws MetadataIndexException { try { final CountingIterator<CatalogObjectMeta> ci = catalogFacade.iterateObjects(null, null, null, new String[] { MetadataIndexConstants.C_IMPORTED }, false); while (ci.hasNext()) { final CatalogObjectMeta meta = ci.next(); final String extId = meta.getId().getId(); matchMetadata(meta, extId); } } catch (final CatalogException e) { throw new MetadataIndexException(e); } }
public void importMetadata() throws MetadataIndexException { try { final CountingIterator<CatalogObjectMeta> ci = catalogFacade.iterateObjects(null, null, null, null, false); while (ci.hasNext()) { final CatalogObjectMeta meta = ci.next(); final String extId = meta.getId().getId(); importMetadata(meta, extId); } } catch (final CatalogException e) { throw new MetadataIndexException(e); } }
public void cleanMetadata() throws MetadataIndexException { try { final CountingIterator<CatalogObjectMeta> ci = catalogFacade.iterateObjects(null, null, null, null, false); while (ci.hasNext()) { final CatalogObjectMeta meta = ci.next(); final String extId = meta.getId().getId(); cleanMetadata(meta, extId); } } catch (final CatalogException e) { throw new MetadataIndexException(e); } }
@Override public void matchInternal(final Date from, final Date until, String[] tags) throws MetadataIndexException { try { if (tags == null) { tags = new String[] {}; } final CountingIterator<CatalogObjectMeta> ci = catalogFacade.iterateObjects( new String[] { MetadataIndexConstants.T_REFMETA }, from, until, tags, false); while (ci.hasNext()) { final CatalogObjectMeta meta = ci.next(); final String extId = meta.getId().getId(); matchMetadata(meta, extId); } } catch (final CatalogException e) { throw new MetadataIndexException(e); } }
public void init() { try { //fetch all CountingIterator<CatalogObjectMeta> i = catalog.iterateObjects(new String[]{partType}, null, null, null, false); while (i.hasNext()) { String id = i.next().getId().getId(); NamedObject no = loadObject(idMapper.getName(id), idMapper.getType(id)); addRelations(no); } } catch (CatalogException ex) { log.error( "Failed to read/process some objects during initialization.", ex); } }
private boolean checkNextElement(){ if (next!=null) return true; if (lastCheck) { while (iterator.hasNext() && next==null) { catToS.logTick(); CatalogObjectMeta meta = iterator.next(); try { CatalogObject<String> object = catalogFacade.getObject(meta.getId()); CatalogObjectPart<String> part = object.getPart(catToS.getPartType()); if (part != null) { next = part.getData(); } } catch (CatalogException e) { log.warn("Cannot process " + meta.getId()); } } } lastCheck=(next!=null); return(next!=null); }
/** * Searches for documents with the given ids and returns the main ids of the * found documents. * * @param ids ids of documents to look for. * @return the main ids of the found documents. * @throws ServiceException */ private Set<DocId> checkExisting(final Collection<DocId> ids) throws ServiceException { if (ids == null) { return Collections.emptySet(); } final Set<DocId> hits = new HashSet<DocId>(); final BooleanCriterion criterion = new BooleanCriterion(); criterion.setOperator(SearchOperator.OR); for (final DocId id : ids) { criterion.addCriterion(new FieldCriterion(MetadataIndexConstants.F_IDENTIFIER, idToString(id)), SearchOperator.OR); } final SearchQuery query = new SearchQuery(); query.addCriterion(criterion); final CountingIterator<SearchResult> ci = searchFacade.query(indexName, query); while (ci.hasNext()) { final SearchResult result = ci.next(); hits.add(new DocId(MetadataIndexConstants.D_EXTID, result.getDocId())); } return hits; }
while (objects.hasNext()) { try {
@Override public int delete(String tag) throws MetadataIndexException { try { tag = MetadataIndexConstants.C_DATA_PREFIX + sanitizeTag(tag); final CountingIterator<CatalogObjectMeta> iterator = catalogFacade.iterateObjects( new String[] { MetadataIndexConstants.T_REFMETA }, null, null, new String[] { tag }, false); final ISessionFacade<IndexDocument> session = indexFacade.connect(indexName); int count = 0; while (iterator.hasNext()) { final YaddaObjectID yid = iterator.next().getId(); final DocId id = new DocId(MetadataIndexConstants.D_EXTID, yid.getId()); final Set<DocId> toRemove = checkExisting(Arrays.asList(new DocId[] { id })); for (final DocId docId : toRemove) { count += delete(session, docId, true); } } session.commit(); return count; } catch (final ServiceException e) { throw new MetadataIndexException(e); } }
archiveFacade.queryObjects(uri, true); if (metasIt!=null) { while (metasIt.hasNext()) { ArchiveObject2Meta meta = metasIt.next(); Set<String> sourceLicenses = LicenseProcessorModuleHelper.extractLicenses(
while (it.hasNext() && (!Thread.interrupted())) { target.process(it.next());
query.addCriterion(criterion); final CountingIterator<SearchResult> ci = searchFacade.query(indexName, query, format); while (ci.hasNext()) { final SearchResult result = ci.next();
query.addCriterion(criterion); final CountingIterator<SearchResult> ci = searchFacade.query(indexName, query, format); while (ci.hasNext()) { final SearchResult result = ci.next();