public String extract(CatalogObjectPart<String> part) { try { String nList = (String)xpath.evaluate("/aal:user/aal:login/text()", new InputSource(new StringReader(part.getData())), XPathConstants.STRING); return nList; } catch (XPathExpressionException e) { log.error("Error processing user data!",e); } return null; }
public static void storeYElements(File fout, List<YElement> lye) throws FileNotFoundException, UnsupportedEncodingException, TransformationException, IOException { FileOutputStream fos = new FileOutputStream(fout); OutputStreamWriter out = new OutputStreamWriter(fos, "UTF-8"); for (CatalogObject<String> co : o3.process(lye, null)) { for (CatalogObjectPart<String> cop : co.getParts()) { out.write(cop.getData()); out.flush(); } } out.close(); fos.close(); }
private static void createOutputFile(NlmYToCatObjProcessingNode y2catObj, File oF, List<YElement> yel) throws TransformationException, UnsupportedEncodingException, FileNotFoundException, IOException { Collection<CatalogObject<String>> cos; cos = y2catObj.process(yel, null); int j = 0; for(CatalogObject<String> co : cos){ j++; if(j%6!=0) continue; OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(oF+"_"+(j/6-1)+".xml"),"UTF-8"); for(CatalogObjectPart<String> cop : co.getParts()){ out.write(cop.getData()); out.flush(); } out.close(); } }
@Override protected void savePart(long fk, CatalogObjectPart<String> part) { jdbc.update( "INSERT INTO "+tablePrefix+PARTS_TABLE_NAME+ '('+PART_FK+','+PART_TYPE+','+PART_DATA+','+PART_STAMP+") VALUES (?,?,?,?)", fk, part.getType(), part.getData(), new Date() ); }
@Override public EnrichedPayload<YElement>[] process(CatalogObject<String> input, ProcessContext ctx) { for (CatalogObjectPart<String> part : input.getParts()) { if (part.getType().equals(CatalogParamConstants.TYPE_BWMETA2)) { log.info("data: \n {}", part.getData()); } } return super.process(input, ctx); } }
@Override public String next() { try { if (elementBuffer.isEmpty()) { List<YaddaObjectID> nextIds = new LinkedList<YaddaObjectID>(); while (nextIds.size() < bufferSize && hasNextId()) { nextIds.add(nextId()); } Iterator<CatalogObject<String>> objectIterator = catalogFacade.iterateParts(nextIds, CatalogParamConstants.TYPE_BWMETA1, null); while (objectIterator.hasNext()) { elementBuffer.offer(objectIterator.next().getPart(CatalogParamConstants.TYPE_BWMETA1).getData()); } } if (elementBuffer.isEmpty()) throw new IllegalStateException(); return elementBuffer.poll(); } catch (CatalogException e) { throw new RuntimeException(e); } }
public void showElementPart(String id, String partType) { try { CatalogObjectPart<String> part = catalogFacade.getPart(new YaddaObjectID(id), partType, null); if (part == null) { os.println("Part doesn't exist"); } else { os.println(part.getData()); } } catch (CatalogException e) { e.printStackTrace(os); } }
@Override public BatchResult batch(final Collection<EditorOperation> operations, final EXECUTION_MODE mode) throws EditorException { for (final EditorOperation oper:operations) { if (oper instanceof SaveOperation) { final SaveOperation<String> op=(SaveOperation<String>) oper; for (final CatalogObjectPart<String> pa:op.getObject().getParts()){ if (pa.getType().equalsIgnoreCase(partType)) { try { queue.put(pa.getData()); } catch (final InterruptedException ex) { LoggerFactory.getLogger(FakeFacadesBeingIterator.class).error("Exception caught", ex); } } } } } return new BatchResult(null, new ArrayList<CatalogObjectMeta>()); }
/** * Updates a data part with a specified foreign key and a specific type. * * @param fk the foreign key (metadata pk) for the part * @param part the part to update */ protected void updatePart(long fk, CatalogObjectPart<String> part) throws DataAccessException { Map<String, Object> extra = extraFieldsForPartUpdate(part); String query = "UPDATE "+tablePrefix+PARTS_TABLE_NAME+" SET "+PART_DATA+"=?"; Object[] params = new Object[3+extra.size()]; params[0] = part.getData(); int n = 1; for (Entry<String, Object> e : extra.entrySet()) { query += ","+e.getKey()+"=?"; params[n] = e.getValue(); n+=1; } String where = " WHERE "+PART_FK+"=? AND "+PART_TYPE+"=?"; params[params.length-2] = fk; params[params.length-1] = part.getType(); jdbc.update(query+where, params); }
protected Date fetchDirtyObject() throws Exception { CatalogObject<String> dirtyObject = catalogFacade.getObject(new YaddaObjectID(DIRTY_DATA_OBJECT_ID)); if (dirtyObject != null && dirtyObject.getPart(DIRTY_DATA_PART_NAME) != null) { return ISODateTimeFormat.dateTimeParser().parseDateTime(dirtyObject.getPart(DIRTY_DATA_PART_NAME).getData()).toDate(); } else { return null; } }
@Override protected Dictionary loadDictonary() throws ServiceException { try { CatalogObject<String> object = catalogFacade.getObject(new YaddaObjectID(licenceObjectName)); Dictionary loadedDictionary = (Dictionary)xStream.fromXML( object.getPart(licenceObjectType).getData()); return loadedDictionary; } catch (CatalogException e) { throw new ServiceException(e); } }
private Element getElement(final String extId) throws CatalogException, YaddaException { if (extId == null) { return null; } final CatalogObject<String> object = catalogFacade.getObject(new YaddaObjectID(extId)); if (object == null) { return null; } final CatalogObjectPart<String> part = object.getPart(MetadataIndexConstants.T_BWMETA); if (part == null) { return null; } return (Element) bwmetaReader.parseEntity(part.getData(), null); }
private Ancestors getAncestors(final String extId) throws CatalogException, YaddaException { if (extId == null) { return null; } final CatalogObject<String> object = catalogFacade.getObject(new YaddaObjectID(extId)); if (object == null) { return null; } final CatalogObjectPart<String> part = object.getPart(MetadataIndexConstants.T_ANCESTORS); if (part == null) { return null; } return (Ancestors) ancestorsSerializer.toObject(null, part.getData()); }
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; }
catalogFacade.getPart(item.getId(), PART_TYPE_GROUP, null); Group group = (Group)serializer.toObject(item.getId().getId(), part.getData());
@Override public String readMetadata(String id) { try { CatalogObject<String> object = catalogFacadeProvider.getCatalogFacade().getObject(new YaddaObjectID(id)); if (object != null) { CatalogObjectPart<String> part = findPreferedPart(object.getParts()); if (part != null) { return part.getData(); } } else { problemHandler.handleProblem(LogSeverity.WARN, id, ImporterConstants.PROBLEM_ERROR_READ_BWMETA, "Object not found in the YADDA repository"); } } catch (Exception e) { logger.error("Exception while processing attachments from yadda", e); problemHandler.handleProblem(LogSeverity.WARN, id, ImporterConstants.PROBLEM_ERROR_READ_BWMETA, e); } return null; }
public Object resolveObject(String id) throws ReferenceResolutionException { try { CatalogObject<String> object = catalogFacade.getObject(new YaddaObjectID(id)); if (object == null) throw new ReferenceResolutionException("Object not found (id=" + id + ")"); for (String type : supportedPartTypes) { CatalogObjectPart<String> part = object.getPart(type); if (part != null) return serializer.toObject(id, part.getData()); } String types = StringUtils.join(object.getPartTypes(), ";"); throw new ReferenceResolutionException("Unknown object types:" + types); } catch (CatalogException e) { throw new ReferenceResolutionException("Access to catalog failed", e); } }
/** * Initializes memory copy of users directory */ protected void fetchUsers() throws CatalogException { List<CatalogObjectMeta> userObjects = catalogFacade.listObjects(new String[]{PART_TYPE_USER}, null, null, null, false); for (CatalogObjectMeta item : userObjects) { if (!item.getStatus().isDeleted()) { CatalogObjectPart<String> part = catalogFacade.getPart(item.getId(), PART_TYPE_USER, null); User user = (User)serializer.toObject(item.getId().getId(), part.getData()); usersByLogin.put(user.getLogin(), user); usersById.put(user.getExtId(), user); } } }
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); }
/** * Initializes memory copy of roles directory * @throws CatalogException */ protected void fetchRoles() throws CatalogException { List<CatalogObjectMeta> roleObjects = catalogFacade.listObjects(new String[]{PART_TYPE_ROLE}, null, null, null, false); for (CatalogObjectMeta item : roleObjects) { if (!item.getStatus().isDeleted()) { CatalogObjectPart<String> part = catalogFacade.getPart(item.getId(), PART_TYPE_ROLE, null); Role role = (Role)serializer.toObject(item.getId().getId(), part.getData()); roles.put(role.getExtId(), role); } } }