<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[Category: Software Development | Chris Weldon]]></title>
  <link href="http://www.chrisweldon.net/blog/categories/software-development/atom.xml" rel="self"/>
  <link href="http://www.chrisweldon.net/"/>
  <updated>2014-08-25T03:04:45+00:00</updated>
  <id>http://www.chrisweldon.net/</id>
  <author>
    <name><![CDATA[Chris Weldon]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[On Helpers and the Use of Static]]></title>
    <link href="http://www.chrisweldon.net/blog/2014/03/03/on-helpers-and-the-use-of-static/"/>
    <updated>2014-03-03T05:08:21+00:00</updated>
    <id>http://www.chrisweldon.net/blog/2014/03/03/on-helpers-and-the-use-of-static</id>
    <content type="html"><![CDATA[<p>One of my most recent interactions with several of my colleagues has been over best practices within software development. More specifically, the idea of static classes, static methods, and helper classes. It was a healthy debate with different view points. Some believe that static methods are perfectly fine for development. Others feel that helper classes provide unity to certain practices such as database access. Generally, however, I believe static and helper classes are an anti-pattern and lead to less maintainable code. This post is an expression of why I believe this to be the case. None of the code samples are actual snippets on real projects. They are paraphrased instances of practices I&rsquo;ve seen on a myriad of past projects.</p>

<!--more-->


<h2>So, why are statics bad? </h2>

<p>I&rsquo;m a huge fan of automated testing. I started with unit tests, but have recently moved into the realm of behavior tests. Yet, for any automated testing, you have to have good architecture in your code to ensure that you <em>can</em> test in any environment.</p>

<p>Let me give the most basic example: the use of a logging facility. Take for example the following loggger that I see all too often:</p>

<p>{% codeblock lang:csharp %}
public static class LoggingHelper
{
    public static void LogMessage(string message, string area)
    {
        var logPath = Constants.LogPath;
        using (StreamWriter writer = System.IO.File.AppendText(logPath))
        {
            writer.WriteLine(&ldquo;INFO\t[&rdquo; + area + &ldquo;]&rdquo; + message);
        }
    }</p>

<pre><code>public static void LogError(string message, string area)
{
    var logPath = Constants.LogPath;
    using (StreamWriter writer = System.IO.File.AppendText(logPath))
    {
        writer.WriteLine("ERROR\t[" + area + "]" + message);
    }
}

public static void LogException(string message, string area, Exception exception)
{
    var logPath = Constants.LogPath;
    using (StreamWriter writer = System.IO.File.AppendText(logPath))
    {
        writer.WriteLine("EXCEPTION\t[" + area + "]" + message + " - " + exception.Message);
        writer.WriteLine("Stack Trace" + exception.StackTrace);
    }
}
</code></pre>

<p>}
{% endcodeblock %}</p>

<p>Here are a few areas the above code block can improve:</p>

<ul>
<li>There&rsquo;s no exception handling. At all.</li>
<li>There&rsquo;s no mutexes/resource locking. Thus, it&rsquo;s possible for multiple threads to attempt to open the file at the same time. The first one in will succeed. All others will throw exceptions.</li>
<li>It&rsquo;s insanely duplicative. In fact, I was able to copy every line of <code>LogMessage</code> to <code>LogError</code> and only have to change 2 lines of code. The same goes for <code>LogException</code>, where I also added an additional line.</li>
<li>What happens when I have another type of message I need to log? That means I must add another method - 6 of those lines likely the same as <code>LogMessage</code>.</li>
<li>What happens when I need to change the location of the log file?</li>
<li>What happens when I need to change the underlying facility for logging? Say, from files to databases?</li>
</ul>


<p>The last two are key here. For the first, I can change from <code>Constants.LogPath</code> to something like <code>ConfigurationManager.AppSettings["LogPath"]</code>, But what happens when the file is a network file system? Not accessible via standard UNC paths? You&rsquo;re up a creek and this <em>entire class</em> needs to change. That&rsquo;s pretty much the case of the second question.</p>

<p>You should assume that your underlying logging destination can <strong>and will</strong> change at any time. If you think that the simple solution to this is to simply change the <code>LoggingHelper</code> class, think again. Let&rsquo;s take this further. You should assume that your destination will be different for <strong>multiple scenarios</strong>. In enterprise development, this is frequently the case. In a pre-integration environment, you may only want to log to the filesystem because it may be a single server. However, in integration and production you might choose to log to a database since you&rsquo;re deploying to a farm of servers and writing to the filesystem makes diagnosing problems a true headache.</p>

<p>Back to the problem of automated testing, you don&rsquo;t really want any logging. Why? What happens when your test runner doesn&rsquo;t have access to the logging path? What happens when your test environment doesn&rsquo;t have the path at all? What happens when you forget you have your test environment dumping massive amounts of logs to the filesystem only to go on a goose chase figuring out why your builds randomly started to fail due to the disk being full? In the case of unit testing, <code>/dev/null</code> should be your destination.</p>

<p>Let&rsquo;s consider one last secenario: what happens if you want to log to multiple facilities at once?</p>

<p>In any of those cases, using a static class with static methods does not afford you <strong>any</strong> flexibility. If you want to expand to multiple logging facilities, you would be forced to create another static class. That class is now called in addition to this one. Yuck.</p>

<p>Here&rsquo;s where I come back to the <a href="3">SOLID principles</a>. Let&rsquo;s look at how Static classes (and static methods) violate these principles.</p>

<ul>
<li>Open/Closed Principle - Classes should be open for extension, but closed for modification.

<ul>
<li>With statics, you <strong>cannot</strong> extend and override the behavior. You throw out the idea of polymorphism. This makes it <del>very difficult</del> impossible for me to inject different behaviors for whatever need I may have.</li>
</ul>
</li>
<li>Dependency Inversion Principle - Depend upon Abstractions. Do not depend upon concretions.

<ul>
<li>With statics, every class that leverages its facilities are now dependent upon a concretion. There is no way to pass around an abstraction of a static class or regular class with static methods. Your only way of doing this is with reflection and that&rsquo;s a definite code smell.</li>
</ul>
</li>
</ul>


<p>In summary, because I cannot leverage the power of inheritance, polymorphism, or really any aspect of object oriented analysis and design with <code>statics</code>, it feels a lot like procedural programming. I suggest leaving this practice behind.</p>

<h2>So, why are helpers bad?</h2>

<p>My discussion with my colleagues yielded an interesting observation: everyone&rsquo;s opinion of a helper was slightly different. One thought of it as a single data access layer. Another thought of it as a way of providing consistent authentication for data access. But others think of helpers as the giant &ldquo;I don&rsquo;t know where to stick this method&rdquo; bucket. So, you end up with something like this (methods only, since that should convey what I&rsquo;m getting at):</p>

<p>{% codeblock lang:csharp %}
public static class Utils
{
    public static string CleanInput(string input);</p>

<pre><code>public static void FlushCacheIndex();

public static bool CheckIfSystemIsHealthy();

public static int GetCountOfActiveUsers();

public static MyModel CreateModelFromInput(string name, string email, int age, DateTime birthday);
</code></pre>

<p>}
{% endcodeblock %}</p>

<p>These types of helpers are a maintainability nightmare. For starters, if you haven&rsquo;t read my section above on why statics are bad, step back and read it. Both SOLID principles are still violated. Yet, there are also a couple of others that are violated.</p>

<ul>
<li>Single Responsibility Principle - A class should have only one reason to change.

<ul>
<li>It&rsquo;s clear in the case above that there are multiple reasons this class exists. However, there are other helper classes (such as <code>StringUtils</code> which are not as clear. However, I&rsquo;m still a firm believer that the Open/Closed Principle dictates whether to add yet another method to an existing class, or create a separate class. I&rsquo;m a huge fan of small classes as their much easier to test and maintain.</li>
</ul>
</li>
<li>Interface Segregation Principle - Many client-specific interfaces are better than one general-purpose interface.

<ul>
<li>Okay, so this isn&rsquo;t an interface. ISP is definitely meant for solving another problem. However, the basics behind this principle apply here. This is a general-purpose class. Why should I have my code <strong>strongly-coupled</strong> to this class if all I need is one method within it?</li>
</ul>
</li>
</ul>


<p>Now, to tackle some of the other arguments in favor of helper classes, let&rsquo;s look at another example I&rsquo;ve seen in the past:</p>

<p>{% codeblock lang:csharp %}
public class DatabaseHelper
{
    private static DataAccessObject daoInstance;</p>

<pre><code>public static DataAccessObject CreateDataAccessObject(User invokingUser)
{
    if (daoInstance == null)
    {
        var dao = new DataAccessObject();
        dao.AuthenticationMode = AuthenticationModes.Shared;
        dao.Credentials = new DataAccessCredentials(invokingUser.Kerberos, invokingUser.Token);
        return dao;
    }
    return daoInstance;
}
</code></pre>

<p>}
{% endcodeblock %}</p>

<p>Ah, rather than a helper, you meant a factory. Okay, I can dig that&hellip;sorta. We&rsquo;re still using <code>static</code> here, which makes it impossible for me to factorize the creation of my DAO without strongly coupling my business logic to this <em>specific</em> class. Now, a factory is meant to abstract away the details of creating an object of a specific type. There&rsquo;s some generally common expected inputs, and you get a generic implementation at the output. But, how should you go about doing that?</p>

<p>If you&rsquo;re using a proper dependency injection/Inversion of Control container, you&rsquo;ll be able to configure your application instance to inject a provider which implements the following interface:</p>

<p>{% codeblock lang:csharp %}
public interface DataAccessFactory
{
    DataAccessObject CreateDataAccessObject(User invokingUser);
}
{% endcodeblock %}</p>

<p>Furthermore, if you&rsquo;re in a spot where you need a singleton instance of the <code>DataAccessObject</code>, then you can make sure that you implement the appropriate logic in your Factory instance <strong>and</strong> setup your IoC container to maintain a singleton instance of the object.</p>

<p>When discussing the use of &ldquo;helper&rdquo; classes, it&rsquo;s more difficult to outright say they aren&rsquo;t useful, because each person&rsquo;s definition of helper classes are different. Nevertheless, if you venture down the path of bucket &ldquo;utility&rdquo; classes, stop. There are better approaches you can take.</p>

<h2>Well, I still don&rsquo;t agree with you&hellip;</h2>

<p>That&rsquo;s fine. You&rsquo;re entitled to your opinion. Just don&rsquo;t expect for me to pass your code reviews.</p>

<p>Are there circumstances where the use of a static method might be worth it? Quite possibly. But I rarely encounter those cases. If one of those reasons is &ldquo;it&rsquo;s faster to do it with a static than via good architecture&rdquo; then you&rsquo;re just being lazy. Yes, software development is about delivering value. However, what debt you introduce to the system must later be addressed save you be unable to deliver any value once you&rsquo;ve built a castle with no doors <strong>around you</strong>.</p>

<p>I&rsquo;m not alone in this. Check out just a few other blogs which carry several really good arguments against the use of statics or helpers:</p>

<ul>
<li><a href="http://lostechies.com/chrismissal/2009/06/01/anti-patterns-and-worst-practices-utils-class/">Anti-patterns and Worst Practices - Utils Classes</a></li>
<li><a href="http://oo-programming.blogspot.com/2009/06/util-classes-must-die.html">Util Classes Must Die</a></li>
<li><a href="http://blogs.msdn.com/b/nickmalik/archive/2005/09/06/461404.aspx">Are Helper Classes Evil?</a></li>
<li><a href="http://blogs.msdn.com/b/elee/archive/2009/05/05/helper-classes-are-evil.aspx">Helper Classes are Evil</a></li>
</ul>


<h2>Where did you shape your thoughts on best practices? </h2>

<p>In my previous role at <a href="2">Improving Enterprises</a>, there were a number of really talented technologists, passionate about best practices. They were staunch supporters of user groups and community as well. Thus, my opinions on best practices have been shaped not only through previous co-workers and colleagues, but also by community.</p>

<p>Community has a lot of benefits, and has a lot of diversity of thought. The software community provides an atmosphere for technologists to actively try many of the best practices they preach through katas, discussions, pull requests, and many other channels. These best practices are most commonly focused around the use of patterns. Why reinvent the wheel when patterns exist to help solve the same or similar problems? However, these patterns often have justifiable use: they leverage the facets of object oriented languages in the manner they were <em>expected</em> to be used.</p>

<p>This is where I started to learn about best practices. My source of community was extremely diverse. It included my colleagues at work, my close developer friends, and those technologists in the community who were extremely passionate about their work. Some of these technologists I engaged only through user groups, some through their blogs, and some through discussion boards. I am a high achiever, and in order for me to achieve, I must learn - so I am always on a continuous search for new information - even if it contradicts previous thoughts or practices I held imporant to me.</p>

<p>Finally, the only other way to really learn and solidify the importance of a best practice is to, well, <strong>practice</strong> it. With enough practice, you&rsquo;ll invariably run into other practices which box you into a corner or make your life <em>very</em> difficult. The more times you encounter these situations, the greater a believer in best practices which leverage the power of object oriented design and development.</p>

<p>Diversity of thought is a great practice and should be encouraged. It leads to more out-of-the-box thinking, approaches to problems, and ensures that all risks are vocalized. However, one of the most important things I&rsquo;ve had to learn is that no matter what, diversity of thought should always be supported with sound reason and justification. Simply citing a preference to a mode of practice, idea, or solution without good justification to a practice is hard to accept in a professional setting.</p>

<p>  [2] <a href="http://www.improvingenterprises.com/">http://www.improvingenterprises.com/</a>
  [3] <a href="http://en.wikipedia.org/wiki/SOLID_">http://en.wikipedia.org/wiki/SOLID_</a>(object-oriented_design)</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[SharePoint 2013 My Site Timer Jobs Missing]]></title>
    <link href="http://www.chrisweldon.net/blog/2013/08/02/sharepoint-2013-my-site-timer-jobs-missing/"/>
    <updated>2013-08-02T15:07:00+00:00</updated>
    <id>http://www.chrisweldon.net/blog/2013/08/02/sharepoint-2013-my-site-timer-jobs-missing</id>
    <content type="html"><![CDATA[<p>The way My Sites are created in SharePoint 2013 is vastly different from SharePoint 2010, but for good reason. I won&rsquo;t go into the details of how it&rsquo;s changed, as Wictor Wilen has done an <em>excellent</em> job of this already in his blog post <a href="http://www.wictorwilen.se/sharepoint-2013-personal-site-instantiation-queues-and-bad-throughput">SharePoint 2013: Personal Site Instantiation Queues and Bad Throughput</a>. I encountered problems with a new development workstation not setting up My Sites for users appropriately - blocking us from testing our solution, which was dependent upon a user having a My Site. In looking online (and in Wictor&rsquo;s blog post), everything was pointing to checking the following three timer jobs:</p>

<ul>
<li>My Site Instantiation Interactive Request Queue</li>
<li>My Site Instantiation Non-Interactive Request Queue</li>
<li>My Site Second Instantiation Interactive Request Queue</li>
</ul>


<p>The problem is, those timer jobs were missing from my server!</p>

<!--more-->


<p>I checked for the timer jobs first through Central Administration, and then subsequently thru PowerShell. The following are the results I found:</p>

<pre><code>Get-SPTimerJob | sort Name | ft Name
</code></pre>

<p>{% img center /images/posts/2013-08-02-sharepoint-2013-my-site-timer-jobs-missing/01-missing-timerjobs.png Timer Jobs Missing %}</p>

<p>I decided to check for the My Site timer jobs on a know working SharePoint 2013 farm. Sure enough, they were there:</p>

<p>{% img center /images/posts/2013-08-02-sharepoint-2013-my-site-timer-jobs-missing/02-present-timerjobs.png Timer Jobs Present on Farm %}</p>

<p>I wanted to look for a way to re-register timer jobs. There should be no reason for me to do something drastic like uninstall/reinstall the User Profile Service just to get the timer job re-registered. This timer job, as expected, was in the <code>Microsoft.Office.Server.UserProfiles</code> assembly:</p>

<p>{% img center /images/posts/2013-08-02-sharepoint-2013-my-site-timer-jobs-missing/03-timerjob-definition.png Timer Jobs Definition %}</p>

<p>So, I cracked open dotPeek and decided to hunt for that timer job definition and find who was using it. It turns out, there&rsquo;s a web application-level feature (<code>MySiteInstantiationQueuesFeatureReceiver</code>) which registers these timer jobs:</p>

<p>{% img center /images/posts/2013-08-02-sharepoint-2013-my-site-timer-jobs-missing/04-featurereceiver.png Timer Job Feature %}</p>

<p>There is a public static method inside that feature receiver used for registering the timer jobs.</p>

<p>{% img center /images/posts/2013-08-02-sharepoint-2013-my-site-timer-jobs-missing/05-methodtoregistertimerjobs.png Method to Register Timer Jobs %}</p>

<p>So, I had one of two options: invoke the static method directly, or simply toggle the feature. I opted to toggle the feature:</p>

<pre><code>$feat = Get-SPFeature 65B53AAF-4754-46D7-BB5B-7ED4CF5564E1
Disable-SPFeature $feat -Url http://webapp
Enable-SPFeature $feat -Url http://webapp
</code></pre>

<p>{% img center /images/posts/2013-08-02-sharepoint-2013-my-site-timer-jobs-missing/06-toggle-feature.png Toggle Feature %}</p>

<p>Finally, I double checked and verified the timer jobs were now present!</p>

<p>{% img center /images/posts/2013-08-02-sharepoint-2013-my-site-timer-jobs-missing/07-timerjobspresent.png Timer Jobs Present %}</p>

<p>I then went to the My Site host URL and got into the queue for provisioning. Within 5 minutes, my personal my site was provisioned!</p>

<p>{% img center /images/posts/2013-08-02-sharepoint-2013-my-site-timer-jobs-missing/08-mysite-provisioned.png My Site Provisioned %}</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Getting the Confusing SharePoint 2013 SocialDataStoreException]]></title>
    <link href="http://www.chrisweldon.net/blog/2013/05/06/getting-the-confusing-sharepoint-2013-socialdatastoreexception/"/>
    <updated>2013-05-06T11:34:00+00:00</updated>
    <id>http://www.chrisweldon.net/blog/2013/05/06/getting-the-confusing-sharepoint-2013-socialdatastoreexception</id>
    <content type="html"><![CDATA[<p>As I was writing an app using the new SharePoint 2013 app model the other day, I ran into an issue when I was trying to follow a site automatically through JavaScript:</p>

<p>{% codeblock %}
The target of the operation was not found. Internal type name: Microsoft.Office.Server.UserProfiles.SocialDataStoreException. Internal error code: 0.
{% endcodeblock %}</p>

<!--more-->


<p>The problem seemed fairly straight-forward. The targeted site I wanted to follow couldn&rsquo;t be found. However, it didn&rsquo;t make sense. The instance URL I was targeting (<a href="https://chrisweldon.sharepoint.com">https://chrisweldon.sharepoint.com</a>) did in fact exist. Furthermore, I was not already following that site. So, why was this failing?</p>

<p>Let&rsquo;s take a look at some code:</p>

<p>{% codeblock lang:javascript %}
SP.SOD.executeOrDelayUntilScriptLoaded(userProfilesLoaded, &lsquo;SP.UserProfiles.js&rsquo;);</p>

<p>function userProfilesLoaded() {
    SP.SOD.executeFunc(&lsquo;userprofile&rsquo;, &lsquo;SP.Social.SocialFollowingManager&rsquo;, followSites);
}</p>

<p>function followSites() {
    var context = SP.ClientContext.get_current();
    var socialManager = new SP.Social.SocialFollowingManager(context);
    var socialSite = new SP.Social.SocialActorInfo();
    socialSite.set_contentUri(&ldquo;<a href="https://chrisweldon.sharepoint.com">https://chrisweldon.sharepoint.com</a>&rdquo;);
    socialSite.set_actorType(SP.Social.SocialActorType.site);
    socialManager.follow(socialSite);</p>

<pre><code>context.executeQueryAsync(
    function() { alert('Sites followed!'); }, 
    function(sender, args) { alert('Error: ' + args.get_message()); });
</code></pre>

<p>}
{% endcodeblock %}</p>

<p>This is fairly straight-forward. I simply setup a social actor to follow and call out to the <code>SocialFollowingManager</code> to attempt to follow that site. This is when I thought, perhaps this is a permissions problem? I&rsquo;m trying to have the JavaScript object model <em>write</em> a request to the Social datastore. Perhaps it wasn&rsquo;t authorized.</p>

<p>I changed the permissions in my <code>AppManifest.xml</code> from <strong>Read</strong> to <strong>Write</strong>:</p>

<table>
<thead>
<tr>
<th> Scope                  </th>
<th> Permission </th>
</tr>
</thead>
<tbody>
<tr>
<td> User Profiles (Social) </td>
<td> Write</td>
</tr>
</tbody>
</table>


<p>Sadly, I received the same error message. However, if you read the <a href="http://msdn.microsoft.com/en-us/library/jj163864.aspx">MSDN Documentation on Developing Social Features in SharePoint 2013</a>, there is a section in there talking about user profiles:</p>

<p>{% blockquote %}
User Profiles (<a href="http://sharepoint/social/tenant">http://sharepoint/social/tenant</a>) The permission request scope used to access all user profiles. Only the profile picture can be changed; all other user profile properties are read-only for apps for SharePoint. Apps that request rights for the User Profiles scope must be installed by a tenant administrator.
{% endblockquote %}</p>

<p>In a nutshell, I have to grant <strong>Tenant</strong> permissions to my app to be able to have my user follow a new site. Therefore, my new permissions look like the following:</p>

<table>
<thead>
<tr>
<th> Scope                  </th>
<th> Permission </th>
</tr>
</thead>
<tbody>
<tr>
<td> User Profiles (Social) </td>
<td> Read</td>
</tr>
<tr>
<td> Tenant                 </td>
<td> Write</td>
</tr>
</tbody>
</table>


<p>As indicated by the paragraph above, the app now needs to be installed by a tenant administrator. However, in doing so, the app now follows sites (and other content) with ease. Why the obscure error message? That I don&rsquo;t know, and I hope the SharePoint team might look to address this with a more <em>correct</em> error message in the near future.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Sorry, Only Tenant Administrators Can Add or Give Access to This App]]></title>
    <link href="http://www.chrisweldon.net/blog/2013/04/30/sorry-only-tenant-administrators-can-add-this-app/"/>
    <updated>2013-04-30T10:41:00+00:00</updated>
    <id>http://www.chrisweldon.net/blog/2013/04/30/sorry-only-tenant-administrators-can-add-this-app</id>
    <content type="html"><![CDATA[<p>I have just completed building my first SharePoint 2013 application. I came across the error message <code>Sorry, only tenant administrators can add or give access to this app.</code> when trying to deploy the application to my site. This happened regardless if I was deploying using a SharePoint development site or after installing the solution in the app catalog.</p>

<p>{% img center /images/posts/2013-04-30-sorry-only-tenant-administrators-can-add-this-app/error.png Error Message %}</p>

<p>The application required Tenant Read permissions as I&rsquo;m accessing the User Profile through the JavaScript object model. The purpose of using the User Profile JSOM is to get the suggestions of sites and people to follow that SharePoint presents.</p>

<p>Now, the concept of a &ldquo;Tenant&rdquo; makes sense for Office 365 or SharePoint Online. As a hosting provider, there are multiple tenants you want to support in a single environment. However, for an on-premise deployment, this error message didn&rsquo;t make much sense. I started poking around and came across <a href="http://www.social-point.com/tenant-administration-sites">spinning up a tenant administration site</a>, being able to set multiple app tenants through the <a href="http://technet.microsoft.com/en-us/library/jj219772.aspx">App Management Service cmdlets</a>, but none of those really seemed like the right solution for my on-premise deployment. I found an <a href="http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/4e844f6c-2b73-46ff-9cda-05105332b8f8">MDSN Forum Question</a> which seemed closer to the solution. That post recommends splitting the service accounts used to host the App Management and Site Settings services from the farm account. This was critical as the Farm Account is <strong>not allowed</strong> to add apps under its identity whatsoever. You will get an error message when trying to provision, and the ULS logs will indicate that an assertion failed checking that the current account was not the system account.</p>

<p>{% img right /images/posts/2013-04-30-sorry-only-tenant-administrators-can-add-this-app/success.png Provision %}</p>

<p>What did it turn out to be? I just needed to make sure my user account was <strong>directly</strong> added as a member of the <strong>Farm Administrators</strong> group. We have traditionally deployed farm administrators via an Active Directory and local (Administrators) group. However, it appears that the App Management service dislikes this approach and wants users <em>explicitly</em> permissioned to the <strong>Farm Administrators</strong> group. Additionally, after granting your user direct permissions, you need to issue an <code>iisreset</code> so those changes take effect. Then, you can provision your app successfully.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Git Interactive Rebase for Svn Without Remotes]]></title>
    <link href="http://www.chrisweldon.net/blog/2013/04/26/git-interactive-rebase-for-svn-without-remotes/"/>
    <updated>2013-04-26T12:30:00+00:00</updated>
    <id>http://www.chrisweldon.net/blog/2013/04/26/git-interactive-rebase-for-svn-without-remotes</id>
    <content type="html"><![CDATA[<p>I&rsquo;ve recently switched from using Subversion directly to using <a href="https://www.kernel.org/pub/software/scm/git/docs/git-svn.html">git svn</a> to allow me to use a git workflow, but interact with a subversion repository. It works <em>great</em>, except when I needed to interactive rebase&hellip;</p>

<!--more-->


<p>When moving this workflow into my customer&rsquo;s environment, they require I specify a JIRA ticket on each commit to the repo. I had forgot to do that for the first few commits, which looked like this:</p>

<p>{% codeblock %}
$ git log &ndash;oneline</p>

<p>6fa0719 Fixing the handlebars template to render the target as parent.
21ad0cf Initial commit of the SiteSuggestions app
6430b3b Adding the .gitignore files
095d92e SP-34: Creating branch to track the new suggestions app part.
{% endcodeblock %}</p>

<p>So, when I tried to commit, I got an error indicating that the commit failed. In looking at the error, I saw the pre-commit hook error requiring that I associate the commit with a JIRA ticket. So, my first comment was easy to fix:</p>

<p>{% codeblock %}
$ git commit &ndash;amend -m &ldquo;SP-34: Fixing the handlebars template to render the target as parent.&rdquo;
[2013-sitesuggestions-svn 6b4bc64] SP-34: Fixing the handlebars template to render the target as parent.&ldquo;
 1 file changed, 1 insertion(+), 1 deletion(-)
{% endcodeblock %}</p>

<p>Now I just had to figure out how to modify commits <code>21ad0cf</code> and <code>6430b3b</code>. I tried to use git interactive rebase as per the <a href="http://trac.parrot.org/parrot/wiki/git-svn-tutorial">git svn tutorial</a> and per the <a href="http://git-scm.com/book/en/Git-Tools-Rewriting-History">git-scm book</a>. However, in both cases, I got the following error message:</p>

<p>{% codeblock %}
$ git rebase -i HEAD-3
fatal: Needed a single revision
invalid branch HEAD-3
{% endcodeblock %}</p>

<p>The solution was to specify the SHA for the commit:</p>

<p>{% codeblock %}
$ git rebase -i 6430b3b^
{% endcodeblock %}</p>

<p>This started the rebase process and allowed me to amend the commits for every faulted commit. Now, everything looks correct:</p>

<p>{% codeblock %}
$ git log &ndash;oneline</p>

<p>6fa0719 SP-34: Fixing the handlebars template to render the target as parent.
21ad0cf SP-34: Initial commit of the SiteSuggestions app
6430b3b SP-34: Adding the .gitignore files
095d92e SP-34: Creating branch to track the new suggestions app part.
{% endcodeblock %}</p>

<p>When I finally committed using <code>git svn dcommit</code>, everything went perfectly!</p>
]]></content>
  </entry>
  
</feed>
