Powered By Blogger

Wednesday, February 1, 2012

Sharepoint flow in Alfresco 3.4.5


${vti.share.siteInBrowser}

${vti.share.siteSettings}

${vti.share.siteGroupMembership}

${vti.share.userInformation}

${vti.share.documentLibrary}

${vti.share.documentDetails}

${vti.share.calendar}



The above bean declaration is using properties defined in the vti.properties which are speciic to site.


vti.share.siteSettings=/page/site/.../customise-site

vti.share.siteGroupMembership=/page/site/.../site-members

vti.share.userInformation=/page/user/.../profile

vti.share.documentLibrary=/page/site/.../documentlibrary

vti.share.documentDetails=/page/site/.../document-details

vti.share.calendar=/page/site/.../calendar



In the run time these values will be used by MS office.


  • alfresco-vti-3.4.5.jar is using the code required for the sharepoint communication.


AlfrescoDwsServiceHandler has the implementation to replace the node id urls



String uuid = req.getParameter("nodeId");


String uri = req.getRequestURI();

String redirectTo;


if (uuid != null)

{

// open site in browser

final NodeRef siteNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, uuid.toLowerCase());

redirectTo = pagesMap.get("siteInBrowser");

redirectTo = redirectTo.replace("...", siteNodeRef.getId());

}





  • Communication happens with MS office docs using WebService response.




here it is pointing to sites.








It talks about what info is required for integration in the class DwsServiceHandler


/**

* Returns information about a document workspace site and the lists it contains

*

* @param document the site-based URL of a document in a document library in the document workspace site

* @param id an optional document globally unique identifier (GUID)

* @param minimal determines whether the output includes information about the schemas, lists, documents, links, and tasks lists of a document workspace site

* @return DwsMetadata information about a document workspace site and the lists it contains ({@link DwsMetadata})

*/

public DwsMetadata getDWSMetaData(String documentURL, String id, boolean minimal) throws Exception;



If we have to support sharepoint protocol then we should have details about tasks,links and document list but in the normal doc we will not have this information.




The server will be done using the bean







The logs are as below


05:50:18,573 DEBUG [vti.web.VtiFilter] Checking request for VTI

05:50:18,573 DEBUG [vti.web.VtiFilter] Check authentication

05:50:18,591 DEBUG [module.vti.handler] Resolved file info for 'templatechange/_vti_bin/_vti_aut/author.dll' is null

05:50:18,596 DEBUG [module.vti.handler] Resolved file info for 'templatechange/_vti_bin/_vti_aut' is null

05:50:18,600 DEBUG [module.vti.handler] Resolved file info for 'templatechange/_vti_bin' is null

