How to edit Web Part properties in REST or CSOM?

This is a follow-up to my earlier question, How to get all properties of a Site Page using REST API?. Using REST in an AngularJS application, I was able to read the properties of the Web Part Page Title Bar and see if the Image property was populated. Now I realize I have to EDIT the property as well.

Can I use the REST API to edit a web part? Or do I need to use CSOM? I have used CSOM in the past to edit the User Information List (because that’s one list you can’t edit with REST). But I am not sure how to proceed.

Domain Models with complex properties construction

According to this article: Using Ids in Domain Models is not a good practice. We should reference the entire domain model instead.

In this case, when we want to provide only Getters for our properties, we have no choice but to use the constructor parameters to pass all the data.

example :

class Car {      public Car(string name, Model model, Engine engine){         Name = name;         Model model = model;         Engine = engine;     }      public string Name {get;}     public Model Model {get;}     public Engine Engine {get} } 

In a case where we receive a DTO from the front end for example:

class CarDto {     public string Name {get;set;}     public long ModelId {get;set;}     public long EngineId {get;set;} } 

How to construct the domain model from this?

  • Should we fetch the Engine and Model from the database by their ids before building the domain model ?

Also in the case when in our Domain Model we have some complex properties that are not always set, is it enough to just pass null as a parameter, or they shouldn’t appear at all in the constructor, and give them a Setter ?

Any other suggestion is welcome.

UnicodeDecodeError error when starting Software Properties GTK Ubuntu 18.04

There is an issue when I try to launch software-properties-gtk on Ubuntu 18.04. Nothing happens when launching via desktop icon, and via terminal this error comes out:

root:~# software-properties-gtk  Traceback (most recent call last):   File "/usr/bin/software-properties-gtk", line 100, in <module>     app = SoftwarePropertiesGtk(datadir=options.data_dir, options=options, file=file)   File "/usr/lib/python3/dist-packages/softwareproperties/gtk/SoftwarePropertiesGtk.py", line 189, in __init__     self.show_keys()   File "/usr/lib/python3/dist-packages/softwareproperties/gtk/SoftwarePropertiesGtk.py", line 886, in show_keys     for key in self.apt_key.list():   File "/usr/lib/python3/dist-packages/softwareproperties/AptAuth.py", line 64, in list     for line in p:   File "/usr/lib/python3.6/codecs.py", line 321, in decode     (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 6808: invalid continuation byte 

It looks like a file contains a non-UTF8 character, but I am unable to know which one. /etc/apt/sources.list.d directory is empty, and /etc/apt/sources.list contains:

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to # newer versions of the distribution. deb http://archive.ubuntu.com/ubuntu/ bionic main restricted # deb-src http://archive.ubuntu.com/ubuntu/ xenial main restricted  ## Major bug fix updates produced after the final release of the ## distribution. deb http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted # deb-src http://archive.ubuntu.com/ubuntu/ xenial-updates main restricted  ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu ## team, and may not be under a free licence. Please satisfy yourself as to ## your rights to use the software. Also, please note that software in ## universe WILL NOT receive any review or updates from the Ubuntu security ## team. deb http://archive.ubuntu.com/ubuntu/ bionic universe # deb-src http://archive.ubuntu.com/ubuntu/ xenial universe deb http://archive.ubuntu.com/ubuntu/ bionic-updates universe # deb-src http://archive.ubuntu.com/ubuntu/ xenial-updates universe  ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu ## team, and may not be under a free licence. Please satisfy yourself as to ## your rights to use the software. Also, please note that software in ## multiverse WILL NOT receive any review or updates from the Ubuntu ## security team. deb http://archive.ubuntu.com/ubuntu/ bionic multiverse # deb-src http://archive.ubuntu.com/ubuntu/ xenial multiverse deb http://archive.ubuntu.com/ubuntu/ bionic-updates multiverse # deb-src http://archive.ubuntu.com/ubuntu/ xenial-updates multiverse  ## N.B. software from this repository may not have been tested as ## extensively as that contained in the main release, although it includes ## newer versions of some applications which may provide useful features. ## Also, please note that software in backports WILL NOT receive any review ## or updates from the Ubuntu security team. deb http://archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse # deb-src http://archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse  ## This software is not part of Ubuntu, but is offered by Canonical and the ## respective vendors as a service to Ubuntu users. deb http://archive.canonical.com/ubuntu bionic partner # deb-src http://archive.canonical.com/ubuntu xenial partner  deb http://security.ubuntu.com/ubuntu bionic-security main restricted # deb-src http://security.ubuntu.com/ubuntu xenial-security main restricted deb http://security.ubuntu.com/ubuntu bionic-security universe # deb-src http://security.ubuntu.com/ubuntu xenial-security universe deb http://security.ubuntu.com/ubuntu bionic-security multiverse # deb-src http://security.ubuntu.com/ubuntu xenial-security multiverse*  deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/ 

