List of usage examples for javax.xml.registry JAXRException JAXRException
public JAXRException(Throwable cause)
JAXRException
object initialized with the given Throwable
object. From source file:de.kp.ames.web.function.domain.model.JsonEvaluation.java
public void set(RegistryObjectImpl ro, Locale locale) throws JSONException, JAXRException { /*//from w w w. jav a2 s .c o m * Convert registry object */ super.set(ro, locale); /* * Convert evaluation specific information */ ExtrinsicObjectImpl evaluation = (ExtrinsicObjectImpl) ro; Object[] associatives = evaluation.getAssociatedObjects().toArray(); int card = associatives.length; if (card != 2) throw new JAXRException("[JsonEvaluation] An evaluation must have exactly two associations."); for (int ix = 0; ix < card; ix++) { RegistryObjectImpl associative = (RegistryObjectImpl) associatives[ix]; String associativeId = associative.getId(); String associativeName = jaxrBase.getName(associative); /* * If no matching locale string exists, get the closest match */ associativeName = (associativeName == "") ? associative.getDisplayName() : associativeName; String associativeDesc = jaxrBase.getDescription(associative); associativeDesc = (associativeDesc == "") ? ((InternationalStringImpl) associative.getDescription()).getClosestValue() : associativeDesc; String associativeType = associative.getObjectType().getKey().getId(); if (associativeType.equals(REGISTRY_PACKAGE)) { /* * Evaluation source (fact base) */ JSONObject jBase = new JSONObject(); jBase.put(JaxrConstants.RIM_ID, associativeId); jBase.put(JaxrConstants.RIM_NAME, associativeName); jBase.put(JaxrConstants.RIM_DESC, associativeDesc); put(JaxrConstants.RIM_BASE, jBase.toString()); } else if (associativeType.equals(SERVICE)) { /* * Evaluation reasoner */ JSONObject jReasoner = new JSONObject(); jReasoner.put(JaxrConstants.RIM_ID, associativeId); jReasoner.put(JaxrConstants.RIM_NAME, associativeName); jReasoner.put(JaxrConstants.RIM_DESC, associativeDesc); put(JaxrConstants.RIM_REASONER, jReasoner.toString()); } } }
From source file:de.kp.ames.web.function.domain.model.ChatObject.java
/** * Create RegistryObject representation of ChatObject * /*from ww w . j a va 2 s. c om*/ * @param data * @return * @throws Exception */ public RegistryObjectImpl create(String data) throws Exception { /* * Initialize data */ JSONObject jForm = new JSONObject(data); /* * A chat message is a certain extrinsic object that holds all * relevant and related information in a single JSON repository item */ ExtrinsicObjectImpl eo = null; /* * Create extrinsic object that serves as a wrapper for * the respective chat message */ eo = jaxrLCM.createExtrinsicObject(); if (eo == null) throw new JAXRException("[ChatObject] Creation of ExtrinsicObject failed."); /* * Identifier */ String eid = JaxrIdentity.getInstance().getPrefixUID(FncConstants.CHAT_PRE); eo.setLid(eid); eo.getKey().setId(eid); /* * Name using default locale */ String name = "[CHAT] " + jForm.getString(JaxrConstants.RIM_MESSAGE_ID); eo.setName(jaxrLCM.createInternationalString(name)); /* * Home url */ String home = jaxrHandle.getEndpoint().replace("/saml", ""); eo.setHome(home); /* * Mime type & handler */ String mimetype = GlobalConstants.MT_JSON; eo.setMimeType(mimetype); byte[] bytes = data.getBytes(GlobalConstants.UTF_8); DataHandler handler = new DataHandler(FileUtil.createByteArrayDataSource(bytes, mimetype)); eo.setRepositoryItem(handler); /* * Create classification */ ClassificationImpl c = jaxrLCM.createClassification(ClassificationConstants.FNC_ID_Chat); c.setName(jaxrLCM.createInternationalString(Locale.US, "Chat Classification")); /* * Associate classification and chat message */ eo.addClassification(c); /* * Indicate as created */ this.created = true; return eo; }
From source file:de.kp.ames.web.function.domain.model.MailObject.java
/** * Create RegistryObject representation of MailObject * //from w w w .j a va 2 s . co m * @param data * @return * @throws Exception */ public RegistryObjectImpl create(String data) throws Exception { /* * Initialize data */ JSONObject jForm = new JSONObject(data); /* * A mail message is a certain extrinsic object that holds all * relevant and related information in a single JSON repository item */ ExtrinsicObjectImpl eo = null; /* * Create extrinsic object that serves as a container for * the respective mail message */ eo = jaxrLCM.createExtrinsicObject(); if (eo == null) throw new JAXRException("[MailObject] Creation of ExtrinsicObject failed."); /* * Identifier */ String eid = JaxrIdentity.getInstance().getPrefixUID(FncConstants.MAIL_PRE); eo.setLid(eid); eo.getKey().setId(eid); /* * Name using default locale */ String name = "[MAIL] " + jForm.getString(JaxrConstants.RIM_MESSAGE_ID); eo.setName(jaxrLCM.createInternationalString(name)); /* * Home url */ String home = jaxrHandle.getEndpoint().replace("/saml", ""); eo.setHome(home); /* * Mime type & handler */ String mimetype = GlobalConstants.MT_JSON; eo.setMimeType(mimetype); byte[] bytes = data.getBytes(GlobalConstants.UTF_8); DataHandler handler = new DataHandler(FileUtil.createByteArrayDataSource(bytes, mimetype)); eo.setRepositoryItem(handler); /* * Create classification */ ClassificationImpl c = jaxrLCM.createClassification(ClassificationConstants.FNC_ID_Mail); c.setName(jaxrLCM.createInternationalString(Locale.US, "Mail Classification")); /* * Associate classification and mail message */ eo.addClassification(c); /* * Indicate as created */ this.created = true; return eo; }
From source file:de.kp.ames.web.function.domain.model.EvaluationObject.java
/** * Create EvaluationObject/*from w w w . ja va 2 s .c o m*/ * * @param source * @param reasoner * @param data * @param stream * @return * @throws Exception */ public RegistryObjectImpl create(String source, String reasoner, String data, InputStream stream) throws Exception { /* * Initialize data */ JSONObject jForm = new JSONObject(data); /* * Create extrinsic object that serves as a wrapper * for the respective evaluation */ // ExtrinsicObjectImpl eo = jaxrLCM.createExtrinsicObject(); if (eo == null) throw new JAXRException("[EvaluationObject] Creation of ExtrinsicObject failed."); /* * Identifier */ String eid = JaxrIdentity.getInstance().getPrefixUID(FncConstants.EVALUATION_PRE); eo.setLid(eid); eo.getKey().setId(eid); /* * Home url */ String home = jaxrHandle.getEndpoint().replace("/saml", ""); eo.setHome(home); /* * Name & description */ String name = jForm.getString(RIM_NAME); String desc = jForm.getString(RIM_DESC); String dtime = jForm.getString(RIM_DATE); name = name.trim() + ", " + dtime.trim(); eo.setName(jaxrLCM.createInternationalString(name)); eo.setDescription(jaxrLCM.createInternationalString(desc)); /* * Associations */ /* * Build directed graph between evaluation and its source */ RegistryObjectImpl sourceObject = jaxrLCM.getRegistryObjectById(source); if (sourceObject == null) throw new JAXRException("[EvaluationObject] RegistryObject with id <." + source + "> does not exist."); AssociationImpl sourceAssociation = jaxrLCM.createAssociation_RelatedTo(sourceObject); eo.addAssociation(sourceAssociation); /* * Build directed graph between evaluation and its reasoner */ RegistryObjectImpl reasonerObject = jaxrLCM.getRegistryObjectById(reasoner); if (reasonerObject == null) throw new JAXRException( "[EvaluationObject] RegistryObject with id <." + reasoner + "> does not exist."); AssociationImpl reasonerAssociation = jaxrLCM.createAssociation_RelatedTo(reasonerObject); eo.addAssociation(reasonerAssociation); /* * Classifications */ ClassificationImpl classification = jaxrLCM.createClassification(ClassificationConstants.FNC_ID_Evaluation); eo.addClassification(classification); /* * Mimetype & repository item */ String mimetype = GlobalConstants.MT_XML; eo.setMimeType(mimetype); byte[] bytes = FileUtil.getByteArrayFromInputStream(stream); DataHandler handler = new DataHandler(FileUtil.createByteArrayDataSource(bytes, mimetype)); eo.setRepositoryItem(handler); /* * Indicate as created */ this.created = true; return eo; }
From source file:de.kp.ames.web.function.domain.model.TransformatorObject.java
/** * Create RegistryObject representation of TransformatorObject * /*from www . j a v a 2 s . co m*/ * @param data * @return * @throws Exception */ public RegistryObjectImpl create(String data) throws Exception { /* * Initialize data */ JSONObject jForm = new JSONObject(data); /* * Create extrinsic object that serves as a wrapper * for the respective transformator */ // ExtrinsicObjectImpl eo = jaxrLCM.createExtrinsicObject(); if (eo == null) throw new JAXRException("[TransformatorObject] Creation of ExtrinsicObject failed."); /* * Identifier */ String eid = JaxrIdentity.getInstance().getPrefixUID(FncConstants.TRANSFORMATOR_PRE); eo.setLid(eid); eo.getKey().setId(eid); /* * Home url */ String home = jaxrHandle.getEndpoint().replace("/saml", ""); eo.setHome(home); /* * The transformator is actually transient and managed by the xslt processor; * to register the respective xslt file, we have to invoke the transient * cache and get the file */ XslCacheManager cacheManager = XslCacheManager.getInstance(); String key = jForm.getString(JsonConstants.J_KEY); XslTransformator transformator = (XslTransformator) cacheManager.getFromCache(key); if (transformator == null) throw new Exception("[TransformatorObject] XSL Transformator with id <" + key + "> not found."); /* * Name & description */ String name = jForm.has(RIM_NAME) ? jForm.getString(RIM_NAME) : null; String desc = jForm.has(RIM_DESC) ? jForm.getString(RIM_DESC) : null; name = (name == null) ? transformator.getName() : name; int pos = name.lastIndexOf("."); if (pos != -1) name = name.substring(0, pos); eo.setName(jaxrLCM.createInternationalString(name)); desc = (desc == null) ? FncMessages.NO_DESCRIPTION_DESC : desc; eo.setDescription(jaxrLCM.createInternationalString(desc)); /* * Classifications */ JSONArray jClases = jForm.has(RIM_CLAS) ? new JSONArray(jForm.getString(RIM_CLAS)) : null; if (jClases != null) { List<ClassificationImpl> classifications = createClassifications(jClases); /* * Set composed object */ eo.addClassifications(classifications); } /* * Mimetype & repository item */ String mimetype = transformator.getMimetype(); DataHandler handler = new DataHandler( FileUtil.createByteArrayDataSource(transformator.getBytes(), mimetype)); eo.setMimeType(mimetype); eo.setRepositoryItem(handler); /* * Indicate as created */ this.created = true; return eo; }
From source file:de.kp.ames.web.function.domain.model.NamespaceObject.java
/** * Create NamespaceObject from JSON representation * //from w w w . jav a 2 s .co m * @param jForm * @return * @throws Exception */ public RegistryObjectImpl create(JSONObject jForm) throws Exception { /* * Create registry package */ String name = jForm.getString(RIM_NAME); // RegistryPackageImpl rp = jaxrLCM.createRegistryPackage(jaxrLCM.createInternationalString(name)); if (rp == null) throw new JAXRException("[NamespaceObject] Creation of RegistryPackage failed."); /* * Identifier */ String rid = JaxrIdentity.getInstance().getPrefixUID(FncConstants.FOLDER_PRE); rp.setLid(rid); rp.getKey().setId(rid); /* * Home url */ String home = jaxrHandle.getEndpoint().replace("/saml", ""); rp.setHome(home); /* * Description */ String desc = jForm.getString(RIM_DESC); rp.setDescription(jaxrLCM.createInternationalString(desc)); /* * Classifications */ JSONArray jClases = jForm.has(RIM_CLAS) ? new JSONArray(jForm.getString(RIM_CLAS)) : null; if (jClases != null) { List<ClassificationImpl> classifications = createClassifications(jClases); /* * Set composed object */ rp.addClassifications(classifications); } /* * Slots */ JSONObject jSlots = jForm.has(RIM_SLOT) ? new JSONObject(jForm.getString(RIM_SLOT)) : null; if (jSlots != null) { List<SlotImpl> slots = createSlots(jSlots); /* * Set composed object */ rp.addSlots(slots); } /* * Indicate as created */ this.created = true; return rp; }
From source file:it.cnr.icar.eric.client.xml.registry.util.SecurityUtil.java
private Properties loadAliasTable() throws JAXRException { String jaxrHome = ProviderProperties.getInstance().getProperty("jaxr-ebxml.home"); if ((jaxrHome == null) || (jaxrHome.length() == 0)) { throw new JAXRException(JAXRResourceBundle.getInstance().getString("message.error.undefined.Property")); }//from w ww. j av a2 s . c o m Properties aliasTable = new Properties(); File aliasFile = new File(jaxrHome, "security/alias.properties"); if (aliasFile.exists()) { try { aliasTable.load(new BufferedInputStream(new FileInputStream(aliasFile))); } catch (IOException x) { log.error(x); throw new JAXRException( JAXRResourceBundle.getInstance().getString("message.error.unexpected.IOException")); } } return aliasTable; }
From source file:it.cnr.icar.eric.client.xml.registry.util.KeystoreUtil.java
/** * Create keystore directory if it does not already exist * * @param keystoreFile Path to keystore file * @throws JAXRException Thrown if directory could not be created *//* w w w . j av a2 s. c om*/ public static void createKeystoreDirectory(File keystoreFile) throws JAXRException { File keystoreDir = keystoreFile.getParentFile(); try { // Ignore return value of mkdirs, returns false if directories // already exist keystoreDir.mkdirs(); } catch (SecurityException e) { log.error(e); throw new JAXRException(JAXRResourceBundle.getInstance().getString("message.error.not.create.directory", new Object[] { keystoreDir.getAbsolutePath() })); } }
From source file:de.kp.ames.web.function.comm.CommDQM.java
/** * Get either single mail message or all registered * products//from w w w .ja va 2 s . c o m * * @param item * @return * @throws Exception */ public JSONArray getMailMessages(String item) throws Exception { if (item == null) { /* * Determine mail messages (metadata) */ List<RegistryObjectImpl> messages = getRegistryObjects_ByClasNode(item, ClassificationConstants.FNC_ID_Mail); /* * Build JSON representation */ return JsonBusinessProvider.getMailMessages(jaxrHandle, messages); } else { /* * Determine content of mail message */ ExtrinsicObjectImpl eo = (ExtrinsicObjectImpl) getRegistryObjectById(item); if (eo == null) throw new JAXRException("[CommDQM] RegistryObject with id <" + item + "> not found."); DataHandler handler = eo.getRepositoryItem(); InputStream stream = handler.getInputStream(); byte[] bytes = FileUtil.getByteArrayFromInputStream(stream); JSONObject jMailMessage = new JSONObject(new String(bytes)); return new JSONArray().put(jMailMessage); } }
From source file:it.cnr.icar.eric.client.xml.registry.util.SecurityUtil.java
private KeyStore loadKeyStore() throws JAXRException { String storepass = ProviderProperties.getInstance().getProperty("jaxr-ebxml.security.storepass"); try {/*w w w . ja va 2s . c o m*/ keyStore = KeyStore .getInstance(ProviderProperties.getInstance().getProperty("jaxr-ebxml.security.storetype")); } catch (KeyStoreException x) { throw new JAXRException(x); } File keyStoreFile = KeystoreUtil.getKeystoreFile(); if (!keyStoreFile.exists()) { throw new JAXRException(JAXRResourceBundle.getInstance().getString("message.error.no.keystore.file", new Object[] { keyStoreFile.toString() })); } try { InputStream keyIS = new BufferedInputStream(new FileInputStream(keyStoreFile)); keyStore.load(keyIS, storepass.toCharArray()); log.debug("Keystore loaded from '" + keyStoreFile.getCanonicalPath() + "'"); } catch (IOException x) { throw new JAXRException(x); } catch (GeneralSecurityException x) { throw new JAXRException(x); } return keyStore; }