05:50:18,607 DEBUG [module.vti.handler] Resolved file info for 'templatechange' is FileInfo[name=templatechange, isFolder=true, nodeRef=workspace://SpacesStore/cb5eb9d0-81ad-43d3-8ef7-c059b1b88704]

05:50:18,617 DEBUG [alfresco.v3.AlfrescoMethodHandler] WebUrl: /alfresco/templatechange, fileUrl: '_vti_bin/_vti_aut/author.dll'

05:50:18,634 DEBUG [vti.web.VtiFilter] User was authenticated successfully

05:50:18,635 DEBUG [vti.web.VtiRequestDispatcher] Process request

05:50:18,635 DEBUG [vti.web.VtiRequestDispatcher] Find appropriate action by specific rules

05:50:18,635 DEBUG [vti.web.VtiRequestDispatcher] Specific rule not found

05:50:18,635 DEBUG [vti.web.VtiRequestDispatcher] Find appropriate action by pattern for uri='/templatechange/_vti_bin/_vti_aut/author.dll'

05:50:18,635 DEBUG [vti.web.VtiRequestDispatcher] Action found for request

05:50:18,635 DEBUG [vti.web.VtiRequestDispatcher] Execute target action

05:50:18,636 DEBUG [web.actions.VtiBinAction] Executing vtiMethod: org.alfresco.module.vti.web.fp.CheckoutDocumentMethod@3941f799

05:50:18,636 DEBUG [web.fp.CheckoutDocumentMethod] Start method execution. Method name: checkout document

05:50:18,636 DEBUG [handler.alfresco.AbstractAlfrescoMethodHandler] Checkout document: documentLibrary/test.doc. Site name: templatechange

05:50:18,647 DEBUG [module.vti.handler] Resolved file info for 'templatechange/documentLibrary/test.doc' is FileInfo[name=test.doc, isFolder=false, nodeRef=workspace://SpacesStore/ee54a9a8-837a-43f1-b02e-276d2603861a]

05:50:18,704 DEBUG [handler.alfresco.AbstractAlfrescoMethodHandler] Short-term checkout.

05:50:18,870 DEBUG [module.vti.handler] Convert FileInfo[name=test.doc, isFolder=false, nodeRef=workspace://SpacesStore/ee54a9a8-837a-43f1-b02e-276d2603861a] to url path 'templatechange/documentLibrary/test.doc'

05:50:18,871 DEBUG [web.fp.CheckoutDocumentMethod] End of method execution. Method name: checkout document




The flow will be



Filter → Handler →Request Dispatcher → Action(VtiBinAction) → Method




Authentication itself is been checked using the siteservice in the Group AlfrescoUserGroupServiceHandler.


/**

* @see org.alfresco.module.vti.handler.UserGroupServiceHandler#isUserMember(java.lang.String, java.lang.String)

*/

public boolean isUserMember(String dwsUrl, String username)

{

// Normalize the user ID taking into account case sensitivity settings

String normalized = personService.getUserIdentifier(username);

if (normalized == null)

{

return false;

}

boolean isMember = siteService.isMember(dwsUrl, normalized);

if (!isMember && authorityService.isAdminAuthority(username))

{

// Admin is allowed to do things even on sites they're not

// a member of. So, pretend they are a member so they're allowed

isMember = true;

}

return isMember;

}




In the DefaultAuthenticationHandler class it checks whether user belongs to site or not


authenticateRequest() → which inturn checks for whether user belongs to site or not. All the requests will be going through the filter and filter calls authentication code. There it fails since the user is not belonging to any of the site.



Conclusion :

All the requests will be passing through the filter which checks whether user belongs to any of the site or not. If the user is not member of the site then user will be stopped from accssing the document.


VtiFilter checks with authenticationhandler.


user = authenticationHandler.authenticateRequest(this.context, httpRequest, httpResponse, getAlfrescoContext());




public SessionUser authenticateRequest(ServletContext context, HttpServletRequest request, HttpServletResponse response,

String alfrescoContext) throws IOException, ServletException

{

if (delegate.authenticateRequest(context, request, response))

{

HttpSession session = request.getSession(false);

if (session == null)

{

return null;

}

SessionUser user = (SessionUser) session.getAttribute(USER_SESSION_ATTRIBUTE);

if (user == null)

{

return null;

}

if(isSiteMember(request, alfrescoContext, user.getUserName()))

{

return user;

}

delegate.restartLoginChallenge(context, request, response);

}

return null;

}


It checks of the user belongs to site. If not it gives back null.





Next topic



/**

* @see org.alfresco.module.vti.handler.MeetingServiceHandler#createWorkspace(String, String, int, TimeZoneInformation, SessionUser)

*/

public String createWorkspace(String title, String templateName, int lcid, TimeZoneInformation timeZoneInformation, SessionUser user) throws Exception

{

title = removeIllegalCharacters(title);


if (title.equals("_"))

{

throw new RuntimeException(getMessage("vti.meeting.error.workspace_name"));

}


SiteInfo siteInfo = null;

String newTitle = null;

int i = 0;

do

{

newTitle = title + (i == 0 ? "" : "_" + i);

siteInfo = siteService.getSite(newTitle);

i++;

} while (siteInfo != null);


shareUtils.createSite(user, MEETING_WORKSPACE_NAME, newTitle, newTitle, "", true);


return newTitle;

}



Creation of the workspace leads to the creation of the site internally.





AlfrescoDwsServiceHandler and AlfrescoCheckOutCheckInServiceHandler these 2 handlers are most important and to be analysed to enable the online edit.




No comments:

Post a Comment