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.persistence.rdb.AffectedObjectDAO.java
protected void loadObject(Object obj, ResultSet rs) throws RegistryException { try {/*from ww w . j a v a 2 s . c o m*/ if (!(obj instanceof org.oasis.ebxml.registry.bindings.rim.ObjectRefType)) { throw new RegistryException(ServerResourceBundle.getInstance() .getString("message.ObjectRefTypeExpected", new Object[] { obj })); } ObjectRefType ro = (ObjectRefType) obj; ro.setId(rs.getString("id")); String home = rs.getString("home"); if (home != null) { ro.setHome(home); } } catch (SQLException e) { log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), e); throw new RegistryException(e); } }
From source file:it.cnr.icar.eric.server.persistence.rdb.NotifyActionDAO.java
protected void loadObject(Object obj, ResultSet rs) throws RegistryException { try {//from ww w. j a va2 s . co m if (!(obj instanceof NotifyActionType)) { throw new RegistryException(ServerResourceBundle.getInstance() .getString("message.NotifyActionTypeExpected", new Object[] { obj })); } NotifyActionType ebNotifyActionType = (NotifyActionType) obj; String notificationOption = rs.getString("notificationOption"); if (notificationOption != null) { ebNotifyActionType.setNotificationOption(notificationOption); } String endPoint = rs.getString("endPoint"); ebNotifyActionType.setEndPoint(endPoint); } catch (SQLException e) { log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), e); throw new RegistryException(e); } }
From source file:it.cnr.icar.eric.server.persistence.rdb.TelephoneNumberDAO.java
/** * @param registryObjects is a List of Organizations or Users * @throws RegistryException if the RegistryObject is not Organization or User, * or it has SQLException when inserting their PostalAddress *//*w w w .j av a2 s .c o m*/ @SuppressWarnings("resource") public void insert(@SuppressWarnings("rawtypes") List registryObjects) throws RegistryException { Statement stmt = null; if (registryObjects.size() == 0) { return; } try { stmt = context.getConnection().createStatement(); Iterator<?> rosIter = registryObjects.iterator(); while (rosIter.hasNext()) { Object ro = rosIter.next(); String parentId = null; Iterator<?> telephoneNumbers; if (ro instanceof OrganizationType) { OrganizationType org = (OrganizationType) ro; telephoneNumbers = org.getTelephoneNumber().iterator(); parentId = org.getId(); } else if (ro instanceof UserType) { UserType user = (UserType) ro; telephoneNumbers = user.getTelephoneNumber().iterator(); parentId = user.getId(); } else { throw new RegistryException( ServerResourceBundle.getInstance().getString("message.incorrectRegistryObject")); } while (telephoneNumbers.hasNext()) { TelephoneNumberType telephoneNumber = (TelephoneNumberType) telephoneNumbers.next(); String areaCode = telephoneNumber.getAreaCode(); if (areaCode != null) { areaCode = "'" + areaCode + "'"; } String countryCode = telephoneNumber.getCountryCode(); if (countryCode != null) { countryCode = "'" + countryCode + "'"; } String extension = telephoneNumber.getExtension(); if (extension != null) { extension = "'" + extension + "'"; } String number = telephoneNumber.getNumber(); if (number != null) { number = "'" + number + "'"; } String phoneType = telephoneNumber.getPhoneType(); if (phoneType != null) { phoneType = "'" + phoneType + "'"; } String str = "INSERT INTO TelephoneNumber " + "VALUES( " + areaCode + ", " + countryCode + ", " + extension + ", " + number + ", " + phoneType + ", " + "'" + parentId + "' )"; log.trace("stmt = " + str); stmt.addBatch(str); } } stmt.executeBatch(); } catch (SQLException e) { log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), e); throw new RegistryException(e); } finally { closeStatement(stmt); } }
From source file:it.cnr.icar.eric.server.persistence.rdb.FederationDAO.java
protected void loadObject(Object obj, ResultSet rs) throws RegistryException { try {/*from w ww. j av a 2 s . c om*/ if (!(obj instanceof FederationType)) { throw new RegistryException(ServerResourceBundle.getInstance() .getString("message.FederationExpected", new Object[] { obj })); } FederationType federation = (FederationType) obj; super.loadObject(obj, rs); String replicationSyncLatencyString = rs.getString("replicationSyncLatency"); Duration replicationSyncLatency = DatatypeFactory.newInstance() .newDuration(replicationSyncLatencyString); // conversion federation.setReplicationSyncLatency(replicationSyncLatency); } catch (SQLException e) { log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), e); throw new RegistryException(e); } catch (DatatypeConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:it.cnr.icar.eric.server.persistence.rdb.InternationalStringDAO.java
InternationalStringType getInternationalStringByParent(String parentId) throws RegistryException { InternationalStringType is = null;//from w w w.ja va 2 s .c o m PreparedStatement stmt = null; try { String tableName = getTableName(); if (tableName.equalsIgnoreCase("Name_")) { is = bu.rimFac.createInternationalStringType(); } else if (tableName.equalsIgnoreCase("Description")) { is = bu.rimFac.createInternationalStringType(); } else if (tableName.equalsIgnoreCase("UsageDescription")) { is = bu.rimFac.createInternationalStringType(); } stmt = context.getConnection() .prepareStatement("SELECT * FROM " + getTableName() + " WHERE parent = ?"); stmt.setString(1, parentId); ResultSet rs = stmt.executeQuery(); while (rs.next()) { String charsetName = rs.getString("charset"); String lang = rs.getString("lang"); String value = rs.getString("value"); if (value != null) { LocalizedStringType ls = bu.rimFac.createLocalizedStringType(); ls.setCharset(charsetName); ls.setLang(lang); ls.setValue(value); is.getLocalizedString().add(ls); } } } catch (SQLException e) { log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), e); throw new RegistryException(e); } finally { closeStatement(stmt); } return is; }
From source file:it.cnr.icar.eric.server.event.EmailNotifier.java
protected void sendNotification(ServerRequestContext context, NotifyActionType notifyAction, NotificationType notification, AuditableEventType ae) throws RegistryException { log.trace("Sending email notification"); String endpoint = notifyAction.getEndPoint(); if ((endpoint == null) || !endpoint.startsWith("mailto:")) { throw new RegistryException(ServerResourceBundle.getInstance() .getString("message.emailNotificationWOmailto", new Object[] { endpoint })); }//from ww w . j a v a 2 s.co m try { // get the body of the message , not yet defined ! StringWriter sw = new StringWriter(); // Marshaller marshaller = BindingUtility.getInstance().rimFac.createMarshaller(); Marshaller marshaller = BindingUtility.getInstance().getJAXBContext().createMarshaller(); marshaller.setProperty(javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); //marshaller.marshal(notification, sw); ObjectFactory of = new ObjectFactory(); marshaller.marshal(of.createNotification(notification), sw); //Now get the RegistryResponse as a String //Produce verbose response String notif = sw.toString(); String action = ae.getEventType(); String userId = ae.getUser(); String userInfo; if (userId != null) { UserType user = (UserType) context.getRegistryObject(userId, "User_"); userInfo = ServerResourceBundle.getInstance().getString("message.user", new String[] { getUserInfo(user) }); } else { userInfo = ServerResourceBundle.getInstance().getString("message.userUnknown"); } SubscriptionType subscription = (SubscriptionType) context .getRegistryObject(notification.getSubscription(), "Subscription"); String xsltId = getStyleSheetId(subscription); RepositoryItem repositoryItem = null; // empty string for notification property == use old format if (!"".equals(xsltId)) { //Dont use transform if there are any problems try { repositoryItem = RepositoryManagerFactory.getInstance().getRepositoryManager() .getRepositoryItem(xsltId); } catch (Exception e) { log.warn(ServerResourceBundle.getInstance().getString("message.rawEmailNotification"), e); } } String contentType; String message; if (repositoryItem == null) { //No style sheet so skip the tranformation contentType = "text/xml"; message = sw.toString(); } else { contentType = "text/html"; try { message = transformContent(context, xsltId, notif, action, userInfo); } catch (RegistryException e) { contentType = "text/xml"; message = sw.toString(); } } // set parameters and send the mail String subject = ServerResourceBundle.getInstance().getString("message.registryNotification", new Object[] { notification.getId() }); postMail(endpoint, message, subject, contentType); } catch (MessagingException e) { throw new RegistryException(e); } catch (JAXBException e) { throw new RegistryException(e); } }
From source file:it.cnr.icar.eric.server.security.authorization.AbstractRegistryFunction.java
/** * Extends 'evalArgs' to check for required parameters. * * @param params//from w ww .j a va2s . com * @param context * @param args * @param minParams Minimal number of parameters in 'params'. * * @return EvaluationResult if something is wrong. Null otherwise. */ protected EvaluationResult evalArgs(List<?> params, EvaluationCtx context, AttributeValue[] args, int minParams) { EvaluationResult result = super.evalArgs(params, context, args); if (result == null) { if (params.size() < minParams) { // Check which arguments are missing StringBuffer sb = new StringBuffer(); for (int i = params.size(); i < minParams; i++) { sb.append(ServerResourceBundle.getInstance().getString("message.xacmlExtFunctionParamMissing", new Object[] { getFunctionName(), getParameterNames()[i], String.valueOf(i + 1) })); if (i + 1 < minParams) { sb.append(' '); } } // Use an Exception to log RegistryException e = new RegistryException(sb.toString()); log.error(ServerResourceBundle.getInstance().getString("message.xacmlExtFunctionEvalError", new Object[] { getFunctionName() }), e); // Return EvaluationResult with missing attribute code List<String> codes = new ArrayList<String>(); codes.add(Status.STATUS_MISSING_ATTRIBUTE); result = new EvaluationResult(new Status(codes, e.getMessage())); } } return result; }
From source file:it.cnr.icar.eric.server.repository.filesystem.FileSystemRepositoryManager.java
/** * Gets the RepositoryItem as a stream of XML markup given its id. * * @param id Unique id for repository item * @return a <code>StreamSource</code> value * @exception RegistryException if an error occurs *///from w w w.jav a2 s . c o m public StreamSource getAsStreamSource(String id) throws RegistryException { StreamSource riFileSrc = null; try { File riFile = new File(getRepositoryItemPath(id)); riFileSrc = new StreamSource(new FileInputStream(riFile)); } catch (Exception e) { throw new RegistryException(e); } return riFileSrc; }
From source file:it.cnr.icar.eric.server.persistence.rdb.AssociationDAO.java
protected void loadObject(Object obj, ResultSet rs) throws RegistryException { try {//from w ww . j a v a 2 s . com if (!(obj instanceof AssociationType1)) { throw new RegistryException(ServerResourceBundle.getInstance() .getString("message.AssociationExpected", new Object[] { obj })); } AssociationType1 ebAssociationType = (AssociationType1) obj; super.loadObject(ebAssociationType, rs); String associationType = rs.getString("associationType"); ebAssociationType.setAssociationType(associationType); String sourceObjectId = rs.getString("sourceObject"); ObjectRefType ebSourceObjectRefType = bu.rimFac.createObjectRefType(); ebSourceObjectRefType.setId(sourceObjectId); context.getObjectRefs().add(ebSourceObjectRefType); ebAssociationType.setSourceObject(sourceObjectId); String targetObjectId = rs.getString("targetObject"); ObjectRefType ebTargetObjectRefType = bu.rimFac.createObjectRefType(); ebTargetObjectRefType.setId(targetObjectId); context.getObjectRefs().add(ebTargetObjectRefType); ebAssociationType.setTargetObject(targetObjectId); } catch (SQLException e) { log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), e); throw new RegistryException(e); } }
From source file:it.cnr.icar.eric.server.cache.RoleCache.java
/** * Gets the roles associated with the user associated with specified * ServerRequestContext./*ww w . j a v a 2s.c o m*/ */ @SuppressWarnings("unchecked") public Set<String> getRoles(ServerRequestContext context) throws RegistryException { Set<String> roles = null; try { UserType user = context.getUser(); if (user != null) { Element elem = internalCache.get(user.getId()); if (elem == null) { //Cache miss. Get from registry //log.trace("RoleCache: cache miss for id: " + id); roles = getRoles(context, user); putRoles(user.getId(), roles); } else { roles = (Set<String>) elem.getValue(); } } else { roles = new HashSet<String>(); } } catch (CacheException e) { throw new RegistryException(e); } return roles; }