to save to the server, correct the invalid or missing required properties

We are using SP 2013 and Office 2010 (yes old) and we are having some trouble when saving a new document to the library as the required fields, even though they are filled in, are still considered as empty.

In the print screen below, requestor is a people and group field. When I enter a user’s name I can’t confirm him/her and the border still remains red dotted.

Any solution to this issue?

enter image description here

Fetch and print all properties of an object graph as string

Below I have setup an extension method that takes any object, cycles through its properties, and prints each out to a Console window in the format Name: Value.

public static string PropertiesToString<T>(this T obj, int tabs = 0) where T : class {     int initTabs = tabs;     string result = string.Empty;     PropertyInfo[] propertyInfo = obj.GetType().GetProperties();     foreach (PropertyInfo property in propertyInfo)     {         string name = property.Name;         object value = property.GetValue(obj, null);         Type valueType = value.GetType();         if (valueType.IsValueType || valueType.Name.Equals("String"))         {             for (int i = 0; i < tabs; i++)             {                result += "    ";             }             result += string.Format("{0}: {1}\n", name, value == null ? string.Empty : value.ToString());         }         else         {             result += string.Format("{0}:\n", name);             result += value.PropertiesToString(++tabs);         }         tabs = initTabs;     }    return result; } 

Here is a class I’m using to test this code, along with the lines responsible for creating an instance of the class and writing its properties to the Console:

Class:

public class Circle : IShape {     public Circle(double x, double y, double radius)     {         Center = new Point         {             X = x,             Y = y         };         Radius = radius;     }      public Point Center { get; set; }     public double Radius { get; set; }      public double Area(int precision = 2)     {         return Math.Round(Radius * Radius * Math.PI, precision);     } } 

Main:

public static void Main(string[] args) {     IShape circle = new Circle(5, 5, 10);     Console.WriteLine(circle.PropertiesToString());     Console.ReadLine(); } 

The above method will also cycle through nested objects and print those to the Console as well, adding in tabs for readability’s sake.

I’m kind of unfamiliar with System.Reflection and was wondering if there was a more efficient way I could approach doing something like this.

How to get all properties of a Site Page using REST API?

I am writing an application in AngularJS for a SharePoint 2013 site collection, using the REST API to talk to SharePoint. My task is to update the Image Link in the Title Bar Properties of every Web Part Page in the Site Pages library of every site. I have managed to iterate through every site and list every Web Part Page (excluding the Wiki Pages), but I am stuck finding the specific property.

My broader question, is there a way within the REST API to retrieve every single property of a Web Part Page?

Add list items to Object & Properties – javaScript

I’m trying to copy specific field data from list items to properties in an object, which appears to be working, however, I have multiple rows of data and the function is pasting the same row every time into my array. I’m obviously missing something, but not sure what. Also, if there is a better way to do this I’m all ears! See code below…

