List of usage examples for javax.xml.registry RegistryException RegistryException
public RegistryException(Throwable cause)
JAXRException
object initialized with the given Throwable
object. From source file:it.cnr.icar.eric.server.interfaces.soap.BSTRequest.java
private UserType getEffectiveUser(UserType requestor) throws RegistryException { RegistryRequestType message = context.getCurrentRegistryRequest(); UserType user = requestor;//from w ww . j a v a 2 s. c o m try { HashMap<String, Object> requestSlots = bu.getSlotsFromRequest(message); String userId = (String) requestSlots.get(BindingUtility.CANONICAL_URI_EFFECTIVE_REQUESTOR); if (userId != null) { boolean isIntermediary = (authc.hasIntermediaryRole(requestor) || authc.hasRegistryAdministratorRole(requestor)); if (isIntermediary) { try { UserType u = (UserType) qm.getRegistryObject(context, userId, "User"); if (u != null) { user = u; } } catch (ObjectNotFoundException e) { // Missing effective user, fall back to requestor userId = null; } } } } catch (JAXBException e) { throw new RegistryException(e); } return user; }
From source file:it.cnr.icar.eric.server.query.ReferenceResolverImpl.java
@SuppressWarnings({ "rawtypes", "unchecked" }) private void internalGetReferencedObjects(ServerRequestContext serverContext, RegistryObjectType ro, int depth, Map<Object, Object> idMap, Collection<RegistryObjectType> refObjs) throws RegistryException { log.trace("start: internalGetReferencedObjects"); try {/*from ww w . jav a2 s. c o m*/ if ((ro != null) && (!refObjs.contains(ro))) { if (log.isDebugEnabled()) { log.debug("get references for this ro: " + ro.getId() + " " + ro.getObjectType()); } refObjs.add(ro); processRefAttribute(serverContext, ro, "org.oasis.ebxml.registry.bindings.rim.RegistryObjectType", idMap, "ObjectType", refObjs); processRefAttribute(serverContext, ro, "org.oasis.ebxml.registry.bindings.rim.ClassificationNodeType", idMap, "Parent", refObjs); processRefAttribute(serverContext, ro, "org.oasis.ebxml.registry.bindings.rim.ClassificationType", idMap, "ClassificationNode", refObjs); processRefAttribute(serverContext, ro, "org.oasis.ebxml.registry.bindings.rim.ClassificationType", idMap, "ClassificationScheme", refObjs); processRefAttribute(serverContext, ro, "org.oasis.ebxml.registry.bindings.rim.ClassificationType", idMap, "ClassifiedObject", refObjs); processRefAttribute(serverContext, ro, "org.oasis.ebxml.registry.bindings.rim.ExternalIdentifierType", idMap, "IdentificationScheme", refObjs); processRefAttribute(serverContext, ro, "org.oasis.ebxml.registry.bindings.rim.ExternalIdentifierType", idMap, "RegistryObject", refObjs); //FederationType fed = (FederationType)ro; //TODO: Fix so it adds only Strings not ObjectRefType //refInfos.addAll(fed.getMembers().getObjectRef()); processRefAttribute(serverContext, ro, "org.oasis.ebxml.registry.bindings.rim.AssociationType1", idMap, "AssociationType", refObjs); processRefAttribute(serverContext, ro, "org.oasis.ebxml.registry.bindings.rim.AssociationType1", idMap, "SourceObject", refObjs); processRefAttribute(serverContext, ro, "org.oasis.ebxml.registry.bindings.rim.AssociationType1", idMap, "TargetObject", refObjs); processRefAttribute(serverContext, ro, "org.oasis.ebxml.registry.bindings.rim.AuditableEventType", idMap, "User", refObjs); processRefAttribute(serverContext, ro, "org.oasis.ebxml.registry.bindings.rim.AuditableEventType", idMap, "RequestId", refObjs); processRefAttribute(serverContext, ro, "org.oasis.ebxml.registry.bindings.rim.OrganizationType", idMap, "Parent", refObjs); processRefAttribute(serverContext, ro, "org.oasis.ebxml.registry.bindings.rim.RegistryType", idMap, "Operator", refObjs); processRefAttribute(serverContext, ro, "org.oasis.ebxml.registry.bindings.rim.ServiceBindingType", idMap, "Service", refObjs); processRefAttribute(serverContext, ro, "org.oasis.ebxml.registry.bindings.rim.ServiceBindingType", idMap, "TargetBinding", refObjs); processRefAttribute(serverContext, ro, "org.oasis.ebxml.registry.bindings.rim.SpecificationLinkType", idMap, "ServiceBinding", refObjs); processRefAttribute(serverContext, ro, "org.oasis.ebxml.registry.bindings.rim.SpecificationLinkType", idMap, "SpecificationObject", refObjs); processRefAttribute(serverContext, ro, "org.oasis.ebxml.registry.bindings.rim.SubscriptionType", idMap, "Selector", refObjs); if (depth != 0) { depth--; // Now process composed objects Set<RegistryObjectType> composedObjects = BindingUtility.getInstance() .getComposedRegistryObjects(ro, 1); Collection<?> composedNoDups = checkForDuplicates(refObjs, composedObjects); // Now process associated objects Collection<?> associatedObjects = getAssociatedObjects(serverContext, ro, depth, idMap, refObjs); Collection assocNoDups = checkForDuplicates(refObjs, associatedObjects); Collection relatedObjects = new ArrayList(); relatedObjects.addAll(composedNoDups); relatedObjects.addAll(assocNoDups); Iterator iter = relatedObjects.iterator(); while (iter.hasNext()) { Object obj = iter.next(); if (obj instanceof RegistryObjectType) { RegistryObjectType regObj = (RegistryObjectType) obj; internalGetReferencedObjects(serverContext, regObj, depth, idMap, refObjs); } } } } } catch (RegistryException re) { throw re; } catch (Throwable t) { throw new RegistryException(t); } log.trace("end: internalGetReferencedObjects"); }
From source file:it.cnr.icar.eric.server.persistence.rdb.SlotDAO.java
/** * @param parentInsert It should be set to true if Slot insert is part of new * RegistryObject insert (i.e. in the case of SubmitObjectsRequest). It should * be set to false in the case of AddSlotsRequest because the parent of the * slot is expected to be already submitted by previous SubmitObjectRequest. * In the latter case whether the parents of the slots exist will be checked. *//*w ww .j a va 2s . c om*/ public void insert(List<?> slots, boolean parentInsert) throws RegistryException { PreparedStatement pstmt = null; String parentId = (String) parent; if (slots.size() == 0) { return; } try { String sql = "INSERT INTO " + getTableName() + " (sequenceId, " + "name_, slotType, value, parent)" + " VALUES(?, ?, ?, ?, ?)"; pstmt = context.getConnection().prepareStatement(sql); List<String> duplicateSlotsNames = getDuplicateSlots(slots); if (duplicateSlotsNames.size() > 0) { // Some slots have duplicate name throw new DuplicateSlotsException(parentId, duplicateSlotsNames); } RegistryObjectDAO roDAO = new RegistryObjectDAO(context); // Check whether the parent exist in database, in case the parent // has been inserted by the previous SubmitObjectsRequest // (i.e. in the case of AddSlotsRequest) if (!parentInsert && !roDAO.registryObjectExist(parentId)) { // The parent does not exist throw new SlotsParentNotExistException(parentId); } List<String> slotsNamesAlreadyExist = slotsExist(parentId, slots); if (slotsNamesAlreadyExist.size() > 0) { // Some slots for this RegistryObject already exist throw new SlotsExistException(parentId, slotsNamesAlreadyExist); } Iterator<?> iter = slots.iterator(); @SuppressWarnings("unused") Vector<Object> slotNames = new Vector<Object>(); while (iter.hasNext()) { SlotType1 slot = (SlotType1) iter.next(); String slotName = slot.getName(); String slotType = slot.getSlotType(); List<String> values = slot.getValueList().getValue(); int size = values.size(); for (int j = 0; j < size; j++) { String value = values.get(j); pstmt.setInt(1, j); pstmt.setString(2, slotName); pstmt.setString(3, slotType); pstmt.setString(4, value); pstmt.setString(5, parentId); log.trace("stmt = " + pstmt.toString()); pstmt.addBatch(); } } if (slots.size() > 0) { @SuppressWarnings("unused") int[] updateCounts = pstmt.executeBatch(); } } catch (SQLException e) { log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), e); throw new RegistryException(e); } finally { closeStatement(pstmt); } }
From source file:it.cnr.icar.eric.server.interfaces.rest.URLHandler.java
/** * Submit the SQL query to the registry as the specified user. * /*from w w w. j a v a2 s .co m*/ * @param queryString * @param user * @throws RegistryException * @return A List of IdentifiableType objects representing the registry * objects that match the query. * @see #findUserByPrincipal(Principal) */ List<RegistryObjectType> submitQueryAs(String queryString, UserType user) throws RegistryException { try { AdhocQueryRequest req = BindingUtility.getInstance().createAdhocQueryRequest(queryString); ObjectFactory queryFac = BindingUtility.getInstance().queryFac; ResponseOptionType responseOption = queryFac.createResponseOptionType(); responseOption.setReturnComposedObjects(true); responseOption.setReturnType(ReturnType.LEAF_CLASS); req.setResponseOption(responseOption); ServerRequestContext context = new ServerRequestContext("URLHandler.submitQueryAs", req); context.setUser(user); AdhocQueryResponse ebAdhocQueryResponse = qm.submitAdhocQuery(context); /* * getIdentifiable() returns JAXBelement<? extends IdentifiableType> * * return should be List of ComplexType */ RegistryObjectListType ebRegistryObjectListType = ebAdhocQueryResponse.getRegistryObjectList(); // get List of Element List<JAXBElement<? extends IdentifiableType>> results = ebRegistryObjectListType.getIdentifiable(); // prepare List of ComplexType List<RegistryObjectType> ebRegistryObjectTypeList = new ArrayList<RegistryObjectType>(); Iterator<JAXBElement<? extends IdentifiableType>> ebRegistryObjectListTypeIter = results.iterator(); while (ebRegistryObjectListTypeIter.hasNext()) { // take ComplexType from Element ebRegistryObjectTypeList.add((RegistryObjectType) ebRegistryObjectListTypeIter.next().getValue()); } // List of ComplexType return ebRegistryObjectTypeList; } catch (Exception e) { throw new RegistryException(e); } }
From source file:it.cnr.icar.eric.server.repository.filesystem.FileSystemRepositoryManager.java
/** * Determines if RepositoryItem exists for specified key. * * @return true if a RepositoryItem exists for specified key, false otherwise * @param key The RepositoryItemKey.//www . j ava2 s . c om */ public boolean itemExists(RepositoryItemKey key) throws RegistryException { throw new RegistryException(ServerResourceBundle.getInstance().getString("message.unimplemented")); }
From source file:it.cnr.icar.eric.server.security.authentication.AuthenticationServiceImpl.java
public X509Certificate getCertificate(String alias) throws RegistryException { X509Certificate cert = null;//from ww w. j a v a2 s . c o m try { cert = (X509Certificate) getKeyStore().getCertificate(alias); if (cert == null) { throw new RegistryException(ServerResourceBundle.getInstance() .getString("message.certificateNotFound", new Object[] { alias })); } } catch (KeyStoreException e) { throw new RegistryException(ServerResourceBundle.getInstance().getString("message.gettingCertificate"), e); } return cert; }
From source file:it.cnr.icar.eric.server.query.CompressContentQueryFilterPlugin.java
/** * This method processes the AdhocQueryRequest in the RequestContext * * @param context//from w ww. jav a 2 s. c o m * A it.cnr.icar.eric.common.spi.RequestContext */ public void processRequest(RequestContext context) throws RegistryException { try { ServerRequestContext serverContext = ServerRequestContext.convert(context); Map<?, ?> queryParamsMap = serverContext.getQueryParamsMap(); int depth = 0; String depthString = (String) queryParamsMap.get(CanonicalConstants.CANONICAL_SEARCH_DEPTH_PARAMETER); if (depthString != null && depthString.length() > 0) { try { depth = Integer.parseInt(depthString); } catch (Throwable t) { log.error(t); } } Iterator<?> resultsItr = serverContext.getQueryResults().iterator(); Collection<Object> idCollection = new ArrayList<Object>(); @SuppressWarnings("unused") Iterator<Object> idIter = idCollection.iterator(); File zipFile = null; ZipOutputStream zos = null; Collection<String> exportedIds = new ArrayList<String>(); try { while (resultsItr.hasNext()) { RegistryObjectType ro = (RegistryObjectType) resultsItr.next(); String id = ro.getId(); ExtrinsicObjectType eot = null; RegistryObjectType rot = null; try { rot = QueryManagerFactory.getInstance().getQueryManager().getRegistryObject(serverContext, id, "ExtrinsicObject"); } catch (ObjectNotFoundException oex) { String msg = ServerResourceBundle.getInstance().getString("message.registryObjectNotFound", new Object[] { id }); log.error(msg, oex); } catch (Throwable t) { log.error(t); } if (rot != null) { if (!(rot instanceof ExtrinsicObjectType)) { String msg = ServerResourceBundle.getInstance() .getString("message.expectedExtrinsicObjectNotFound", new Object[] { rot }); log.debug(msg); } else { eot = (ExtrinsicObjectType) rot; RepositoryItem ri = (RepositoryItem) context.getRepositoryItemsMap().get(id); if (ri == null) { // Get each artifact from the Repository try { ri = RepositoryManagerFactory.getInstance().getRepositoryManager() .getRepositoryItem(id); } catch (RepositoryItemNotFoundException rex) { String msg = ServerResourceBundle.getInstance().getString( "message.RepositoryItemDoesNotExist", new Object[] { rot.getId() }); log.warn(msg); } catch (Throwable t) { log.warn(t); } } if (ri == null) { // Check if EO is an element contained in a different EO eot = getContainedExtrinsicObject(eot, serverContext); if (eot != null) { try { ri = RepositoryManagerFactory.getInstance().getRepositoryManager() .getRepositoryItem(eot.getId()); } catch (RepositoryItemNotFoundException rex) { String msg = ServerResourceBundle.getInstance().getString( "message.RepositoryItemDoesNotExist", new Object[] { rot.getId() }); log.warn(msg); } catch (Throwable t) { log.warn(t); } } } if (ri != null) { if (zipFile == null) { zipFile = getZipFile(serverContext); zos = getZipOutputStream(zipFile); } // Store each RI in the compressed content zip file addRepositoryItemToZipFile(ri, zos, serverContext, eot, exportedIds, depth); } } } } } finally { if (zos != null) { try { zos.close(); } catch (Throwable t) { zos = null; } } } ArrayList<ExtrinsicObjectType> results = new ArrayList<ExtrinsicObjectType>(); if (zipFile != null) { // Create an initialze the compressed content zip file EO ExtrinsicObjectType ebExtrinsicObjectType = BindingUtility.getInstance().rimFac .createExtrinsicObjectType(); String lid = "urn:uuid:" + UUIDFactory.getInstance().newUUID().toString(); String zipFileName = zipFile.getName(); ebExtrinsicObjectType.setId(lid); ebExtrinsicObjectType.setLid(lid); ebExtrinsicObjectType.setName(bu.createInternationalStringType(zipFileName)); SlotType1 slot = bu.rimFac.createSlotType1(); slot.setName(BindingUtility.FREEBXML_REGISTRY_FILTER_QUERY_COMPRESSCONTENT_FILENAME); ValueListType vlt = bu.rimFac.createValueListType(); // Value value = bu.rimFac.createValue(zipFileName); vlt.getValue().add(zipFileName); slot.setValueList(vlt); ebExtrinsicObjectType.getSlot().add(slot); ebExtrinsicObjectType.setMimeType("application/zip"); ebExtrinsicObjectType.setObjectType(CanonicalConstants.CANONICAL_OBJECT_TYPE_ID_ExtrinsicObject); ebExtrinsicObjectType.setContentVersionInfo(bu.rimFac.createVersionInfoType()); results.add(ebExtrinsicObjectType); } serverContext.setSpecialQueryResults(results); } catch (RegistryException re) { throw re; } catch (Throwable t) { throw new RegistryException(t); } }
From source file:it.cnr.icar.eric.server.query.federation.FederatedQueryProcessor.java
private AdhocQueryResponse getUnifiedResponse() throws RegistryException { AdhocQueryResponse response = null;// w w w.j a v a 2s. co m try { response = bu.queryFac.createAdhocQueryResponse(); RegistryObjectListType ebRegistryObjectListType = bu.rimFac.createRegistryObjectListType(); response.setRegistryObjectList(ebRegistryObjectListType); int maxTotalResultCount = -1; RegistryErrorList ebRegistryErrorList = null; Iterator<AdhocQueryResponse> i = responses.iterator(); while (i.hasNext()) { AdhocQueryResponse ebAdhocQueryResponse = i.next(); int totalResultCount = ebAdhocQueryResponse.getTotalResultCount().intValue(); if (totalResultCount > maxTotalResultCount) { maxTotalResultCount = totalResultCount; } if ((ebAdhocQueryResponse.getRegistryErrorList() != null) && (ebAdhocQueryResponse.getRegistryErrorList().getRegistryError().size() > 0)) { if (ebRegistryErrorList == null) { ebRegistryErrorList = bu.rsFac.createRegistryErrorList(); response.setRegistryErrorList(ebRegistryErrorList); } response.getRegistryErrorList().getRegistryError() .addAll(ebAdhocQueryResponse.getRegistryErrorList().getRegistryError()); } //Spec Issue: How to handle duplicate id across registries?? //Need to return one. Which one? The latest? Probably the one from current registry. //May require always querying current registry last since code below keeps replacing existing objects //with new ones that have same id. if (ebAdhocQueryResponse.getRegistryObjectList() != null) { IdentifiableComparator comparator = new IdentifiableComparator(); List<JAXBElement<? extends IdentifiableType>> unifiedObjects = response.getRegistryObjectList() .getIdentifiable(); List<JAXBElement<? extends IdentifiableType>> currentObjects = ebAdhocQueryResponse .getRegistryObjectList().getIdentifiable(); Collections.sort(unifiedObjects, comparator); //Remove duplicates. //unifiedObjects.removeAll(currentObjects) will not work as there is no comparator implemented for JAXB objects Iterator<JAXBElement<? extends IdentifiableType>> currentObjectsIter = currentObjects .iterator(); while (currentObjectsIter.hasNext()) { RegistryObjectType currentObject = (RegistryObjectType) currentObjectsIter.next() .getValue(); int index = Collections.binarySearch(unifiedObjects, currentObject, comparator); if (index >= 0) { unifiedObjects.remove(index); log.trace("Removing duplicate object returned by a previous registry: id=" + currentObject.getId() + " name=" + bu.getInternationalStringAsString(currentObject.getName())); } log.trace("Adding object returned by registry: id=" + currentObject.getId() + " name=" + bu.getInternationalStringAsString(currentObject.getName())); } //Add the currentObjects to unified objects unifiedObjects.addAll(currentObjects); } } if ((response.getRegistryErrorList() != null) && (response.getRegistryErrorList().getRegistryError().size() > 0)) { response.setStatus(BindingUtility.CANONICAL_RESPONSE_STATUS_TYPE_ID_Failure); } else { response.setStatus(BindingUtility.CANONICAL_RESPONSE_STATUS_TYPE_ID_Success); } //Set iterative query related attributes response.setStartIndex(adhocQueryRequest.getStartIndex()); response.setTotalResultCount(BigInteger.valueOf(maxTotalResultCount)); } catch (JAXRException e) { throw new RegistryException(e); } return response; }
From source file:it.cnr.icar.eric.server.cache.ClassificationSchemeCache.java
/** * Gets schemes that match id pattern. Note that descendent nodes of schemes * up to the depth level that is configured for the cache may also be loaded * into the object cache./*from ww w.j ava 2 s . c o m*/ */ @SuppressWarnings({ "rawtypes", "unchecked" }) public List<?> getClassificationSchemesById(ServerRequestContext context, String idPattern) throws RegistryException { List matchedSchemes = null; try { primeCacheOnFirstUse(context); if (Utility.getInstance().isValidRegistryId(idPattern)) { // Valid id: check if it is in cache Element elem = internalCache.get(idPattern); if (null == elem) { // Cache miss. Get from dB matchedSchemes = updateScheme(context, idPattern, true /* false */); } else { ClassificationSchemeType scheme = (ClassificationSchemeType) elem.getValue(); // Cache hit matchedSchemes = Collections.singletonList(scheme); } } else { // Not a valid id: must be a pattern List schemes = getAllClassificationSchemes(context); if (idPattern.equals("%")) { matchedSchemes = schemes; } else { matchedSchemes = new ArrayList(); Iterator iter = schemes.iterator(); while (iter.hasNext()) { ClassificationSchemeType scheme = (ClassificationSchemeType) iter.next(); String schemeId = scheme.getId(); if (idPattern.equalsIgnoreCase(schemeId)) { matchedSchemes.add(scheme); } else if (schemeId.matches(idPattern)) { matchedSchemes.add(scheme); } } } } } catch (CacheException e) { throw new RegistryException(e); } return matchedSchemes; }
From source file:it.cnr.icar.eric.server.repository.filesystem.FileSystemRepositoryManager.java
public void delete(it.cnr.icar.eric.server.repository.RepositoryItemKey key) throws RegistryException { throw new RegistryException(ServerResourceBundle.getInstance().getString("message.unimplemented")); }