List of usage examples for java.text Collator equals
public boolean equals(String source, String target)
From source file:Decomposition.java
public void compare(Collator c, String a, String b) { switch (c.getDecomposition()) { case Collator.NO_DECOMPOSITION: System.out.print(" NO DECOMPOSITION: "); break;//from w w w . jav a 2s .co m case Collator.CANONICAL_DECOMPOSITION: System.out.print(" CANONICAL DECOMPOSITION: "); break; case Collator.FULL_DECOMPOSITION: System.out.print(" FULL DECOMPOSITION: "); break; default: System.out.print(" UNKNOWN DECOMPOSITION: "); } if (c.equals(a, b)) System.out.println("The strings are equal."); else System.out.println("The strings are NOT equal."); }
From source file:com.google.enterprise.connector.sharepoint.client.SiteDataHelper.java
/** * Gets the collection of all the lists on the sharepoint server which are of * a given type. E.g., DocumentLibrary//from w ww .j a va 2 s. co m * * @param webstate The web from which the list/libraries are to be discovered * @return list of BaseList objects. */ public List<ListState> getNamedLists(final WebState webstate) { final ArrayList<ListState> listCollection = new ArrayList<ListState>(); if (webstate == null) { LOGGER.warning("Unable to get the list collection because webstate is null"); return listCollection; } final ArrayOf_sListHolder vLists = Util.makeWSRequest(sharepointClientContext, siteDataWS, new Util.RequestExecutor<ArrayOf_sListHolder>() { public ArrayOf_sListHolder onRequest(final BaseWS ws) throws Throwable { return ((SiteDataWS) ws).getListCollection(); } public void onError(final Throwable e) { LOGGER.log(Level.WARNING, "Call to getListCollection failed.", e); } }); if (vLists == null) { LOGGER.log(Level.WARNING, "Unable to get the list collection"); return listCollection; } final Collator collator = Util.getCollator(); try { final _sList[] sl = vLists.value; if (sl != null) { webstate.setExisting(true); for (_sList element : sl) { String url = null; String strBaseTemplate = null; if (element == null) { continue; } final String baseType = element.getBaseType(); LOGGER.log(Level.FINE, "Base Type returned by the Web Service : " + baseType); if (!collator.equals(baseType, (SPConstants.DISCUSSION_BOARD)) && !collator.equals(baseType, (SPConstants.DOC_LIB)) && !collator.equals(baseType, (SPConstants.GENERIC_LIST)) && !collator.equals(baseType, (SPConstants.ISSUE)) && !collator.equals(baseType, (SPConstants.SURVEYS))) { LOGGER.log(Level.WARNING, "Skipping List [{0}] with unsupported base type [{1}]", new Object[] { element.getTitle(), baseType }); continue; } MessageElement listMetadata = getListMetadata(element.getInternalName()); if (listMetadata == null) { LOGGER.log(Level.WARNING, "Unable to get metadata for List [{0}]. Skipping List", element.getTitle()); continue; } String rootFolder = getMetadataAttributeForList(listMetadata, "RootFolder"); if (Strings.isNullOrEmpty(rootFolder)) { LOGGER.log(Level.WARNING, "Unable to get Root Folder for List [{0}]. Skipping List", element.getTitle()); continue; } String defaultViewItemUrl = getMetadataAttributeForList(listMetadata, "DefaultViewItemUrl"); if (Strings.isNullOrEmpty(defaultViewItemUrl)) { LOGGER.log(Level.WARNING, "Unable to get default View Item Url " + "for List [{0}]. Skipping List", element.getTitle()); continue; } LOGGER.log(Level.FINE, "List [{0}] Root Folder [{1}] Default View Item URL [{2}]", new Object[] { element.getTitle(), rootFolder, defaultViewItemUrl }); String siteUrl = sharepointClientContext.getSiteURL(); if (Strings.isNullOrEmpty(element.getDefaultViewUrl())) { LOGGER.log(Level.WARNING, "List [{0}] with empty default view URL." + " Using root folder for List URL.", element.getTitle()); StringBuilder listUrl = new StringBuilder(siteUrl); if (!siteUrl.endsWith("/")) { listUrl.append("/"); } listUrl.append(rootFolder); url = listUrl.toString(); } else { url = Util.getWebApp(sharepointClientContext.getSiteURL()) + element.getDefaultViewUrl(); } LOGGER.log(Level.INFO, "List url for List [{0}] is [{1}]", new Object[] { element.getTitle(), url }); strBaseTemplate = element.getBaseTemplate(); if (strBaseTemplate == null) { strBaseTemplate = SPConstants.NO_TEMPLATE; } else if (collator.equals(strBaseTemplate, SPConstants.ORIGINAL_BT_SLIDELIBRARY)) {// for // SlideLibrary strBaseTemplate = SPConstants.BT_SLIDELIBRARY; } else if (collator.equals(strBaseTemplate, SPConstants.ORIGINAL_BT_TRANSLATIONMANAGEMENTLIBRARY)) {// for // TranslationManagementLibrary strBaseTemplate = SPConstants.BT_TRANSLATIONMANAGEMENTLIBRARY; } else if (collator.equals(strBaseTemplate, SPConstants.ORIGINAL_BT_TRANSLATOR)) {// for // Translator strBaseTemplate = SPConstants.BT_TRANSLATOR; } else if (collator.equals(strBaseTemplate, SPConstants.ORIGINAL_BT_REPORTLIBRARY)) {// for // ReportLibrary strBaseTemplate = SPConstants.BT_REPORTLIBRARY; } else if (collator.equals(strBaseTemplate, SPConstants.ORIGINAL_BT_PROJECTTASK)) {// for // ReportLibrary strBaseTemplate = SPConstants.BT_PROJECTTASK; } else if (collator.equals(strBaseTemplate, SPConstants.ORIGINAL_BT_SITESLIST)) {// for // ReportLibrary strBaseTemplate = SPConstants.BT_SITESLIST; } else { // for FormLibrary for (String formTemplate : sharepointClientContext.getInfoPathBaseTemplate()) { if (collator.equals(strBaseTemplate, formTemplate)) { strBaseTemplate = SPConstants.BT_FORMLIBRARY; break; } } } LOGGER.config("List URL :" + url); // Children of all URLs are discovered ListState list = new ListState(element.getInternalName(), element.getTitle(), element.getBaseType(), Util.siteDataStringToCalendar(element.getLastModified()), strBaseTemplate, url, webstate); list.setInheritedSecurity(element.isInheritedSecurity()); list.setApplyReadSecurity(element.getReadSecurity() == 2); String myNewListConst = ""; LOGGER.log(Level.FINE, "getting listConst for list URL [{0}]", defaultViewItemUrl); if (defaultViewItemUrl != null) { final StringTokenizer strTokList = new StringTokenizer(defaultViewItemUrl, SPConstants.SLASH); if (null != strTokList) { while ((strTokList.hasMoreTokens()) && (strTokList.countTokens() > 1)) { final String listToken = strTokList.nextToken(); if (list.isDocumentLibrary() && listToken.equals(SPConstants.FORMS_LIST_URL_SUFFIX) && (strTokList.countTokens() == 1)) { break; } if (null != listToken) { myNewListConst += listToken + SPConstants.SLASH; } } list.setListConst(myNewListConst); LOGGER.log(Level.CONFIG, "using listConst [ " + myNewListConst + " ] for list URL [ " + defaultViewItemUrl + " ] "); // Apply the URL filter here // check if the entire list subtree is to excluded // by comparing the prefix of the list URL with the // patterns if (sharepointClientContext .isIncludedUrl(webstate.getWebUrl() + SPConstants.SLASH + myNewListConst)) { // is included check if actual list url itself // is to be excluded if (sharepointClientContext.isIncludedUrl(url, LOGGER)) { // if a List URL is included, it WILL be // sent as a // Document list.setSendListAsDocument(true); } else { // if a List URL is EXCLUDED, it will NOT be // sent as a // Document list.setSendListAsDocument(false); } // add the attribute(Metadata to the list ) list = getListWithAllAttributes(list, element); listCollection.add(list); } else { // entire subtree is to be excluded // do not construct list state LOGGER.finest("Excluding " + url + " because entire subtree of " + myNewListConst + " is excluded"); } } } // Sort the base list Collections.sort(listCollection); } } } catch (final Throwable e) { LOGGER.log(Level.FINER, e.getMessage(), e); } if (listCollection.size() > 0) { LOGGER.info("Discovered " + listCollection.size() + " lists/libraries under site [ " + webstate + " ] for crawling"); } else { LOGGER.config("No lists/libraries to crawl under site [ " + webstate + " ]"); } return listCollection; }
From source file:com.google.enterprise.connector.sharepoint.spiimpl.SPDocument.java
/** Returns meta-data property value associated with Attribute for Given * attribute name./*from w w w. ja v a 2 s . c om*/ */ public String getMetaDataAttributeValue(final String strPropertyName) { final Collator collator = Util.getCollator(); for (Attribute attr : getAllAttrs()) { if (collator.equals(strPropertyName, attr.getName())) { return attr.getValue().toString(); } } return null; }
From source file:com.google.enterprise.connector.sharepoint.spiimpl.SPDocument.java
/** * Returns the property object for a given property name. CM calls this to * gather all the information about a document. The property names that are * requested can be either well known properties defined under connector SPI * or, connector can inform them pre-hand during the call to getAll * propertoes./* w ww .j a v a 2 s.c o m*/ */ @Override public Property findProperty(final String strPropertyName) throws RepositoryException { if (!sharepointClientContext.isPushAcls() && documentType == DocumentType.ACL) { throw new SkippedDocumentException("This should not happen here, isToBeFed() = " + isToBeFed() + ". Skipping document [" + url + "] as DocumentType is ACL and PushAcls is false."); } final Collator collator = Util.getCollator(); if (collator.equals(strPropertyName, SpiConstants.PROPNAME_CONTENT)) { if (FeedType.CONTENT_FEED == getFeedType() && ActionType.ADD.equals(getAction())) { synchronized (this) { if (content == null || content.isConsumed()) { content = downloadContents(); } InputStream contentStream = content.getContentStream(); return (contentStream == null) ? null : new SimpleProperty(Value.getBinaryValue(contentStream)); } } } else if (collator.equals(strPropertyName, SpiConstants.PROPNAME_MIMETYPE)) { if (FeedType.CONTENT_FEED == getFeedType() && ActionType.ADD.equals(getAction())) { synchronized (this) { if (content == null || content.getContentType() == null) { content = downloadContents(); } String contentType = content.getContentType(); return (contentType == null) ? null : new SimpleProperty(Value.getStringValue(contentType)); } } } else if (collator.equals(strPropertyName, SPConstants.HTTP_STATUS_CODE)) { if (FeedType.CONTENT_FEED == getFeedType()) { synchronized (this) { if (content == null) { content = downloadContents(); } if (content.getStatusCode() != 0) { return new SimpleProperty(Value.getLongValue(content.getStatusCode())); } else { return null; } } } } else if (collator.equals(strPropertyName, SpiConstants.PROPNAME_SEARCHURL)) { if (FeedType.CONTENT_FEED != getFeedType()) { // TODO Handle ACL feed here. return new SimpleProperty(Value.getStringValue(getUrl())); } } else if (collator.equals(strPropertyName, SpiConstants.PROPNAME_ACLINHERITANCETYPE)) { if (!isWebAppPolicyDoc() && parentUrl == null) { // Returning null as ACL information is not complete. // Every Inherited ACL should have parentUrl other than // web application policy document. return null; } return new SimpleProperty( Value.getStringValue(SpiConstants.AclInheritanceType.PARENT_OVERRIDES.toString())); } else if (collator.equals(strPropertyName, SpiConstants.PROPNAME_ACLINHERITFROM_DOCID)) { String parentUrlToSend = getParentUrl(); if (parentUrlToSend == null) { return null; } if (getFeedType() == FeedType.CONTENT_FEED) { parentUrlToSend = parentUrlToSend + "|" + getParentId().toUpperCase(); } return new SimpleProperty(Value.getStringValue(parentUrlToSend)); } else if (collator.equals(strPropertyName, SpiConstants.PROPNAME_ACLINHERITFROM)) { String parentUrlToSend = getParentUrl(); if (FeedType.CONTENT_FEED == getFeedType()) { return null; } return new SimpleProperty(Value.getStringValue(parentUrlToSend)); } else if (collator.equals(strPropertyName, SpiConstants.PROPNAME_FEEDTYPE)) { return new SimpleProperty(Value.getStringValue(feedType.toString())); } else if (collator.equals(strPropertyName, SpiConstants.PROPNAME_ACLINHERITFROM_FEEDTYPE)) { return new SimpleProperty(Value.getStringValue(feedType.toString())); } else if (collator.equals(strPropertyName, SpiConstants.PROPNAME_DISPLAYURL)) { return new SimpleProperty(Value.getStringValue(displayUrl)); } else if (collator.equals(strPropertyName, SPConstants.PARENT_WEB_TITLE)) { return new SimpleProperty(Value.getStringValue(getParentWebTitle())); } else if (collator.equals(strPropertyName, SpiConstants.PROPNAME_DOCID)) { return new SimpleProperty(Value.getStringValue(getDocId())); } else if (collator.equals(strPropertyName, SpiConstants.PROPNAME_LASTMODIFIED)) { return new SimpleProperty(Value.getDateValue(getLastMod())); } else if (collator.equals(strPropertyName, SPConstants.LIST_GUID)) { if (null != getParentList()) { return new SimpleProperty(Value.getStringValue(getParentList().getPrimaryKey())); } } else if (collator.equals(strPropertyName, SPConstants.SPAUTHOR)) { return new SimpleProperty(Value.getStringValue(getAuthor())); } else if (strPropertyName.equals(SPConstants.OBJECT_TYPE)) { return new SimpleProperty(Value.getStringValue(getObjType())); } else if (strPropertyName.equals(SpiConstants.PROPNAME_ISPUBLIC)) { return new SimpleProperty(Value.getBooleanValue(publicDocument)); } else if (strPropertyName.equals(SpiConstants.PROPNAME_ACTION)) { return new SimpleProperty(Value.getStringValue(getAction().toString())); } else if (strPropertyName.equals(SpiConstants.PROPNAME_ACLDENYUSERS)) { return getPrincipalProperty(aclDenyUsers); } else if (strPropertyName.equals(SpiConstants.PROPNAME_ACLDENYGROUPS)) { return getPrincipalProperty(aclDenyGroups); } else if (strPropertyName.equals(SpiConstants.PROPNAME_ACLUSERS)) { return getPrincipalProperty(aclUsers); } else if (strPropertyName.equals(SpiConstants.PROPNAME_ACLGROUPS)) { return getPrincipalProperty(aclGroups); } else if (strPropertyName.startsWith(SpiConstants.PROPNAME_TITLE)) { return new SimpleProperty(Value.getStringValue(title)); } else if (strPropertyName.equals(SpiConstants.PROPNAME_DOCUMENTTYPE)) { if (documentType != null) { return new SimpleProperty(Value.getStringValue(documentType.toString())); } else { return null; } } else { // FIXME: We can get rid of this if-else-if ladder here by setting all // the relevant properties (in appropriate type) right at the time of // document creation. After doing that, all that will be required is to // maintain a map of all the properties with key as the prop name. This // will also eliminate maintaining multiple member attributes in this // class. All the attribute will be there in a common map. for (final Iterator<Attribute> iter = getAllAttrs().iterator(); iter.hasNext();) { final Attribute attr = iter.next(); if (collator.equals(strPropertyName, attr.getName())) { String strAttrValue = attr.getValue().toString(); // Current approach is to parse field values for ;# characters. // TODO Utilize SharePoint Field meta-data and process values // for only columns with SharePoint Field type as // "LookupMulti" or "MultiChoice" List<Value> valuesToPass; if (null != strAttrValue) { List<String> values = Util.processMultiValueMetadata(strAttrValue); valuesToPass = new ArrayList<Value>(); for (String str : values) { valuesToPass.add(Value.getStringValue(str)); } } else { valuesToPass = null; } return new SimpleProperty(valuesToPass); } } } LOGGER.finer("no matches found for[" + strPropertyName + "]"); return null;// no matches found }
From source file:com.google.enterprise.connector.sharepoint.wsclient.soap.SPSiteDataWS.java
/** * Gets the collection of all the lists on the sharepoint server which are of * a given type. E.g., DocumentLibrary//from w w w . ja va 2 s.c o m * * @param webstate The web from which the list/libraries are to be discovered * @return list of BaseList objects. */ public List<ListState> getNamedLists(final WebState webstate) throws SharepointException { final ArrayList<ListState> listCollection = new ArrayList<ListState>(); if (stub == null) { LOGGER.warning("Unable to get the list collection because stub is null"); return listCollection; } if (webstate == null) { LOGGER.warning("Unable to get the list collection because webstate is null"); return listCollection; } final Collator collator = Util.getCollator(); final ArrayOf_sListHolder vLists = new ArrayOf_sListHolder(); final UnsignedIntHolder getListCollectionResult = new UnsignedIntHolder(); try { stub.getListCollection(getListCollectionResult, vLists); } catch (final AxisFault af) { // Handling of username formats for // different authentication models. if ((SPConstants.UNAUTHORIZED.indexOf(af.getFaultString()) != -1) && (sharepointClientContext.getDomain() != null)) { final String username = Util.switchUserNameFormat(stub.getUsername()); LOGGER.log(Level.CONFIG, "Web Service call failed for username [ " + stub.getUsername() + " ]. Trying with " + username); stub.setUsername(username); try { stub.getListCollection(getListCollectionResult, vLists); } catch (final Exception e) { LOGGER.log(Level.WARNING, "Unable to get List Collection for stubURL[ " + sharepointClientContext.getSiteURL() + " ].", e); } } else { LOGGER.log(Level.WARNING, "Unable to get List Collection for stubURL[ " + sharepointClientContext.getSiteURL() + " ].", af); } } catch (final Throwable e) { LOGGER.log(Level.WARNING, "Unable to get List Collection for stubURL[ " + sharepointClientContext.getSiteURL() + " ].", e); } if (vLists == null) { LOGGER.log(Level.WARNING, "Unable to get the list collection"); return listCollection; } try { final _sList[] sl = vLists.value; if (sl != null) { webstate.setExisting(true); for (_sList element : sl) { String url = null; String strBaseTemplate = null; if (element == null) { continue; } final String baseType = element.getBaseType(); LOGGER.log(Level.FINE, "Base Type returned by the Web Service : " + baseType); if (!collator.equals(baseType, (SPConstants.DISCUSSION_BOARD)) && !collator.equals(baseType, (SPConstants.DOC_LIB)) && !collator.equals(baseType, (SPConstants.GENERIC_LIST)) && !collator.equals(baseType, (SPConstants.ISSUE)) && !collator.equals(baseType, (SPConstants.SURVEYS))) { continue; } url = Util.getWebApp(sharepointClientContext.getSiteURL()) + element.getDefaultViewUrl(); strBaseTemplate = element.getBaseTemplate(); if (strBaseTemplate == null) { strBaseTemplate = SPConstants.NO_TEMPLATE; } else if (collator.equals(strBaseTemplate, SPConstants.ORIGINAL_BT_SLIDELIBRARY)) {// for // SlideLibrary strBaseTemplate = SPConstants.BT_SLIDELIBRARY; } else if (collator.equals(strBaseTemplate, SPConstants.ORIGINAL_BT_TRANSLATIONMANAGEMENTLIBRARY)) {// for // TranslationManagementLibrary strBaseTemplate = SPConstants.BT_TRANSLATIONMANAGEMENTLIBRARY; } else if (collator.equals(strBaseTemplate, SPConstants.ORIGINAL_BT_TRANSLATOR)) {// for // Translator strBaseTemplate = SPConstants.BT_TRANSLATOR; } else if (collator.equals(strBaseTemplate, SPConstants.ORIGINAL_BT_REPORTLIBRARY)) {// for // ReportLibrary strBaseTemplate = SPConstants.BT_REPORTLIBRARY; } else if (collator.equals(strBaseTemplate, SPConstants.ORIGINAL_BT_PROJECTTASK)) {// for // ReportLibrary strBaseTemplate = SPConstants.BT_PROJECTTASK; } else if (collator.equals(strBaseTemplate, SPConstants.ORIGINAL_BT_SITESLIST)) {// for // ReportLibrary strBaseTemplate = SPConstants.BT_SITESLIST; } else { // for FormLibrary for (String formTemplate : sharepointClientContext.getInfoPathBaseTemplate()) { if (collator.equals(strBaseTemplate, formTemplate)) { strBaseTemplate = SPConstants.BT_FORMLIBRARY; break; } } } LOGGER.config("List URL :" + url); // Children of all URLs are discovered ListState list = new ListState(element.getInternalName(), element.getTitle(), element.getBaseType(), Util.siteDataStringToCalendar(element.getLastModified()), strBaseTemplate, url, webstate); list.setInheritedSecurity(element.isInheritedSecurity()); list.setApplyReadSecurity(element.getReadSecurity() == 2); String myNewListConst = ""; final String listUrl = element.getDefaultViewUrl();// e.g. // /sites/abc/Lists/Announcements/AllItems.aspx LOGGER.log(Level.FINE, "getting listConst for list URL [ " + listUrl + " ] "); if ((listUrl != null) /* && (siteRelativeUrl!=null) */) { final StringTokenizer strTokList = new StringTokenizer(listUrl, SPConstants.SLASH); if (null != strTokList) { while ((strTokList.hasMoreTokens()) && (strTokList.countTokens() > 1)) { final String listToken = strTokList.nextToken(); if (list.isDocumentLibrary() && listToken.equals(SPConstants.FORMS_LIST_URL_SUFFIX) && (strTokList.countTokens() == 1)) { break; } if (null != listToken) { myNewListConst += listToken + SPConstants.SLASH; } } list.setListConst(myNewListConst); LOGGER.log(Level.CONFIG, "using listConst [ " + myNewListConst + " ] for list URL [ " + listUrl + " ] "); // Apply the URL filter here // check if the entire list subtree is to excluded // by comparing the prefix of the list URL with the // patterns if (sharepointClientContext .isIncludedUrl(webstate.getWebUrl() + SPConstants.SLASH + myNewListConst)) { // is included check if actual list url itself // is to be excluded if (sharepointClientContext.isIncludedUrl(url)) { // if a List URL is included, it WILL be // sent as a // Document list.setSendListAsDocument(true); } else { // if a List URL is EXCLUDED, it will NOT be // sent as a // Document list.setSendListAsDocument(false); LOGGER.warning("excluding " + url.toString()); } // add the attribute(Metadata to the list ) list = getListWithAllAttributes(list, element); listCollection.add(list); } else { // entire subtree is to be excluded // do not construct list state LOGGER.warning("Excluding " + url + " because entire subtree of " + myNewListConst + " is excluded"); } } } // Sort the base list Collections.sort(listCollection); // dumpcollection(listCollection); } } } catch (final Throwable e) { LOGGER.log(Level.FINER, e.getMessage(), e); return listCollection; } if (listCollection.size() > 0) { LOGGER.info("Discovered " + listCollection.size() + " lists/libraries under site [ " + webstate + " ] for crawling"); } else { LOGGER.config("No lists/libraries to crawl under site [ " + webstate + " ]"); } return listCollection; }