function getListData(listName) { dfd = $  .Deferred(); parentId = GetUrlKeyValue("ID", false, location.href); var context = SP.ClientContext.get_current(); var web = context.get_web(); context.load(web); var list = web.get_lists().getByTitle(listName); var caml = new SP.CamlQuery(); caml.set_viewXml('<View><Query><Where><Eq><FieldRef Name="LinkID" /><Value Type="Lookup">' + parentId + '</Value></Eq></Where></Query></View>'); listItems = list.getItems(caml); context.load(listItems, "Include(ID, Current_x0020_Public_x0020_IP_x0, New_x0020_Public_x0020_IP_x0020_, New_x0020_Assigned_x0020_Public_, Disconnect_x0020_IP_x0020_Subnet)"); context.executeQueryAsync(function() {     var count = listItems.get_count();     var arraySubnet = [];     var PublicSubnet = { current: "", new: "", assigned: "" };     var listEnumerator = listItems.getEnumerator();     while (listEnumerator.moveNext()) {         listItem = listEnumerator.get_current();         id = listItem.get_item("ID");         currentSubnet = listItem.get_item('Current_x0020_Public_x0020_IP_x0');         newSubnetRequested = listItem.get_item('New_x0020_Public_x0020_IP_x0020_');         newAssignedSubnet = listItem.get_item('New_x0020_Assigned_x0020_Public_');         PublicSubnet.current = currentSubnet;         PublicSubnet.new = newSubnetRequested;         PublicSubnet.assigned = newAssignedSubnet;         arraySubnet.push(PublicSubnet);      } // End while     console.log(arraySubnet);     dfd.resolve(); }, function() {     dfd.reject(); }); return dfd.promise(); } 

What is the best name for class that adds properties to artefacts on Artifactory? [on hold]

I need to figure out a name for a class that is adds properties to artefacts on Artifactory, as described here.

What would be the best name? Names such as ArtifactoryPropertiesHandler or ArtifactoryPropertiesManager aren’t a sign of clean code- I could use something more specific, like ArtifactoryPropertiesAdder, but adder is a kind of a snake, not someone or something who adds something.

What would be the best name for my class?

Non-testable class wrapping Java Properties with basic logic

I written simple java.util.Properties wrapping class. Unfortunatelly in my opinion it isn’t testable at the moment and I don’t have any great idea, how to improve it. I could use PowerMockito to change properties after loading or add setter for them or inject some class that provides properties, but I don’t like any of that. I would like to avoid exposing properties by making it public or by getter/setter.

My application details:

  • Spring boot
  • my class is injected by @Bean mechanic
  • CONF_FILE_NAME contains key=value formatted properies with names same as in Keys subclass.

I would like to unit-test logic in this class (both public method) without relying on values in file.

My class:

package pl.myapp;  imports ...  public class PropertiesManager  {     private final String secretToken = "SECRET";      public final class Keys      {         public final static String KEY1 = "VALUE1";         public final static String KEY2 = "VALUE2";     }      private static final Logger logger = LogManager.getLogger(PropertiesManager.class);     private final String CONF_FILE_NAME = "conf_file.conf";      private Properties properties;      public PropertiesManager() throws IOException     {         logger.info("Looking for configuration file " + CONF_FILE_NAME + " in directory:" + System.getProperty("user.dir")); //          properties = new Properties();         InputStream in = new FileInputStream(CONF_FILE_NAME); // not finding properties is program-breaking so I allow this exception to propagate         properties.load(in);     }      public String getProperty(String name)     {         String property = properties.getProperty(name);         if (property == null) {             logger.warn("Property " + name + " not found in properties file");         }         return property;     }      public HashMap<String, String> getAllPublicProperties()     {         HashMap<String, String> map = new HashMap<>();           properties.keySet().stream().map(f -> (String)f).filter(f -> !f.contains(secretToken)).forEach(f -> map.put(f, properties.getProperty(f)));         return map;     } }