List of usage examples for com.liferay.portal.kernel.util PropsUtil get
public static String get(String key)
From source file:at.meduni.graz.patho.haybaeck.service.ClpSerializer.java
License:Open Source License
public static String getServletContextName() { if (Validator.isNotNull(_servletContextName)) { return _servletContextName; }//from w w w . ja va2 s . c o m synchronized (ClpSerializer.class) { if (Validator.isNotNull(_servletContextName)) { return _servletContextName; } try { ClassLoader classLoader = ClpSerializer.class.getClassLoader(); Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps"); Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] { String.class }); String portletPropsServletContextName = (String) getMethod.invoke(null, "IRIS-portlet-deployment-context"); if (Validator.isNotNull(portletPropsServletContextName)) { _servletContextName = portletPropsServletContextName; } } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to locate deployment context from portlet properties"); } } if (Validator.isNull(_servletContextName)) { try { String propsUtilServletContextName = PropsUtil.get("IRIS-portlet-deployment-context"); if (Validator.isNotNull(propsUtilServletContextName)) { _servletContextName = propsUtilServletContextName; } } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to locate deployment context from portal properties"); } } } if (Validator.isNull(_servletContextName)) { _servletContextName = "IRIS-portlet"; } return _servletContextName; } }
From source file:at.meduni.liferay.portlet.bbmrieric.service.ClpSerializer.java
License:Open Source License
public static String getServletContextName() { if (Validator.isNotNull(_servletContextName)) { return _servletContextName; }/*from w ww .jav a2 s . co m*/ synchronized (ClpSerializer.class) { if (Validator.isNotNull(_servletContextName)) { return _servletContextName; } try { ClassLoader classLoader = ClpSerializer.class.getClassLoader(); Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps"); Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] { String.class }); String portletPropsServletContextName = (String) getMethod.invoke(null, "BBMRIERICDatabase-portlet-deployment-context"); if (Validator.isNotNull(portletPropsServletContextName)) { _servletContextName = portletPropsServletContextName; } } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to locate deployment context from portlet properties"); } } if (Validator.isNull(_servletContextName)) { try { String propsUtilServletContextName = PropsUtil .get("BBMRIERICDatabase-portlet-deployment-context"); if (Validator.isNotNull(propsUtilServletContextName)) { _servletContextName = propsUtilServletContextName; } } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to locate deployment context from portal properties"); } } } if (Validator.isNull(_servletContextName)) { _servletContextName = "BBMRIERICDatabase-portlet"; } return _servletContextName; } }
From source file:at.meduni.liferay.portlet.bbmrieric.service.impl.ContactInformationLocalServiceImpl.java
License:Open Source License
/** * //from w ww . j a v a2s. c o m * @param contactinformationId * @return */ public ContactInformation getContactInformationWithLdapUpdate(long contactinformationId) { try { ContactInformation contactinformation = ContactInformationLocalServiceUtil .getContactInformation(contactinformationId); // ServiceContext to create the assets long companyId = Long.parseLong(PropsUtil.get("D2BiobankCompany")); long groupId = Long.parseLong(PropsUtil.get("D2BiobankGroup")); ServiceContext serviceContext = new ServiceContext(); serviceContext.setAddGroupPermissions(true); serviceContext.setAddGuestPermissions(true); try { Company company = CompanyLocalServiceUtil.getCompany(companyId); serviceContext.setUserId(company.getDefaultUser().getUserId()); } catch (Exception e) { e.printStackTrace(); } serviceContext.setCompanyId(companyId); serviceContext.setScopeGroupId(groupId); // Reading data from the LDAP Hashtable<String, String> environment = new Hashtable<String, String>(); environment.put(LdapContext.CONTROL_FACTORIES, "com.sun.jndi.ldap.ControlFactory"); environment.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); environment.put(Context.PROVIDER_URL, "ldap://directory-ldap.bbmri-eric.eu:10389"); environment.put(Context.SECURITY_AUTHENTICATION, "simple"); environment.put(Context.REFERRAL, "follow"); try { Date now = new Date(); contactinformation.setModifiedDate(serviceContext.getModifiedDate(now)); DirContext ctx = new InitialDirContext(environment); SearchControls ctls = new SearchControls(); ctls.setReturningAttributes(null); ctls.setSearchScope(SearchControls.SUBTREE_SCOPE); // Search for objects using filter and controls NamingEnumeration<?> answer = ctx.search("contactID=" + contactinformation.getContactID() + ",c=" + contactinformation.getContactCountry().toLowerCase() + ",ou=contacts,dc=directory,dc=bbmri-eric,dc=eu", "(objectclass=*)", ctls); int counter = 0; int counter_contacts = 0; while (answer.hasMore()) { counter++; SearchResult sr = (SearchResult) answer.next(); Attributes attrs = sr.getAttributes(); contactinformation = ContactInformationLocalServiceUtil .contactInformationFromLdapAttribute(attrs, contactinformation); return contactInformationPersistence.update(contactinformation); } } catch (Exception ex) { System.err.println("[" + date_format_apache_error.format(new Date()) + "] [error] [" + classpath_ + "::getContactInformationWithLdapUpdate] Error updating ContactInformation Attributes"); ex.printStackTrace(); } } catch (Exception e) { System.out.println("[" + date_format_apache_error.format(new Date()) + "] [error] [" + classpath_ + "::getContactInformationWithLdapUpdate] Error getting ContactInformation with LDAP update."); e.printStackTrace(); } return null; }
From source file:at.meduni.liferay.portlet.bbmrieric.service.impl.ContactInformationLocalServiceImpl.java
License:Open Source License
public ContactInformation getContactInformationWithLdapUpdate(String contactID) { contactID = removeOtherIds(contactID); try {/*from w w w .j av a 2 s.c o m*/ long companyId = Long.parseLong(PropsUtil.get("D2BiobankCompany")); long groupId = Long.parseLong(PropsUtil.get("D2BiobankGroup")); ContactInformation contactinformation = ContactInformationLocalServiceUtil .getContactInformationByBBMRIERICID(groupId, contactID); // ServiceContext to create the assets ServiceContext serviceContext = new ServiceContext(); serviceContext.setAddGroupPermissions(true); serviceContext.setAddGuestPermissions(true); try { Company company = CompanyLocalServiceUtil.getCompany(companyId); serviceContext.setUserId(company.getDefaultUser().getUserId()); } catch (Exception e) { e.printStackTrace(); } serviceContext.setCompanyId(companyId); serviceContext.setScopeGroupId(groupId); // Reading data from the LDAP Hashtable<String, String> environment = new Hashtable<String, String>(); environment.put(LdapContext.CONTROL_FACTORIES, "com.sun.jndi.ldap.ControlFactory"); environment.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); environment.put(Context.PROVIDER_URL, "ldap://directory-ldap.bbmri-eric.eu:10389"); environment.put(Context.SECURITY_AUTHENTICATION, "simple"); environment.put(Context.REFERRAL, "follow"); try { Date now = new Date(); contactinformation.setModifiedDate(serviceContext.getModifiedDate(now)); DirContext ctx = new InitialDirContext(environment); SearchControls ctls = new SearchControls(); ctls.setReturningAttributes(null); ctls.setSearchScope(SearchControls.SUBTREE_SCOPE); // Search for objects using filter and controls NamingEnumeration<?> answer = ctx.search("contactID=" + contactinformation.getContactID() + ",c=" + contactinformation.getContactCountry().toLowerCase() + ",ou=contacts,dc=directory,dc=bbmri-eric,dc=eu", "(objectclass=*)", ctls); int counter = 0; int counter_contacts = 0; while (answer.hasMore()) { counter++; SearchResult sr = (SearchResult) answer.next(); Attributes attrs = sr.getAttributes(); contactinformation = ContactInformationLocalServiceUtil .contactInformationFromLdapAttribute(attrs, contactinformation); return contactInformationPersistence.update(contactinformation); } } catch (Exception ex) { System.err.println("[" + date_format_apache_error.format(new Date()) + "] [error] [" + classpath_ + "::getContactInformationWithLdapUpdate] Error updating ContactInformation Attributes"); ex.printStackTrace(); } } catch (Exception e) { System.out.println("[" + date_format_apache_error.format(new Date()) + "] [error] [" + classpath_ + "::getContactInformationWithLdapUpdate] Error getting ContactInformation with LDAP update."); e.printStackTrace(); } return null; }
From source file:at.meduni.liferay.portlet.bbmrieric.service.impl.D2BiobankLocalServiceImpl.java
License:Open Source License
/** * //from w ww.j av a2s . c o m */ public D2Biobank getBiobankWithLdapUpdate(long biobankId) { D2Biobank d2biobank = null; // ServiceContext to create the assets long companyId = Long.parseLong(PropsUtil.get("D2BiobankCompany")); long groupId = Long.parseLong(PropsUtil.get("D2BiobankGroup")); ServiceContext serviceContext = new ServiceContext(); serviceContext.setAddGroupPermissions(true); serviceContext.setAddGuestPermissions(true); try { Company company = CompanyLocalServiceUtil.getCompany(companyId); serviceContext.setUserId(company.getDefaultUser().getUserId()); } catch (Exception e) { e.printStackTrace(); } serviceContext.setCompanyId(companyId); serviceContext.setScopeGroupId(groupId); //------------------------------------- // Reading data from the LDAP Hashtable<String, String> environment = new Hashtable<String, String>(); environment.put(LdapContext.CONTROL_FACTORIES, "com.sun.jndi.ldap.ControlFactory"); environment.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); environment.put(Context.PROVIDER_URL, "ldap://directory-ldap.bbmri-eric.eu:10389"); environment.put(Context.SECURITY_AUTHENTICATION, "simple"); environment.put(Context.REFERRAL, "follow"); try { d2biobank = D2BiobankLocalServiceUtil.getD2Biobank(biobankId); DirContext ctx = new InitialDirContext(environment); SearchControls ctls = new SearchControls(); ctls.setReturningAttributes(null); ctls.setSearchScope(SearchControls.SUBTREE_SCOPE); // Search for objects using filter and controls String filter = "biobankID=" + d2biobank.getBbmribiobankID() + ",c=" + d2biobank.getBiobankCountry().toLowerCase() + ",ou=biobanks,dc=directory,dc=bbmri-eric,dc=eu"; NamingEnumeration<?> answer = ctx.search(filter, "(objectclass=*)", ctls); int counter_collections = 0; int counter_biobanks = 0; while (answer.hasMore()) { SearchResult sr = (SearchResult) answer.next(); Attributes attrs = sr.getAttributes(); try { if (attrs.get("biobankID") != null) { counter_biobanks++; String ldapbiobankID = getAttributeValues(attrs.get("biobankID")); d2biobank = getD2BiobankFromLDAP(d2biobank, attrs, false); D2BiobankLocalServiceUtil.updateD2Biobank(d2biobank, serviceContext); } else { /*counter_collections++; String[] ldapid = LDAPAttributeEscaper.getAttributeValues(attrs.get("collectionID")).split(":"); String bbmricollectionID = LDAPAttributeEscaper.getAttributeValues(attrs.get("collectionID")); String bbmribiobankID = ""; String bbmriparentcollectionID = ""; int idcount = 0; for(int count = ldapid.length-1; count >= 0; count--) { idcount ++; if(ldapid[count].equals("collection")) { if(idcount > 2) { for(int parentcounter = 0; parentcounter < ldapid.length-1; parentcounter++) { if(bbmriparentcollectionID.length() != 0) { bbmriparentcollectionID += ":"; } bbmriparentcollectionID += ldapid[parentcounter]; } break; } else { break; } } } for(int count = 0; count < ldapid.length-idcount; count++) { if(bbmribiobankID.length() != 0) { bbmribiobankID += ":"; } bbmribiobankID += ldapid[count]; }*/ String id_string = sr.getNameInNamespace(); String bbmricollectionID = LDAPAttributeEscaper .getAttributeValues(attrs.get("collectionID")); String bbmribiobankID = ""; String bbmriparentcollectionID = ""; String[] ldapid = id_string.split(","); boolean firstid = true; for (String id : ldapid) { if (firstid) { firstid = false; continue; } String[] title_id = id.split("="); if (title_id[0].equalsIgnoreCase("collectionID") && bbmriparentcollectionID.equals("")) { bbmriparentcollectionID = title_id[1]; continue; } if (title_id[0].equalsIgnoreCase("biobankID")) { bbmribiobankID = title_id[1]; break; } } long parentcollectionId = 0; if (!bbmriparentcollectionID.equals("")) { D2Collection parentcollection = D2CollectionLocalServiceUtil .getD2CollectionByBBMRIERICID(groupId, bbmriparentcollectionID, bbmribiobankID); if (parentcollection != null) { parentcollectionId = parentcollection.getD2collectionId(); } } D2Collection collection = D2CollectionLocalServiceUtil.getD2CollectionByBBMRIERICID(groupId, bbmricollectionID, bbmribiobankID); if (collection == null) { serviceContext.setCreateDate(new Date()); collection = D2CollectionLocalServiceUtil.getD2CollectionFromLDAP(collection, attrs, sr, false); collection.setBiobankId(biobankId); collection.setParentd2collectionId(parentcollectionId); collection = D2CollectionLocalServiceUtil.addD2Collection(collection, serviceContext); } else { collection = D2CollectionLocalServiceUtil.getD2CollectionFromLDAP(collection, attrs, sr, false); collection.setBiobankId(biobankId); collection.setParentd2collectionId(parentcollectionId); collection = D2CollectionLocalServiceUtil.updateD2Collection(collection, serviceContext); } } } catch (Exception ex) { System.err.println("[" + date_format_apache_error.format(new Date()) + "] [error] [BBMRIERICDatabase-portlet::at.meduni.liferay.portlet.bbmrieric.scheduler.LDAPSyncService::connectLDAP] Error Creating Entrys for Biobank: " + getAttributeValues(attrs.get("biobankName"))); ex.printStackTrace(); } } System.out.println("LDAP contained: " + counter_biobanks + " Biobanks and " + counter_collections + " Collections"); } catch (Exception ex) { System.err.println("[" + date_format_apache_error.format(new Date()) + "] [error] [BBMRIERICDatabase-portlet::at.meduni.liferay.portlet.bbmrieric.scheduler.LDAPSyncService::connectLDAP] Error reading data from LDAP Server."); ex.printStackTrace(); } return d2biobank; }
From source file:at.meduni.liferay.portlet.bbmrieric.services.service.ClpSerializer.java
License:Open Source License
public static String getServletContextName() { if (Validator.isNotNull(_servletContextName)) { return _servletContextName; }/*w w w . j a va2 s. com*/ synchronized (ClpSerializer.class) { if (Validator.isNotNull(_servletContextName)) { return _servletContextName; } try { ClassLoader classLoader = ClpSerializer.class.getClassLoader(); Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps"); Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] { String.class }); String portletPropsServletContextName = (String) getMethod.invoke(null, "BBMRIERIC-portlet-deployment-context"); if (Validator.isNotNull(portletPropsServletContextName)) { _servletContextName = portletPropsServletContextName; } } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to locate deployment context from portlet properties"); } } if (Validator.isNull(_servletContextName)) { try { String propsUtilServletContextName = PropsUtil.get("BBMRIERIC-portlet-deployment-context"); if (Validator.isNotNull(propsUtilServletContextName)) { _servletContextName = propsUtilServletContextName; } } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to locate deployment context from portal properties"); } } } if (Validator.isNull(_servletContextName)) { _servletContextName = "BBMRIERIC-portlet"; } return _servletContextName; } }
From source file:at.meduni.liferay.portlet.rdconnect.service.ClpSerializer.java
License:Open Source License
public static String getServletContextName() { if (Validator.isNotNull(_servletContextName)) { return _servletContextName; }/*from w w w. java 2 s. c o m*/ synchronized (ClpSerializer.class) { if (Validator.isNotNull(_servletContextName)) { return _servletContextName; } try { ClassLoader classLoader = ClpSerializer.class.getClassLoader(); Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps"); Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] { String.class }); String portletPropsServletContextName = (String) getMethod.invoke(null, "RDConnect-portlet-deployment-context"); if (Validator.isNotNull(portletPropsServletContextName)) { _servletContextName = portletPropsServletContextName; } } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to locate deployment context from portlet properties"); } } if (Validator.isNull(_servletContextName)) { try { String propsUtilServletContextName = PropsUtil.get("RDConnect-portlet-deployment-context"); if (Validator.isNotNull(propsUtilServletContextName)) { _servletContextName = propsUtilServletContextName; } } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to locate deployment context from portal properties"); } } } if (Validator.isNull(_servletContextName)) { _servletContextName = "RDConnect-portlet"; } return _servletContextName; } }
From source file:at.pw.service.ClpSerializer.java
License:Open Source License
public static String getServletContextName() { if (Validator.isNotNull(_servletContextName)) { return _servletContextName; }/*from www . j a v a 2 s .c o m*/ synchronized (ClpSerializer.class) { if (Validator.isNotNull(_servletContextName)) { return _servletContextName; } try { ClassLoader classLoader = ClpSerializer.class.getClassLoader(); Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps"); Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] { String.class }); String portletPropsServletContextName = (String) getMethod.invoke(null, "PW-portlet-deployment-context"); if (Validator.isNotNull(portletPropsServletContextName)) { _servletContextName = portletPropsServletContextName; } } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to locate deployment context from portlet properties"); } } if (Validator.isNull(_servletContextName)) { try { String propsUtilServletContextName = PropsUtil.get("PW-portlet-deployment-context"); if (Validator.isNotNull(propsUtilServletContextName)) { _servletContextName = propsUtilServletContextName; } } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to locate deployment context from portal properties"); } } } if (Validator.isNull(_servletContextName)) { _servletContextName = "PW-portlet"; } return _servletContextName; } }
From source file:at.rdconnect.update.service.ClpSerializer.java
License:Open Source License
public static String getServletContextName() { if (Validator.isNotNull(_servletContextName)) { return _servletContextName; }//from w ww. ja va2 s . co m synchronized (ClpSerializer.class) { if (Validator.isNotNull(_servletContextName)) { return _servletContextName; } try { ClassLoader classLoader = ClpSerializer.class.getClassLoader(); Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps"); Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] { String.class }); String portletPropsServletContextName = (String) getMethod.invoke(null, "UpdateRDConnect-portlet-deployment-context"); if (Validator.isNotNull(portletPropsServletContextName)) { _servletContextName = portletPropsServletContextName; } } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to locate deployment context from portlet properties"); } } if (Validator.isNull(_servletContextName)) { try { String propsUtilServletContextName = PropsUtil .get("UpdateRDConnect-portlet-deployment-context"); if (Validator.isNotNull(propsUtilServletContextName)) { _servletContextName = propsUtilServletContextName; } } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to locate deployment context from portal properties"); } } } if (Validator.isNull(_servletContextName)) { _servletContextName = "UpdateRDConnect-portlet"; } return _servletContextName; } }
From source file:au.com.billingbuddy.porlet.services.service.ClpSerializer.java
License:Open Source License
public static String getServletContextName() { if (Validator.isNotNull(_servletContextName)) { return _servletContextName; }/*from ww w . java 2s . co m*/ synchronized (ClpSerializer.class) { if (Validator.isNotNull(_servletContextName)) { return _servletContextName; } try { ClassLoader classLoader = ClpSerializer.class.getClassLoader(); Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps"); Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] { String.class }); String portletPropsServletContextName = (String) getMethod.invoke(null, "BusinessType-portlet-deployment-context"); if (Validator.isNotNull(portletPropsServletContextName)) { _servletContextName = portletPropsServletContextName; } } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to locate deployment context from portlet properties"); } } if (Validator.isNull(_servletContextName)) { try { String propsUtilServletContextName = PropsUtil.get("BusinessType-portlet-deployment-context"); if (Validator.isNotNull(propsUtilServletContextName)) { _servletContextName = propsUtilServletContextName; } } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to locate deployment context from portal properties"); } } } if (Validator.isNull(_servletContextName)) { _servletContextName = "BusinessType-portlet"; } return _servletContextName; } }